/* ============================================================
   SuperCSV — Spec Pages: "Kōtare" (Sacred Kingfisher)
   Light mode. Sidebar TOC. Sub-banner. Source Serif headings.
   Palette mapped to Todiramphus sanctus.
   Loaded AFTER styles.css — overrides :root for light theme.
   v2.1 — 2026-04-04
   ============================================================ */

:root {
    /* Kōtare palette — light-theme overrides for spec content */
    --bg-page:        #f0e8d8;
    --bg-card:        #ffffff;
    --bg-code:        #1a2d35;
    --bg-sidebar:     rgba(240, 232, 216, 0.95);
    --bg-sub-banner:  rgba(8, 36, 50, 0.97);

    --border-rule:    rgba(106, 96, 88, 0.25);
    --border-code:    #1a3d4a;

    --accent-primary: #1a6b8a;
    --accent-badge:   #1a6b8a;
    --accent-pop:     #d4a060;

    --text-body:      #1a2a2a;
    --text-muted:     #6a6058;
    --text-heading:   #1a2a2a;

    --code-text:      #c8dce6;

    --sidebar-width:  220px;
    --nav-height:     4.5rem;
    --sub-banner-height: 2.2rem;
    --top-offset:     calc(var(--nav-height) + var(--sub-banner-height));
}

body {
    color: var(--text-body);
    background: var(--bg-page);
}

/* Ensure gradient text uses intro palette, not spec overrides */
.menu-logo .csv-highlight {
    background: linear-gradient(135deg, #e86520, #f5a623);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.menu-links a.nav-about {
    background: linear-gradient(135deg, #e86520, #f5a623);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

/* Keep nav bar colours from intro palette on spec pages */
.menu-bar {
    background: rgba(10, 46, 62, 0.97);
}

.menu-logo {
    color: #f0eee8;
}

.menu-links a {
    color: #7aa0b0;
}

.menu-links a.nav-spec {
    color: #f0eee8;
}

.menu-toggle span {
    background: #f0eee8;
}

/* ============================================================
   SUB-BANNER (spec pages only)
   ============================================================ */
.sub-banner {
    position: sticky;
    top: var(--nav-height);
    left: 0;
    right: 0;
    height: var(--sub-banner-height);
    background: var(--bg-sub-banner);
    z-index: 1000;
    border-bottom: 1px solid rgba(18, 196, 216, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.sub-banner a {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #7aa0b0;
    text-decoration: none;
    padding: 0.15rem 0;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.sub-banner a:hover {
    color: #12c4d8;
}

.sub-banner a.active {
    color: #12c4d8;
    border-bottom-color: #12c4d8;
    font-weight: 600;
}

.sub-banner .separator {
    color: rgba(18, 196, 216, 0.3);
    font-size: 0.75rem;
    user-select: none;
}

/* ============================================================
   SIDEBAR TOC
   ============================================================ */
.sidebar-toc {
    position: fixed;
    top: var(--top-offset);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-nav);
    overflow-y: auto;
    padding: 1.5rem 1rem 2rem 1.25rem;
    z-index: 999;
    font-size: 0.95rem;
    line-height: 1.5;
}

.sidebar-toc::-webkit-scrollbar { width: 4px; }
.sidebar-toc::-webkit-scrollbar-track { background: transparent; }
.sidebar-toc::-webkit-scrollbar-thumb { background: rgba(106, 96, 88, 0.2); border-radius: 2px; }

.sidebar-toc .toc-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 600;
    font-size: 1.02rem;
    color: var(--text-heading);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-rule);
}

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

.sidebar-toc li {
    margin-bottom: 0.15rem;
}

.sidebar-toc a {
    color: var(--text-muted);
    text-decoration: none;
    display: block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: color 0.15s ease, background 0.15s ease;
    border-left: 2px solid transparent;
}

.sidebar-toc a:hover {
    color: var(--accent-primary);
    background: rgba(26, 107, 138, 0.06);
}

.sidebar-toc a.active {
    color: var(--accent-primary);
    font-weight: 600;
    border-left-color: var(--accent-primary);
    background: rgba(26, 107, 138, 0.08);
}

/* Indented sub-sections (h3 under h2) */
.sidebar-toc .toc-h3 {
    padding-left: 1.2rem;
    font-size: 0.88rem;
}

/* ============================================================
   MAIN CONTENT AREA (offset for sidebar)
   ============================================================ */
.spec-layout {
    margin-left: var(--sidebar-width);
}

.spec-content {
    max-width: 780px;
    margin: 0 auto;
    padding: 2rem 2.5rem 4rem 2.5rem;
}

/* ============================================================
   SPEC TYPOGRAPHY
   ============================================================ */

/* Page title */
.spec-content > h1 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.spec-content > .spec-subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.spec-content > .spec-intro {
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-rule);
}

/* Section headings (h2) */
.spec-content h2 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.3rem, 2.5vw, 1.7rem);
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 3rem;
    margin-bottom: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-rule);
    scroll-margin-top: calc(var(--top-offset) + 1rem);
}

