@import url("https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&family=Montserrat:wght@300;400;500;600;700&display=swap");

/* ==========================================================================
   Orangeleaf Web-Design Course — shared stylesheet
   Built on the Orangeleaf Design System tokens. Every lesson and reference
   doc links THIS file. The course is itself a demonstration of the brand:
   white surfaces, warm neutrals, one decisive orange accent per view,
   Montserrat display + Hanken Grotesk body + JetBrains Mono code.
   ========================================================================== */

/* ---- Design tokens (mirrored from the Orangeleaf Design System) ---------- */
:root {
    /* Brand — orange */
    --orange-50: #fff1e8;
    --orange-100: #ffe0cc;
    --orange-200: #ffc6a3;
    --orange-300: #ffa571;
    --orange-400: #ff863f;
    --orange-500: #ff6b1a;
    --orange-600: #e85a0c;
    --orange-700: #b8521a;
    --orange-800: #8a3d14;
    --orange-900: #57280e;

    /* Brand — indigo */
    --indigo-50: #eceef7;
    --indigo-100: #d6daee;
    --indigo-200: #aeb5dc;
    --indigo-300: #8089c7;
    --indigo-400: #4f5cac;
    --indigo-500: #2a3990;
    --indigo-600: #243079;
    --indigo-700: #1d2660;
    --indigo-800: #161d49;
    --indigo-900: #0f1432;

    /* Warm neutrals */
    --neutral-0: #ffffff;
    --neutral-50: #faf9f7;
    --neutral-100: #f1efeb;
    --neutral-200: #e4e1da;
    --neutral-300: #cfcbc2;
    --neutral-400: #9e9a90;
    --neutral-500: #6f6b63;
    --neutral-600: #4d4a44;
    --neutral-700: #36332e;
    --neutral-800: #221f1b;
    --neutral-900: #181613;
    --neutral-950: #0a0a0a;

    /* Cream + status */
    --cream-50: #fbf9f4;
    --cream-100: #f5f1ea;
    --cream-200: #ede7db;
    --green-50: #e8f6ef;
    --green-100: #c9ebdb;
    --green-500: #1f8a5b;
    --green-600: #197349;
    --green-700: #145b3a;
    --amber-50: #fcf3dc;
    --amber-100: #f7e3ae;
    --amber-500: #c98a06;
    --amber-600: #a77105;
    --red-50: #fbebeb;
    --red-100: #f5cfcf;
    --red-500: #d14343;
    --red-600: #b23333;
    --red-700: #8f2727;

    /* Semantic aliases */
    --brand: var(--orange-500);
    --brand-hover: var(--orange-600);
    --brand-active: var(--orange-700);
    --brand-subtle: var(--orange-50);
    --brand-on: #ffffff;
    --accent: var(--indigo-500);
    --accent-subtle: var(--indigo-50);
    --bg-page: var(--neutral-50);
    --bg-inset: var(--neutral-100);
    --surface: var(--neutral-0);
    --surface-cream: var(--cream-100);
    --surface-ink: var(--neutral-950);
    --text-primary: var(--neutral-900);
    --text-secondary: var(--neutral-600);
    --text-muted: var(--neutral-500);
    --text-faint: var(--neutral-400);
    --text-on-ink: var(--neutral-0);
    --text-brand: var(--orange-600);
    --text-accent: var(--indigo-500);
    --text-link: var(--indigo-500);
    --border: var(--neutral-200);
    --border-strong: var(--neutral-300);
    --divider: var(--neutral-200);
    --ring: color-mix(in oklab, var(--orange-500) 55%, transparent);
    --success: var(--green-500);
    --success-subtle: var(--green-50);
    --success-text: var(--green-700);
    --warning: var(--amber-500);
    --warning-subtle: var(--amber-50);
    --warning-text: var(--amber-600);
    --danger: var(--red-500);
    --danger-subtle: var(--red-50);
    --danger-text: var(--red-700);
    --info: var(--indigo-500);
    --info-subtle: var(--indigo-50);
    --info-text: var(--indigo-700);

    /* Typography */
    --font-display:
        "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
        sans-serif;
    --font-sans:
        "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
        sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --weight-light: 300;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --text-2xs: 0.6875rem;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;
    --text-4xl: 3rem;
    --text-5xl: 3.75rem;
    --leading-tight: 1.12;
    --leading-snug: 1.28;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;
    --tracking-tight: -0.01em;
    --tracking-wide: 0.04em;
    --tracking-eyebrow: 0.16em;

    /* Spacing (4px grid) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;

    /* Radius / shadow / motion */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-pill: 999px;
    --shadow-xs: 0 1px 2px rgba(26, 22, 18, 0.06);
    --shadow-sm:
        0 1px 2px rgba(26, 22, 18, 0.06), 0 1px 3px rgba(26, 22, 18, 0.08);
    --shadow-md:
        0 2px 4px rgba(26, 22, 18, 0.05), 0 6px 14px rgba(26, 22, 18, 0.08);
    --shadow-lg:
        0 8px 18px rgba(26, 22, 18, 0.08), 0 18px 40px rgba(26, 22, 18, 0.1);
    --shadow-brand: 0 6px 18px rgba(255, 107, 26, 0.32);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 120ms;
    --dur-base: 200ms;

    /* Layout */
    --measure: 72ch;
    --container: 880px;
}

