/* Atlas: one condition at a time. Same-origin stylesheet; no inline styles anywhere (strict CSP).
   Homepage system: IBM Plex (declared in /shared/site-nav.css), near-black on off-white, hairline rules.
   Sections are separated by a hairline, like the homepage doors, with no card fill or box. The series and
   sequential palettes encode data and keep their values; tiles and dots are ringed in the page color.
   No-data tiles are hollow with a dashed outline, so they never read as the lowest bin. */

:root {
  color-scheme: light;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --page: #f6f5f1;
  --surface: #fdfcfa;
  --soft: #ecebe5;
  --ink: #191918;
  --ink-2: #3d3d38;
  --muted: #62625b;
  --line: #d5d4cd;
  --line-strong: #84837b;
  --grid: #e4e3dc;
  --axis: #a9a89f;
  --band: rgba(25, 25, 24, 0.035);
  --gap: rgba(25, 25, 24, 0.07);
  --accent: #ae0808;
  --banner-bg: #ecebe5;
  --banner-ink: #191918;
  --focus: #ae0808;
  --on-ink: #f6f5f1;
  --neg: #ae0808;
  --tile-text-dark: #191918;
  --tile-text-light: #fffdf8;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;

  --seq-0: #cde2fb;
  --seq-1: #86b6ef;
  --seq-2: #3987e5;
  --seq-3: #1c5cab;
  --seq-4: #0d366b;
  --na: #d9d6cf;
  --wh: #b9b4aa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #171918;
    --surface: #1c1e1d;
    --soft: #202321;
    --ink: #eeeee7;
    --ink-2: #d6d6cf;
    --muted: #adaea5;
    --line: #3c403a;
    --line-strong: #74786f;
    --grid: #2c2f2b;
    --axis: #5a5e57;
    --band: rgba(238, 238, 231, 0.04);
    --gap: rgba(238, 238, 231, 0.08);
    --accent: #d87067;
    --banner-bg: #202321;
    --banner-ink: #eeeee7;
    --focus: #d87067;
    --on-ink: #171918;
    --neg: #f08b6f;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #2f9a2f;
    --seq-0: #1d4450;
    --seq-1: #184f95;
    --seq-2: #2a78d6;
    --seq-3: #6da7ec;
    --seq-4: #b7d3f6;
    --na: #3a403d;
    --wh: #59605c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #171918;
  --surface: #1c1e1d;
  --soft: #202321;
  --ink: #eeeee7;
  --ink-2: #d6d6cf;
  --muted: #adaea5;
  --line: #3c403a;
  --line-strong: #74786f;
  --grid: #2c2f2b;
  --axis: #5a5e57;
  --band: rgba(238, 238, 231, 0.04);
  --gap: rgba(238, 238, 231, 0.08);
  --accent: #d87067;
  --banner-bg: #202321;
  --banner-ink: #eeeee7;
  --focus: #d87067;
  --on-ink: #171918;
  --neg: #f08b6f;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #2f9a2f;
  --seq-0: #1d4450;
  --seq-1: #184f95;
  --seq-2: #2a78d6;
  --seq-3: #6da7ec;
  --seq-4: #b7d3f6;
  --na: #3a403d;
  --wh: #59605c;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 10;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--on-ink);
}
.skip-link:focus { left: 16px; }


.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Layout */
/* Same column as the homepage and the site bar (/shared/site-nav.css). */
main { width: min(100% - 2 * var(--unm-gutter, 16px), var(--unm-wrap, 1120px)); margin: 0 auto; padding-bottom: 48px; }

.hero { padding: clamp(24px, 4vw, 44px) 0 clamp(14px, 2vw, 22px); }

.kicker {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 400;
}

/* What the Atlas is for, above the title (the site's lede text). */
.lede {
  max-width: 46rem;
  margin: 0 0 1rem;
  font-size: clamp(1rem, 1.3vw, 1.12rem);
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--sans); font-weight: 400; }

h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(2rem, 4.6vw, 3.2rem);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
h1 em { color: inherit; font-style: normal; }

/* Condition selector: links (one address per condition), styled like the toggles, under their family names.
   Phones get the same groups as a native select instead (one control, the system picker). */
