/* ============================================================
   Contrastive Discovery — project page styles
   One file, no build step. Edit the variables in :root to change
   colors, fonts, and column widths; everything else follows.
   ============================================================ */

:root {
  /* Colors */
  --bg: #fbfaf7;          /* page background (warm off-white) */
  --surface: #ffffff;     /* cards, figure panels */
  --ink: #1d1b18;         /* body text */
  --muted: #5f5a53;       /* captions, secondary text */
  --line: #e6e1d8;        /* hairline borders */
  --accent: #1f5fa8;      /* brand blue ("resolved") */
  --accent-tint: #e9f1fb; /* pale blue backgrounds */
  --red: #c8412c;         /* "rejected" red, used sparingly */
  --link: #2b78c5;        /* author links: lighter than the title blue */

  /* Paper Figure 1 colors. Use these for data (belief bars, check/cross marks)
     so a blue bar means the same thing on the page as in the figure; keep
     --accent for headings and links. */
  --f-blue: #0076ba;      /* leading / resolved */
  --f-red: #ee220c;       /* ruled out / rejected */
  --f-gray: #929292;      /* other explanations */
  --f-light: #d5d5d5;     /* unknown ("?") */
  --f-yel: #ffe1a5;       /* experimental evidence */
  --f-label: #5e5e5e;
  --f-ax: #8a8a8a;        /* mini-plot axes */
  --lane-cd: #e6f1f9;     /* Contrastive Discovery lane */
  --lane-pw: #efefef;     /* Pointwise lane */
  /* Explanation colors by direction: line / text / tint */
  --pos: #2a9d6e; --pos-ink: #1b7650; --pos-tint: #dcf1e6;      /* positive, higher, increases */
  --flat: #f27200; --flat-ink: #b95200; --flat-tint: #fde6d2;   /* none, no difference */
  --neg: #7d5bc6; --neg-ink: #5a3b9e; --neg-tint: #e9e2f6;      /* negative, lower, decreases */

  /* Type */
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fig: "Helvetica Neue", Helvetica, Arial, sans-serif;  /* the figure's typeface */

  /* Layout */
  --column: 880px;        /* text column */
  --column-wide: 1080px;  /* wide figures */
  --radius: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h2 { font-size: 1.9rem; margin-bottom: .6rem; }
h3 { font-size: 1.15rem; margin-bottom: .4rem; }
p { margin: 0 0 1rem; }
strong { font-weight: 600; }

.wrap { max-width: var(--column); margin: 0 auto; padding: 0 24px; }
.wrap.wide { max-width: var(--column-wide); }

/* Inline math written in plain HTML */
.math { font-family: var(--serif); font-style: italic; white-space: nowrap; }
.math sub, .math sup { font-style: normal; font-size: .75em; }

/* Figure vocabulary, shared by the scroll story and the Method section:
   a highlighted phrase (<em class="ph pos">) and a mini-plot glyph (svg.mp). */
.ph { font-style: normal; border-radius: 999px; padding: 0 .32em; white-space: nowrap; }
.ph.pos { background: var(--pos-tint); color: var(--pos-ink); }
.ph.flat { background: var(--flat-tint); color: var(--flat-ink); }
.ph.neg { background: var(--neg-tint); color: var(--neg-ink); }
.mp { flex: none; display: block; }
.mp-ax { fill: none; stroke: var(--f-ax); stroke-width: 2.2; }
.mp-l { fill: none; stroke-width: 3.4; stroke-linecap: round; }
.mp-l.pos { stroke: var(--pos); } .mp-l.flat { stroke: var(--flat); } .mp-l.neg { stroke: var(--neg); }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 72px 0 40px; }

.eyebrow {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(2.2rem, 1.2rem + 4vw, 3.6rem);
  letter-spacing: -.01em;
  color: var(--accent);
}
.hero .subtitle {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 1rem + 1.4vw, 1.7rem);
  color: var(--ink);
  margin: 10px auto 22px;
  max-width: 44ch;
  line-height: 1.3;
}
.hero .dek {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 60ch;
  margin: 0 auto 28px;
}

