/* Your Brain, Region by Region: the anatomical atlas plate.
   Identity: Crimson Pro (an old-style text serif in the tradition of the great anatomy atlases) for reading and for
   very large, heavy titles; Alegreya Sans (a humanist sans with calligraphic roots) for figure labels, leader-line
   annotations and controls. White page. One accent, a deep madder red ("fixative red"), for links and the title marks.
   The lobes keep ONE colour code everywhere on the site (Okabe–Ito): frontal blue, parietal orange, temporal green,
   occipital vermilion, cerebellum reddish purple, brainstem sky-to-steel blue. The header's bottom edge is that key. */
:root {
  --bg: #fff; --surface: #f6f4f0; --ink: #191716; --ink-soft: #383432; --muted: #5f5a56; --rule: #e3dfd8;
  --accent: #8e1b2e; --accent-ink: #fff; --link: #8e1b2e; --focus: #8e1b2e; --mark: rgba(142, 27, 46, .09);
  --font-display: "Crimson Pro", Georgia, serif;
  --font-serif: "Crimson Pro", Georgia, "Times New Roman", serif;
  --font-sans: "Alegreya Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-body: var(--font-serif); --font-ui: var(--font-sans); --font-h1: var(--font-display);
  --fs-body: 1.27rem; --lh-body: 1.52; --prose: 40rem; --wide: 70rem; --radius: 2px;
  --fig-bg: #fff; --fig-surface: #f6f4f0; --fig-ink: #191716; --fig-muted: #5f5a56; --fig-grid: rgba(0,0,0,.08);
  --fig-grid-strong: rgba(0,0,0,.42); --fig-border: transparent;
  --c-primary: #0072B2;  /* the thing being taught (in experiments: the measured response) */
  --c-ref: #3a3633;      /* reference: the stimulus, the instrument */
  --c-second: #D55E00;   /* comparison series */
  --c-third: #CC79A7;
  --c-ok: #007a5a; --c-warn: #a3172a;
  --ctl-accent: #8e1b2e;
  --band-bg: #8e1b2e; --band-ink: #fff; --band-muted: rgba(255,255,255,.86);
  --lobe-frontal: #0072B2; --lobe-parietal: #E69F00; --lobe-temporal: #009E73; --lobe-occipital: #D55E00;
  --lobe-cerebellum: #CC79A7; --lobe-stem: #56B4E9;
  --t-frontal: #005a8c; --t-parietal: #8a5a00; --t-temporal: #00704f; --t-occipital: #a64200; --t-cerebellum: #9a4675; --t-stem: #23729c;
}
:root[data-theme="dark"] {
  --bg: #141312; --surface: #1d1c1a; --ink: #ece8e2; --ink-soft: #cfcac2; --muted: #a39d94; --rule: #35322f;
  --accent: #e2778a; --link: #ec8c9c; --focus: #ec8c9c; --mark: rgba(226, 119, 138, .16);
  --fig-bg: #141312; --fig-surface: #1d1c1a; --fig-ink: #ece8e2; --fig-muted: #a8a299; --fig-grid: rgba(255,255,255,.09);
  --fig-grid-strong: rgba(255,255,255,.45);
  --c-primary: #56B4E9; --c-ref: #e6e1da; --c-second: #f08a4b; --c-third: #e39ac6; --c-ok: #3cc39a; --c-warn: #f07a8a;
  --ctl-accent: #e2778a; --band-bg: #5d1220;
  --t-frontal: #7cc3ef; --t-parietal: #f0b84a; --t-temporal: #4fd1a5; --t-occipital: #f08a4b; --t-cerebellum: #e39ac6; --t-stem: #8fd0f2;
}

/* Header: plain, with the lobe colour key as its bottom edge */
.site-header { border-bottom: 0; box-shadow: none; }
.site-header::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg, var(--lobe-frontal) 0 22%, var(--lobe-parietal) 22% 44%, var(--lobe-temporal) 44% 66%, var(--lobe-occipital) 66% 82%, var(--lobe-cerebellum) 82% 92%, var(--lobe-stem) 92% 100%); /* physical: the site's lobe colour key, hard stops, no blend */ }
.wordmark { font: 800 1.22rem/1 var(--font-display); letter-spacing: -.01em; }
.wordmark .wm-v { color: var(--accent); font-style: italic; font-weight: 400; }
.site-nav a { font-size: 1rem; }

/* Headings: heavy Crimson Pro, big, against calm text */
h1 { font-family: var(--font-h1); font-weight: 800; letter-spacing: -.018em; line-height: .95; }
h2 { font: 800 clamp(1.7rem, 3.6vw, 2.25rem)/1.08 var(--font-display); letter-spacing: -.01em; margin-top: 2.8rem; }
h3 { font: 600 1.35rem/1.2 var(--font-display); }
.prose .lede { font-size: 1.22em; line-height: 1.45; }
var { font-style: italic; }
.prose p, .prose li { hyphens: manual; }

/* Lobe words in prose carry the lobe colour (and stay readable) */
.lobe { font-weight: 600; }
.lobe.frontal { color: var(--t-frontal); } .lobe.parietal { color: var(--t-parietal); } .lobe.temporal { color: var(--t-temporal); }
.lobe.occipital { color: var(--t-occipital); } .lobe.cerebellum { color: var(--t-cerebellum); } .lobe.stem { color: var(--t-stem); }

