/* ============================================
   Zera Student Handbook — Brand Stylesheet
   Font: OG (S3-hosted)   Palette: Zera Education
   Book layout: sticky sidebar TOC + reading pane
   ============================================ */

/* --- Font Faces --- */
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_Light.ttf')   format('truetype'); font-weight: 300; font-style: normal; }
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_Regular.ttf') format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_Medium.ttf')  format('truetype'); font-weight: 500; font-style: normal; }
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_SemiBold.ttf') format('truetype'); font-weight: 600; font-style: normal; }
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_Bold.ttf')    format('truetype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_RegItal.ttf') format('truetype'); font-weight: 400; font-style: italic; }
@font-face { font-family: 'OG'; src: url('/brand/fonts/OG_BoldItal.ttf') format('truetype'); font-weight: 700; font-style: italic; }

/* --- Design Tokens --- */
:root {
    --edu: #0D4A34;
    --edu-light: #e8f0ec;
    --edu-mid: #b8d4c6;
    --bg: #F7F7F5;
    --white: #FFFFFF;
    --border: #E4E4E4;
    --text: #1A1A1A;
    --muted: #6B6B6B;
    --dark: #141414;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.08);
    --max-width: 1180px;
    --sidebar-w: 280px;
    --read-w: 760px;
    --header-h: 77px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'OG', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-inner {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.logo-link { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
.logo { height: 52px; width: auto; margin: -10px -4px -18px -4px; }
.header-meta { display: flex; gap: 8px; }
.badge { font-size: 0.75rem; font-weight: 600; padding: 4px 12px; border-radius: 20px; white-space: nowrap; }
.badge-team { background: var(--edu); color: var(--white); }
.toc-toggle {
    display: none;
    place-items: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: var(--edu-light);
    color: var(--edu);
    border: none;
    border-radius: 12px;
    cursor: pointer;
}
.toc-toggle svg { width: 22px; height: 22px; }
.toc-toggle:active { transform: scale(0.94); }

/* --- Mobile scrim behind drawer (shown only via the ≤880px media query) --- */
.scrim {
    display: none;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(20, 20, 20, 0.5);
    z-index: 85;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

/* --- Book Layout --- */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    align-items: start;
    min-height: calc(100vh - var(--header-h));
}

/* --- Sidebar TOC --- */
.sidebar {
    position: sticky;
    top: var(--header-h);
    align-self: start;
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 24px 0;
}
.toc { font-size: 0.9rem; }
.toc-home {
    display: block;
    padding: 6px 24px 14px;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--edu);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
.toc-part { margin-top: 20px; }
.toc-part-label {
    display: block;
    padding: 0 24px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
}
.toc-part ul { list-style: none; }
.toc-part li a {
    display: block;
    padding: 7px 24px;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.toc-part li a:hover { background: var(--edu-light); color: var(--edu); }
.toc-part li.is-active a {
    background: var(--edu-light);
    color: var(--edu);
    border-left-color: var(--edu);
    font-weight: 600;
}

/* --- Reading Pane --- */
.main { padding: 40px 48px 72px; min-width: 0; }
.content { max-width: var(--read-w); margin: 0 auto; }

/* --- Cover Hero --- */
.cover-eyebrow,
.chapter-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 8px;
}
.cover-hero {
    background: linear-gradient(140deg, var(--edu-light) 0%, var(--bg) 70%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    margin-bottom: 12px;
}
.cover-title { font-weight: 700; font-size: 2.6rem; line-height: 1.1; color: var(--edu); margin-bottom: 14px; letter-spacing: -0.01em; }
.cover-lede { font-size: 1.1rem; color: var(--text); max-width: 540px; margin-bottom: 24px; }

/* --- Search box (shared: hero + sidebar) --- */
.hb-searchbox {
    position: relative;
    display: flex;
    align-items: center;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.hb-search {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    color: var(--text);
}
.hb-search::placeholder { color: var(--muted); }
.hb-search-icon { color: var(--muted); flex-shrink: 0; }

/* Hero variant (cover page) */
.hb-searchbox--hero {
    gap: 10px;
    padding: 0 16px;
    max-width: 460px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.hb-searchbox--hero:focus-within { border-color: var(--edu); box-shadow: 0 0 0 3px var(--edu-mid); }
.hb-searchbox--hero .hb-search { height: 48px; font-size: 1rem; }
.hb-searchbox--hero .hb-search-icon { width: 20px; height: 20px; }

/* Sidebar variant (every page) */
.hb-searchbox--side {
    gap: 8px;
    margin: 0 16px 12px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.hb-searchbox--side:focus-within { border-color: var(--edu); box-shadow: 0 0 0 2px var(--edu-mid); }
.hb-searchbox--side .hb-search { height: 42px; font-size: 0.9rem; }
.hb-searchbox--side .hb-search-icon { width: 17px; height: 17px; }

/* Results dropdown */
.hb-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 120;
    max-height: 64vh;
    overflow-y: auto;
    padding: 6px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}
.hb-searchbox--side .hb-results { right: auto; width: 290px; max-width: 78vw; }
.hb-result { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; }
.hb-result:hover, .hb-result:focus-visible { background: var(--edu-light); }
.hb-result-crumb { display: block; font-weight: 600; font-size: 0.9rem; color: var(--edu); }
.hb-result-snip { display: block; font-size: 0.82rem; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.hb-results mark { background: #fde68a; color: var(--dark); padding: 0 1px; border-radius: 2px; }
.hb-noresult { padding: 12px; color: var(--muted); font-size: 0.9rem; }

.cover-meta { font-size: 0.85rem; color: var(--muted); margin-top: 16px; }

/* --- Cover sections --- */
.cover-part { margin-top: 40px; }
.cover-part[hidden] { display: none; }
.cover-part-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.cover-part-head h2 { font-weight: 600; font-size: 1.2rem; color: var(--edu); margin: 0; }
.part-icon { width: 22px; height: 22px; color: var(--edu); flex-shrink: 0; }

.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 14px; }
.cover-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 18px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.cover-card[hidden] { display: none; }
.cover-card:hover { border-color: var(--edu); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.cover-card-num {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--edu);
    background: var(--edu-light);
    border-radius: 8px;
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.cover-card-title { font-weight: 600; font-size: 1rem; color: var(--edu); flex: 1; line-height: 1.3; }
.cover-card-arrow { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; transition: transform 0.18s ease, color 0.18s ease; }
.cover-card:hover .cover-card-arrow { color: var(--edu); transform: translateX(3px); }
.cover-empty { color: var(--muted); font-style: italic; margin: 24px 0; }

/* --- Cover contact CTA --- */
.cover-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 48px;
    padding: 28px 32px;
    background: var(--edu);
    border-radius: var(--radius-lg);
    color: var(--white);
}
.content .cover-cta h2 { font-size: 1.25rem; font-weight: 600; margin: 0 0 4px; padding: 0; border: none; color: var(--white); }
.cover-cta p { color: rgba(255,255,255,0.85); margin: 0; }
.cover-cta-btn {
    background: var(--white);
    color: var(--edu);
    font-weight: 600;
    text-decoration: none;
    padding: 12px 22px;
    border-radius: 10px;
    white-space: nowrap;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.cover-cta-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

/* --- Chapter Typography --- */
.content h1 { font-weight: 700; font-size: 2rem; color: var(--edu); margin-bottom: 8px; padding-bottom: 12px; border-bottom: 3px solid var(--edu); }
.content h2 { font-weight: 600; font-size: 1.35rem; color: var(--edu); margin-top: 40px; margin-bottom: 16px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.content h3 { font-weight: 600; font-size: 1.1rem; color: var(--dark); margin-top: 32px; margin-bottom: 12px; }
.content h4 { font-weight: 600; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 24px; margin-bottom: 8px; }
.content p { margin-bottom: 12px; }
.content strong { font-weight: 600; color: var(--dark); }
.content em { font-style: italic; }
.content a { color: var(--edu); text-decoration: underline; text-underline-offset: 2px; }
/* Structural links in generated markup are not inline body links — no underline */
.content .cover-card,
.content .cover-cta-btn,
.content .hb-result,
.content .brand-link { text-decoration: none; }
.content .brand-link { color: var(--white); }
.content code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; background: var(--edu-light); color: var(--edu); padding: 2px 6px; border-radius: 4px; }

/* --- Callouts / blockquotes --- */
.content blockquote {
    background: var(--edu-light);
    border-left: 4px solid var(--edu);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 16px 20px;
    margin: 16px 0 24px;
    font-size: 0.95rem;
}
.content blockquote p { margin-bottom: 0; }

/* --- Lists --- */
.content ul, .content ol { margin: 8px 0 16px 20px; }
.content li { margin-bottom: 6px; padding-left: 4px; }
.content li::marker { color: var(--edu); font-weight: 600; }

/* --- Rules --- */
.content hr { border: none; height: 1px; background: var(--border); margin: 32px 0; }

/* --- Tables --- */
.content table { width: 100%; border-collapse: collapse; margin: 16px 0 24px; font-size: 0.9rem; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.content thead { background: var(--edu); color: var(--white); }
.content th { font-weight: 600; text-align: left; padding: 10px 14px; }
.content td { padding: 10px 14px; border-top: 1px solid var(--border); }
.content tbody tr:hover { background: var(--edu-light); }

/* --- Checklists --- */
.content li input[type="checkbox"] { appearance: none; width: 16px; height: 16px; border: 2px solid var(--edu); border-radius: 3px; vertical-align: middle; margin-right: 6px; position: relative; top: -1px; }
.content li input[type="checkbox"]:checked { background: var(--edu); }
.content li input[type="checkbox"]:checked::after { content: '\2713'; color: var(--white); font-size: 11px; position: absolute; top: -1px; left: 2px; }

/* --- Images --- */
.content img { max-width: 100%; height: auto; border-radius: var(--radius); margin: 20px auto; display: block; }
.content p > img { box-shadow: var(--shadow); }

/* --- Anthem audio players --- */
.anthem-players { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 16px 0 28px; }
.anthem-player { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); }
.anthem-player-tag { display: block; font-weight: 600; color: var(--edu); font-size: 0.95rem; }
.anthem-player-desc { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.anthem-player audio { width: 100%; height: 38px; }

/* --- Brand guide link button --- */
.brand-link { display: inline-block; background: var(--edu); color: var(--white); font-weight: 600; padding: 11px 20px; border-radius: 10px; margin: 4px 0 8px; transition: transform 0.18s ease, box-shadow 0.18s ease; }
.brand-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); color: var(--white); }

/* --- Prev / Next --- */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}
.chapter-nav a {
    flex: 1;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 18px;
    text-decoration: none;
    color: var(--edu);
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: all 0.18s ease;
}
.chapter-nav a:hover { border-color: var(--edu); box-shadow: var(--shadow-lg); }
.chapter-nav .nav-next { text-align: right; }

/* --- Footer --- */
.footer { background: var(--dark); color: var(--white); text-align: center; padding: 32px 24px; font-size: 0.85rem; }
.footer-inner { max-width: var(--read-w); margin: 0 auto; }
.footer-mark { height: 40px; width: auto; margin: -10px -15px 8px -15px; opacity: 0.9; filter: brightness(0) invert(1); }
.footer-muted { color: rgba(255,255,255,0.5); margin-top: 4px; }

/* --- Print --- */
@media print {
    .header, .sidebar, .toc-toggle, .chapter-nav { display: none !important; }
    .layout { display: block; }
    .main { padding: 0; }
    .content h1 { font-size: 1.5rem; }
    body { background: white; }
}

/* --- Accessibility: focus & motion --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
.cover-card:focus-visible,
.toc-part li a:focus-visible {
    outline: 3px solid var(--edu-mid);
    outline-offset: 2px;
    border-radius: 6px;
}
html { -webkit-tap-highlight-color: transparent; }

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

/* --- Responsive --- */
@media (max-width: 880px) {
    .toc-toggle { display: grid; }
    .layout { display: block; }
    .scrim { display: block; }
    body.toc-open .scrim { opacity: 1; pointer-events: auto; }
    .sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        width: var(--sidebar-w);
        max-width: 86vw;
        height: calc(100dvh - var(--header-h));
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 90;
        box-shadow: var(--shadow-lg);
    }
    body.toc-open .sidebar { transform: translateX(0); }
    /* Larger touch targets in the drawer */
    .toc-home { padding: 12px 24px 16px; }
    .toc-part li a { padding: 12px 24px; }
    .main { padding: 28px 22px 60px; }
    .cover-hero { padding: 28px 22px; }
    .cover-title { font-size: 2rem; }
    .cover-lede { font-size: 1rem; }
}

@media (max-width: 480px) {
    .header-inner { padding: 10px 14px; gap: 12px; }
    .logo { height: 44px; }
    .cover-title { font-size: 1.7rem; }
    .cover-grid { grid-template-columns: 1fr; }
    .cover-cta { padding: 22px; }
    .cover-cta-btn { width: 100%; text-align: center; }
    .chapter-nav { flex-direction: column; }
}
