/* ---------------------------------------------------------------------------
   Design tokens.
   Series colours are from the Okabe-Ito palette, which stays distinguishable
   under every common form of colour vision deficiency. Every pair used against
   a background is checked for at least 3:1 contrast in both themes.
   --------------------------------------------------------------------------- */
:root {
  --combo:        #D55E00;  /* vermillion  - vaccine + antibody */
  --control:      #0072B2;  /* blue        - antibody alone */
  --accent:       #009E73;  /* green       - selected / confirmed */
  --warn:         #E69F00;  /* amber       - caveats */
  --muted-series: #8C8C8C;

  --bg:        #FFFFFF;
  --bg-soft:   #F4F6F8;
  --bg-card:   #FFFFFF;
  --fg:        #15181C;
  --fg-muted:  #4A5159;
  --rule:      #D7DCE1;
  --shadow:    0 1px 2px rgba(16,24,32,.06), 0 8px 24px rgba(16,24,32,.06);

  --measure: 34rem;
  --radius: 14px;
  --gutter: 16px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --combo:   #FF8A3D;
    --control: #4FA8E0;
    --accent:  #2ECC9A;
    --warn:    #F5B731;
    --muted-series: #9AA3AC;
    --bg:      #0F1216;
    --bg-soft: #161B21;
    --bg-card: #171C23;
    --fg:      #EDF1F5;
    --fg-muted:#A8B2BC;
    --rule:    #2A323B;
    --shadow:  0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --combo:#FF8A3D; --control:#4FA8E0; --accent:#2ECC9A; --warn:#F5B731;
  --muted-series:#9AA3AC;
  --bg:#0F1216; --bg-soft:#161B21; --bg-card:#171C23;
  --fg:#EDF1F5; --fg-muted:#A8B2BC; --rule:#2A323B;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* ---- layout ---- */
.wrap { width: 100%; max-width: calc(var(--measure) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.wide { max-width: 62rem; }
/* Inside a wide section, prose stays at a readable measure while figures,
   tables and controls use the full width. */
.wide > :where(p, h2, h3, .eyebrow, .lead, .note) { max-width: var(--measure); }
section { padding-block: clamp(2.5rem, 7vw, 4.5rem); }
section + section { border-top: 1px solid var(--rule); }
.band { background: var(--bg-soft); }

h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0 0 .6em; }
h1 { font-size: clamp(2rem, 7vw, 3.25rem); letter-spacing: -.022em; font-weight: 760; }
h2 { font-size: clamp(1.45rem, 4.2vw, 2.1rem); letter-spacing: -.016em; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 680; }
p  { margin: 0 0 1.05em; }
p.lead { font-size: clamp(1.1rem, 2.6vw, 1.3rem); color: var(--fg-muted); }
.eyebrow {
  font-size: .78rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .75rem;
}
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

/* ---- hero ---- */
.hero { padding-block: clamp(3rem, 10vw, 6rem) clamp(2rem, 6vw, 3.5rem); }
.hero h1 .hl { color: var(--combo); }
.badge-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem; font-weight: 650; padding: .35rem .7rem;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--bg-card);
  color: var(--fg-muted);
}
.badge.warn { border-color: var(--warn); color: var(--warn); }

/* ---- cards & callouts ---- */
.card {
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.note {
  border-left: 4px solid var(--warn); background: var(--bg-soft);
  padding: .9rem 1.1rem; border-radius: 0 var(--radius) var(--radius) 0; margin: 1.5rem 0;
  font-size: .96rem;
}
.note strong { color: var(--warn); }
.stat-row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); margin: 1.5rem 0; }
.stat { background: var(--bg-card); border: 1px solid var(--rule); border-radius: var(--radius); padding: .9rem; }
.stat .v { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 740; letter-spacing: -.02em; line-height: 1.1; }
.stat .k { font-size: .8rem; color: var(--fg-muted); margin-top: .2rem; }

/* ---- tooltip terms ---- */
.term {
  border-bottom: 1.5px dotted var(--accent); cursor: help;
  background: none; border-top: 0; border-left: 0; border-right: 0;
  font: inherit; color: inherit; padding: 0;
}
#tip {
  position: absolute; z-index: 60; max-width: min(21rem, 88vw);
  background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--rule); border-radius: 10px; padding: .65rem .8rem;
  font-size: .9rem; line-height: 1.5; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .12s, transform .12s;
}
#tip[data-open="true"] { opacity: 1; transform: translateY(0); }
#tip .t { font-weight: 700; display: block; margin-bottom: .15rem; }

/* ---- figures ---- */
figure { margin: 1.75rem 0; }
figcaption { font-size: .88rem; color: var(--fg-muted); margin-top: .7rem; }
svg { display: block; max-width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .88rem; margin: .65rem 0 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: .4rem; }
.swatch { width: 14px; height: 14px; border-radius: 3px; flex: none; }

/* ---- controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.25rem 0; max-width: 100%; }
/* Wraps rather than overflowing the viewport on a narrow phone. */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--bg-card); max-width: 100%; }
.seg button {
  font: inherit; font-size: .88rem; font-weight: 600; padding: .45rem .85rem;
  background: none; border: 0; color: var(--fg-muted); cursor: pointer; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.slider-row { display: grid; grid-template-columns: 9.5rem 1fr 3rem; gap: .6rem; align-items: center; font-size: .9rem; margin-bottom: .45rem; }
.slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-row .n { font-variant-numeric: tabular-nums; color: var(--fg-muted); text-align: right; }

/* ---- tables ---- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-weight: 650; color: var(--fg-muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
code, .mono { font-family: var(--mono); font-size: .92em; }
tr.sel td:first-child { border-left: 3px solid var(--accent); padding-left: calc(.6rem - 3px); }

/* ---- icon array ---- */
.people { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; max-width: 22rem; }
.people svg { width: 100%; height: auto; }

/* ---- funnel ---- */
.funnel-step { display: grid; grid-template-columns: 1fr; gap: .35rem; margin-bottom: 1.1rem; }
.funnel-bar { height: 2rem; background: var(--bg-soft); border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); }
.funnel-fill { height: 100%; background: var(--accent); display: flex; align-items: center; padding-left: .5rem; color: #fff; font-size: .82rem; font-weight: 650; }
.funnel-meta { font-size: .85rem; color: var(--fg-muted); }

/* ---- construct map ---- */
.blocks { display: flex; width: 100%; height: 3rem; border-radius: 8px; overflow: hidden; border: 1px solid var(--rule); }
.blocks > button { border: 0; padding: 0; cursor: pointer; min-width: 2px; font-size: 0; }

footer { padding-block: 3rem; font-size: .9rem; color: var(--fg-muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }
#theme-toggle {
  position: fixed; right: 12px; top: 12px; z-index: 50;
  background: var(--bg-card); color: var(--fg); border: 1px solid var(--rule);
  border-radius: 999px; width: 40px; height: 40px; cursor: pointer; font-size: 1rem; box-shadow: var(--shadow);
}
