/*  Cooking and Culinary Science from the Beginning — design system
    ----------------------------------------------------------------
    A cook's notebook: cream paper, Fraunces for display, Source Serif for
    prose, JetBrains Mono for numbers. The accent is paprika; the second
    colour is a herb green. A plate is a title, a lede, a workshop (panels on
    the left, controls and readings on the right), the prose, an "At the
    stove" box, terms, try-its and the ten-question check.

    Colours are tokens. Canvases read the --fig-* ones through js/figure.js,
    including the kitchen palette (raw … crust, golden, yolk, dough, veg, oil,
    water, steel, wood, flame) the food drawings use. The dark values are
    written twice, once for a system preference and once for an explicit
    choice; tools/build.py fails if the two copies differ.
*/
@import url('../vendor/fonts/fonts.css');

:root {
    --paper: #fbf7ef;  --paper-deep: #f3ebdc;  --paper-rule: #e4d8c2;
    --ink: #1f1a17;  --ink-soft: #3d3530;  --ink-mute: #6e6359;  --ink-faint: #9d9184;
    --accent: #b4441f;  --accent-tint: #f7e4da;  --herb: #3f6b35;  --herb-tint: #e3eedc;  --red: #a8322b;  --red-tint: #f5e2df;  --green: #2f6b3c;  --green-tint: #def0e2;  --ochre: #b07b1c;  --ochre-tint: #f5e8c9;
    --input: #fffdf8;
    --fig-paper: #fffcf6;  --fig-grid: #d7cbb4;  --fig-rule: #ebe1cf;  --fig-ink: #1f1a17;  --fig-muted: #6e6359;  --fig-faint: #a69a8b;
    --fig-blue: #2f5aa8;  --fig-red: #b4441f;  --fig-green: #3f6b35;  --fig-teal: #18706b;  --fig-plum: #6e3d7c;  --fig-ochre: #b07b1c;  --fig-sienna: #95501a;  --fig-olive: #64641f;
    --fig-raw: #b3263a;  --fig-rare: #c9454f;  --fig-pink: #dc8a84;  --fig-medium: #c9a08f;  --fig-done: #8f7464;  --fig-crust: #5b3418;  --fig-golden: #d39a35;  --fig-yolk: #f0b823;
    --fig-white: #f4f1e8;  --fig-dough: #ead7b0;  --fig-veg: #4f8f3a;  --fig-oil: #d7b44a;  --fig-water: #7fb1d8;  --fig-steel: #9aa0a6;  --fig-wood: #a9784a;  --fig-flame: #e8762c;
    --shadow: 0 2px 6px rgba(31, 26, 23, 0.07);
    --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --font-body: 'Source Serif 4', 'Iowan Old Style', Georgia, 'Songti SC', 'Noto Serif CJK SC', serif;
    --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
    --paper: #17140f;  --paper-deep: #201c16;  --paper-rule: #3a332a;
    --ink: #ece4d6;  --ink-soft: #cdc3b3;  --ink-mute: #a0958a;  --ink-faint: #776d63;
    --accent: #ec8a64;  --accent-tint: #3c2219;  --herb: #8cbf7c;  --herb-tint: #1e2a1a;  --red: #e7746a;  --red-tint: #3a201d;  --green: #78c18a;  --green-tint: #19301f;  --ochre: #e5b55a;  --ochre-tint: #3a2f17;
    --input: #1d1914;
    --fig-paper: #1a1712;  --fig-grid: #3f382e;  --fig-rule: #2d2820;  --fig-ink: #ece4d6;  --fig-muted: #a0958a;  --fig-faint: #756b60;
    --fig-blue: #86a7e6;  --fig-red: #ec8a64;  --fig-green: #8cbf7c;  --fig-teal: #5bbab3;  --fig-plum: #c39ad2;  --fig-ochre: #e5b55a;  --fig-sienna: #d98a4f;  --fig-olive: #bcbc6a;
    --fig-raw: #d2475a;  --fig-rare: #db6670;  --fig-pink: #e4a39d;  --fig-medium: #c6a597;  --fig-done: #9d8474;  --fig-crust: #6b4022;  --fig-golden: #dca64a;  --fig-yolk: #f2c23f;
    --fig-white: #d9d4c8;  --fig-dough: #d3c09a;  --fig-veg: #6aac53;  --fig-oil: #d6b956;  --fig-water: #6f9fc7;  --fig-steel: #8c939a;  --fig-wood: #a47a50;  --fig-flame: #ef8a45;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    }
}
:root[data-theme="dark"] {
    --paper: #17140f;  --paper-deep: #201c16;  --paper-rule: #3a332a;
    --ink: #ece4d6;  --ink-soft: #cdc3b3;  --ink-mute: #a0958a;  --ink-faint: #776d63;
    --accent: #ec8a64;  --accent-tint: #3c2219;  --herb: #8cbf7c;  --herb-tint: #1e2a1a;  --red: #e7746a;  --red-tint: #3a201d;  --green: #78c18a;  --green-tint: #19301f;  --ochre: #e5b55a;  --ochre-tint: #3a2f17;
    --input: #1d1914;
    --fig-paper: #1a1712;  --fig-grid: #3f382e;  --fig-rule: #2d2820;  --fig-ink: #ece4d6;  --fig-muted: #a0958a;  --fig-faint: #756b60;
    --fig-blue: #86a7e6;  --fig-red: #ec8a64;  --fig-green: #8cbf7c;  --fig-teal: #5bbab3;  --fig-plum: #c39ad2;  --fig-ochre: #e5b55a;  --fig-sienna: #d98a4f;  --fig-olive: #bcbc6a;
    --fig-raw: #d2475a;  --fig-rare: #db6670;  --fig-pink: #e4a39d;  --fig-medium: #c6a597;  --fig-done: #9d8474;  --fig-crust: #6b4022;  --fig-golden: #dca64a;  --fig-yolk: #f2c23f;
    --fig-white: #d9d4c8;  --fig-dough: #d3c09a;  --fig-veg: #6aac53;  --fig-oil: #d6b956;  --fig-water: #6f9fc7;  --fig-steel: #8c939a;  --fig-wood: #a47a50;  --fig-flame: #ef8a45;
    --shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* ─── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.66 var(--font-body); font-optical-sizing: auto; }