/* ---- Reset / base -------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--text-md);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1,
h2,
h3,
h4,
h5 {
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
    color: var(--text-primary);
    margin: 0;
    text-wrap: balance;
}
p {
    margin: 0;
    text-wrap: pretty;
}
a {
    color: var(--text-link);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
strong {
    font-weight: var(--weight-semibold);
}
code,
kbd,
samp,
pre {
    font-family: var(--font-mono);
}
::selection {
    background: var(--orange-200);
    color: var(--neutral-950);
}
:focus-visible {
    outline: 3px solid var(--ring);
    outline-offset: 2px;
    border-radius: 3px;
}
img {
    max-width: 100%;
    height: auto;
}
hr {
    border: 0;
    border-top: 1px solid var(--divider);
    margin: var(--space-10) 0;
}

/* ---- Eyebrow (brand signature label) ------------------------------------ */
.eyebrow {
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
    color: var(--text-brand);
    margin: 0;
}

/* ---- Page scaffold ------------------------------------------------------- */
.page {
    max-width: var(--container);
    margin-inline: auto;
    padding: var(--space-10) var(--space-6) var(--space-24);
}
.page--wide {
    max-width: 1180px;
}

/* Top brand bar — a consistent full-width app bar on EVERY page. The inner
   content is centred to one shared max-width (via auto side padding) so the
   brand sits in the same place whether the page body is narrow (lessons) or
   wide (home, facilitator guide, references). This keeps the header identical
   across the whole app. */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    width: 100%;
    margin: 0;
    padding-block: var(--space-4);
    padding-inline: max(var(--space-6), calc((100% - 1180px) / 2));
    font-size: var(--text-sm);
    color: var(--text-muted);
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
}
/* Width is now consistent for every page; the modifier is kept as a no-op so
   existing markup (topbar--wide) keeps working. */
.topbar--wide {
    max-width: none;
}
.brandmark {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    color: var(--text-primary);
    letter-spacing: var(--tracking-tight);
}
.brandmark .dot {
    width: 44px;
    height: 48px;
    flex-shrink: 0;
    background: url("logo-mark.svg") center / contain no-repeat;
}

/* ---- Lesson header ------------------------------------------------------- */
.lesson-head {
    margin-bottom: var(--space-10);
    border-bottom: 1px solid var(--divider);
    padding-bottom: var(--space-8);
}
.lesson-head h1 {
    font-size: var(--text-4xl);
    margin-top: var(--space-2);
}
.lesson-head .dek {
    font-size: var(--text-lg);
    color: var(--text-secondary);
    margin-top: var(--space-4);
    max-width: var(--measure);
}
.lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin-top: var(--space-5);
    font-size: var(--text-sm);
    color: var(--text-muted);
}
.lesson-meta .pip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

