/* =================================================================
   shell.css — Shared chrome for vlist.io
   Header · Sidebar · Layout · Overlay · Overview cards · Responsive
   ================================================================= */

/* ─── Reset ──────────────────────────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ─── Design Tokens ──────────────────────────────────────────────── */

/* All design tokens are now in tokens.css — loaded before this file */

/* ─── Utilities ──────────────────────────────────────────────────── */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ─── Base ───────────────────────────────────────────────────────── */

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

/* ─── Header ─────────────────────────────────────────────────────── */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.header__inner {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 1472px;
    padding: 0 12px 0 24px;
    gap: 16px;
}

.header__logo {
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
}

.header__logo:hover {
    opacity: 0.85;
}

.header__sep {
    color: var(--text-dim);
    font-weight: 300;
    font-size: var(--fs-md);
    user-select: none;
}

.header__section {
    font-size: var(--fs-lg);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
}

.header__section:hover {
    color: var(--text);
}

.header__nav {
    margin-left: auto;
    display: flex;
    gap: 20px;
}

.header__nav a {
    font-size: var(--fs-md);
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.15s;
}

.header__nav a:hover {
    color: var(--text-muted);
}

.header__nav a.active {
    color: var(--text);
}

.header__hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
    order: -1;
    margin-right: 12px;
}

/* ─── Mobile Dropdown ────────────────────────────────────────────── */

.dropdown {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--dropdown-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 16px;
    z-index: 99;
    flex-direction: column;
    gap: 4px;
}

.dropdown--open {
    display: flex;
}

.dropdown a {
    display: block;
    font-size: var(--fs-base);
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 0;
}

.dropdown a:hover {
    color: var(--text);
}

/* ─── Badge ──────────────────────────────────────────────────────── */

