/* =============================================================================
   docs.css — Documentation pages (single + archive)
   CSS variables used: --blue, --blue-pale, --blue-border, --bg, --white,
                       --border, --ink, --ink-mid, --ink-soft, --ink-faint,
                       --shadow-md  (all defined in global.css)
============================================================================= */


/* ── Page shell ─────────────────────────────────────────────────────────────── */

.docs-main {
    padding: 0 0 80px;
}

.docs-wrap {
    max-width: 1240px;
    margin: 0 auto;
    padding: 56px 32px 0;
    display: grid;
    grid-template-columns: 268px 1fr;
    gap: 56px;
    align-items: start;
}


/* ── TOC sidebar (desktop) ───────────────────────────────────────────────── */

.docs-toc {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 108px);
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Elements only used in mobile drawer — hidden on desktop */
.docs-toc-close,
.docs-toc-head,
.docs-toc-fab,
.docs-toc-backdrop {
    display: none;
}


/* ── TOC list ──────────────────────────────────────────────────────────────── */

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list .toc-list {
    padding-left: 14px;
    margin-top: 2px;
}

.toc-item {
    margin: 0;
}

.toc-link {
    display: block;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--ink-soft);
    text-decoration: none;
    transition: color .14s, background .14s;
}

.toc-link:hover {
    color: var(--ink);
    background: var(--bg);
}

.toc-link.active {
    color: var(--blue);
    background: var(--blue-pale);
    font-weight: 500;
}

.toc-level-2 > .toc-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
}

.toc-level-3 > .toc-link {
    font-size: 13.5px;
}

.toc-level-4 > .toc-link,
.toc-level-5 > .toc-link {
    font-size: 12.5px;
}


/* ── Article ──────────────────────────────────────────────────────────────── */

.docs-title {
    font-size: clamp(1.75rem, 3.5vw, 2.4rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 36px;
    color: var(--ink);
}

.docs-body {
    font-size: 16px;
    line-height: 1.8;
    color: var(--ink);
}

.docs-body h2,
.docs-body h3,
.docs-body h4,
.docs-body h5 {
    font-weight: 650;
    line-height: 1.3;
    margin: 2.2em 0 0.65em;
    scroll-margin-top: 100px;
    color: var(--ink);
}

.docs-body h2 { font-size: 1.5rem; }
.docs-body h3 { font-size: 1.2rem; }
.docs-body h4 { font-size: 1.05rem; }
.docs-body h5 { font-size: 0.95rem; }

.docs-body p   { margin: 0 0 1.25em; }

.docs-body ul,
.docs-body ol  { padding-left: 1.6em; margin: 0 0 1.25em; }

.docs-body li  { margin-bottom: 0.35em; }

.docs-body a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.docs-body a:hover { opacity: .78; }

.docs-body code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: .875em;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
}

.docs-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 22px;
    overflow-x: auto;
    margin: 0 0 1.5em;
    line-height: 1.6;
}
.docs-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: .875rem;
}

.docs-body blockquote {
    border-left: 4px solid var(--blue);
    margin: 0 0 1.5em;
    padding: 14px 20px;
    background: var(--blue-pale);
    border-radius: 0 8px 8px 0;
    color: var(--ink-soft);
    font-style: italic;
}

.docs-body img {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    margin: 0 0 1.25em;
}

.docs-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 1.5em;
    font-size: 14.5px;
}
.docs-body th,
.docs-body td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.docs-body th {
    background: var(--bg);
    font-weight: 600;
}

.docs-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2em 0;
}


/* ── Mobile — drawer TOC ─────────────────────────────────────────────────── */

@media (max-width: 900px) {

    /* Single column; TOC leaves the flow (becomes fixed drawer) */
    .docs-wrap {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 32px 20px 60px;
    }

    /* ── Drawer panel ── */
    .docs-toc {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 290px;
        max-width: 85vw;
        max-height: none;
        overflow-y: auto;
        padding: 20px 20px 32px;
        background: var(--white);
        border-right: 1px solid var(--border);
        box-shadow: 6px 0 32px rgba(0, 0, 0, .14);
        z-index: 500;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1);
        scrollbar-width: thin;
    }

    .docs-toc.open {
        transform: translateX(0);
    }

    /* ── Close button (top-right inside drawer) ── */
    .docs-toc-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 14px;
        right: 14px;
        width: 32px;
        height: 32px;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 8px;
        cursor: pointer;
        color: var(--ink-soft);
        transition: color .14s, background .14s;
        flex-shrink: 0;
    }
    .docs-toc-close:hover {
        color: var(--ink);
        background: var(--border);
    }
    .docs-toc-close svg {
        width: 16px;
        height: 16px;
    }

    /* ── Drawer heading ── */
    .docs-toc-head {
        display: block;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .08em;
        color: var(--ink-soft);
        margin: 0 0 14px;
        padding-right: 40px; /* clear the close button */
    }

    /* ── Backdrop ── */
    .docs-toc-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .45);
        z-index: 499;
        opacity: 0;
        pointer-events: none;
        transition: opacity .28s;
    }
    .docs-toc-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* ── FAB trigger button ── */
    .docs-toc-fab {
        display: flex;
        align-items: center;
        gap: 8px;
        position: fixed;
        bottom: 28px;
        left: 20px;
        z-index: 400;
        background: var(--blue);
        color: #fff;
        border: none;
        border-radius: 999px;
        padding: 11px 20px 11px 14px;
        font-family: 'Outfit', system-ui, sans-serif;
        font-size: 14px;
        font-weight: 600;
        line-height: 1;
        cursor: pointer;
        box-shadow: 0 4px 20px rgba(26, 78, 216, .35);
        transition: opacity .15s, transform .15s, box-shadow .15s;
        white-space: nowrap;
    }
    .docs-toc-fab:hover {
        opacity: .92;
        transform: translateY(-2px);
        box-shadow: 0 6px 24px rgba(26, 78, 216, .45);
    }
    .docs-toc-fab svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        stroke: #fff;
    }

    /* Hide FAB when drawer is open */
    .docs-toc-fab.hidden {
        opacity: 0;
        pointer-events: none;
        transform: translateY(8px);
    }

}


/* ── Very small screens ──────────────────────────────────────────────────── */

@media (max-width: 480px) {

    .docs-title    { font-size: 1.5rem; }
    .docs-body     { font-size: 15px; }
    .docs-body pre { padding: 14px 16px; }

}