/* ---- Prose rhythm -------------------------------------------------------- */
.prose {
    max-width: var(--measure);
}
.prose > * + * {
    margin-top: var(--space-5);
}
.prose h2 {
    font-size: var(--text-2xl);
    margin-top: var(--space-12);
    padding-top: var(--space-2);
}
.prose h3 {
    font-size: var(--text-xl);
    margin-top: var(--space-8);
}
.prose h2 + p,
.prose h3 + p {
    margin-top: var(--space-3);
}
.prose ul,
.prose ol {
    margin: 0;
    padding-left: var(--space-6);
}
.prose li + li {
    margin-top: var(--space-2);
}
.prose li {
    padding-left: var(--space-1);
}
.prose a {
    color: var(--text-link);
    text-decoration: underline;
    text-decoration-color: var(--indigo-200);
    text-underline-offset: 2px;
}
.prose a:hover {
    text-decoration-color: var(--indigo-500);
}

/* Section number flourish */
.section-no {
    color: var(--brand);
    font-family: var(--font-mono);
    font-size: var(--text-md);
    margin-right: var(--space-2);
}

/* ---- Code ---------------------------------------------------------------- */
:not(pre) > code {
    font-size: 0.875em;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.1em 0.4em;
    color: var(--text-primary);
}
pre {
    background: var(--neutral-950);
    color: #ece8e1;
    border-radius: var(--radius-md);
    padding: var(--space-5);
    overflow-x: auto;
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--neutral-800);
}
pre code {
    background: none;
    border: 0;
    padding: 0;
    color: inherit;
    font-size: inherit;
}
/* lightweight token colors for hand-tagged code */
.tok-sel {
    color: #ffa571;
} /* selector */
.tok-prop {
    color: #8fb7ff;
} /* property */
.tok-val {
    color: #c9ebdb;
} /* value */
.tok-com {
    color: #8a857c;
    font-style: italic;
} /* comment */
.tok-punc {
    color: #b7b1a8;
}
.code-label {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

/* ---- Cards --------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}
.card--accent {
    border-top: 3px solid var(--brand);
}
.card--ink {
    background: var(--surface-ink);
    color: var(--text-on-ink);
    border-color: var(--neutral-800);
}
.card--ink h1,
.card--ink h2,
.card--ink h3 {
    color: #fff;
}

/* ---- Callouts ------------------------------------------------------------ */
.callout {
    border: 1px solid var(--border);
    border-left: 4px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-5) var(--space-5) var(--space-5) var(--space-5);
    background: var(--surface);
    margin: var(--space-6) 0;
}
.callout > :first-child {
    margin-top: 0;
}
.callout > * + * {
    margin-top: var(--space-3);
}
.callout__label {
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.callout--mendix {
    border-left-color: var(--brand);
    background: var(--brand-subtle);
}
.callout--mendix .callout__label {
    color: var(--text-brand);
}
.callout--tip {
    border-left-color: var(--indigo-500);
    background: var(--accent-subtle);
}
.callout--tip .callout__label {
    color: var(--indigo-700);
}
.callout--warning {
    border-left-color: var(--amber-500);
    background: var(--warning-subtle);
}
.callout--warning .callout__label {
    color: var(--warning-text);
}
.callout--recall {
    border-left-color: var(--green-500);
    background: var(--success-subtle);
}
.callout--recall .callout__label {
    color: var(--success-text);
}
.callout--source {
    border-left-color: var(--neutral-400);
    background: var(--bg-inset);
}
.callout--source .callout__label {
    color: var(--text-secondary);
}
.callout--source a {
    font-weight: var(--weight-medium);
}

/* ---- Tables -------------------------------------------------------------- */
.table-wrap {
    overflow-x: auto;
    margin: var(--space-6) 0;
}
table.ol {
    border-collapse: collapse;
    width: 100%;
    font-size: var(--text-sm);
}
table.ol th,
table.ol td {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
table.ol thead th {
    font-family: var(--font-display);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1.5px solid var(--border-strong);
}
table.ol tbody tr:hover {
    background: var(--bg-inset);
}
table.ol code {
    white-space: nowrap;
}

/* ---- Buttons / badges ---------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-display);
    font-weight: var(--weight-medium);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-5);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition:
        background var(--dur-fast) var(--ease-out),
        transform var(--dur-fast) var(--ease-out),
        box-shadow var(--dur-fast) var(--ease-out);
}
.btn--primary {
    background: var(--brand);
    color: var(--brand-on);
}
.btn--primary:hover {
    background: var(--brand-hover);
    box-shadow: var(--shadow-brand);
    text-decoration: none;
}
.btn--primary:active {
    transform: translateY(0.5px) scale(0.99);
}
.btn--ghost {
    background: var(--surface);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn--ghost:hover {
    background: var(--bg-inset);
    text-decoration: none;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-display);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    padding: 0.2em 0.6em;
    border-radius: var(--radius-pill);
    background: var(--bg-inset);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.badge--brand {
    background: var(--brand-subtle);
    color: var(--text-brand);
    border-color: var(--orange-200);
}
.badge--accent {
    background: var(--accent-subtle);
    color: var(--indigo-700);
    border-color: var(--indigo-200);
}

/* ---- Module / lesson navigation ------------------------------------------ */
.pager {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-16);
    padding-top: var(--space-6);
    border-top: 1px solid var(--divider);
}
.pager a {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 48%;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition:
        border-color var(--dur-fast),
        box-shadow var(--dur-fast);
}
.pager a:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}
.pager .dir {
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-muted);
    font-family: var(--font-display);
}
.pager .ttl {
    font-weight: var(--weight-medium);
    color: var(--text-primary);
}
.pager .next {
    text-align: right;
    margin-left: auto;
}