.picker { margin: 1rem 0 0; }
.picker ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
#picker { gap: 14px 28px; }
.picker .family { display: flex; flex-direction: column; gap: 6px; }
.family-label { color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }
.picker-select { display: none; }
.picker-select select { width: 100%; min-height: 44px; font-size: 1rem; }
@media (max-width: 640px) {
  #picker { display: none; }
  .picker-select { display: grid; gap: 6px; max-width: 420px; color: var(--muted); font-family: var(--mono); font-size: 0.82rem; }
  .picker-select select { color: var(--ink); font-family: var(--sans); }
}
.picker a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 0.98rem;
  text-decoration: none;
}
.picker a:hover { border-color: var(--ink); color: var(--ink); }
.picker a[aria-current="true"] { border-color: var(--ink); background: var(--ink); color: var(--on-ink); font-weight: 600; }
.definition { max-width: 820px; margin: 16px 0 0; color: var(--ink-2); font-size: 0.96rem; }
.definition:empty { display: none; }

/* One-screen summary */
.summary { margin: 0 0 32px; }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stat-grid li { display: flex; }
.stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  padding: 14px 0 4px;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--ink);
  color: var(--ink);
  text-decoration: none;
}
.stat:hover { color: var(--ink); }
.stat:hover .stat-link { color: var(--accent); }
.stat-num { font-size: clamp(2.1rem, 3.6vw, 2.8rem); font-weight: 400; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-text { color: var(--ink-2); font-size: 0.98rem; line-height: 1.45; flex: 1; }
.stat-link { color: var(--ink); font-size: 0.9rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.stat-link::after { content: " \2192"; }


.panel {
  margin: 0;
  padding: clamp(32px, 5vw, 56px) 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 104px;
}

.explain { max-width: 860px; margin: 0 0 1.1rem; color: var(--ink-2); font-size: 0.96rem; }
.chart-title { margin: 1.2rem 0 0.4rem; font-family: var(--sans); font-size: 1.02rem; font-weight: 600; line-height: 1.3; }
.sub-title { margin: 2rem 0 0.5rem; font-size: 1.5rem; }

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  letter-spacing: -0.005em;
  line-height: 1.15;
}

.takeaway {
  max-width: 860px;
  margin: 0 0 1.4rem;
  font-size: clamp(1.08rem, 1.6vw, 1.28rem);
  line-height: 1.45;
}

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }

.toggle {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 400;
  cursor: pointer;
}
.toggle[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--on-ink); font-weight: 600; }
.toggle:hover { border-color: var(--ink); }

.chart-note, .small { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }
.notice { padding: 10px 14px; border-left: 3px solid var(--line-strong); background: var(--band); }

.chart { width: 100%; min-height: 60px; }
.chart svg { display: block; overflow: visible; }

.chart-error { color: var(--muted); font-style: italic; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; font-size: 0.9rem; color: var(--ink-2); }
.legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--series-1); }
.sw.square { border-radius: 2px; }
.sw.line { width: 22px; height: 0; border-radius: 0; border-top: 2px dashed var(--muted); background: none; }
.sw.tick-ref { width: 3px; height: 15px; border-radius: 0; background: var(--ink-2); }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }
.sw.s3 { background: var(--series-3); }
.sw.s4 { background: var(--series-4); }
.sw.s5 { background: var(--series-5); }
.sw.s6 { background: var(--series-6); }
.sw.b0 { border-radius: 2px; background: var(--seq-0); }
.sw.b1 { border-radius: 2px; background: var(--seq-1); }
.sw.b2 { border-radius: 2px; background: var(--seq-2); }
.sw.b3 { border-radius: 2px; background: var(--seq-3); }
.sw.b4 { border-radius: 2px; background: var(--seq-4); }
.sw.line.s1 { border-top: 2px solid var(--series-1); }
.sw.line.s2 { border-top: 2px solid var(--series-2); }
.sw.ci-band { border-radius: 2px; background: var(--line); }
.sw.gap { border-radius: 2px; background: var(--gap); }