::selection { background: var(--ochre-tint); }
a { color: var(--accent); text-underline-offset: 2px; }
code, .mono { font-family: var(--font-mono); font-size: 0.86em; }
p code, li code, dd code { background: var(--paper-deep); border: 1px solid var(--paper-rule); border-radius: 3px; padding: 0 0.28em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
sub, sup { line-height: 0; }
.btn { border: 1px solid var(--ink-soft); background: var(--ink); color: var(--paper); padding: 5px 14px; border-radius: 3px; cursor: pointer; font: 13px var(--font-mono); }
.btn:hover { background: var(--ink-soft); }
.btn-quiet { background: transparent; color: var(--ink-soft); border-color: var(--paper-rule); }
.btn-quiet:hover { background: var(--paper-deep); }

/* ─── Top bar ──────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 20px; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--paper-rule); font: 13px var(--font-mono); }
.topbar a { color: var(--ink-soft); text-decoration: none; }
.topbar a:hover { color: var(--accent); }
.topbar-left { display: flex; gap: 14px; align-items: center; min-width: 0; }
.topbar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-mute); }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.lang-btn, .theme-btn { border: 1px solid var(--paper-rule); background: var(--paper); border-radius: 3px; padding: 2px 10px; cursor: pointer; font: 13px var(--font-mono); color: var(--ink-soft); }

/* ─── Plate ────────────────────────────────────────────────── */
.main-content { max-width: 1120px; margin: 0 auto; padding: 26px 28px 60px; }
.plate-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font: 12.5px var(--font-mono); color: var(--ink-mute); border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.thread { display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid var(--ink-faint); border-radius: 2px; font-size: 11px; color: var(--ink-soft); }
.plate-title { font: 400 44px/1.1 var(--font-display); letter-spacing: -0.01em; margin: 22px 0 8px; }
.plate-title em { color: var(--accent); font-style: italic; }
.plate-deck { font: italic 20px/1.45 var(--font-body); color: var(--ink-soft); margin: 0 0 20px; max-width: 46em; }
.lede { border-left: 3px solid var(--accent); padding: 2px 0 2px 18px; margin: 18px 0; max-width: 48em; }
.lede p { margin: 0 0 10px; }
.lede .preview { color: var(--ink-mute); font-size: 15.5px; }
.formula { font: 17px var(--font-mono); text-align: center; margin: 16px 0; color: var(--ink-soft); overflow-x: auto; }
.learning-objectives { background: var(--paper-deep); border: 1px solid var(--paper-rule); padding: 12px 18px; border-radius: 3px; margin: 18px 0; max-width: 48em; }
.learning-objectives-title, .section-title { font: 600 11px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); margin: 6px 0 10px; }
.learning-objectives ul { margin: 0; padding-left: 20px; }
.figure { margin: 10px 0 24px; }
.figure-caption { font-size: 14.5px; color: var(--ink-mute); margin-top: 8px; max-width: 52em; }
h2 { font: 400 27px/1.2 var(--font-display); margin: 34px 0 10px; }
.prose { max-width: 46em; }
.prose p { margin: 0 0 14px; }
.stove { border: 1px solid var(--herb); background: var(--herb-tint); border-radius: 3px; padding: 10px 18px 6px; margin: 22px 0; max-width: 48em; }
.stove-title { font: 600 11px/1 var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--herb); margin: 6px 0 8px; }
.stove p { margin: 0 0 8px; }
.marginalia { font-size: 15px; color: var(--ink-mute); border-top: 1px solid var(--paper-rule); border-bottom: 1px solid var(--paper-rule); padding: 10px 0; margin: 20px 0; max-width: 46em; font-style: italic; }
.terms { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; max-width: 50em; margin: 0; }
.terms dt { font-weight: 600; }
.terms dd { margin: 0; color: var(--ink-soft); }
.key-idea { background: var(--accent-tint); border-radius: 3px; padding: 12px 18px; margin: 24px 0; max-width: 48em; }
.sources { font-size: 14px; color: var(--ink-mute); max-width: 50em; }
.sources li { margin-bottom: 4px; }
.plate-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 14px; border-top: 2px solid var(--ink); font: 14px var(--font-mono); }
.plate-nav a { text-decoration: none; }
.plate-footer { display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; font: 12.5px var(--font-mono); color: var(--ink-faint); margin-top: 18px; }
.plate-footer a { color: var(--ink-mute); }

