/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #F7F5F0;
  --bg-2: #EFECE5;          /* tinted sections, tiles */
  --card: #FFFFFF;
  --ink: #1A1917;
  --ink-2: #4A4741;
  --muted: #76726A;
  --line: #E0DCD2;
  --accent: #04806A;        /* marks (validated chart hue) */
  --accent-ink: #03664F;    /* text-safe on --bg */
  --accent-wash: rgba(4, 128, 106, .10);
  --before: #8E897F;        /* de-emphasis mark: "before" values */
  --shadow: 0 1px 2px rgba(26, 25, 23, .04), 0 12px 40px -12px rgba(26, 25, 23, .14);

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --gutter: 20px;
  --narrow: 760px;
  --wide: 1240px;
  --radius: 24px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --bg-2: #1C1B19;
    --card: #222120;
    --ink: #EEEBE4;
    --ink-2: #C4C0B7;
    --muted: #8F8B82;
    --line: #34322E;
    --accent: #2BA696;
    --accent-ink: #5CC4B3;
    --accent-wash: rgba(43, 166, 150, .14);
    --before: #77736B;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 48px -16px rgba(0, 0, 0, .6);
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
p { margin: 0 0 1em; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.015em;
  margin: 0 0 .5em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 7vw, 5.4rem); line-height: 1.02; letter-spacing: -.025em; }
h2 { font-size: clamp(2.1rem, 5vw, 3.75rem); line-height: 1.06; }
h3 { font-size: clamp(1.6rem, 3.4vw, 2.6rem); line-height: 1.12; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--card); padding: 8px 14px; border-radius: 8px; }

.wrap { width: min(100% - 2 * var(--gutter), var(--wide)); margin-inline: auto; }
.narrow > * { max-width: var(--narrow); }
.center { text-align: center; }
.center > * { margin-inline: auto; }
.muted { color: var(--muted); }
.dot { color: var(--muted); padding: 0 .2em; }

.eyebrow {
  font-size: .9375rem; font-weight: 600; color: var(--accent-ink);
  margin-bottom: 1.1rem; letter-spacing: .005em; text-wrap: balance;
}
.kicker { font-size: .875rem; font-weight: 500; color: var(--muted); margin-bottom: .9rem; }
.kicker a { color: inherit; }
.lead { font-size: clamp(1.125rem, 2.1vw, 1.3125rem); line-height: 1.55; color: var(--ink-2); text-wrap: pretty; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .8em 1.4em; border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font: 500 .9375rem/1 var(--sans); text-decoration: none;
  border: 1px solid var(--ink);
  transition: transform .2s var(--ease), background-color .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-sm { padding: .55em 1.05em; font-size: .875rem; }

/* ---------------------------------------------------------------- nav */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner {
  width: min(100% - 2 * var(--gutter), var(--wide)); margin-inline: auto;
  display: flex; align-items: center; gap: 24px; height: 60px;
}
.nav-name { font-family: var(--serif); font-size: 1.1875rem; color: var(--ink); text-decoration: none; margin-right: auto; }
.nav nav { display: none; gap: 28px; }
.nav nav a { color: var(--ink-2); text-decoration: none; font-size: .9375rem; }
.nav nav a:hover { color: var(--ink); }
@media (min-width: 760px) { .nav nav { display: flex; } }

/* ---------------------------------------------------------------- hero */
.hero { padding: clamp(72px, 14vh, 150px) 0 clamp(24px, 4vw, 48px); }
.hero h1 { margin-bottom: .45em; max-width: 15ch; }
.hero .lead { max-width: 640px; margin-inline: auto; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 2rem; }

.stats {
  display: grid; gap: 12px; margin-top: clamp(64px, 10vw, 120px);
  grid-template-columns: 1fr;
}
@media (min-width: 860px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--bg-2); border-radius: var(--radius); padding: clamp(28px, 3.4vw, 40px); }
.stat-num {
  font: 600 clamp(2.5rem, 5.2vw, 3.75rem)/1 var(--sans);
  letter-spacing: -.035em; margin-bottom: .5em; white-space: nowrap;
}
.stat-num .arrow { color: var(--accent); font-weight: 400; }
.stat-cap { color: var(--ink-2); margin: 0; font-size: 1rem; line-height: 1.5; max-width: 30ch; }

/* ---------------------------------------------------------------- sections */
.section { padding: clamp(88px, 13vw, 168px) 0; }
.section.tint { background: var(--bg-2); }
.section > .narrow { margin-bottom: clamp(40px, 6vw, 72px); }

/* case studies */
.case { margin-top: clamp(72px, 11vw, 144px); }
.case h3 { max-width: 20ch; }
.shot { margin-top: clamp(28px, 4vw, 48px); margin-bottom: 0; }
.shot img { border-radius: var(--radius); box-shadow: var(--shadow); background: var(--bg-2); }
.shot figcaption { color: var(--muted); font-size: .8125rem; margin-top: 14px; text-align: center; }