/* SVG marks */
.ax-grid { stroke: var(--grid); stroke-width: 1; }
.ax-base { stroke: var(--axis); stroke-width: 1; }
.ax-text { fill: var(--muted); font-family: var(--sans); font-variant-numeric: tabular-nums; }
.ax-title { fill: var(--ink-2); font-family: var(--sans); font-weight: 600; }
.row-band { fill: var(--band); }
.header-strip { fill: var(--page); }
.row-label { fill: var(--ink); font-family: var(--sans); }
.row-label.strong { font-weight: 600; }
.row-header { fill: var(--muted); font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
.row-note { fill: var(--muted); font-family: var(--sans); font-style: italic; }
.ref-mark { stroke: var(--ink-2); stroke-width: 2.5; stroke-linecap: round; }
.ref-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.ref-text { fill: var(--muted); font-family: var(--sans); }
.ci { stroke-width: 2; stroke-linecap: round; }
.dot { stroke: var(--page); stroke-width: 2; }
.hit { fill: transparent; cursor: default; }
.val-label { fill: var(--ink); font-family: var(--sans); font-variant-numeric: tabular-nums; font-weight: 600; }

.s1 .ci, .ci.s1 { stroke: var(--series-1); }
.s2 .ci, .ci.s2 { stroke: var(--series-2); }
.s3 .ci, .ci.s3 { stroke: var(--series-3); }
.s4 .ci, .ci.s4 { stroke: var(--series-4); }
.s5 .ci, .ci.s5 { stroke: var(--series-5); }
.s6 .ci, .ci.s6 { stroke: var(--series-6); }
.s1 .dot, .s1 .bar, .cursor-dot.s1 { fill: var(--series-1); }
.s2 .dot, .s2 .bar, .cursor-dot.s2 { fill: var(--series-2); }
.s3 .dot, .s3 .bar { fill: var(--series-3); }
.s4 .dot, .s4 .bar { fill: var(--series-4); }
.s5 .dot, .s5 .bar { fill: var(--series-5); }
.s6 .dot, .s6 .bar { fill: var(--series-6); }

/* Weekly line chart (Long COVID activity and sleep): lines over their 95% interval bands, gaps where a week is
   not shown, a crosshair that follows the pointer or the arrow keys. */
.series .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series .band { stroke: none; opacity: 0.16; }
.series.s1 .line, .series.s1 .ci { stroke: var(--series-1); }
.series.s2 .line, .series.s2 .ci { stroke: var(--series-2); }
.series.s1 .band { fill: var(--series-1); }
.series.s2 .band { fill: var(--series-2); }
.gap-band { fill: var(--gap); }
.gap-text { fill: var(--muted); font-family: var(--sans); font-style: italic; }
.end-label { fill: var(--ink); font-family: var(--sans); }
.cursor-line { stroke: var(--ink); stroke-width: 1; }
.cursor-dot { stroke: var(--page); stroke-width: 2; }
.cursor[hidden], .cursor-dot[hidden] { display: none; }
.overlay { fill: transparent; cursor: crosshair; }
.line-chart:focus { outline: none; }
.line-chart:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }

/* State tiles */
.tile rect { stroke: var(--page); stroke-width: 2; cursor: pointer; }
.tile.b0 rect { fill: var(--seq-0); }
.tile.b1 rect { fill: var(--seq-1); }
.tile.b2 rect { fill: var(--seq-2); }
.tile.b3 rect { fill: var(--seq-3); }
.tile.b4 rect { fill: var(--seq-4); }
.tile.na rect { fill: var(--page); stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 3 2; }
.tile.wh rect { fill: var(--wh); }
.tile.wh text { fill: var(--ink-2); }
.sw.wh { border-radius: 2px; background: var(--wh); }
.tile.na text { fill: var(--ink-2); }
.tile.static rect { cursor: default; }
.sw.na { border: 1px dashed var(--line-strong); border-radius: 0; background: transparent; }
.tile text { font-family: var(--sans); pointer-events: none; text-anchor: middle; }
.tile .abbr { font-weight: 600; }
.tile.b0 text, .tile.b1 text, .tile.b2 text { fill: var(--tile-text-dark); }
.tile.b3 text, .tile.b4 text { fill: var(--tile-text-light); }
.tile:hover rect, .tile:focus rect { stroke: var(--ink); stroke-width: 2.5; }
.tile[aria-pressed="true"] rect { stroke: var(--accent); stroke-width: 4; }
.tile:focus { outline: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tile.b0 text, :root:not([data-theme="light"]) .tile.b1 text, :root:not([data-theme="light"]) .tile.b2 text { fill: var(--tile-text-light); }
  :root:not([data-theme="light"]) .tile.b3 text, :root:not([data-theme="light"]) .tile.b4 text { fill: var(--tile-text-dark); }
}
:root[data-theme="dark"] .tile.b0 text, :root[data-theme="dark"] .tile.b1 text, :root[data-theme="dark"] .tile.b2 text { fill: var(--tile-text-light); }
:root[data-theme="dark"] .tile.b3 text, :root[data-theme="dark"] .tile.b4 text { fill: var(--tile-text-dark); }

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
#where-map { max-width: 760px; }
.county-panel[hidden], .panel[hidden], .controls[hidden] { display: none; }

