/* ==========================================================================
   Jejaksales Docs (/docs) — mobile-first, loaded after jejaksales.css
   ========================================================================== */

html:has(.docs-page) {
    --docs-head: 56px; --docs-tabs: 46px; --docs-gutter: clamp(14px, 4vw, 32px);
    scroll-behavior: smooth; scroll-padding-top: calc(var(--docs-head) + var(--docs-tabs) + 14px); }
html:has(.docs-page), html:has(.docs-page) body { height: auto; min-height: 100%; }

.docs-page {
    min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
    background: var(--bg); color: var(--text); overflow-x: clip; font-size: 15px;
}
.docs-page *, .docs-page *::before, .docs-page *::after { min-width: 0; }
.docs-page p { margin: 0; }
.docs-page code {
    font-family: var(--font-num); font-size: .9em; padding: 1px 5px; border-radius: 5px;
    background: var(--bg); border: 1px solid var(--line); overflow-wrap: anywhere;
}

.docs-skip {
    position: absolute; left: 12px; top: -60px; z-index: 50; padding: 10px 14px; border-radius: 10px;
    background: var(--gold); color: #052325; font-weight: 700; text-decoration: none;
}
.docs-skip:focus { top: 10px; }

/* Header ------------------------------------------------------------------ */
.docs-nav {
    position: sticky; top: 0; z-index: 30; height: var(--docs-head);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px);
    border-bottom: 1px solid var(--line); padding: 0 var(--docs-gutter);
}
.docs-nav-inner {
    max-width: var(--max); height: 100%; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.docs-brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: 0 1 auto; }