.story {
  display: grid; gap: 28px 48px; margin-top: clamp(40px, 6vw, 72px);
  grid-template-columns: 1fr;
}
@media (min-width: 900px) { .story { grid-template-columns: repeat(3, 1fr); } }
.beat-h, .fact-h, .rule-h, .lookback-h {
  font-weight: 600; color: var(--ink); margin-bottom: .45em; font-size: 1.0625rem;
}
.beat p:not(.beat-h) { color: var(--ink-2); }

.facts {
  display: grid; gap: 12px; margin-top: clamp(32px, 4vw, 48px);
  grid-template-columns: 1fr;
}
@media (min-width: 700px) { .facts { grid-template-columns: repeat(2, 1fr); } }
.fact { background: var(--bg-2); border-radius: 20px; padding: 26px 28px; }
.fact p:last-child { margin: 0; color: var(--ink-2); font-size: 1rem; }

/* projects */
.projects { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .projects { grid-template-columns: repeat(2, 1fr); } }
.project {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(28px, 4vw, 48px);
}
.project h3 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
.project > p:not(.kicker) { color: var(--ink-2); }
.project > p:last-child { margin-bottom: 0; }
.project strong { color: var(--ink); }

/* ---------------------------------------------------------------- charts (HTML, so they reflow on phones) */
.chart { margin: 28px 0; padding: 22px 22px 18px; border: 1px solid var(--line); border-radius: 18px; }
.chart-title { font-weight: 600; margin-bottom: .2em; }
.chart-sub { color: var(--muted); font-size: .875rem; line-height: 1.45; margin-bottom: 14px; }
.chart figcaption { color: var(--muted); font-size: .8125rem; line-height: 1.5; margin-top: 18px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 0 0 6px; font-size: .8125rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.key { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.key-before { background: var(--before); }
.key-after { background: var(--accent); }

/* shared track + axis: positions come from --x / --a / --b percentages set inline */
.db-track, .ci-track, .bar-track {
  position: relative; height: 28px;
  background:
    linear-gradient(var(--line), var(--line)) 0 50% / 100% 1px no-repeat;
}
.db-label, .ci-label, .bar-label { font-size: .875rem; color: var(--ink-2); margin: 12px 0 2px; display: flex; justify-content: space-between; gap: 12px; }
.ci-label b { font-weight: 600; color: var(--ink); white-space: nowrap; }
.muted-row .ci-label b { color: var(--muted); font-weight: 500; }
.axis { position: relative; height: 22px; margin-top: 8px; border-top: 1px solid var(--line); }
.axis span {
  position: absolute; left: var(--x); top: 6px; transform: translateX(-50%);
  font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }

/* dumbbell */
.db-line {
  position: absolute; top: 50%; height: 2px; margin-top: -1px;
  left: var(--a); width: calc(var(--b) - var(--a)); background: var(--before); opacity: .6;
}
.db-dot {
  position: absolute; top: 50%; left: var(--x); width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border-radius: 50%; box-shadow: 0 0 0 2px var(--card); cursor: default;
}
.db-dot.before { background: var(--before); }
.db-dot.after { background: var(--accent); }
.db-dot b {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font: 600 .75rem/1 var(--sans); color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.db-track { margin-top: 14px; }

/* bars */
.bar-track { display: flex; align-items: center; background: none; padding-right: 36px; }
.bar {
  position: relative; height: 20px; width: var(--w); background: var(--before);
  border-radius: 0 4px 4px 0;
}
.bar.hot { background: var(--accent); }
.bar b {
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 8px;
  font: 600 .875rem/1 var(--sans); color: var(--ink); font-variant-numeric: tabular-nums;
}
.bars .axis { margin-right: 36px; }

/* confidence intervals */
.ci-zero { position: absolute; left: var(--x); top: 2px; bottom: 2px; width: 1px; background: var(--ink-2); opacity: .5; }
.ci-bar {
  position: absolute; top: 50%; height: 2px; margin-top: -1px;
  left: var(--a); width: calc(var(--b) - var(--a)); background: var(--accent); border-radius: 2px;
}
.ci-dot {
  position: absolute; top: 50%; left: var(--x); width: 12px; height: 12px; margin: -6px 0 0 -6px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--card);
}
.muted-row .ci-bar, .muted-row .ci-dot { background: var(--before); }
.stage .chart { background: var(--card); }

/* ---------------------------------------------------------------- research thread */
.thread {
  --rail: 28px;
  list-style: none; padding: 0; position: relative;
}
.stage { max-width: 900px; }
.thread::before, .thread::after {
  content: ""; position: absolute; left: calc(var(--rail) / 2 - 1px); top: 10px; bottom: 10px; width: 2px;
  border-radius: 2px;
}
.thread::before { background: var(--line); }
.thread::after { background: var(--accent); transform-origin: top; transform: scaleY(var(--p, 1)); }

.stage { position: relative; padding-left: calc(var(--rail) + clamp(16px, 4vw, 40px)); }
.stage + .stage { margin-top: clamp(72px, 12vh, 140px); }
.node {
  position: absolute; left: calc(var(--rail) / 2 - 7px); top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
  transition: background-color .4s, border-color .4s, transform .4s var(--ease);
}
.stage.lit .node, html:not(.js) .node { background: var(--accent); border-color: var(--accent); }
.stage-when { font-size: .875rem; font-weight: 500; color: var(--muted); margin-bottom: .8rem; }
.stage > p { color: var(--ink-2); }
.stage-links { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: .9375rem; margin-top: 1.2rem; }
.stage-links a { font-weight: 500; }

/* cards grow toward the thesis */
.s1 h3 { font-size: clamp(1.45rem, 2.6vw, 1.9rem); }
.s2 h3 { font-size: clamp(1.6rem, 3vw, 2.3rem); }
.s3 h3 { font-size: clamp(1.9rem, 4vw, 3rem); }
.s3 {
  isolation: isolate;
  padding: clamp(28px, 4vw, 48px) clamp(20px, 4vw, 48px) clamp(28px, 4vw, 48px) calc(var(--rail) + 8px + clamp(20px, 4vw, 44px));
}
.s3::before {
  content: ""; position: absolute; z-index: -1; inset: 0 0 0 calc(var(--rail) + 8px);
  background: var(--bg-2); border-radius: var(--radius);
}
.s3 .node { top: calc(clamp(28px, 4vw, 48px) + 4px); }
.s4 h3 { font-style: italic; font-size: clamp(1.45rem, 2.6vw, 1.9rem); }

.finding { color: var(--ink) !important; font-size: 1.0625rem; }
.finding-num {
  font: 600 2.25rem/1 var(--sans); letter-spacing: -.03em; color: var(--ink);
  display: block; margin-bottom: .2em;
}
.finding-num.sm { display: inline; font-size: inherit; letter-spacing: 0; }

.lookback {
  border-left: 2px solid var(--accent); padding: 4px 0 4px 18px; margin: 20px 0;
}
.lookback p:last-child { margin: 0; color: var(--ink-2); font-size: 1rem; }

.pull {
  font-family: var(--serif); font-style: italic; font-size: clamp(1.3rem, 2.4vw, 1.7rem); line-height: 1.3;
  margin: 28px 0; padding: 0; color: var(--ink); text-wrap: balance;
}

.chips { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li {
  font-size: .8125rem; line-height: 1; padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.chips li.new { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); font-weight: 500; }

/* ---------------------------------------------------------------- how I work */
.rules { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .rules { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .rules { grid-template-columns: repeat(4, 1fr); } }
.rule { background: var(--card); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.rule-n { font: 500 .8125rem/1 var(--sans); color: var(--accent-ink); margin-bottom: 1.4rem; font-variant-numeric: tabular-nums; }
.rule-h { font-family: var(--serif); font-weight: 400; font-size: 1.375rem; line-height: 1.2; }
.rule p:last-child { color: var(--ink-2); margin: 0; font-size: 1rem; }

/* ---------------------------------------------------------------- about */
.about p { font-size: clamp(1.0625rem, 1.8vw, 1.1875rem); color: var(--ink-2); }
.contact { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2rem; }
.where { color: var(--muted); font-size: .9375rem; margin-top: 1.4rem; }

/* ---------------------------------------------------------------- footer */
.footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: .875rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer p { margin: 0; }

/* ---------------------------------------------------------------- PDF viewer (wide screens; phones open a new tab) */
html.modal-open { overflow: hidden; }
.pdf {
  width: min(1100px, 100vw - 48px); height: min(92vh, 1240px); max-width: none; max-height: none;
  padding: 0; border: 0; border-radius: 20px; overflow: hidden;
  background: var(--card); color: var(--ink);
  box-shadow: 0 40px 100px -24px rgba(0, 0, 0, .5);
}
.pdf[open] { display: flex; flex-direction: column; animation: pdf-in .35s var(--ease); }
.pdf::backdrop { background: rgba(20, 20, 19, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.pdf-bar { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--line); }
.pdf-title { margin: 0 auto 0 0; font-weight: 600; font-size: .9375rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-close {
  width: 36px; height: 36px; flex: none; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--ink); font: 400 1.375rem/1 var(--sans); cursor: pointer;
}
.pdf-close:hover { border-color: var(--ink-2); }
.pdf iframe { flex: 1; width: 100%; border: 0; background: var(--bg-2); }
@keyframes pdf-in { from { opacity: 0; transform: translateY(16px) scale(.985); } }

/* ---------------------------------------------------------------- motion (JS adds .js; content shows without it) */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .thread::after { transform: none; }
  .node { transition: none; }
  .btn { transition: none; }
  .pdf[open] { animation: none; }
}