.authors {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 28px;
  font-size: 1.1rem; margin-bottom: 8px;
}
.authors span { white-space: nowrap; }
.authors a { color: var(--link); }
.authors a:hover { color: var(--accent); }
.authors sup { color: var(--muted); margin-left: 1px; line-height: 0; }
.affil { color: var(--muted); font-size: .95rem; margin-bottom: 26px; }
.affil small { display: block; font-size: .85rem; margin-top: 2px; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  font-size: .95rem;
  background: var(--surface);
  transition: background .15s, color .15s;
}
.btn:hover { background: var(--ink); color: #fff; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #17497f; border-color: #17497f; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn.disabled { color: var(--muted); border-color: var(--line); cursor: default; }
.btn.disabled:hover { background: var(--surface); color: var(--muted); }

/* One-line TL;DR under the buttons */
.tldr-line {
  max-width: 64ch; margin: 30px auto 0; padding: 16px 22px;
  background: var(--accent-tint); border: 1px solid #cfdff2; border-radius: var(--radius);
  font-size: 1.05rem; text-align: left;
}
.tldr-line .label {
  font-family: var(--mono); font-size: .75rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-right: 8px;
}

/* ---------- Sticky section nav ---------- */
.site-nav {
  position: sticky; top: 0; z-index: 10;
  background: rgba(251, 250, 247, .92);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.nav-inner {
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 16px; overflow-x: auto; scrollbar-width: none;
}
.nav-inner::-webkit-scrollbar { display: none; }
.site-nav a {
  flex: none; padding: 5px 14px; border-radius: 999px;
  color: var(--muted); font-size: .92rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.site-nav a:hover { background: var(--accent-tint); color: var(--accent); text-decoration: none; }
.site-nav a.is-active { background: var(--accent); color: #fff; }
section[id], h3[id] { scroll-margin-top: 64px; }


/* ---------- Scroll story (#problem) ----------
   Text steps scroll on the left; the stage stays pinned on the right (on top on phones).
   Each explanation is a line on one scatter plot, in the paper figure's colors. The script
   sets classes on .stage, each .hyp line, and each .hrow row from its STATES table. */
.story { padding: 56px 0 24px; }
.story-inner { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 44px; margin-top: 24px; }
.story-steps { grid-column: 1; grid-row: 1; min-width: 0; }
.story-stage { grid-column: 2; grid-row: 1; min-width: 0; }
.story-stage .stage { position: sticky; top: 72px; }

/* Each step's text stays in place while its step is current, so there is no blank stretch between steps. */
.story-step { min-height: 76vh; transition: opacity .35s; }
.story-step:last-child { min-height: 92vh; }
.step-text { position: sticky; top: 180px; padding-top: 6px; }
.story-step h3 { font-size: 1.45rem; margin-bottom: 8px; }
.story-step p { font-size: 1.04rem; }
.story-step .aside { font-size: .94rem; color: var(--muted); border-left: 3px solid var(--f-red); padding-left: 12px; }
.story-js .story-step { opacity: .28; }
.story-js .story-step.is-active { opacity: 1; }

.stage {
  font-family: var(--fig); background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; box-shadow: 0 8px 28px rgba(29, 27, 24, .07); transition: opacity .18s;
}
.stage.swap { opacity: 0; }
.stage-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.agent svg { width: 32px; height: 32px; display: block; }
.mode {
  font: 700 .72rem var(--mono); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; background: var(--lane-pw); color: var(--f-label); transition: background .4s, color .4s;
}
.stage.is-cont .mode { background: var(--f-blue); color: #fff; }
.ev-chip {
  margin-left: auto; font: 600 .78rem var(--sans); color: #7a4a00; background: var(--f-yel); border-radius: 999px;
  padding: 4px 10px; white-space: nowrap; opacity: 0; transform: translateX(8px); transition: opacity .35s, transform .35s;
}
.ev-chip.on { opacity: 1; transform: none; }
.stage-label { font: .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }

/* The plot: data points, the dashed fit, and one line per explanation */
.plot { display: block; width: 100%; height: auto; margin: 2px 0 6px; }
.p-ax { fill: none; stroke: var(--f-ax); stroke-width: 3; }
.p-axl { font: 700 17px var(--fig); fill: var(--f-ax); }
.p-band { fill: #fde8d6; opacity: 0; transition: opacity .5s 1.2s; }
.p-fit { fill: none; stroke: var(--f-label); stroke-width: 3; stroke-dasharray: .025 .018; opacity: 0; transition: opacity .5s 1.2s; }
.p-dot {
  fill: #111; stroke: #fff; stroke-width: 2.2; opacity: 0; transform: scale(.2); transform-box: fill-box; transform-origin: center;
  transition: opacity .25s, transform .3s cubic-bezier(.3, 1.5, .5, 1); transition-delay: calc(150ms + var(--i) * 40ms);
}
.ev-on .p-dot { opacity: 1; transform: none; }
.ev-on .p-band, .fit-on .p-fit { opacity: 1; }
.hyp { transition: opacity .5s; }
.hyp-line { fill: none; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1;
  transition: stroke-dashoffset .9s ease var(--d, 0ms), stroke-width .4s; }
.hyp-line.pos { stroke: var(--pos); } .hyp-line.flat { stroke: var(--flat); } .hyp-line.neg { stroke: var(--neg); }
.hyp.drawn .hyp-line { stroke-dashoffset: 0; }
.hyp.rej { opacity: .32; }
.hyp.dim { opacity: .2; }
.hyp.win .hyp-line { stroke-width: 9; }
.hyp-tag { opacity: 0; transition: opacity .4s calc(var(--d, 0ms) + 500ms); }
.hyp.drawn .hyp-tag { opacity: 1; }
.hyp-tag circle { fill: #fff; stroke-width: 3.5; }
.hyp[data-h="1"] .hyp-tag circle { stroke: var(--pos); }
.hyp[data-h="2"] .hyp-tag circle { stroke: var(--flat); }
.hyp[data-h="3"] .hyp-tag circle { stroke: var(--neg); }
.hyp.rej .hyp-tag circle { stroke: var(--f-red); }
.hyp-tag text { font: 700 14px var(--fig); fill: #111; }
.r-tag { opacity: 0; transition: opacity .4s 1.6s; }
.ev-on .r-tag { opacity: 1; }
.r-tag rect { fill: #fff; stroke: #dcdcdc; stroke-width: 1.5; }
.r-tag text { font: 700 17px var(--fig); fill: #111; }

/* Rows: H ring, statement, verdict mark, belief bar (as in the figure) */
.hrows { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.hrow {
  --track: 96px; display: grid; grid-template-columns: 36px minmax(0, 1fr) 24px calc(var(--track) + 2.6em);
  gap: 10px; align-items: center; transition: opacity .45s, transform .45s;
}
.hrow.hidden { opacity: 0; transform: translateY(6px); }
.ring {
  width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--f-gray); background: #fff;
  display: grid; place-items: center; font: 700 14px/1 var(--fig); color: #111;
}
.ring sub { font-size: .66em; vertical-align: -.3em; }
.hrow[data-row="0"] .ring { border-color: var(--f-blue); }
.ring .q, .stmt .q { display: none; }
.hrow.unknown .ring { border-color: var(--f-light); color: #333; }
.hrow.unknown .ring .h, .hrow.unknown .stmt .h, .hrow.unknown .mp { display: none; }
.hrow.unknown .ring .q, .hrow.unknown .stmt .q { display: inline; }
.stmt {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 38px; padding: 6px 10px; border-radius: 10px;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .13); font: 14px/1.25 var(--fig); color: #111;
}
.hrow[data-row="0"] .stmt { box-shadow: inset 0 0 0 3px var(--f-blue), 0 2px 6px rgba(0, 0, 0, .13); }
.hrow.unknown .stmt { background: transparent; box-shadow: none; border: 2px dashed #c4c4c4; color: var(--f-gray); font-style: italic; }
.stage .mp { width: 34px; height: 24px; }
.mp-l { transition: stroke-dashoffset .6s .25s; stroke-dasharray: 1; stroke-dashoffset: 0; }
.hrow.hidden .mp-l { stroke-dashoffset: 1; }
.bb { position: relative; height: 22px; }
.bb i {
  position: absolute; inset: 0 auto 0 0; width: calc(var(--v, 0) * var(--track)); min-width: 3px; background: var(--f-gray);
  transition: width .85s cubic-bezier(.3, .7, .2, 1) var(--bd, 0ms), background-color .45s var(--bd, 0ms);
}
.bb.blue i { background: var(--f-blue); }
.bb.red i { background: var(--f-red); }
.bv {
  position: absolute; top: 50%; left: calc(var(--v, 0) * var(--track) + 7px); transform: translateY(-50%);
  font: 700 15px var(--fig); font-variant-numeric: tabular-nums; color: #111;
  transition: left .85s cubic-bezier(.3, .7, .2, 1) var(--bd, 0ms);
}
.hrow.unknown .bb i { width: var(--qs, 22px); background: var(--f-light); transition: none; }
.hrow.unknown .bv { left: calc(var(--qs, 22px) + 7px); transition: none; }
.mk {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; transform: scale(0);
  transition: transform .4s cubic-bezier(.3, 1.6, .5, 1) calc(var(--bd, 0ms) + 500ms);
}
.mk svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.mk .ok, .mk .no { display: none; }
.mk.ok { background: var(--f-blue); transform: none; } .mk.ok .ok { display: inline; }
.mk.bad { background: var(--f-red); transform: none; } .mk.bad .no { display: inline; }
.mk.gray { background: var(--f-gray); transform: none; } .mk.gray .no { display: inline; }

.verdicts { display: grid; margin-top: 12px; }
.verdict {
  grid-area: 1 / 1; margin: 0; padding: 9px 14px; border-radius: 12px; font: 700 1.05rem/1.3 var(--fig);
  opacity: 0; transform: translateY(4px); transition: opacity .4s .6s, transform .4s .6s;
}
.verdict span { font-weight: 400; font-size: .88rem; margin-left: 6px; }
.verdict.bad { background: #fdecea; color: var(--f-red); }
.verdict.good { background: var(--lane-cd); color: var(--f-blue); }
.stage[data-verdict="bad"] .verdict.bad, .stage[data-verdict="good"] .verdict.good { opacity: 1; transform: none; }

/* Narrower desktops: the statements show just the colored phrase so they stay on one line */
@media (max-width: 1060px) {
  .stmt .xw { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .stage, .stage *, .story-step { transition: none !important; }
}

/* ---------- Abstract + headline numbers ---------- */
.abstract p { text-align: justify; hyphens: auto; }

.stats {
  list-style: none; padding: 0; margin: 28px 0 8px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s, transform .15s;
}
.stat:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat a { display: block; height: 100%; padding: 18px 18px 16px; color: inherit; }
.stat a:hover { text-decoration: none; }
.stat .num { font-family: var(--serif); font-size: 2.3rem; line-height: 1; color: var(--accent); }
.stat .num.red { color: var(--red); }
.stat .lbl { font-size: .9rem; color: var(--muted); margin-top: 8px; line-height: 1.4; }

/* ---------- Sections ---------- */
.section { padding: 56px 0 8px; }
.section.tint { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-bottom: 48px; }
.kicker {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 10px;
}
.lead { font-size: 1.1rem; max-width: 66ch; }

/* Figures */
.fig { margin: 24px 0 8px; }
.fig .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.fig img { margin: 0 auto; }
.swipe-hint { display: none; }
.fig figcaption { color: var(--muted); font-size: .95rem; line-height: 1.5; margin: 12px 4px 0; max-width: 90ch; }
.fig figcaption b { color: var(--ink); }

/* Narrow figure with its caption alongside (stacks on small screens) */
.fig.side { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.fig.side figcaption { margin: 0; }

/* Question-style subheadings inside a section */
h3.sub.q { font-size: 1.45rem; margin-top: 48px; }
h3.sub.q + p { max-width: 70ch; }

/* Method walkthrough: one row per step, text left and a small visual right */
.walk { list-style: none; margin: 26px 0 18px; padding: 0; display: grid; gap: 14px; }
.walk-step {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px;
}
.walk-text { display: grid; grid-template-columns: 28px 1fr; column-gap: 12px; }
.walk-text .n {
  grid-row: 1 / span 2; width: 28px; height: 28px; line-height: 28px; text-align: center;
  border-radius: 50%; background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: .85rem; font-weight: 600;
}
.walk-text h3 { margin: 3px 0 6px; }
.walk-text p { font-size: .97rem; color: var(--muted); margin: 0; }
.walk-vis {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
}
.vis-q { font-family: var(--serif); font-size: 1.08rem; margin-bottom: 10px; }

/* Before/after belief bars, drawn like the figure: blue = leading, red = ruled out,
   gray = other; marks (<b class="m ok|bad|gray">) as in the figure's posterior column */
.beliefs {
  display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px 14px; align-items: center;
  font: 700 .88rem var(--fig); font-variant-numeric: tabular-nums;
}
.beliefs .bh { font: 400 .7rem var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.beliefs .hl {
  width: 30px; text-align: center; border-radius: 6px; background: var(--accent-tint); color: var(--accent);
  font: 600 .72rem/18px var(--mono);
}
.beliefs .hl.pos { background: var(--pos-tint); color: var(--pos-ink); }
.beliefs .hl.flat { background: var(--flat-tint); color: var(--flat-ink); }
.beliefs .hl.neg { background: var(--neg-tint); color: var(--neg-ink); }
.beliefs .b { display: flex; align-items: center; gap: 7px; color: #111; }
/* bar length leaves room for a mark and the value in the same column */
.beliefs .b i { display: block; height: 14px; flex: none; width: calc((100% - 66px) * var(--w) / 100); min-width: 3px; background: var(--f-gray); }
.beliefs .b.top i { background: var(--f-blue); }
.beliefs .b.out i { background: var(--f-red); }
.beliefs .m { width: 16px; height: 16px; border-radius: 50%; flex: none; background: var(--f-gray) center / 12px no-repeat; }
.beliefs .m.ok { background-color: var(--f-blue); background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6.5 12.5l3.6 3.8 7.4-8.6' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/></svg>"); }
.beliefs .m.bad { background-color: var(--f-red); background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M8 8l8 8M16 8l-8 8' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'/></svg>"); }
.beliefs .m.gray { background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M8 8l8 8M16 8l-8 8' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'/></svg>"); }

/* Step 3 outcomes */
.walk-vis.outcomes { display: grid; gap: 10px; background: none; border: 0; padding: 0; }
.outcome { border-radius: 10px; padding: 12px 16px; border: 1px solid; }
.outcome p { margin: 0; }
.outcome .who { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.outcome .what { font-family: var(--serif); font-size: 1.08rem; color: var(--ink); line-height: 1.35; margin-top: 2px; }
.outcome.good { background: var(--accent-tint); border-color: #cfdff2; }
.outcome.good .who { color: var(--f-blue); }
.outcome.bad { background: #fbeeeb; border-color: #f0d3cc; }
.outcome.bad .who { color: var(--f-red); }

/* Collapsible formal definitions */
details.formal { margin: 4px 0 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
details.formal summary {
  cursor: pointer; padding: 12px 18px; font-weight: 600; font-size: .95rem; color: var(--accent);
  list-style: none;
}
details.formal summary::-webkit-details-marker { display: none; }
details.formal summary::before { content: "+"; display: inline-block; width: 1.1em; font-family: var(--mono); }
details.formal[open] summary::before { content: "\2212"; }
.formal-body { padding: 0 18px 6px 38px; }
.formal-body p { font-size: .95rem; color: var(--muted); }

.note { font-size: .95rem; color: var(--muted); max-width: 70ch; }
h3.sub { font-size: 1.35rem; margin: 36px 0 6px; }

/* Example contrast sets: one card each */
.cset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0 12px; }
.cset {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 20px; box-shadow: 0 1px 2px rgba(29, 27, 24, .04);
}
.cset-domain {
  display: inline-block; margin: 0 0 10px; padding: 3px 10px; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.cset-q {
  font-family: var(--serif); font-size: 1.1rem; line-height: 1.35;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px dashed var(--line);
}
.cset .alts { font-size: .95rem; }

.alts { list-style: none; margin: 0; padding: 0; counter-reset: h; }
.alts li { position: relative; padding-left: 40px; margin: 0 0 6px; counter-increment: h; }
.alts li:last-child { margin-bottom: 0; }
.alts li::before {
  content: "H" counter(h); position: absolute; left: 0; top: 3px;
  width: 30px; text-align: center; border-radius: 6px;
  background: var(--accent-tint); color: var(--accent);
  font-family: var(--mono); font-size: .72rem; font-weight: 600; line-height: 18px;
}
/* With data-dir on an <li>, the badge takes the figure's direction color and a mini-plot
   glyph follows it: pos (higher / increases), flat (no difference), neg (lower / decreases),
   curve (nonlinear or none). The color follows the meaning, not the H number. */
.alts li[data-dir] { padding-left: 74px; }
.alts li[data-dir]::after {
  content: ""; position: absolute; left: 37px; top: 2px; width: 29px; height: 21px;
  background: center / contain no-repeat;
}
.alts li[data-dir="pos"]::before { background: var(--pos-tint); color: var(--pos-ink); }
.alts li[data-dir="flat"]::before, .alts li[data-dir="curve"]::before { background: var(--flat-tint); color: var(--flat-ink); }
.alts li[data-dir="neg"]::before { background: var(--neg-tint); color: var(--neg-ink); }
.alts li[data-dir="pos"]::after { background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'><path d='M3 2V25H39' fill='none' stroke='%238a8a8a' stroke-width='2.2'/><path d='M8 22L36 5' fill='none' stroke='%232a9d6e' stroke-width='3.4' stroke-linecap='round'/></svg>"); }
.alts li[data-dir="flat"]::after { background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'><path d='M3 2V25H39' fill='none' stroke='%238a8a8a' stroke-width='2.2'/><path d='M8 14L36 14' fill='none' stroke='%23f27200' stroke-width='3.4' stroke-linecap='round'/></svg>"); }
.alts li[data-dir="neg"]::after { background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'><path d='M3 2V25H39' fill='none' stroke='%238a8a8a' stroke-width='2.2'/><path d='M8 6L36 23' fill='none' stroke='%237d5bc6' stroke-width='3.4' stroke-linecap='round'/></svg>"); }
.alts li[data-dir="curve"]::after { background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 28'><path d='M3 2V25H39' fill='none' stroke='%238a8a8a' stroke-width='2.2'/><path d='M8 21Q22 0 36 21' fill='none' stroke='%23f27200' stroke-width='3.4' stroke-linecap='round'/></svg>"); }

/* Compact evidence cards (validation section) */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 22px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
}
.card p { font-size: .95rem; color: var(--muted); margin: 0; }
.card.wide-card { grid-column: 1 / -1; }
.section.tint .card { background: var(--bg); }
.formal-body .human { background: var(--surface); }
.section.tint .fig .panel { background: var(--surface); }

/* Headline number on a robustness card */
.card p.big {
  font-family: var(--serif); font-size: 2rem; line-height: 1; color: var(--accent);
  margin-bottom: 12px;
}
.card p.big span { font-size: 1rem; color: var(--muted); }

/* Three-up card row */
.cards.three { grid-template-columns: repeat(3, 1fr); }

/* Expert agreement: two headline bars */
.agree {
  margin: 18px 0 14px; padding: 18px 20px; max-width: 640px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.agree-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 3.2em; gap: 14px; align-items: center; margin-bottom: 10px; }
.agree-lbl { font-size: .95rem; }
.agree-bar {
  height: 12px; border-radius: 6px;
  background: linear-gradient(to right, var(--f-blue) calc(var(--w) * 1%), var(--line) 0);
}
.agree-row b { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; color: var(--f-blue); text-align: right; }
.agree-cap { font-size: .85rem; color: var(--muted); margin: 4px 0 0; }

/* Spacing for "More detail" boxes that follow a figure or cards */
.fig + details.formal, .wrap > details.formal:first-child { margin-top: 18px; }
.cards + details.formal, .agree + details.formal { margin-top: 14px; }
.formal-body .human { margin: 4px 0 16px; }

/* Expert-agreement table with inline bars */
.human {
  width: 100%; border-collapse: collapse; font-size: .92rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.human caption { caption-side: bottom; text-align: left; font-size: .85rem; color: var(--muted); padding: 8px 4px 0; }
.human th, .human td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.human th {
  border-top: 0; font-family: var(--mono); font-weight: 600; font-size: .72rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.human .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.human td:last-child { font-variant-numeric: tabular-nums; }
.human tr.grp td { border-top: 1.5px solid var(--ink); }
.human tr.hl td:first-child { font-weight: 600; }
/* Each bar is a fixed-width track filled to --w percent */
.human .bar {
  display: inline-block; vertical-align: middle; height: 8px; margin-right: 10px;
  width: 72px; border-radius: 4px;
  background: linear-gradient(to right, var(--f-gray) calc(var(--w) * 1%), var(--line) 0);
}
.human tr.hl .bar { background: linear-gradient(to right, var(--f-blue) calc(var(--w) * 1%), var(--line) 0); }

.note.scope { margin-top: 28px; }

/* Takeaway quote */
.takeaway {
  font-family: var(--serif); font-size: 1.5rem; line-height: 1.35;
  text-align: center; max-width: 34ch; margin: 44px auto 0; color: var(--ink);
}

/* BibTeX */
.bibtex { position: relative; background: #1d1b18; color: #e9e5dd; border-radius: var(--radius); padding: 18px 20px; margin-top: 18px; overflow-x: auto; }
.bibtex pre { margin: 0; font-family: var(--mono); font-size: .85rem; line-height: 1.5; }
.bibtex button {
  position: absolute; top: 12px; right: 12px;
  background: transparent; color: #e9e5dd; border: 1px solid #5b5750; border-radius: 6px;
  font: 600 .8rem var(--sans); padding: 5px 10px; cursor: pointer;
}
.bibtex button:hover { background: var(--accent); border-color: var(--accent); }

footer { text-align: center; color: var(--muted); font-size: .9rem; padding: 48px 24px 60px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .walk-step { grid-template-columns: 1fr; gap: 16px; }
  .fig.side { grid-template-columns: 1fr; gap: 0; }
  .fig.side figcaption { margin: 12px 4px 0; }
  .cards.three { grid-template-columns: 1fr; }

  /* Scroll story on phones and tablets: the stage pins under the nav and the
     steps scroll up beneath it. */
  .story-inner { display: block; margin-top: 16px; }
  .story-stage {
    position: sticky; top: 51px; z-index: 5;
    background: var(--bg); padding: 8px 0 10px;
    box-shadow: 0 10px 12px -10px rgba(29, 27, 24, .14);
  }
  .story-stage .stage { position: static; }
  .story-step { min-height: 56vh; }
  .story-step:last-child { min-height: 64vh; }
  .step-text { position: static; padding-top: 5vh; }
  .story-step h3 { font-size: 1.25rem; }
  .plot { width: auto; max-width: 100%; height: min(176px, 22vh); margin-inline: auto; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .cset-grid { grid-template-columns: 1fr; gap: 12px; }
  .cset { padding: 16px 16px 18px; }
  .walk-step { padding: 16px; }
  .walk-vis { padding: 14px; }
  .formal-body { padding: 0 16px 4px; }
  .authors { gap: 2px 20px; font-size: 1.02rem; }
  .story { padding-top: 40px; }
  .story-stage { top: 46px; }
  .stage { padding: 10px 12px; border-radius: 16px; }
  .stage-top { gap: 8px; }
  .agent svg { width: 26px; height: 26px; }
  .mode { font-size: .62rem; letter-spacing: .05em; padding: 3px 8px; }
  .ev-chip { font-size: .7rem; padding: 3px 8px; }
  .hrows { gap: 6px; }
  .hrow { --track: 50px; --qs: 16px; grid-template-columns: 28px minmax(0, 1fr) 20px calc(var(--track) + 2.3em); gap: 7px; }
  .ring { width: 28px; height: 28px; border-width: 3px; font-size: 11px; }
  .stmt { font-size: 11.5px; padding: 4px 7px; gap: 5px; min-height: 30px; border-radius: 8px; }
  .stmt .xw { display: none; }
  .stage .mp { width: 24px; height: 18px; }
  .bb { height: 16px; }
  .bv { font-size: 12px; }
  .mk { width: 20px; height: 20px; }
  .mk svg { width: 13px; height: 13px; }
  .verdict { font-size: .92rem; padding: 7px 11px; }
  .verdict span { font-size: .8rem; }
  .story-step p { font-size: 1rem; }
  .agree { padding: 14px; }
  .agree-row { grid-template-columns: minmax(0, 1fr) 3em; row-gap: 6px; column-gap: 10px; margin-bottom: 14px; }
  .agree-bar { grid-column: 1 / -1; grid-row: 2; }
  .hero { padding-top: 48px; }
  .section { padding-top: 44px; }
  .cards { grid-template-columns: 1fr; }
  .fig .panel { padding: 10px; }
  .tldr-line { padding: 14px 16px; }
  .site-nav .nav-inner { justify-content: flex-start; }
  .abstract p { text-align: left; hyphens: manual; }
  .human th, .human td { padding: 8px 6px; }
  .human td:first-child { white-space: normal; }
  .human .bar { width: 36px; margin-right: 6px; }
  .takeaway { font-size: 1.25rem; margin-top: 36px; }

  /* Phone layout: 16px gutters, tighter type and spacing */
  .wrap { padding: 0 16px; }
  h2 { font-size: 1.55rem; }
  h3.sub, h3.sub.q { font-size: 1.25rem; margin-top: 36px; }
  .lead { font-size: 1.02rem; }
  .hero { padding-bottom: 28px; }
  .eyebrow { margin-bottom: 14px; font-size: .72rem; }
  .authors { font-size: .98rem; }
  .affil { font-size: .88rem; margin-bottom: 20px; }
  .buttons { gap: 6px; flex-wrap: nowrap; }
  .btn { padding: 7px 11px; font-size: .84rem; gap: 5px; white-space: nowrap; border-width: 1.25px; }
  .btn svg { width: 15px; height: 15px; }
  .tldr-line { margin-top: 22px; font-size: .98rem; }

  /* Nav: one swipeable row, edge fade hints there is more */
  .nav-inner {
    padding: 6px 12px;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
            mask-image: linear-gradient(to right, #000 85%, transparent);
  }
  .site-nav a { padding: 5px 11px; font-size: .86rem; }
  section[id], h3[id] { scroll-margin-top: 52px; }

  /* Wide multi-panel figures: keep text legible and let them scroll sideways */
  .fig .panel.wide-fig { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .fig .panel.wide-fig img { min-width: 680px; margin: 0; }
  .swipe-hint {
    display: block; margin: 6px 4px 0; text-align: right;
    font-family: var(--mono); font-size: .7rem; letter-spacing: .04em; color: var(--muted);
  }
  .fig figcaption { font-size: .9rem; margin-top: 10px; }

  .stats { gap: 10px; }
  .stat a { padding: 14px 14px 12px; }
  .stat .num { font-size: 1.9rem; }
  .stat .lbl { font-size: .84rem; }
  .card { padding: 16px 16px 14px; }
  .card p.big { font-size: 1.7rem; }
  .note { font-size: .9rem; }

  /* BibTeX: Copy button sits above the entry instead of over it */
  .bibtex { padding: 46px 14px 14px; }
  .bibtex pre { font-size: .74rem; }
  footer { padding: 36px 16px 48px; }
}
@media (max-width: 350px) {
  .buttons { flex-wrap: wrap; }
}
/* Narrowest phones: drop the agent icon and shrink the stage so it fits */
@media (max-width: 360px) {
  .agent { display: none; }
  .mode { font-size: .58rem; }
  .ev-chip { font-size: .66rem; }
  .hrow { --track: 40px; grid-template-columns: 26px minmax(0, 1fr) 18px calc(var(--track) + 2.2em); gap: 6px; }
  .stmt { font-size: 10.5px; }
}