.field-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 10px; font-weight: 600; }
select, input {
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.table-scroll { max-height: 480px; overflow: auto; border: 1px solid var(--line); }
.table-scroll table { font-size: 0.88rem; }
.table-scroll th, .table-scroll td { padding: 5px 10px; white-space: nowrap; }
.table-scroll caption { padding: 6px 10px; }

/* Tables */
.data-table { margin: 14px 0 0; }
.data-table summary, .formulas summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.data-table > div, .data-table > p { margin-top: 10px; }
.data-table > div { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
caption { padding: 6px 0; color: var(--muted); font-size: 0.85rem; text-align: left; caption-side: top; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--ink-2); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.group-row th { padding-top: 14px; border-bottom: 1px solid var(--line-strong); color: var(--muted); }
.table-scroll thead th { position: sticky; top: 0; background: var(--page); }
.sort-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: inherit;
}
.sort-btn::after { content: ""; margin-left: 4px; }
th[aria-sort="ascending"] .sort-btn::after { content: "\2191"; }
th[aria-sort="descending"] .sort-btn::after { content: "\2193"; }

.source { max-width: 980px; margin: 16px 0 0; color: var(--ink-2); font-size: 0.9rem; }
.source:empty, .chart-note:empty, .takeaway:empty { display: none; }

/* Calculator */
.headline-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 0 0 18px; }
.headline-card { padding: 18px 20px; border: 1px solid var(--line); }
.headline-card.primary { border: 1px solid var(--ink); }
.headline-card h4 { margin: 0 0 6px; font-family: var(--sans); font-size: 1.02rem; font-weight: 600; }
.headline-card p { margin: 0 0 8px; color: var(--ink-2); font-size: 0.96rem; }
.headline-card .big { color: var(--ink); }
.headline-card .big > span:first-child { font-size: clamp(2.1rem, 3.6vw, 2.7rem); font-weight: 400; line-height: 1.05; font-variant-numeric: tabular-nums; }
.big-unit { display: block; color: var(--ink-2); font-size: 0.95rem; font-weight: 400; }

.assumptions { margin: 0 0 8px; padding: 12px 16px; border: 1px solid var(--line); }
.assumptions > summary { cursor: pointer; font-weight: 600; }
.assumptions[open] > summary { margin-bottom: 14px; }

.calc fieldset { margin: 0; padding: 0; border: 0; }
.calc-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px 22px; margin-bottom: 14px; }
.calc-field label { display: block; margin-bottom: 4px; font-size: 0.9rem; font-weight: 600; }
.calc-field .input-row { display: flex; align-items: center; gap: 8px; }
.calc-field input { width: 100%; max-width: 160px; font-variant-numeric: tabular-nums; }
.calc-field .unit { color: var(--muted); font-size: 0.9rem; }
.calc-field .help { margin: 4px 0 0; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.calc-field.assumption label::after { content: " (assumption)"; color: var(--accent); font-weight: 400; }

.calc-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; margin: 22px 0 18px; }
.result-card { padding: 16px 18px; border: 1px solid var(--line); }
.result-card h4 { margin: 0 0 8px; font-family: var(--sans); font-size: 1.15rem; font-weight: 400; }
.result-card dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; margin: 0; font-size: 0.95rem; }
.result-card dt { color: var(--ink-2); }
.result-card dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.result-card dd.neg { color: var(--neg); }

.formulas { margin: 18px 0 0; }
.formulas ol { margin: 10px 0 0; padding-left: 1.4rem; font-size: 0.95rem; }
.formulas li { margin: 0 0 6px; }
.formulas .eq { font-family: var(--mono); font-size: 0.88em; overflow-wrap: anywhere; }

/* Tooltip */

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: 300px;
  padding: 8px 11px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 0.875rem;
  line-height: 1.4;
  pointer-events: none;
}
.tooltip[hidden] { display: none; }
.tip-head { margin-bottom: 4px; font-weight: 600; }
.tip-row { padding-left: 20px; text-indent: -20px; }
.tip-key { display: inline-block; width: 14px; height: 0; margin-right: 6px; border-top: 2px solid var(--series-1); vertical-align: middle; }
.tip-key.s2 { border-top-color: var(--series-2); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .panel { padding: 28px 0; }
  .calc-inputs { grid-template-columns: minmax(0, 1fr); }
}

@media print {
  .controls, .tooltip, .skip-link { display: none; }
  .panel { break-inside: avoid; border: 0; }
}