.docs-brand .brand-wm { height: 30px; }
.docs-tag {
    font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.docs-brand b { display: block; font-size: 16px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 359.98px) { .docs-brand .brand-wm { height: 24px; } .docs-tag { display: none; } }
.docs-brand small { display: none; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docs-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.docs-actions .btn { min-height: 38px; white-space: nowrap; gap: 0; }
.docs-actions .iconbtn { width: 38px; height: 38px; font-size: 16px; flex: none; }
@media (max-width: 479.98px) { .docs-hide-sm { display: none !important; } }

/* Section navigation: scrollable strip on mobile, sidebar on desktop ------- */
.docs-shell { width: 100%; max-width: var(--max); margin: 0 auto; flex: 1; }
.docs-toc {
    position: sticky; top: var(--docs-head); z-index: 20; height: var(--docs-tabs);
    display: flex; align-items: center; gap: 6px;
    margin: 0; padding: 0 var(--docs-gutter);
    background: var(--bg); border-bottom: 1px solid var(--line);
    overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.docs-toc::-webkit-scrollbar { display: none; }
.docs-toc-title { display: none; }
.docs-toc a {
    flex: none; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
    border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
    color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
    transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.docs-toc a:hover { color: var(--text); border-color: var(--cyan); }
.docs-toc a[aria-current="true"] { background: var(--gold); border-color: var(--gold); color: #052325; }
:root[data-theme="light"] .docs-toc a[aria-current="true"] { background: #052325; border-color: #052325; color: #baff2b; }

/* Content ----------------------------------------------------------------- */
.docs-container {
    max-width: none; width: 100%; margin: 0;
    padding: 16px var(--docs-gutter) 48px; display: flex; flex-direction: column; gap: 14px;
}
.docs-sec { padding: clamp(16px, 4.2vw, 28px); gap: 14px; border-radius: 16px; }
.docs-sec > h1 { font-size: clamp(23px, 6vw, 32px); line-height: 1.2; letter-spacing: -.02em; }
.docs-sec > h2 { font-size: clamp(18px, 4.6vw, 22px); line-height: 1.3; letter-spacing: -.01em; }
.docs-lead { color: var(--muted); font-size: clamp(14.5px, 3.8vw, 16px); line-height: 1.6; max-width: 70ch; }
.docs-note { color: var(--muted); font-size: 14px; line-height: 1.55; max-width: 75ch; }
.docs-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.docs-meta .pill { white-space: normal; }

.docs-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.docs-card {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
    padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
}
.docs-card h3 {
    font-size: 15.5px; font-weight: 700; line-height: 1.35; color: var(--text);
    text-transform: none; letter-spacing: 0; margin: 0;
}
.docs-card h3.gold { color: var(--gold); }
.docs-card h3.cyan { color: var(--cyan); }
.docs-card p, .docs-card li { color: var(--muted); font-size: 14px; line-height: 1.6; }
.docs-card ul, .docs-card ol { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.docs-card strong { color: var(--text); font-weight: 650; }
.docs-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.docs-step-no { font-family: var(--font-num); font-weight: 700; color: var(--dim); font-size: 15px; }

/* Tables: stacked cards on mobile, real table from 760px ------------------- */
.docs-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.docs-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.docs-table, .docs-table tbody, .docs-table tr, .docs-table td, .docs-table th[scope="row"] { display: block; }
.docs-table tr {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
    padding: 6px 14px; margin-bottom: 10px;
}
.docs-table tr:last-child { margin-bottom: 0; }
.docs-table th[scope="row"] {
    padding: 8px 0; font-size: 15px; font-weight: 700; color: var(--text); text-transform: none;
    letter-spacing: 0; white-space: normal; border-bottom: 1px solid var(--line);
}
.docs-table td {
    display: grid; grid-template-columns: minmax(96px, 40%) 1fr; gap: 10px; align-items: baseline;
    padding: 8px 0; border: 0; border-bottom: 1px dashed var(--line); color: var(--text);
}
.docs-table td:last-child { border-bottom: 0; }
.docs-table td::before {
    content: attr(data-label); font-family: var(--font-body); font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1.4;
}
.docs-yes { color: var(--gold); font-weight: 700; }
.docs-no { color: var(--dim); }

/* FAQ --------------------------------------------------------------------- */
.docs-faq { display: flex; flex-direction: column; gap: 8px; }
.docs-faq details { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.docs-faq summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 48px; padding: 10px 14px; font-weight: 650; font-size: 14.5px; line-height: 1.4;
}
.docs-faq summary::-webkit-details-marker { display: none; }
.docs-faq summary::after {
    content: "+"; flex: none; font-family: var(--font-num); font-size: 18px; color: var(--cyan); transition: transform .2s ease;
}
.docs-faq details[open] summary::after { transform: rotate(45deg); }
.docs-faq details > div { padding: 0 14px 14px; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* CTA + footer ------------------------------------------------------------ */
.docs-cta { display: flex; flex-direction: column; gap: 14px; }
.docs-cta-actions { display: flex; flex-direction: column; gap: 8px; }
.docs-cta-actions .btn { min-height: 46px; width: 100%; font-size: 14.5px; }
.docs-foot {
    padding: 18px var(--docs-gutter) calc(22px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
    color: var(--dim); font-size: 12.5px; text-align: center; line-height: 1.6;
}
.docs-foot a { color: var(--muted); }

/* ≥ 480px ----------------------------------------------------------------- */
@media (min-width: 480px) {
    .docs-cta-actions { flex-direction: row; flex-wrap: wrap; }
    .docs-cta-actions .btn { width: auto; flex: 1 1 200px; }
}

/* ≥ 640px ----------------------------------------------------------------- */
@media (min-width: 640px) {
    html:has(.docs-page) { --docs-head: 62px; }
    .docs-brand small { display: block; }
    .docs-grid.c2, .docs-grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .docs-container { gap: 18px; padding-top: 22px; }
}

/* ≥ 760px: real tables ---------------------------------------------------- */
@media (min-width: 760px) {
    .docs-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
    .docs-table { display: table; }
    .docs-table thead { position: static; width: auto; height: auto; clip-path: none; display: table-header-group; }
    .docs-table tbody { display: table-row-group; }
    .docs-table tr { display: table-row; background: none; border: 0; border-radius: 0; padding: 0; margin: 0; }
    .docs-table td, .docs-table th[scope="row"] { display: table-cell; }
    .docs-table th, .docs-table td, .docs-table th[scope="row"] {
        padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line);
        text-align: left; vertical-align: top; white-space: normal;
    }
    .docs-table thead th { background: var(--surface-2); font-size: 12px; }
    .docs-table th[scope="row"] { font-size: 14px; }
    .docs-table tbody tr:last-child > * { border-bottom: 0; }
    .docs-table td::before { content: none; }
    .docs-table td.c { text-align: center; }
    .docs-table thead th.c { text-align: center; }
}

/* ≥ 1040px: sidebar TOC --------------------------------------------------- */
@media (min-width: 1040px) {
    html:has(.docs-page) { scroll-padding-top: calc(var(--docs-head) + 18px); }
    .docs-shell {
        display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 28px; align-items: start;
        padding: 0 var(--docs-gutter);
    }
    .docs-toc {
        top: calc(var(--docs-head) + 24px); height: auto; max-height: calc(100vh - var(--docs-head) - 48px);
        flex-direction: column; align-items: stretch; gap: 2px; margin-top: 24px; padding: 0;
        background: none; border: 0; overflow: hidden auto;
    }
    .docs-toc-title {
        display: block; padding: 0 12px 8px; font-size: 11.5px; font-weight: 700;
        text-transform: uppercase; letter-spacing: .07em; color: var(--dim);
    }
    .docs-toc a {
        min-height: 36px; border-radius: 9px; border-color: transparent; background: none;
        font-size: 13.5px; white-space: normal; border-left: 2px solid transparent;
    }
    .docs-toc a:hover { background: var(--surface); border-color: transparent; }
    .docs-toc a[aria-current="true"],
    :root[data-theme="light"] .docs-toc a[aria-current="true"] {
        background: var(--surface); color: var(--text); border-color: transparent; border-left-color: var(--gold);
    }
    .docs-container { padding: 24px 0 64px; }
    .docs-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .docs-cta { flex-direction: row; align-items: center; justify-content: space-between; }
    .docs-cta-actions { flex: none; }
    .docs-cta-actions .btn { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
    html:has(.docs-page) { scroll-behavior: auto; }
}

@media print {
    .docs-nav, .docs-toc, .docs-cta, .docs-foot { display: none !important; }
    .docs-shell { display: block; }
    .docs-faq details > div { display: block; }
}