/* ─── Workshop ─────────────────────────────────────────────── */
.workshop { display: grid; grid-template-columns: minmax(0, 1fr) 260px; border: 1px solid var(--paper-rule); background: var(--fig-paper); border-radius: 3px; }
.ws-stage { position: relative; display: flex; flex-wrap: wrap; align-content: flex-start; border-right: 1px solid var(--paper-rule); min-width: 0; overflow: hidden; }
.ws-panel { min-width: 150px; padding: 6px; }
.ws-panel canvas { display: block; max-width: 100%; }
.ws-panel-title { font: 600 11px var(--font-mono); color: var(--ink-mute); padding: 2px 4px 4px; letter-spacing: 0.04em; }
.ws-rail { padding: 10px 14px; font: 12.5px/1.45 var(--font-mono); background: var(--paper); min-width: 0; }
.ws-controls { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.ws-ctl { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; color: var(--ink-mute); }
.ws-ctl input[type="range"], .ws-ctl select { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.ws-ctl select { border: 1px solid var(--paper-rule); background: var(--input); border-radius: 3px; padding: 3px 6px; font: 13px var(--font-mono); }
.ws-val { color: var(--ink); font-weight: 500; text-align: right; }
.ws-check { grid-template-columns: auto 1fr; cursor: pointer; }
.ws-reset { align-self: flex-start; padding: 2px 10px; font-size: 11.5px; }
.rail-stats { border-top: 1px solid var(--paper-rule); padding-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.rail-stats .stat { display: flex; justify-content: space-between; gap: 10px; }
.stat-k { color: var(--ink-mute); }
.stat-v { color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.stat-k { flex-shrink: 0; max-width: 55%; }
.ws-note { padding: 10px 14px; border: 1px solid var(--paper-rule); border-top: none; background: var(--paper); font: 15px/1.55 var(--font-body); color: var(--ink-soft); border-radius: 0 0 3px 3px; }
.ws-note:empty { display: none; }
.ws-error { display: none; padding: 8px 14px; background: var(--red-tint); color: var(--red); font: 13px var(--font-mono); }

/* ─── Try-its, drills, projects, journey ───────────────────── */
.try-block { margin: 20px 0; max-width: 50em; }
.try { border: 1px solid var(--paper-rule); border-radius: 3px; padding: 10px 14px; margin-bottom: 10px; background: var(--paper); }
.try-q { margin-bottom: 8px; }
.try-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.try-opt { border: 1px solid var(--paper-rule); background: var(--input); border-radius: 3px; padding: 4px 12px; cursor: pointer; font-size: 15px; text-align: left; }
.try-opt:hover:not(:disabled) { border-color: var(--accent); }
.try-opt.right { background: var(--green-tint); border-color: var(--green); }
.try-opt.wrong { background: var(--red-tint); border-color: var(--red); }
.try-why { margin-top: 8px; font-size: 15px; color: var(--ink-soft); }
.try-src { font: 11.5px var(--font-mono); color: var(--ink-faint); }
.drill-head { font: 13px var(--font-mono); color: var(--ink-mute); margin-bottom: 10px; }
.project-box { border: 2px solid var(--ink); border-radius: 3px; padding: 10px 16px; margin: 16px 0; }
.brief { list-style: none; padding: 0; margin: 0 0 10px; font: 14px var(--font-mono); }
.brief li.ok { color: var(--green); }
.brief li.no { color: var(--red); }
.verdict { font-weight: 600; }
.verdict.pass { color: var(--green); }
.verdict.fail { color: var(--ink-mute); }
.journey-sum { font: 14px var(--font-mono); margin-bottom: 14px; }
.journey-vol { display: grid; grid-template-columns: 300px 1fr; gap: 10px; align-items: center; margin-bottom: 6px; }
.journey-name { font-size: 14px; text-decoration: none; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.journey-cells { display: flex; gap: 3px; flex-wrap: wrap; }
.jcell { width: 18px; height: 18px; border: 1px solid var(--paper-rule); background: var(--paper); border-radius: 2px; }
.jcell.seen { background: var(--accent-tint); border-color: var(--accent); }
.jcell.passed { background: var(--accent); }

/* ─── Knowledge check ──────────────────────────────────────── */
.quiz { margin-top: 36px; max-width: 50em; }
.quiz-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--ink); margin-bottom: 12px; }
.quiz-head h3 { font: 400 25px var(--font-display); margin: 0 0 4px; }
.quiz-score { font: 13px var(--font-mono); color: var(--ink-mute); }
.quiz-q { margin-bottom: 14px; }
.quiz-q p { margin: 0 0 6px; }
.quiz-q .n { font: 13px var(--font-mono); color: var(--ink-faint); margin-right: 4px; }
.quiz-opts { display: flex; flex-direction: column; gap: 5px; }
.quiz-opts button { text-align: left; border: 1px solid var(--paper-rule); background: var(--input); border-radius: 3px; padding: 5px 12px; cursor: pointer; font-size: 15.5px; }
.quiz-opts button:hover:not(:disabled) { border-color: var(--accent); }
.quiz-opts button.right { background: var(--green-tint); border-color: var(--green); }
.quiz-opts button.wrong { background: var(--red-tint); border-color: var(--red); }
.quiz-why { font-size: 15px; color: var(--ink-soft); margin-top: 6px; }
.quiz-foot { margin-top: 10px; }

/* ─── Report dialog ────────────────────────────────────────── */
.report-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 90; }
.report-dialog { position: fixed; z-index: 91; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, 92vw); background: var(--paper); border: 1px solid var(--paper-rule); border-radius: 4px; padding: 16px 20px; box-shadow: var(--shadow); }
.report-dialog h3 { font: 400 22px var(--font-display); margin: 0 0 8px; }
.report-note { font-size: 14px; color: var(--ink-mute); }
.report-sel { font-size: 14px; border-left: 3px solid var(--ochre); margin: 8px 0; padding-left: 10px; color: var(--ink-soft); max-height: 6em; overflow: auto; }
.report-dialog textarea, .report-dialog input { width: 100%; border: 1px solid var(--paper-rule); background: var(--input); border-radius: 3px; padding: 6px 8px; margin-top: 6px; font: 14px var(--font-body); }
.report-hp { position: absolute; left: -9999px; width: 1px; height: 1px; }
.report-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 10px; }
.report-status { flex: 1; font: 12.5px var(--font-mono); color: var(--ink-mute); }