/* ---- "Ask your teacher" footer ------------------------------------------- */
.teacher-note {
    margin-top: var(--space-12);
    background: var(--neutral-950);
    color: var(--text-on-ink);
    border-radius: var(--radius-lg);
    padding: var(--space-6) var(--space-8);
}
.teacher-note h3 {
    color: #fff;
    font-size: var(--text-lg);
    margin-top: unset;
}
.teacher-note p {
    color: var(--neutral-300);
    margin-top: var(--space-2);
}

/* Links on dark surfaces (ink cards, teacher note) need a high-contrast color —
   dark indigo on near-black is unreadable. Orange pops and stays on-brand. */
.teacher-note a,
.card--ink a {
    color: var(--orange-300);
    text-decoration: underline;
    text-decoration-color: var(--orange-300);
    text-underline-offset: 2px;
    font-weight: var(--weight-medium);
}
.teacher-note a:hover,
.card--ink a:hover {
    color: var(--orange-200);
    text-decoration-color: var(--orange-200);
}

/* ---- Token / swatch helpers (for the tokens reference) ------------------- */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--space-3);
    margin: var(--space-5) 0;
}
.swatch {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: var(--text-xs);
}
.swatch .chip {
    height: 64px;
}
.swatch .meta {
    padding: var(--space-2) var(--space-3);
    background: var(--surface);
}
.swatch .name {
    font-family: var(--font-mono);
    color: var(--text-primary);
}
.swatch .hex {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ---- Utility ------------------------------------------------------------- */
.muted {
    color: var(--text-muted);
}
.small {
    font-size: var(--text-sm);
}
.center {
    text-align: center;
}
.stack-tight > * + * {
    margin-top: var(--space-2);
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-4);
}
.lead {
    font-size: var(--text-lg);
    color: var(--text-secondary);
}

/* ==========================================================================
   QUIZ widget (assets/quiz.js) — retrieval practice with instant feedback
   ========================================================================== */