.badge {
    font-size: var(--fs-base);
    padding: 5px 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.badge--accent {
    border-color: var(--accent);
    color: var(--accent-text);
    background: var(--accent-dim);
}

/* ─── Layout ─────────────────────────────────────────────────────── */

.layout {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
    max-width: 1472px;
    margin: 0 auto;
}

/* ─── Sidebar ────────────────────────────────────────────────────── */

.sidebar {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    width: var(--sidebar-width);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px 0;
    z-index: 50;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.sidebar__group {
    margin-bottom: 20px;
}

.sidebar__label {
    font-size: var(--fs-base);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--accent-text);
    padding: 0 20px;
    margin-bottom: 6px;
}

.sidebar__link {
    display: block;
    font-size: var(--fs-md);
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 20px;
    transition: all 0.1s;
    margin-right: 8px;
    border-radius: 6px;
    /*border-right: 2px solid transparent;*/
}

.sidebar__link:hover {
    color: var(--text);
    background: var(--sidebar-hover);
}

.sidebar__link--active,
.sidebar__link--active:hover {
    color: var(--accent-text);
    border-right-color: var(--accent);
    background: var(--accent-dim);
}

/* ─── Content ────────────────────────────────────────────────────── */

.content {
    position: relative;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
    display: flex;
    flex-direction: column;
}

/* ─── Markdown Content ───────────────────────────────────────────── */

/* Offset scroll position to account for fixed header (56px + 16px padding) */
.md h1,
.md h2,
.md h3,
.md h4,
.md h5,
.md h6 {
    scroll-margin-top: calc(var(--header-height) + 16px);
}

/* ─── Table of Contents (right sidebar) ──────────────────────────── */

.toc {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    width: var(--toc-width);
    flex-shrink: 0;
    padding: 32px 20px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
}

.toc::-webkit-scrollbar {
    width: 4px;
}

.toc::-webkit-scrollbar-track {
    background: transparent;
}

.toc::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.toc__title {
    font-size: var(--fs-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.toc__list {
    list-style: none;
}

.toc__item {
    margin-bottom: 0;
}

.toc__link {
    display: block;
    font-size: var(--fs-sm);
    line-height: 1.5;
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 0;
    transition: color 0.15s;
    border-left: 2px solid transparent;
    padding-left: 10px;
    margin-left: -10px;
}

.toc__link:hover {
    color: var(--text);
}

.toc__link--active {
    color: var(--accent-text);
    border-left-color: var(--accent);
}

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

.toc__link--sub {
    font-size: var(--fs-xs);
    padding-left: 20px;
    margin-left: -10px;
    color: var(--text-dim);
}

.toc__link--sub:hover {
    color: var(--text-muted);
}

.toc__link--sub.toc__link--active {
    color: var(--accent-text);
}

/* Context label for disambiguated duplicate headings — hidden visually, keeps slugs unique */

.toc-context {
    display: none;
}

/* ─── Overlay (mobile sidebar backdrop) ──────────────────────────── */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 40;
}

.overlay--visible {
    display: block;
}

/* ─── Overview Cards (docs, examples & benchmarks index) ──────────── */

.overview {
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 36px 80px;
}

.overview__title {
    font-size: 38px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    color: var(--text);
}

.overview__tagline {
    font-size: var(--fs-xl);
    color: var(--text-muted);
    margin-bottom: 36px;
    line-height: 1.6;
}

.overview__tagline a {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.overview__tagline a:hover {
    text-decoration-thickness: 2px;
}

.overview__section {
    margin-bottom: 32px;
}

.overview__section-title {
    font-size: var(--fs-base);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.overview__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.overview__card {
    display: block;
    padding: 20px 22px;
}

.overview__card-icon {
    font-size: var(--fs-xl);
    margin-bottom: 6px;
}

.overview__card-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.overview__card-desc {
    font-size: var(--fs-base);
    color: var(--text-dim);
    line-height: 1.5;
}

.overview__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.overview__chip {
    display: inline-block;
    font-size: var(--fs-2xs);
    font-weight: 500;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 4px;
    background: var(--bg-subtle, rgba(127, 127, 127, 0.1));
    color: var(--text-dim);
    white-space: nowrap;
}

/* ─── Variant Switcher ───────────────────────────────────────────── */

.variant-switcher {
    position: absolute;
    top: 10px;
    left: 36px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.variant-switcher__option {
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 400;
    text-transform: uppercase;
    color: var(--text-muted);
    text-decoration: none;
    background: transparent;
    border-radius: 4px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.variant-switcher__option:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.variant-switcher__option--active {
    color: #fff;
    background-color: var(--accent);
    font-weight: 500;
}
.variant-switcher__option--active:hover {
    color: #fff;
    background-color: var(--accent);
    font-weight: 500;
}

.variant-switcher__option--disabled {
    color: var(--text-dim);
    cursor: not-allowed;
    pointer-events: none;
    opacity: 0.5;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

.header__theme {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition:
        color 0.2s,
        background 0.2s,
        border-color 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.header__theme:hover {
    color: var(--text-muted);
    background: var(--sidebar-hover);
    border-color: var(--border);
}

.header__theme-sun,
.header__theme-moon {
    width: 18px;
    height: 18px;
}

/* Dark mode: show moon, hide sun */
.header__theme-sun {
    display: none;
}
.header__theme-moon {
    display: block;
}

/* Light mode: show sun, hide moon */
[data-theme-mode="light"] .header__theme-sun {
    display: block;
}
[data-theme-mode="light"] .header__theme-moon {
    display: none;
}

/* ─── Theme Transition ───────────────────────────────────────────── */

html[data-theme-mode] body,
html[data-theme-mode] .header,
html[data-theme-mode] .sidebar,
html[data-theme-mode] .content,
html[data-theme-mode] .toc,
html[data-theme-mode] .ui-card,
html[data-theme-mode] .sidebar__link,
html[data-theme-mode] .md pre,
html[data-theme-mode] .md code,
html[data-theme-mode] .md table,
html[data-theme-mode] .badge {
    transition:
        background-color 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease;
}

/* ─── Responsive: large screens ──────────────────────────────────── */

@media (min-width: 1200px) {
    .overview {
        max-width: 980px;
        width: 980px;
    }
}

/* ─── Responsive: tablet ─────────────────────────────────────────── */

@media (max-width: 1200px) {
    .toc {
        display: none;
    }

    .content {
        margin-right: 0;
    }
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 190px;
    }

    .overview {
        padding: 32px 28px 60px;
    }

    .overview__title {
        font-size: 32px;
    }

    .overview__tagline {
        font-size: 18px;
        margin-bottom: 28px;
    }

    .overview__section-title {
        font-size: 14px;
    }

    .overview__card {
        padding: 16px 18px;
    }

    .overview__card-title {
        font-size: 16px;
    }

    .overview__card-desc {
        font-size: 14px;
    }
}

/* ─── Responsive: no-sidebar pages (hamburger at 640px instead of 720px) ── */

body.no-sidebar .header__hamburger {
    display: none;
}

body.no-sidebar .header__nav {
    display: flex;
}

@media (max-width: 640px) {
    body.no-sidebar .header__nav {
        display: none;
    }

    body.no-sidebar .header__hamburger {
        display: block;
    }

    body.no-sidebar .dropdown--open {
        display: flex;
    }
}

/* ─── Responsive: mobile ─────────────────────────────────────────── */

@media (max-width: 720px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 260px;
        background: var(--bg);
        box-shadow: 4px 0 24px var(--shadow-sidebar);
    }

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

    .header__inner {
        padding: 0 12px 0 12px;
        gap: 8px;
    }

    .header__hamburger {
        display: block;
        margin-right: 0;
    }

    .header__nav {
        display: none;
    }

    .header__theme {
        margin-left: auto;
    }

    .header__logo {
        display: block;
        font-size: 20px;
        margin-bottom: 4px;
    }

    .header__sep {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .header__section {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .sidebar__label {
        font-size: 11px;
    }

    .sidebar__link {
        font-size: 14px;
    }

    .overview {
        padding: 12px 20px 60px;
    }

    .overview__title {
        font-size: 28px;
    }

    .overview__tagline {
        font-size: 16px;
        margin-bottom: 24px;
    }

    .overview__section {
        margin-bottom: 24px;
    }

    .overview__section-title {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .overview__grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .overview__card {
        padding: 14px 16px;
    }

    .overview__card-title {
        font-size: 15px;
    }

    .overview__card-desc {
        font-size: 14px;
    }

    .variant-switcher {
        display: none;
    }

    .variant-switcher__option {
        padding: 3px 10px;
        font-size: 14px;
    }
}

/* ─── Prev/Next Navigation ────────────────────────────────────────── */

.doc-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.doc-nav__link {
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
}

.doc-nav__link--prev {
    text-align: left;
}

.doc-nav__link--next {
    text-align: right;
    grid-column: 2;
}

.doc-nav__label {
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.doc-nav__title {
    font-size: var(--fs-md);
    font-weight: 500;
    color: var(--accent-text);
}

/*
SWICHER

*/

.button-group {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 3px;
    border-radius: 6px;
}

.button-group button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: var(--fs-xs);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}

.button-group button:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.button-group .button--active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.button-group .button--active:hover {
    background: var(--accent);
}

/*
doc-nav__link
*/

[data-theme-mode="light"] .doc-nav__link {
    background: #f8f8fa;
    border-color: #e0e0e8;
}

[data-theme-mode="light"] .doc-nav__link:hover {
    background: #f0f0f5;
    border-color: #d0d0d8;
}

/* ─── Accessibility: Focus indicators ────────────────────────────── */

/* Global focus ring */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Cards — inset ring (cards have border-radius) */
.ui-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Sidebar links — highlight instead of ring */
.sidebar__link:focus-visible {
    background: var(--accent-dim);
    color: var(--accent-text);
    outline: none;
}

/* ─── Accessibility: Reduced motion ──────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
