/* ---------------------------------------------------------------------------
   Economic Policy Map — shared design system
   A civic-data instrument: calibrated, sourced. Candidates are colored by
   party (red/blue) for instant identification; the axis scores themselves
   stay directional and untouched by party — see methodology.html §2.
--------------------------------------------------------------------------- */

:root {
  --paper:      #F1F3EF;
  --paper-dim:  #E7EAE4;
  --panel:      #FFFFFF;
  --ink:        #1B2320;
  --ink-soft:   #5B655F;
  --ink-faint:  #8B948C;
  --line:       #C9D0C7;
  --line-soft:  #DCE1D8;

  /* Neutral UI accent — map "data ready" shading, current nav item, the
     "you are here" locator. Never used to represent a candidate or party. */
  --accent:      #2E6E73;
  --accent-fill: rgba(46, 110, 115, 0.16);

  /* Party colors — the only colors ever used to identify a candidate. */
  --party-r:      #BC3A2B;
  --party-r-fill: rgba(188, 58, 43, 0.14);
  --party-d:      #2A5C94;
  --party-d-fill: rgba(42, 92, 148, 0.14);
  --party-i:      #6B5B95;
  --party-i-fill: rgba(107, 91, 149, 0.14);

  --focus:      #1B2320;

  --font: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --radius: 3px;
  --max-text: 72ch;
}

/* Light is the default regardless of OS/browser preference — dark only
   applies when explicitly chosen via the theme toggle (see theme.js),
   which stamps this attribute onto <html> and remembers the choice. */
