/* ==========================================
   Alphie Docs — public user guide pages (website/docs/)
   Layered on top of css/style.css: same tokens, navbar, footer and fonts.
   Pages are generated by the public-docs generator; this file only lays them out.
   ========================================== */

.docs-page {
    --docs-nav-h: 65px;          /* fixed .navbar from style.css */
    --docs-sidebar-w: 268px;
    background: var(--ds-bg-white);
}

/* Visible only when focused from the keyboard */
.docs-skip {
    position: absolute;
    left: 16px;
    top: -48px;
    z-index: 1003;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: var(--ds-text-primary);
    color: var(--ds-bg-white);
    font-size: 14px;
    text-decoration: none;
}

.docs-skip:focus {
    top: 12px;
}

.docs-page a:focus-visible,
.docs-page summary:focus-visible,
.docs-page button:focus-visible {
    outline: 2px solid var(--ds-accent);
    outline-offset: 2px;
    border-radius: 6px;
}

/* The language switcher is made of links here (same chapter, other language), not buttons */
.docs-page .nav-links a.lang-btn {
    font-size: 13px;
    color: var(--ds-text-tertiary);
    padding: 4px 8px;
}

.docs-page .nav-links a.lang-btn.active {
    color: var(--ds-text-primary);
}

.docs-page .nav-links a.nav-active {
    color: var(--ds-text-primary);
}

/* ---------- Layout ---------- */
.docs-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--docs-nav-h) + 32px) 24px 80px;
    display: grid;
    grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr);
    gap: 56px;
    align-items: start;
}

/* ---------- Left column ---------- */
.docs-sidebar {
    position: sticky;
    top: calc(var(--docs-nav-h) + 24px);
    max-height: calc(100vh - var(--docs-nav-h) - 48px);
    overflow-y: auto;
    padding-right: 4px;
}

.docs-nav-toggle {
    display: none;               /* desktop: the list is always open, no toggle */
}

.docs-toc,
.docs-toc-sections {
    list-style: none;
}

.docs-toc-chapter > a {
    display: block;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--ds-text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.docs-toc-chapter > a:hover {
    background: var(--ds-surface-hover);
    color: var(--ds-text-primary);
}

.docs-toc-chapter.is-current > a {
    background: var(--ds-accent-bg);
    color: var(--ds-accent);
    font-weight: 600;
}

.docs-toc-sections {
    margin: 4px 0 10px 12px;
    padding-left: 10px;
    border-left: 1px solid var(--ds-border-med);
}

.docs-toc-sections a {
    display: block;
    padding: 5px 10px;
    border-radius: 6px;
    color: var(--ds-text-secondary);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.45;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.docs-toc-sections a:hover {
    color: var(--ds-text-primary);
    background: var(--ds-surface);
}

.docs-toc-sections a.is-current {
    color: var(--ds-accent);
    background: var(--ds-accent-hover);
    font-weight: 600;
}

/* ---------- Article ---------- */
.docs-main {
    min-width: 0;
    max-width: 780px;
}

.docs-main:focus {
    outline: none;
}

.docs-article {
    color: var(--ds-text-primary);
    font-size: 16px;
    line-height: 1.75;
    overflow-wrap: break-word;
}

.docs-article h1,
.docs-article h2,
.docs-article h3 {
    scroll-margin-top: calc(var(--docs-nav-h) + 20px);
}

.docs-article h1 {
    font-size: 2.25rem;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.docs-article h2 {
    font-size: 1.4rem;
    margin: 48px 0 14px;
    padding-top: 28px;
    border-top: 1px solid var(--ds-border);
}

.docs-article h3 {
    font-size: 1.1rem;
    margin: 28px 0 10px;
}

.docs-article p {
    margin: 0 0 16px;
}

.docs-article h1 + p {
    font-size: 1.075rem;
    color: var(--ds-text-secondary);
}

.docs-article ul,
.docs-article ol {
    margin: 0 0 16px;
    padding-left: 1.5em;
}

.docs-article li {
    margin: 6px 0;
}

.docs-article li > ul,
.docs-article li > ol {
    margin: 6px 0 0;
}

.docs-article strong {
    font-weight: 600;
}

.docs-article a {
    color: var(--ds-accent);
    text-decoration: underline;
    text-decoration-color: rgba(99, 102, 241, 0.35);
    text-underline-offset: 3px;
}

.docs-article a:hover {
    text-decoration-color: var(--ds-accent);
}

.docs-article code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--ds-surface-hover);
}

.docs-article pre {
    margin: 0 0 16px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--ds-surface);
    border: 1px solid var(--ds-border-med);
    overflow-x: auto;
}

