/* Preparation-guide styling.
   Directly adapted from the orchestrator admin theme:
   dark-first, flat, monospace-aware. Reference: Linear / Vercel / Supabase Studio.
   - Inter for UI, JetBrains Mono for data/code.
   - Single green accent (#00C853), used only for signal.
   - Flat: 1px borders, no shadows except on floating surfaces.
*/

:root {
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --bg:           #fafafa;
    --bg-elev:      #ffffff;
    --bg-subtle:    #f4f4f5;
    --bg-row-hover: #f4f4f5;
    --fg:           #18181b;
    --fg-dim:       #71717a;
    --fg-muted:     #a1a1aa;
    --border:       #e4e4e7;
    --border-soft:  #f4f4f5;

    --accent:       #00C853;
    --accent-fg:    #052e16;
    --accent-soft:  rgba(0, 200, 83, 0.10);

    --ok:           #16a34a;
    --warn:         #d97706;
    --fail:         #dc2626;

    --radius: 4px;
    --pad: 16px;
    --gap: 10px;
}

:root[data-theme="dark"] {
    --bg:           #0a0a0a;
    --bg-elev:      #0f0f10;
    --bg-subtle:    #131316;
    --bg-row-hover: #161618;
    --fg:           #d4d4d8;
    --fg-dim:       #a1a1aa;
    --fg-muted:     #71717a;
    --border:       #27272a;
    --border-soft:  #1c1c1f;
    --accent-soft:  rgba(0, 200, 83, 0.14);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:           #0a0a0a;
        --bg-elev:      #0f0f10;
        --bg-subtle:    #131316;
        --bg-row-hover: #161618;
        --fg:           #d4d4d8;
        --fg-dim:       #a1a1aa;
        --fg-muted:     #71717a;
        --border:       #27272a;
        --border-soft:  #1c1c1f;
        --accent-soft:  rgba(0, 200, 83, 0.14);
    }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; }
html, body { background: var(--bg); }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--fg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11", "ss01";
}

/* --- reading progress bar ---------------------------------------------- */
#progress {
    position: fixed;
    top: 0; left: 0;
    height: 2px;
    width: 0;
    background: var(--accent);
    z-index: 60;
    transition: width 80ms linear;
}

/* --- top bar ------------------------------------------------------------ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--pad);
    padding: 12px 24px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.brand-logo {
    display: grid;
    place-items: center;
    width: 26px; height: 26px;
    border-radius: 5px;
    background: var(--fg);
    color: var(--bg);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
}
.brand-name {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 500;
    color: var(--fg);
}
.brand-org {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 400;
    color: var(--fg-dim);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.workshop-badge {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
}
.theme-toggle {
    height: 30px; width: 30px;
    display: grid; place-items: center;
    padding: 0;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg-dim);
    cursor: pointer;
    transition: color 80ms ease, border-color 80ms ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }
:root[data-theme="dark"] .theme-toggle .i-sun,
:root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon,
:root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
.theme-toggle .i-sun { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

/* --- hero --------------------------------------------------------------- */
.hero {
    max-width: 1180px;
    margin: 0 auto;
    padding: 64px 24px 40px;
    border-bottom: 1px solid var(--border);
}
.hero .eyebrow {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 16px;
}
.hero h1 {
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 600;
    margin: 0 0 16px;
    max-width: 18ch;
}
.hero .lede {
    font-size: 18px;
    color: var(--fg-dim);
    max-width: 60ch;
    margin: 0 0 24px;
}
.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--fg-dim);
    border: 1px solid var(--border);
    background: var(--bg-elev);
    border-radius: var(--radius);
    padding: 5px 11px;
}
.chip::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 999px;
    background: var(--accent);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    text-decoration: none;
    border: 1px solid var(--fg);
    transition: opacity 80ms ease, border-color 80ms ease, color 80ms ease;
}
.btn-primary { background: var(--fg); color: var(--bg); }
.btn-primary:hover { opacity: 0.88; }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* --- layout: sidebar + content ----------------------------------------- */
.layout {
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 48px;
    padding: 0 24px 96px;
    align-items: start;
}