.quiz {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin: var(--space-8) 0;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.quiz__tag {
    font-family: var(--font-display);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-eyebrow);
    text-transform: uppercase;
    color: var(--text-brand);
}
.quiz__q {
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    font-size: var(--text-lg);
    margin: var(--space-2) 0 var(--space-5);
    line-height: var(--leading-snug);
}
.quiz__options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.quiz__option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    width: 100%;
    text-align: left;
    font: inherit;
    color: var(--text-primary);
    cursor: pointer;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    transition:
        border-color var(--dur-fast) var(--ease-out),
        background var(--dur-fast) var(--ease-out);
}
.quiz__option:hover:not(:disabled) {
    border-color: var(--brand);
    background: var(--brand-subtle);
}
.quiz__option .key {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-muted);
    flex: none;
    width: 1.4em;
}
.quiz__option:disabled {
    cursor: default;
}
.quiz__option.is-correct {
    border-color: var(--success);
    background: var(--success-subtle);
}
.quiz__option.is-correct .key {
    color: var(--success-text);
}
.quiz__option.is-wrong {
    border-color: var(--danger);
    background: var(--danger-subtle);
}
.quiz__option.is-wrong .key {
    color: var(--danger-text);
}
.quiz__feedback {
    margin-top: var(--space-5);
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: none;
}
.quiz__feedback.show {
    display: block;
}
.quiz__feedback.ok {
    background: var(--success-subtle);
    color: var(--success-text);
    border: 1px solid var(--green-100);
}
.quiz__feedback.no {
    background: var(--danger-subtle);
    color: var(--danger-text);
    border: 1px solid var(--red-100);
}
.quiz__feedback strong {
    color: inherit;
}

/* ==========================================================================
   PLAYGROUND widget (assets/playground.js) — live CSS editor + preview
   ========================================================================== */
.pg {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: var(--space-8) 0;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    width: min(
        calc(100vw - 2 * var(--space-6)),
        calc(var(--container) - 2 * var(--space-6))
    );
}
.pg__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-inset);
    border-bottom: 1px solid var(--border);
}
.pg__title {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
}
.pg__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 480px;
}
/* Expanded playground: grow the work area to almost fill the viewport height. */
.pg--full .pg__grid {
    min-height: calc(100vh - 6rem);
}
.pg__pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.pg__pane + .pg__pane {
    border-left: 1px solid var(--border);
}
.pg__pane-label {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--text-muted);
    padding: var(--space-2) var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg-inset);
}
.pg__edit {
    position: relative;
    flex: 1;
    min-height: 420px;
    overflow: hidden;
    background: var(--neutral-950);
}
.pg__edit:focus-within {
    box-shadow: inset 3px 0 0 var(--brand);
}
.pg__hl,
.pg__editor {
    margin: 0;
    border: 0;
    padding: var(--space-4);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
    tab-size: 2;
    white-space: pre;
    box-sizing: border-box;
}
.pg__hl {
    position: absolute;
    inset: 0;
    overflow: auto;
    pointer-events: none;
    color: #ece8e1;
    background: var(--neutral-950);
    scrollbar-width: none;
}
.pg__hl::-webkit-scrollbar {
    width: 0;
    height: 0;
}
.pg__hl code {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
}
.pg__editor {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    resize: none;
    overflow: auto;
    color: transparent;
    -webkit-text-fill-color: transparent;
    background: transparent;
    caret-color: var(--brand);
}
.pg__editor:focus {
    outline: none;
}
.pg__editor::selection {
    background: rgba(255, 107, 26, 0.3);
}
.pg__editor::-moz-selection {
    background: rgba(255, 107, 26, 0.3);
}
.pg__preview {
    flex: 1;
    border: 0;
    width: 100%;
    min-height: 440px;
    background: #fff;
}
.pg__reset {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: var(--space-1) var(--space-3);
    color: var(--text-secondary);
}
.pg__reset svg {
    width: 14px;
    height: 14px;
    flex: none;
}
.pg__reset:hover {
    background: var(--bg-inset);
    border-color: var(--brand);
    color: var(--text-brand);
}
.pg__actions {
    display: inline-flex;
    gap: var(--space-2);
}
.pg__reset--icon {
    padding-inline: var(--space-2);
}
@media (max-width: 640px) {
    .pg__grid {
        grid-template-columns: 1fr;
    }
    .pg__pane + .pg__pane {
        border-left: 0;
        border-top: 1px solid var(--border);
    }
}

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