.docs-article pre code {
    padding: 0;
    background: none;
}

.docs-article blockquote {
    margin: 0 0 16px;
    padding: 4px 16px;
    border-left: 3px solid var(--ds-accent-dim);
    color: var(--ds-text-secondary);
}

/* Tables scroll inside themselves on narrow screens instead of widening the page */
.docs-article table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 0 0 20px;
    font-size: 15px;
}

.docs-article th,
.docs-article td {
    padding: 9px 14px;
    border: 1px solid var(--ds-border-med);
    text-align: left;
    vertical-align: top;
}

.docs-article th {
    background: var(--ds-surface);
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- Previous / next ---------- */
.docs-pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid var(--ds-border);
}

.docs-pager a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 48%;
    padding: 12px 16px;
    border: 1px solid var(--ds-border-med);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.docs-pager a:hover {
    border-color: var(--ds-accent-dim);
    box-shadow: var(--shadow-sm);
}

.docs-pager-next {
    margin-left: auto;
    text-align: right;
}

.docs-pager-label {
    font-size: 12px;
    color: var(--ds-text-tertiary);
}

.docs-pager-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ds-text-primary);
}

/* ---------- Entry page (docs/index.html) ---------- */
.docs-entry {
    max-width: 640px;
    margin: 0 auto;
    padding: calc(var(--docs-nav-h) + 72px) 24px 96px;
    text-align: center;
}

.docs-entry h1 {
    font-size: 2.25rem;
    margin-bottom: 32px;
}

.docs-entry-links {
    list-style: none;
    display: grid;
    gap: 12px;
}

.docs-entry-links a {
    display: block;
    padding: 16px 20px;
    border: 1px solid var(--ds-border-med);
    border-radius: var(--radius-md);
    color: var(--ds-text-primary);
    font-weight: 600;
    text-decoration: none;
}

.docs-entry-links a:hover {
    border-color: var(--ds-accent-dim);
    color: var(--ds-accent);
}

/* ---------- Narrow screens: the left column folds into a menu above the text ---------- */
@media (max-width: 900px) {
    .docs-page {
        --docs-nav-h: 57px;
    }

    .docs-layout {
        display: block;
        padding: calc(var(--docs-nav-h) + 16px) 16px 64px;
    }

    .docs-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
        padding-right: 0;
        margin-bottom: 28px;
    }

    .docs-nav {
        border: 1px solid var(--ds-border-med);
        border-radius: var(--radius-md);
        background: var(--ds-bg-white);
    }

    .docs-nav-toggle {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 16px;
        cursor: pointer;
        list-style: none;
        font-size: 15px;
        font-weight: 600;
        color: var(--ds-text-primary);
    }

    .docs-nav-toggle::-webkit-details-marker {
        display: none;
    }

    .docs-nav-toggle::after {
        content: "";
        margin-left: auto;
        width: 8px;
        height: 8px;
        border-right: 2px solid var(--ds-text-tertiary);
        border-bottom: 2px solid var(--ds-text-tertiary);
        transform: rotate(45deg) translateY(-2px);
        transition: transform var(--transition-fast);
        flex: none;
    }

    .docs-nav[open] > .docs-nav-toggle::after {
        transform: rotate(-135deg) translateY(-2px);
    }

    .docs-nav-current {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 500;
        color: var(--ds-text-secondary);
    }

    .docs-nav-current::before {
        content: "·";
        margin-right: 10px;
        color: var(--ds-text-tertiary);
    }

    .docs-nav > nav {
        padding: 0 8px 10px;
        border-top: 1px solid var(--ds-border);
    }

    .docs-toc {
        padding-top: 8px;
    }

    .docs-article h1 {
        font-size: 1.75rem;
    }

    .docs-article h2 {
        font-size: 1.25rem;
        margin-top: 36px;
        padding-top: 22px;
    }

    .docs-pager {
        flex-direction: column;
    }

    .docs-pager a {
        max-width: none;
    }

    .docs-entry {
        padding-top: calc(var(--docs-nav-h) + 40px);
    }
}

/* ---------- Reduced motion: nothing moves, not even briefly ---------- */
@media (prefers-reduced-motion: reduce) {
    .docs-page,
    .docs-page::before,
    .docs-page::after,
    .docs-page *,
    .docs-page *::before,
    .docs-page *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }

    html:has(.docs-page) {
        scroll-behavior: auto;
    }
}