/* Chapter title area: white, a heavy title, a short madder rule */
.essay-head h1 { font-size: clamp(2.5rem, 7.2vw, 4.6rem); margin: .08em 0 .18em; }
.essay-head .kicker { font: 500 1.02rem/1.3 var(--font-ui); color: var(--muted); margin: 0; }
.essay-head .kicker span { color: var(--accent); font-weight: 700; }
.essay-head .dek { font-size: clamp(1.14rem, 2.4vw, 1.42rem); line-height: 1.38; max-width: 40rem; color: var(--ink-soft); }
.essay-head-text::after { content: ""; display: block; width: 4.5rem; height: 3px; background: var(--accent); margin-top: .8rem; }
.essay-head.has-hero { padding-top: 1.4rem; }
@media (max-width: 559px) {
  .essay-head { padding-top: .8rem !important; }
  .essay-head h1 { font-size: 2.35rem; }
  .essay-head .dek { font-size: 1.06rem; margin: .2rem 0 .3rem; }
  .essay-head .meta-line, .essay-head-text::after { display: none; }
  .essay-head .kicker { font-size: .92rem; }
}

/* Home */
.bh-head { max-width: var(--wide); margin: 0 auto; padding: 1.5rem var(--gutter) 0; }
.bh-head h1 { font-size: clamp(2.6rem, 7.6vw, 5.4rem); margin: 0 0 .1em; }
.bh-head h1 em { font-style: italic; font-weight: 400; color: var(--accent); }
.bh-head .dek { margin: 0; max-width: 42rem; font-size: clamp(1.1rem, 2.4vw, 1.45rem); line-height: 1.36; color: var(--ink-soft); }
.bh-plate { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.bh-plate .figure { margin: .3rem 0 0; }
.bh-plate figcaption { max-width: 48rem; }
.bh-plate .start { margin: .9rem 0 0; }
.btn-start { font: 700 1.1rem var(--font-ui); }
@media (max-width: 559px) { .bh-head { padding-top: .7rem; } .bh-head h1 { font-size: 2.45rem; } .bh-head .dek { font-size: 1.02rem; line-height: 1.32; } }
.home-cards { max-width: var(--prose); }
.home-cards li::marker { font: 800 1.3rem var(--font-display); color: var(--accent); }
.home-cards .card-t { font: 800 1.35rem/1.15 var(--font-display); }
.home-cards .card-d { font-size: 1.08rem; color: var(--ink-soft); }
.home-tools { max-width: var(--prose); margin: 0 auto 3rem; padding: 0 var(--gutter); }
.home-tools h2 { margin-top: 1.5rem; }
.home-tools ul { list-style: none; padding: 0; }
.home-tools li { margin: 0 0 1rem; }
.home-tools a { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.home-tools .card-t { font: 700 1.2rem var(--font-ui); color: var(--link); text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
.home-tools .card-d { color: var(--ink-soft); font-size: 1.05rem; }

/* Figures */
.fig-n { font: 700 .9rem var(--font-ui); font-variant: all-small-caps; letter-spacing: .05em; color: var(--accent); }
.figure figcaption { font-size: 1.02rem; line-height: 1.42; }
.w-note { font-size: 1.04rem; color: var(--ink-soft); max-width: 46rem; }
.w-note b { color: var(--fig-ink); font-weight: 700; }
.w-stage canvas { border-radius: 0; }
.w-stage canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.w-ctl label, .w-lab, .w-check { font-family: var(--font-ui); }
.b3-info { margin: .5rem 0 .2rem; font: 400 1.06rem/1.42 var(--font-serif); max-width: 46rem; color: var(--ink-soft); }
.b3-info b { color: var(--ink); font-weight: 700; }
.b3-muted { color: var(--muted); }
.b3-quiz { margin: .4rem 0 .2rem; font: 500 1.08rem/1.4 var(--font-ui); }
.b3-deck { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; align-items: end; }
.b3-opts { display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; align-items: center; min-height: 44px; }

/* Experiment figures */
.xp-say { margin: .45rem 0 0; font-size: 1.04rem; line-height: 1.42; color: var(--ink-soft); }
.xp-say b { color: var(--ink); }
.xp-row { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; align-items: end; }

/* Tables in prose */
.prose table { font-family: var(--font-ui); font-size: 1rem; border-collapse: collapse; width: 100%; }
.prose th, .prose td { padding: .38rem .5rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.prose th { font-weight: 700; }
.prose td.num, .prose th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.callout-history { border-left-color: var(--accent); }
.simplification { border-left-color: var(--accent); }
.ymyl { font: 400 .98rem/1.45 var(--font-ui); color: var(--muted); border-top: 1px solid var(--rule); padding-top: .5rem; }

/* Case-file details (Phineas Gage) */
.casefile { font-family: var(--font-ui); font-size: 1.02rem; border-top: 3px solid var(--ink); border-bottom: 1px solid var(--rule); padding: .6rem 0 .4rem; margin: 1.2rem 0 1.6rem; }
.casefile dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; margin: 0; }
.casefile dt { font-weight: 700; }
.casefile dd { margin: 0; }
.verdict { font-family: var(--font-ui); font-weight: 700; }
.verdict.myth { color: var(--c-warn); } .verdict.ok { color: var(--c-ok); } .verdict.mixed { color: var(--t-parietal); }

.theme-toggle { white-space: nowrap; }
@media (max-width: 559px) { .wordmark { font-size: 1.02rem; } }
.ev-active, .ev-contested { color: var(--t-occipital); }
/* 3-D plates: Share/Reset sit inside the plate's top-right corner (labels start below them), so no empty band above */
.w-stage.b3-stage, .w-stage.g3-stage { margin-top: .5rem; }
.w-stage.b3-stage .w-toolbar, .w-stage.g3-stage .w-toolbar { top: 0; right: 0; }
@media (pointer: coarse) { .w-stage.b3-stage, .w-stage.g3-stage { margin-top: .5rem; } .w-stage.b3-stage .w-toolbar, .w-stage.g3-stage .w-toolbar { top: 0; } }
