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

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

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

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

:root {
    --text: #e8e8ed;
    --text-muted: #9a9aaa;
    --text-dim: #5a5a68;
    --bg: #0c0c10;
    --bg-sidebar: #101014;
    --bg-card: #141418;
    --bg-card-hover: #161619;
    --border: #1e1e25;
    --border-hover: #2e2e38;
    --accent: #667eea;
    --accent-dim: rgba(102, 126, 234, 0.15);
    --accent-text: #8da0f2;
    --header-bg: rgba(12, 12, 16, 0.85);
    --sidebar-hover: rgba(255, 255, 255, 0.03);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --shadow-sidebar: rgba(0, 0, 0, 0.4);
    --sidebar-width: 220px;
    --toc-width: 240px;
    --header-height: 56px;
    --radius: 8px;

    /* Material Design 3 Surface Tokens - Dark Theme */
    --surface: #1a1a1e;
    --surface-dim: #131316;
    --surface-bright: #3a3a3e;
    --surface-container-lowest: #0e0e11;
    --surface-container-low: #1a1a1e;
    --surface-container: #1e1e22;
    --surface-container-high: #282831;
    --surface-container-highest: #33333c;
    --outline-variant: rgba(255, 255, 255, 0.2);

    /* Material Design 3 On-Surface Text Tokens - Dark Theme */
    --on-surface: #e6e1e5;
    --on-surface-variant: #cac4d0;
    --text-primary: #e8e8ed;
    --color-success: #4caf50;
    --color-error: #ef5350;
}

/* ─── Light Theme ────────────────────────────────────────────────── */

[data-theme-mode="light"] {
    --text: #1a1a2e;
    --text-muted: #4a4a60;
    --text-dim: #8080a0;
    --bg: #ffffff;
    --bg-sidebar: #f5f5f8;
    --bg-card: #f0f0f5;
    --bg-card-hover: #e8e8f0;
    --border: #dcdce5;
    --border-hover: #c0c0d0;
    --accent: #4a5cd8;
    --accent-dim: rgba(74, 92, 216, 0.08);
    --accent-text: #4a5cd8;
    --header-bg: rgba(255, 255, 255, 0.85);
    --sidebar-hover: rgba(0, 0, 0, 0.03);
    --overlay-bg: rgba(0, 0, 0, 0.3);
    --shadow-sidebar: rgba(0, 0, 0, 0.15);

    /* Material Design 3 Surface Tokens - Light Theme */
    --surface: #fefbff;
    --surface-dim: #ddd9e0;
    --surface-bright: #fefbff;
    --surface-container-lowest: #ffffff;
    --surface-container-low: #f7f4fa;
    --surface-container: #f2eff5;
    --surface-container-high: #ece9ef;
    --surface-container-highest: #e6e3e9;
    --outline-variant: rgba(0, 0, 0, 0.15);

    /* Material Design 3 On-Surface Text Tokens - Light Theme */
    --on-surface: #1c1b1f;
    --on-surface-variant: #49454f;
    --text-primary: #1a1a2e;
    --color-success: #2e7d32;
    --color-error: #c62828;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
        sans-serif;
    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: 16px;
    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: 16px;
    user-select: none;
}

.header__section {
    font-size: 17px;
    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: 16px;
    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-muted);
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
}

/* ─── 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: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    padding: 0 20px;
    margin-bottom: 6px;
}

.sidebar__link {
    display: block;
    font-size: 16px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 5px 20px;
    transition: all 0.1s;
    border-right: 2px solid transparent;
}

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

.sidebar__link--active {
    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: 11px;
    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: 13px;
    line-height: 1.5;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 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: 12px;
    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: 20px;
    color: var(--text-muted);
    margin-bottom: 36px;
    line-height: 1.6;
}

.overview__section {
    margin-bottom: 32px;
}

.overview__section-title {
    font-size: 15px;
    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;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
}

.overview__card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.overview__card-icon {
    font-size: 20px;
    margin-bottom: 6px;
}

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

.overview__card-desc {
    font-size: 15px;
    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: 11px;
    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: var(--text);
    background: var(--bg-hover);
    font-weight: 500;
    background-color: #4a5cd8;
}
.variant-switcher__option--active:hover {
    color: var(--text);
    background: var(--bg-hover);
    font-weight: 500;
    background-color: #4a5cd8;
}

.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,
[data-theme-mode="light"] .header__theme-sun {
    display: block;
}
[data-theme-mode="light"] .header__theme-moon,
[data-theme="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] .overview__card,
html[data-theme-mode] .sidebar__link {
    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: 880px;
    }
}

/* ─── 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: 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__hamburger {
        display: block;
    }

    .header__nav {
        display: none;
    }

    .header__logo {
        font-size: 18px;
    }

    .header__sep {
        font-size: 20px;
    }

    .header__section {
        font-size: 15px;
    }

    .sidebar__label {
        font-size: 11px;
    }

    .sidebar__link {
        font-size: 14px;
    }

    .overview {
        padding: 24px 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 {
        gap: 8px;
        margin-bottom: 12px;
    }

    .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;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s;
}

.doc-nav__link:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

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

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

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

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

.doc-nav__spacer {
    /* Empty space when no prev/next */
}

[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;
}
