/* ==========================================================================
   docs.css — documentation page layout
   Sticky topbar · sidebar TOC (off-canvas on mobile) · scroll progress
   Requires site.css.
   ========================================================================== */

/* ---------- Scroll progress ---------- */

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    z-index: 60;
    pointer-events: none;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent-bright);
}

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 3.25rem;
    padding: 0 1.25rem;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-home {
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-soft);
    white-space: nowrap;
}

.topbar-home:hover {
    color: var(--accent-strong);
}

.topbar-home::before {
    content: "←";
    margin-right: 0.45rem;
    color: var(--accent-bright);
}

.topbar-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-toggle {
    display: none;
    align-items: center;
    gap: 0.45rem;
    height: 2.25rem;
    padding: 0 0.8rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-soft);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.toc-toggle:hover {
    color: var(--accent);
    border-color: var(--border-strong);
}

.toc-toggle svg {
    width: 0.95rem;
    height: 0.95rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* ---------- Shell: sidebar + content ---------- */

.docs-shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
    gap: 2.5rem;
}

.docs-sidebar {
    position: sticky;
    top: 3.25rem;
    align-self: start;
    height: calc(100vh - 3.25rem);
    overflow-y: auto;
    padding: 1.5rem 0.25rem 2rem 0;
    scrollbar-width: thin;
}

.docs-sidebar h2 {
    font-size: 0.95rem;
    margin: 0 0 1.25rem;
    padding: 0 0.75rem;
}

.nav-section {
    margin-bottom: 1.4rem;
}

.nav-section h3 {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.4rem;
    padding: 0 0.75rem;
}

.nav-section ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-section li {
    margin: 0;
}

.nav-section a {
    display: block;
    padding: 0.3rem 0.75rem;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-soft);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-section a:hover {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.nav-section a.active {
    color: var(--accent-strong);
    border-left-color: var(--accent-bright);
    background: var(--accent-soft);
    font-weight: 500;
}

.sidebar-backdrop {
    display: none;
}

/* ---------- Content ---------- */

.docs-content {
    max-width: 76ch;
    padding: 2.25rem 0 4rem;
    min-width: 0;
}

.docs-content h1 {
    margin: 0 0 0.75rem;
}

.docs-content .lead {
    font-size: 1.08rem;
    color: var(--muted);
    margin: 0 0 2rem;
}

.docs-content h2 {
    font-size: 1.45rem;
    margin: 2.75rem 0 1rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--border);
}

.docs-content h3 {
    font-size: 1.15rem;
    margin: 2rem 0 0.75rem;
}

.docs-content h4 {
    font-size: 1rem;
    margin: 1.5rem 0 0.6rem;
}

/* anchor offset below sticky topbar */
.docs-content [id] {
    scroll-margin-top: 4.25rem;
}

.docs-content p {
    margin: 0 0 1rem;
}

.docs-content ul,
.docs-content ol {
    margin: 0 0 1.1rem;
    padding-left: 1.5rem;
}

.docs-content li {
    margin-bottom: 0.45rem;
}

.docs-content li > p {
    margin-bottom: 0.5rem;
}

/* Step numbers in headings */
.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.7rem;
    height: 1.7rem;
    margin-right: 0.55rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-strong);
    background: var(--accent-soft);
    border: 1px solid var(--accent-bright);
    border-radius: var(--radius-sm);
    vertical-align: 0.12em;
}

/* Step labels above command blocks (quick-reference pages) */
.section-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-soft);
    margin: 1rem 0 0.45rem;
}

/* Caption note directly under a code block */
.code-caption {
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
    margin-top: -0.5rem;
}

/* Footnote / attribution block at end of guides */
.footnote {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
    .docs-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .toc-toggle {
        display: inline-flex;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        z-index: 80;
        width: min(20rem, 85vw);
        height: 100vh;
        height: 100dvh;
        background: var(--surface);
        border-left: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        padding: 1.5rem 1.25rem 2rem;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        visibility: hidden;
    }

    .docs-sidebar.open {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 70;
        background: rgba(15, 12, 8, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .docs-content {
        padding-top: 1.75rem;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 0 0.9rem;
    }

    .topbar-title {
        display: none;
    }

    .docs-shell {
        padding: 0 1rem;
    }

    .docs-content h1 {
        font-size: 1.65rem;
        overflow-wrap: break-word;
    }

    .docs-content h2 {
        font-size: 1.3rem;
        margin-top: 2.25rem;
    }

    .docs-content h3 {
        font-size: 1.08rem;
    }

    pre {
        font-size: 0.8rem;
        padding: 0.75rem 0.9rem;
    }
}

/* ---------- Print ---------- */

@media print {
    .topbar,
    .progress-bar,
    .docs-sidebar,
    .sidebar-backdrop,
    .copy-btn,
    .home-link {
        display: none !important;
    }

    .docs-shell {
        display: block;
        max-width: 100%;
        padding: 0;
    }

    body {
        font-size: 11pt;
        background: #fff;
    }

    pre {
        white-space: pre-wrap;
        word-wrap: break-word;
        border: 1px solid #999;
        background: #fff;
        color: #000;
    }

    .note, .important, .warning {
        break-inside: avoid;
    }
}