/* ─── Contents page ────────────────────────────────────────── */
.masthead { max-width: 1120px; margin: 0 auto; padding: 40px 28px 10px; }
.masthead h1 { font: 400 54px/1.05 var(--font-display); margin: 0 0 10px; letter-spacing: -0.015em; }
.masthead h1 em { color: var(--accent); }
.masthead .sub { font: italic 21px/1.45 var(--font-body); color: var(--ink-soft); max-width: 44em; margin: 0; }
.masthead .counts { font: 13px var(--font-mono); color: var(--ink-mute); margin-top: 14px; }
.index-tools { max-width: 1120px; margin: 0 auto; padding: 10px 28px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.index-tools input[type="search"] { flex: 1 1 260px; min-width: 0; border: 1px solid var(--paper-rule); background: var(--input); border-radius: 3px; padding: 7px 12px; font: 15px var(--font-body); }
.continue { font: 14px var(--font-mono); }
.search-results { max-width: 1120px; margin: 0 auto; padding: 0 28px; }
.search-results a { display: block; padding: 6px 0; border-bottom: 1px solid var(--paper-rule); text-decoration: none; color: var(--ink); }
.search-results small { color: var(--ink-mute); font-family: var(--font-mono); }
.catalog { max-width: 1120px; margin: 0 auto; padding: 0 28px 60px; }
.part-head { font: 600 12px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin: 34px 0 6px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.vol { border-bottom: 1px solid var(--paper-rule); padding: 12px 0; }
.vol summary { cursor: pointer; list-style: none; display: grid; grid-template-columns: 64px 1fr 120px; gap: 12px; align-items: baseline; }
.vol summary::-webkit-details-marker { display: none; }
.vol-roman { font: 13px var(--font-mono); color: var(--ink-mute); }
.vol-name { font: 400 23px/1.25 var(--font-display); }
.vol-desc { display: block; font: italic 15.5px var(--font-body); color: var(--ink-mute); }
.vol-bar { height: 6px; background: var(--paper-deep); border-radius: 3px; overflow: hidden; align-self: center; }
.vol-bar span { display: block; height: 100%; background: var(--herb); }
.vol ol { margin: 10px 0 4px 76px; padding: 0; columns: 2; column-gap: 30px; }
.vol li { font-size: 15.5px; margin-bottom: 3px; break-inside: avoid; }
.vol li a { text-decoration: none; color: var(--ink); }
.vol li a:hover { color: var(--accent); }
.vol li.done a::after { content: ' ✓'; color: var(--green); }
.settings { max-width: 1120px; margin: 0 auto; padding: 10px 28px 40px; font: 13.5px var(--font-mono); color: var(--ink-mute); }
.colophon { max-width: 1120px; margin: 0 auto; padding: 16px 28px 40px; font-size: 14px; color: var(--ink-mute); border-top: 1px solid var(--paper-rule); }

@media (max-width: 820px) {
    .workshop { grid-template-columns: minmax(0, 1fr); }
    .ws-stage { border-right: none; border-bottom: 1px solid var(--paper-rule); }
    .ws-panel { min-width: 0; flex-basis: 100% !important; }
    .plate-title { font-size: 34px; }
    .masthead { padding: 28px 16px 8px; }
    .masthead h1 { font-size: 38px; }
    .index-tools, .search-results, .catalog, .settings, .colophon { padding-left: 16px; padding-right: 16px; }
    .vol ol { columns: 1; margin-left: 0; }
    .vol summary { grid-template-columns: 48px 1fr; }
    .vol-bar { display: none; }
    .journey-vol { grid-template-columns: 1fr; }
    .main-content { padding: 18px 16px 50px; }
    .terms { grid-template-columns: 1fr; }
    .topbar { padding: 8px 16px; }
}
@media print { .topbar, .ws-rail, .quiz, .try-block, .plate-footer { display: none; } }