:root[data-theme="dark"] {
  --paper:      #14180F;
  --paper-dim:  #1A1F14;
  --panel:      #1C2118;
  --ink:        #ECEFE8;
  --ink-soft:   #A9B2A2;
  --ink-faint:  #737C6E;
  --line:       #33392C;
  --line-soft:  #262B1F;
  --accent:      #59B0B6;
  --accent-fill: rgba(89, 176, 182, 0.18);
  --party-r:      #E2604A;
  --party-r-fill: rgba(226, 96, 74, 0.20);
  --party-d:      #5B9BD9;
  --party-d-fill: rgba(91, 155, 217, 0.20);
  --party-i:      #A996D6;
  --party-i-fill: rgba(169, 150, 214, 0.20);
  --focus:      #ECEFE8;
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

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

a { color: inherit; }
a:not(.plain) { text-decoration-color: var(--line); text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }

.tabular { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- layout */

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: 32px;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 18px;
  flex-wrap: wrap;
}

.wordmark {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark span {
  color: var(--ink-soft);
  font-weight: 500;
}

.topnav {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.topnav a {
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.topnav a:hover, .topnav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.theme-toggle {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--ink-soft); color: var(--ink); }

/* ---------------------------------------------------------------- hero */

.hero {
  padding-block: 40px 8px;
}

.hero h1 {
  font-size: clamp(32px, 4.6vw, 52px);
  line-height: 1.08;
  max-width: 30ch;
  text-wrap: balance;
}

/* One-sentence subheading: a step down from the title, a step up from the body. */
.hero .hero-sub {
  margin: 14px 0 0;
  max-width: 44ch;
  color: var(--ink);
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.005em;
}

.hero .hero-body {
  margin: 16px 0 0;
  max-width: 66ch;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.55;
}

.legend-row {
  display: flex;
  gap: 26px;
  align-items: center;
  margin-top: 22px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink-soft);
}
.legend-chip { display: inline-flex; align-items: center; gap: 8px; }
.legend-swatch {
  width: 14px; height: 14px; border-radius: 2px; flex: none;
}
.legend-swatch.ready { background: #FFFFFF; border: 1px solid var(--line); }
.legend-swatch.party-d { background: var(--party-d); opacity: 0.75; }
.legend-swatch.party-r { background: var(--party-r); opacity: 0.75; }
.legend-swatch.party-split { background: var(--party-i); opacity: 0.75; }
.legend-swatch.pending {
  background: repeating-linear-gradient(135deg, var(--line) 0 3px, transparent 3px 6px);
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------------- map */

.map-wrap {
  padding-block: 14px 44px;
}

.map-frame {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
}

svg.usmap { width: 100%; height: auto; display: block; }

.usmap path.state {
  stroke: var(--paper);
  stroke-width: 1.1;
  cursor: pointer;
  transition: fill 120ms ease;
}
/* States on the ballot in 2026: neutral, so no one reads party into it. */
.usmap path.state.ready { fill: #FFFFFF; stroke: var(--ink-faint); }
.usmap path.state.ready:hover,
.usmap path.state.ready:focus-visible { stroke: var(--accent); stroke-width: 1.8; }

/* States with no 2026 race: colored by which party already holds the seat —
   context, not part of any score. */
.usmap path.state.party-d { fill: var(--party-d); fill-opacity: 0.55; cursor: default; }
.usmap path.state.party-r { fill: var(--party-r); fill-opacity: 0.55; cursor: default; }
.usmap path.state.party-split { fill: var(--party-i); fill-opacity: 0.55; cursor: default; }

/* A 2026 race exists but isn't sourced yet (currently just Delaware). */
.usmap path.state.pending { fill: var(--line-soft); cursor: default; }
.usmap path.state.pending:hover { fill: var(--line); }

.usmap path.state.active { fill: var(--accent); fill-opacity: 0.9; stroke: var(--ink); stroke-width: 1.6; }

.map-tip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 2px;
  z-index: 50;
  transform: translate(-50%, -130%);
  white-space: nowrap;
}
.map-tip[hidden] { display: none; }

/* ---------------------------------------------------------------- race view */

.race-view { display: none; padding-block: 28px 64px; }
.race-view.open { display: block; }

.race-grid {
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 40px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 84px;
}

.rail-map {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}
.rail-map svg { width: 100%; height: auto; display: block; }
.rail-map path.state { fill: var(--line-soft); stroke: var(--paper); stroke-width: 1; }
.rail-map path.state.ready { fill: #FFFFFF; cursor: pointer; }
.rail-map path.state.party-d { fill: var(--party-d); fill-opacity: 0.45; }
.rail-map path.state.party-r { fill: var(--party-r); fill-opacity: 0.45; }
.rail-map path.state.party-split { fill: var(--party-i); fill-opacity: 0.45; }
.rail-map path.state.active { fill: var(--accent); fill-opacity: 0.9; stroke: var(--ink); stroke-width: 1.4; }

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
}
.back-link:hover { color: var(--ink); }

.jump-select {
  margin-top: 16px;
  width: 100%;
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 600;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
}

.stat-card {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 18px;
}
.stat-card h3 {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 11px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-block: 7px;
  border-top: 1px solid var(--line-soft);
  gap: 8px;
}
.stat-row:first-of-type { border-top: none; }
.stat-label { font-size: 14px; color: var(--ink-soft); }
.stat-value { font-size: 16px; font-weight: 700; }
.stat-note { font-size: 12.5px; color: var(--ink-faint); display: block; }
.stat-sources {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.6;
}
.stat-sources a { color: var(--ink-soft); }

/* race header */

.race-head h2 {
  font-size: clamp(30px, 3.6vw, 40px);
}
.race-head .seat-note {
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 15.5px;
  max-width: 62ch;
}

.candidate-pair {
  display: flex;
  gap: 32px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.candidate-id { display: flex; align-items: center; gap: 11px; }
.candidate-dot {
  width: 13px; height: 13px; border-radius: 50%; flex: none;
}
.candidate-dot.r { background: var(--party-r); }
.candidate-dot.d { background: var(--party-d); }
.candidate-dot.i { background: var(--party-i); }
.candidate-name { font-weight: 700; font-size: 18px; }
.candidate-role { font-size: 14px; color: var(--ink-soft); }
.party-chip {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 6px;
  margin-left: 6px;
  color: var(--ink-soft);
}

/* dial chart */

.dial-wrap {
  margin-top: 30px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 32px 24px;
}
.dial-wrap svg { display: block; width: 100%; height: auto; margin-inline: auto; }
.dial-ring { fill: none; stroke: var(--line-soft); stroke-width: 1; }
.dial-spoke { stroke: var(--line-soft); stroke-width: 1; }
.dial-tick { fill: var(--ink-faint); font-size: 11px; font-weight: 600; }
.dial-axis-label { fill: var(--ink-soft); font-size: 14.5px; font-weight: 700; }
.dial-poly-r { fill: var(--party-r-fill); stroke: var(--party-r); stroke-width: 2.5; }
.dial-poly-d { fill: var(--party-d-fill); stroke: var(--party-d); stroke-width: 2.5; }
.dial-poly-i { fill: var(--party-i-fill); stroke: var(--party-i); stroke-width: 2.5; }
.dial-vertex-r { fill: var(--party-r); }
.dial-vertex-d { fill: var(--party-d); }
.dial-vertex-i { fill: var(--party-i); }
.dial-hit { fill: transparent; cursor: pointer; }
.dial-hit:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.dial-caption {
  text-align: center;
  font-size: 13px;
  color: var(--ink-faint);
  margin-top: 12px;
}

/* axis comparison table */

.axis-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 48px;
}
.axis-section h3 { font-size: 22px; }
.axis-toggle-all {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 4px 10px;
  cursor: pointer;
}
.axis-toggle-all:hover { border-color: var(--ink-soft); color: var(--ink); }
.axis-section > p { color: var(--ink-soft); margin-top: 8px; max-width: var(--max-text); font-size: 15px; }

/* Each axis is a native <details>: collapses to just its header row. */
.axis-row { border-top: 1px solid var(--line); }
.axis-row:last-child { border-bottom: 1px solid var(--line); }

.axis-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-block: 18px;
  cursor: pointer;
  list-style: none;
}
.axis-row-head::-webkit-details-marker { display: none; }
.axis-row-head:hover .axis-title { color: var(--accent); }
.axis-title { font-size: 16.5px; font-weight: 700; }

.axis-chevron {
  flex: none;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
  margin-right: 4px;
}
.axis-row[open] > .axis-row-head .axis-chevron { transform: rotate(45deg); }

.axis-body { padding-bottom: 22px; }
.axis-tools { display: flex; justify-content: flex-start; }

.axis-meaning-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 4px 9px;
  cursor: pointer;
}
.axis-meaning-btn:hover { border-color: var(--ink-soft); color: var(--ink); }

.axis-meaning {
  display: none;
  margin-top: 11px;
  font-size: 14.5px;
  color: var(--ink-soft);
  max-width: var(--max-text);
  border-left: 2px solid var(--line);
  padding-left: 13px;
}
.axis-meaning.open { display: block; }
.axis-meaning .macro { display: block; margin-top: 6px; color: var(--ink-faint); font-size: 13px; }

.compare { margin-top: 20px; }

.compare-track {
  position: relative;
  height: 30px;
  margin-inline: 12px;
}
.compare-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 2px;
  background: var(--line);
  transform: translateY(-50%);
}
.compare-tick {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 9px;
  background: var(--line);
  transform: translate(-50%, -50%);
}
.compare-range {
  position: absolute;
  top: 50%;
  height: 4px;
  background: var(--ink-faint);
  opacity: 0.35;
  border-radius: 2px;
  transform: translateY(-50%);
}
.compare-marker {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 0 0 1px var(--line);
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: width 100ms ease, height 100ms ease;
}
.compare-marker.r { background: var(--party-r); }
.compare-marker.d { background: var(--party-d); }
.compare-marker.i { background: var(--party-i); }
.compare-marker:hover, .compare-marker:focus-visible {
  width: 24px; height: 24px;
  outline: none;
}

.compare-legend {
  display: flex;
  gap: 24px;
  margin-top: 11px;
  flex-wrap: wrap;
}
.compare-legend-item {
  font-size: 14px;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.compare-legend-item strong { color: var(--ink); font-size: 15px; }
.compare-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.compare-dot.r { background: var(--party-r); }
.compare-dot.d { background: var(--party-d); }
.compare-dot.i { background: var(--party-i); }

.axis-note {
  margin-top: 11px;
  font-size: 14px;
  color: var(--ink-soft);
  max-width: var(--max-text);
}
.axis-note strong { color: var(--ink); font-weight: 700; }
.axis-note .cite { display: inline; font-size: 12.5px; color: var(--ink-faint); }
.axis-note .cite a { color: var(--ink-faint); }

/* ---------------------------------------------------------------- doc pages */

.doc-page { padding-block: 44px 80px; }
.doc-page h1 { font-size: clamp(30px, 4.2vw, 42px); max-width: 22ch; }
.doc-page .lede {
  margin-top: 15px;
  font-size: 18px;
  color: var(--ink-soft);
  max-width: var(--max-text);
}
.doc-section { margin-top: 48px; max-width: var(--max-text); }
.doc-section h2 { font-size: 23px; }
.doc-section h3 { font-size: 17px; margin-top: 26px; }
.doc-section p { margin-top: 13px; }
.doc-section ul, .doc-section ol { margin-top: 13px; padding-left: 22px; }
.doc-section li { margin-top: 9px; }
.doc-section a { font-weight: 600; }

.checklist {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.checklist li {
  list-style: none;
  margin: 0;
  padding: 13px 17px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 13px;
}
.checklist li:first-child { border-top: none; }
.checklist .step-n {
  flex: none;
  color: var(--ink-faint);
  font-weight: 700;
  font-size: 14px;
  width: 1.6em;
}

.doc-section code {
  font-family: 'Archivo', monospace;
  font-weight: 700;
  font-size: 0.92em;
  background: var(--paper-dim);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
}

.glossary-list { margin-top: 8px; }
.glossary-item {
  border-top: 1px solid var(--line);
  padding-block: 22px;
}
.glossary-item:last-child { border-bottom: 1px solid var(--line); }
.glossary-item h3 { font-size: 18px; }
.glossary-item p { margin-top: 9px; color: var(--ink-soft); max-width: var(--max-text); }
.glossary-item .macro-tag {
  display: block;
  margin-top: 9px;
  font-size: 14px;
  color: var(--ink-faint);
}

footer.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 26px;
  font-size: 13.5px;
  color: var(--ink-faint);
}
footer.site-footer a { color: var(--ink-faint); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 960px) {
  .race-grid { grid-template-columns: 1fr; }
  .rail { position: static; display: flex; flex-direction: column; gap: 14px; }
  .rail-map { max-width: 280px; }
  .topnav { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