.toc {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    padding: 32px 0;
    font-size: 13px;
}
.toc-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-dim);
    font-weight: 500;
    margin: 0 0 12px;
}
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { margin: 0; }
.toc a {
    display: block;
    padding: 4px 10px 4px 12px;
    color: var(--fg-dim);
    text-decoration: none;
    border-left: 2px solid var(--border-soft);
    border-radius: 0;
    transition: color 80ms ease, border-color 80ms ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toc a:hover { color: var(--fg); }
.toc a.active {
    color: var(--fg);
    border-left-color: var(--accent);
    font-weight: 500;
}
.toc .toc-num {
    font-family: var(--font-mono);
    color: var(--fg-muted);
    margin-right: 8px;
    font-size: 11px;
}

/* --- content ------------------------------------------------------------ */
.content { padding: 32px 0; min-width: 0; max-width: 760px; }

section.part { scroll-margin-top: 80px; padding-top: 8px; }
section.part + section.part {
    margin-top: 48px;
    padding-top: 48px;
    border-top: 1px solid var(--border);
}
.part-kicker {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 8px;
}
h2 {
    font-size: 26px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 600;
    margin: 0 0 8px;
}
h3 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 28px 0 8px;
}
h4 {
    font-family: var(--font-mono);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-dim);
    font-weight: 500;
    margin: 20px 0 6px;
}
p { margin: 12px 0; }
.content > section p, .content > section li { color: var(--fg); }
.dim { color: var(--fg-dim); }
strong { font-weight: 600; color: var(--fg); }
ul, ol { padding-left: 22px; margin: 12px 0; }
li { margin: 5px 0; }
li::marker { color: var(--fg-muted); }

a.inline {
    color: var(--fg);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
a.inline:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* --- code --------------------------------------------------------------- */
code, kbd, pre { font-family: var(--font-mono); }
code {
    font-size: 0.86em;
    background: var(--bg-subtle);
    border: 1px solid var(--border-soft);
    padding: 1px 5px;
    border-radius: var(--radius);
    color: var(--fg);
}
pre {
    background: #0a0a0a;
    border: 1px solid #27272a;
    color: #e4e4e7;
    padding: 14px 16px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 12px 0 16px;
    line-height: 1.6;
    font-size: 13px;
}
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
kbd {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: var(--radius);
    padding: 2px 6px;
    color: var(--fg-dim);
    font-size: 12px;
}

/* --- tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 16px 0; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
th {
    text-align: left;
    padding: 9px 14px;
    background: var(--bg-subtle);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fg-dim);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--fg);
    vertical-align: top;
}
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 60ms ease; }
tbody tr:hover { background: var(--bg-row-hover); }
td code { white-space: nowrap; }

/* --- callouts ----------------------------------------------------------- */
.callout {
    border: 1px solid var(--border);
    border-left: 2px solid var(--fg-muted);
    background: var(--bg-elev);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 18px 0;
}
.callout .callout-label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
    color: var(--fg-dim);
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 7px;
}
.callout p:first-of-type { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }

/* Try-this: the green, do-it-yourself box. */
.try {
    border-left-color: var(--accent);
    background: var(--accent-soft);
}
.try .callout-label { color: var(--accent); }
.try .callout-label::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Key idea: the emphasised principle box. */
.key { border-left-color: var(--fg); background: var(--bg-subtle); }
.key .big {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 4px 0;
}

/* Warn: the gotcha box. */
.warn { border-left-color: var(--warn); }
.warn .callout-label { color: var(--warn); }