/* ---- Print (reference docs should print clean) --------------------------- */
@media print {
    body {
        background: #fff;
        color: #000;
    }
    .topbar,
    .pager,
    .teacher-note,
    .pg__bar,
    .quiz__option,
    .no-print {
        display: none !important;
    }
    .page {
        max-width: none;
        padding: 0;
    }
    .card,
    .callout,
    pre,
    table.ol {
        box-shadow: none;
    }
    pre {
        background: #f4f3f1;
        color: #111;
        border: 1px solid #ccc;
    }
    a {
        color: #000;
        text-decoration: underline;
    }
    h1,
    h2,
    h3 {
        break-after: avoid;
    }
    .card,
    .callout {
        break-inside: avoid;
    }
    .theme-fab,
    .theme-panel {
        display: none !important;
    }
}

/* ==========================================================================
   THEME CUSTOMIZER — dark mode, the settings panel, and ghost topbar nav.
   Driven by assets/theme.js, which writes CSS variables + [data-theme] on
   <html> and persists choices to localStorage.
   ========================================================================== */

/* ---- Topbar nav links as ghost buttons (no underline-on-hover) ----------- */
.topbar a:not(.brandmark) {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-display);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    transition:
        background var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out),
        color var(--dur-fast) var(--ease-out);
}
.topbar a:not(.brandmark):hover {
    text-decoration: none;
    background: var(--bg-inset);
    border-color: var(--brand);
    color: var(--text-brand);
}

/* ---- Dark mode ----------------------------------------------------------- */
html[data-theme="dark"] {
    color-scheme: dark;
    /* Aligned to the Orangeleaf deck's dark world (design system slides.css):
     warm-black #0A0A0A ground, neutral-gray surfaces & lines, cream text,
     warm-gray muted text, and the bright orange accent. */
    --bg-page: #0a0a0a; /* deck-matched warm black */
    --bg-inset: #222222; /* d-surface-2 — subtle raised fills */
    --surface: #1a1a1a; /* d-surface — cards, callouts, panels */
    --surface-raised: #222222;
    --surface-sunken: #0a0a0a;
    --surface-cream: #1a1a1a;
    --surface-ink: #000000;
    --text-primary: #f5f1ea; /* cream */
    --text-secondary: #cac4b8;
    --text-muted: #8a8580; /* warm gray */
    --text-faint: #5a5650;
    --text-on-ink: #f5f1ea;
    --border: #2e2e2e; /* d-line */
    --border-strong: #3d3d3d;
    --divider: #242424;
    --text-link: #aeb5dc;
    --text-accent: #aeb5dc;
    --text-brand: #ff6b1a; /* deck eyebrows use orange-500 directly on ink */
    --brand-subtle: color-mix(in oklab, var(--brand) 16%, var(--surface));
    --accent-subtle: color-mix(in oklab, var(--indigo-400) 22%, var(--surface));
    --success-subtle: color-mix(in oklab, var(--green-500) 22%, var(--surface));
    --success-text: #74d6a6;
    --warning-subtle: color-mix(in oklab, var(--amber-500) 24%, var(--surface));
    --warning-text: #e7c25f;
    --danger-subtle: color-mix(in oklab, var(--red-500) 24%, var(--surface));
    --danger-text: #f0a0a0;
    --info-subtle: color-mix(in oklab, var(--indigo-400) 22%, var(--surface));
    --info-text: #aeb9f0;
    --ring: color-mix(in oklab, var(--brand) 60%, transparent);
}
/* Dark fixups for the few spots that pin a fixed ramp colour */
html[data-theme="dark"] .callout--tip {
    border-left-color: var(--indigo-400);
}
html[data-theme="dark"] .callout--tip .callout__label {
    color: #aeb9f0;
}
html[data-theme="dark"] .callout--source {
    border-left-color: var(--neutral-600);
}
html[data-theme="dark"] .badge--accent {
    color: #aeb9f0;
    border-color: color-mix(in oklab, var(--indigo-400) 45%, transparent);
}
html[data-theme="dark"] .badge--brand {
    color: var(--text-brand);
    border-color: color-mix(in oklab, var(--brand) 45%, transparent);
}
html[data-theme="dark"] .prose a:hover {
    text-decoration-color: var(--indigo-300);
}
html[data-theme="dark"] .quiz__feedback.ok {
    border-color: color-mix(in oklab, var(--green-500) 35%, transparent);
}
html[data-theme="dark"] .quiz__feedback.no {
    border-color: color-mix(in oklab, var(--red-500) 35%, transparent);
}
/* On the dark ground, the "ink" blocks become raised neutral-surface cards
   (a near-black block on near-black would vanish). */