.spec-content h2:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* Sub-section headings (h3) */
.spec-content h3 {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1.05rem, 2vw, 1.25rem);
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    scroll-margin-top: calc(var(--top-offset) + 1rem);
}

/* Sub-sub headings (h4) */
.spec-content h4 {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    scroll-margin-top: calc(var(--top-offset) + 1rem);
}

/* h5 for deeper nesting */
.spec-content h5 {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 1.25rem;
    margin-bottom: 0.4rem;
}

/* Paragraphs */
.spec-content p {
    font-size: 1.02rem;
    line-height: 1.8;
    color: var(--text-body);
    margin-bottom: 1rem;
    max-width: 680px;
}

/* Emphasis / strong */
.spec-content strong {
    font-weight: 600;
    color: var(--text-heading);
}

.spec-content em {
    font-style: italic;
}

.spec-content a {
    color: var(--accent-primary);
    text-decoration: underline;
    text-decoration-color: rgba(26, 107, 138, 0.35);
    text-underline-offset: 2px;
    transition: color 0.2s, text-decoration-color 0.2s;
}

.spec-content a:visited {
    color: var(--text-muted);
}

.spec-content a:hover {
    color: var(--accent-pop);
    text-decoration-color: var(--accent-pop);
}

/* ============================================================
   LISTS
   ============================================================ */
.spec-content ul,
.spec-content ol {
    margin: 0.75rem 0 1rem 1.5rem;
    font-size: 1.02rem;
    line-height: 1.8;
    color: var(--text-body);
}

.spec-content li {
    margin-bottom: 0.3rem;
}

.spec-content li ul,
.spec-content li ol {
    margin-top: 0.3rem;
    margin-bottom: 0.3rem;
}

/* ============================================================
   INLINE CODE
   ============================================================ */
.spec-content code:not(pre code) {
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    font-size: 0.92em;
    background: rgba(26, 107, 138, 0.08);
    color: var(--accent-primary);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    white-space: nowrap;
}

/* ============================================================
   CODE BLOCKS
   ============================================================ */
.spec-content pre {
    background: var(--bg-code);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    max-width: 100%;
    border-top: 2px solid var(--border-code);
    margin: 1rem 0 1.5rem 0;
}

.spec-content pre code,
.code-block code {
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--code-text);
    white-space: pre;
    display: block;
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.code-block {
    background: var(--bg-code);
    border-radius: 6px;
    padding: 1.25rem 1.5rem;
    overflow-x: auto;
    max-width: 100%;
    border-top: 2px solid var(--border-code);
    margin: 1rem 0 1.5rem 0;
}

/* ============================================================
   TABLES
   ============================================================ */
.spec-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem 0;
    font-size: 0.95rem;
}

.spec-content th {
    font-weight: 600;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 2px solid var(--border-code);
    color: var(--text-heading);
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.spec-content td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-rule);
    color: var(--text-body);
    vertical-align: top;
}

.spec-content td code {
    font-size: 0.8em;
}

.spec-content tr:last-child td {
    border-bottom: none;
}

/* ============================================================
   TABLE SCROLL WRAPPER
   ============================================================ */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0 1.5rem;
}

.table-scroll table {
    margin: 0;
    min-width: 500px;
}

/* ============================================================
   BLOCKQUOTES (for warnings / notes)
   ============================================================ */
.spec-content blockquote {
    border-left: 3px solid var(--accent-pop);
    background: rgba(212, 160, 96, 0.08);
    padding: 0.75rem 1rem;
    margin: 1rem 0 1.5rem 0;
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
    color: var(--text-body);
}

.spec-content blockquote p {
    margin-bottom: 0.25rem;
}