/* --- checklist (before the course) ------------------------------------- */
.checklist { list-style: none; padding: 0; margin: 16px 0; }
.checklist li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
    margin: 8px 0;
    cursor: pointer;
    transition: border-color 80ms ease;
}
.checklist li:hover { border-color: var(--fg-muted); }
.checklist input { display: none; }
.checklist .box {
    flex: 0 0 auto;
    width: 18px; height: 18px;
    margin-top: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    color: transparent;
    transition: all 80ms ease;
}
.checklist input:checked + .box {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-fg);
}
.checklist .box svg { width: 12px; height: 12px; }
.checklist input:checked ~ .ck-text { color: var(--fg-dim); text-decoration: line-through; text-decoration-color: var(--fg-muted); }
.checklist .ck-text { color: var(--fg); }
.checklist .ck-text small { display: block; color: var(--fg-dim); font-size: 12.5px; text-decoration: none; margin-top: 2px; }

/* --- ascii diagram ------------------------------------------------------ */
pre.diagram {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--fg);
    font-size: 12.5px;
    line-height: 1.4;
}

/* --- footer ------------------------------------------------------------- */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px;
}
.site-footer .inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--pad);
    flex-wrap: wrap;
}
.site-footer a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--fg-dim);
    text-decoration: none;
    transition: color 80ms ease;
}
.site-footer a:hover { color: var(--fg); }
.github-icon { width: 18px; height: 18px; fill: currentColor; }
.footer-note { font-family: var(--font-mono); font-size: 12px; color: var(--fg-dim); }

/* --- responsive --------------------------------------------------------- */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; gap: 0; }
    .toc {
        position: static;
        max-height: none;
        overflow: visible;
        padding: 24px 0 8px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 16px;
    }
    .toc ol {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    .toc a { border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
    .toc a.active { border-color: var(--accent); border-left-color: var(--accent); }
    .toc .toc-num { display: none; }
    .content { max-width: none; }
}
@media (max-width: 560px) {
    .hero { padding: 40px 20px 32px; }
    .brand-org { display: none; }
}

/* --- print / PDF -------------------------------------------------------- */
/* Force a clean light document: drop the sidebar, chrome and interactive
   bits, flatten colours to ink-on-paper, keep callouts and code readable. */
@media print {
    :root {
        --bg: #ffffff; --bg-elev: #ffffff; --bg-subtle: #f4f4f5;
        --fg: #18181b; --fg-dim: #52525b; --fg-muted: #71717a;
        --border: #d4d4d8; --border-soft: #e4e4e7;
        --accent: #059669; --accent-soft: #ecfdf5;
    }
    html, body { background: #fff; font-size: 11pt; }
    #progress, .topbar, .toc, .theme-toggle, .btn-row, .hero-meta,
    .site-footer { display: none !important; }

    .hero {
        border: 0;
        padding: 0 0 12pt;
        margin: 0 0 12pt;
        border-bottom: 1.5pt solid var(--border);
    }
    .hero h1 { font-size: 22pt; }
    .hero .lede { font-size: 12pt; }
    .hero .eyebrow { color: var(--accent); }

    .layout {
        display: block;
        max-width: none;
        padding: 0;
        margin: 0;
    }
    .content { max-width: none; padding: 0; }

    /* Each numbered part starts a fresh page; never orphan a heading. */
    section.part { break-inside: auto; }
    section.part + section.part {
        break-before: page;
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }
    h2, h3, h4 { break-after: avoid; }
    table, pre, .callout, .checklist li { break-inside: avoid; }

    a.inline { color: var(--fg); border-bottom: 0; }

    /* Code blocks: the dark terminal look becomes ink on a light card so it
       does not burn a page of toner and stays legible in print. */
    pre {
        background: #f4f4f5;
        border: 1pt solid var(--border);
        color: #18181b;
        font-size: 8.5pt;
    }
    pre.diagram { background: #f4f4f5; color: #18181b; }
    code { background: #f4f4f5; border-color: var(--border-soft); }

    .callout { background: #fff !important; }
    .try { background: var(--accent-soft) !important; }
    .checklist li { background: #fff; }

    thead { display: table-header-group; } /* repeat headers across pages */
    tbody tr:hover { background: transparent; }
}