html[data-theme="dark"] .teacher-note,
html[data-theme="dark"] .card--ink {
    background: var(--surface);
    border: 1px solid var(--border-strong);
}
html[data-theme="dark"] .teacher-note p {
    color: var(--text-secondary);
}
/* Code block: lift slightly off the #0A0A0A page so it reads as a panel */
html[data-theme="dark"] pre {
    background: #151515;
    border-color: var(--border);
}
html[data-theme="dark"] .pg__edit,
html[data-theme="dark"] .pg__hl {
    background: #151515;
}
/* Brand logo on the home hero; swap to the dark-background artwork in dark mode */
.hero-logo {
    display: block;
    height: 72px;
    width: auto;
    margin-bottom: var(--space-6);
}
.hero-logo--dark {
    display: none;
}
html[data-theme="dark"] .brandmark .dot {
    background-image: url("logo-mark-white.svg");
}
html[data-theme="dark"] .hero-logo--light {
    display: none;
}
html[data-theme="dark"] .hero-logo--dark {
    display: block;
}

/* ---- Settings button (FAB) ----------------------------------------------- */
.theme-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: var(--z-overlay, 1000);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition:
        transform var(--dur-fast) var(--ease-out),
        border-color var(--dur-fast) var(--ease-out),
        color var(--dur-fast) var(--ease-out);
}
.theme-fab:hover {
    border-color: var(--brand);
    color: var(--text-brand);
    transform: translateY(-1px);
}
.theme-fab svg {
    width: 22px;
    height: 22px;
}

/* ---- Settings panel ------------------------------------------------------ */
.theme-panel {
    position: fixed;
    right: 20px;
    bottom: 80px;
    z-index: var(--z-modal, 1100);
    width: 320px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-5);
    display: none;
}
.theme-panel.open {
    display: block;
}
.theme-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}
.theme-panel__title {
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    font-size: var(--text-md);
}
.theme-panel__sub {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: 2px;
}
.theme-panel__close {
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    display: inline-flex;
}
.theme-panel__close:hover {
    color: var(--text-primary);
    background: var(--bg-inset);
}
.theme-panel__close svg {
    width: 18px;
    height: 18px;
}
.theme-field {
    margin-bottom: var(--space-4);
}
.theme-field > label {
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}
.theme-seg {
    display: flex;
    gap: 4px;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 3px;
}
.theme-seg button {
    flex: 1;
    font: inherit;
    font-size: var(--text-sm);
    font-family: var(--font-display);
    cursor: pointer;
    border: 0;
    background: none;
    color: var(--text-secondary);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition:
        background var(--dur-fast) var(--ease-out),
        color var(--dur-fast) var(--ease-out);
}
.theme-seg button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-xs);
}
.theme-select {
    width: 100%;
    font: inherit;
    font-size: var(--text-sm);
    color: var(--text-primary);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    cursor: pointer;
}
.theme-swatches {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    align-items: center;
}
.theme-swatch {
    width: 26px;
    height: 26px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border-strong);
    cursor: pointer;
    padding: 0;
}
.theme-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px var(--brand);
}
.theme-color {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
}
.theme-rangewrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.theme-range {
    flex: 1;
    accent-color: var(--brand);
}
.theme-rangeval {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
    min-width: 3.2em;
    text-align: right;
}
.theme-reset {
    width: 100%;
    font: inherit;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    cursor: pointer;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    margin-top: var(--space-2);
}
.theme-reset:hover {
    border-color: var(--brand);
    color: var(--text-brand);
}