/* ============================================================
   HORIZONTAL RULES
   ============================================================ */
.spec-content hr {
    border: none;
    border-top: 1px solid var(--border-rule);
    margin: 2rem 0;
}

/* ============================================================
   SYNTAX HIGHLIGHTING (kōtare-adjusted)
   ============================================================ */
.scsv-column  { color: #E8E090; }
.scsv-type    { color: #5a9ab5; }
.scsv-value   { color: #9CDCFE; }
.scsv-special { color: #7a98b0; }
.scsv-string  { color: #9CDCFE; }
.scsv-comment { color: #6A9955; }
.scsv-meta    { color: #808080; }
.scsv-punct   { color: #D4D4D4; }

/* ============================================================
   BADGES (for spec sections)
   ============================================================ */
.spec-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-badge);
    background: rgba(26, 107, 138, 0.12);
    padding: 0.2rem 0.65rem;
    border-radius: 100px;
    margin-bottom: 0.4rem;
}

/* ============================================================
   FOOTER
   ============================================================ */
footer {
    margin-left: var(--sidebar-width);
    background: rgba(7, 24, 34, 0.95);
    color: rgba(240, 238, 232, 0.55);
    text-align: center;
    padding: 2.5rem 0;
    border-top: 1px solid rgba(18, 196, 216, 0.08);
    font-size: 0.85rem;
}

footer p + p {
    margin-top: 0.25rem;
    opacity: 0.5;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: rgba(106, 96, 88, 0.25); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-primary); }

/* Firefox scrollbar */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(106, 96, 88, 0.25) var(--bg-page);
}

.sidebar-toc {
    scrollbar-width: thin;
    scrollbar-color: rgba(106, 96, 88, 0.2) transparent;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* ============================================================
   MOBILE TOC (replaces hidden sidebar on small screens)
   ============================================================ */
.mobile-toc {
    display: none;
}

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

    .sidebar-toc {
        display: none;
    }

    .mobile-toc {
        display: block;
        position: sticky;
        top: calc(var(--nav-height) + var(--sub-banner-height));
        z-index: 998;
        background: var(--bg-page);
        border-bottom: 1px solid var(--border-rule);
    }

    .mobile-toc-toggle {
        width: 100%;
        padding: 0.6rem 1rem;
        background: none;
        border: none;
        color: var(--text-heading);
        font-size: 0.9rem;
        font-weight: 600;
        text-align: left;
        cursor: pointer;
        font-family: inherit;
    }

    .mobile-toc-panel {
        display: none;
        max-height: 60vh;
        overflow-y: auto;
        padding: 0.5rem 1rem 1rem;
    }

    .mobile-toc-panel.open {
        display: block;
    }

    .mobile-toc-panel a {
        display: block;
        padding: 0.35rem 0.5rem;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.88rem;
        border-radius: 4px;
    }

    .mobile-toc-panel a:hover {
        color: var(--accent-primary);
        background: rgba(26, 107, 138, 0.06);
    }

    .mobile-toc-panel .toc-h3 {
        padding-left: 1.2rem;
        font-size: 0.82rem;
    }

    .spec-layout {
        margin-left: 0;
    }

    .spec-content {
        padding: 1.5rem 1rem 3rem 1rem;
    }

    .spec-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    footer {
        margin-left: 0;
    }
}

/* ============================================================
   PORTRAIT ORIENTATION (spec pages)
   ============================================================ */
@media (max-width: 480px) and (orientation: portrait) {
    .spec-content {
        padding: 1rem 0.75rem 2rem;
    }

    .spec-content pre code {
        font-size: 0.65rem;
    }

    .spec-content table {
        font-size: 0.8rem;
    }

    .spec-content th,
    .spec-content td {
        padding: 0.35rem 0.5rem;
    }
}

@media (max-width: 600px) {
    .sub-banner { gap: 1rem; }
    .sub-banner a { font-size: 0.75rem; }
    .spec-content pre { padding: 0.75rem 1rem; }
    .spec-content pre code { font-size: 0.72rem; }
}

/* ============================================================
   SMOOTH SCROLL + FADE
   ============================================================ */
html {
    scroll-behavior: smooth;
}

.spec-layout {
    opacity: 0;
    animation: fadeIn 0.5s ease-in forwards;
}

@keyframes fadeIn { to { opacity: 1; } }
