/* ============================================================
   Base, layout, and components.
   ============================================================ */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(1200px 600px at 85% -5%, rgba(91, 75, 232, 0.06), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(15, 158, 144, 0.05), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.08; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { text-wrap: pretty; }
a { color: var(--brand-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
/* Headings/regions get programmatic focus on route change (for screen readers);
   don't show a visible ring on them since the user didn't navigate there by keyboard. */
[tabindex="-1"]:focus { outline: none; }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--sp-5); }
.container-narrow { max-width: 760px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -100px; left: var(--sp-4); z-index: 200;
  background: var(--brand); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm); font-weight: 600; transition: top var(--dur-1);
}
.skip-link:focus { top: var(--sp-3); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: saturate(1.4) blur(10px);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.site-header__inner { display: flex; align-items: center; gap: var(--sp-4); min-height: var(--header-h); }
.wordmark {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-display); font-weight: 700; font-size: var(--step-1);
  letter-spacing: -0.03em; color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
/* The hidden attribute must win over component display rules (e.g. the
   header Reset is inline-flex but starts hidden until there's state). */
[hidden] { display: none !important; }
.wordmark__dot {
  width: 1.05rem; height: 1.05rem; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fff, var(--brand) 62%);
  box-shadow: var(--shadow-brand); flex: none;
}
.wordmark__tag { font-family: var(--font-body); font-weight: 600; font-size: var(--step--2);
  color: var(--ink-faint); letter-spacing: 0.04em; text-transform: uppercase; }
.site-header__spacer { flex: 1; }
.site-header nav { display: flex; gap: var(--sp-1); align-items: center; }
.site-nav { position: relative; }
.site-nav__links { display: flex; gap: var(--sp-1); align-items: center; }
.nav-toggle {
  display: none; width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  place-items: center; color: var(--ink);
}
.nav-toggle svg { width: 1.15rem; height: 1.15rem; }
.nav-toggle[aria-expanded="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.navlink {
  padding: 0.4rem 0.7rem; border-radius: var(--r-pill); text-decoration: none;
  color: var(--ink-soft); font-weight: 600; font-size: var(--step--1); white-space: nowrap;
}
.navlink:hover { background: var(--surface-2); color: var(--ink); }
.navlink--cta { background: var(--ink); color: var(--paper); }
.navlink--cta:hover { background: var(--brand); color: #fff; }

/* always-visible Reset control in the header */
.header-reset {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  padding: 0.4rem 0.7rem; border-radius: var(--r-pill);
  border: 1.5px solid var(--line-strong); background: transparent;
  color: var(--ink-soft); font-family: var(--font-display); font-weight: 600; font-size: var(--step--1);
  transition: color var(--dur-1), border-color var(--dur-1), background var(--dur-1);
}
.header-reset:hover { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
.header-reset svg { width: 1em; height: 1em; flex: none; }
@media (max-width: 760px) { .header-reset__txt { display: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.25rem; border-radius: var(--r-pill); border: 1.5px solid transparent;
  font-family: var(--font-display); font-weight: 600; font-size: var(--step-0);
  text-decoration: none; transition: transform var(--dur-1) var(--ease), background var(--dur-1), box-shadow var(--dur-1), border-color var(--dur-1);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }
.btn--primary:hover { background: var(--brand-ink); }
.btn--ink { background: var(--ink); color: var(--paper); }
.btn--ink:hover { background: #000; }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--ink-faint); }
.btn--lg { padding: 0.95rem 1.7rem; font-size: var(--step-1); }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn__arrow { transition: transform var(--dur-1); }
.btn:hover .btn__arrow { transform: translateX(3px); }

/* ---------- Generic cards / pills ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.65rem; border-radius: var(--r-pill);
  font-size: var(--step--2); font-weight: 700; letter-spacing: 0.02em;
  background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.pill--rcv { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
/* "All voters": teal-tinted, but text is ink-soft for AA contrast (teal-on-tint was 2.6:1); teal identity carried by the border. */
.pill--all { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--ink-soft); border-color: color-mix(in srgb, var(--teal) 42%, transparent); }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
/* Match pill: tint of the candidate color with ink text, so contrast holds in both light and dark themes (white-on-color failed AA for several candidates). --cand-color is set on the parent card. */
.pill--match { background: color-mix(in srgb, var(--cand-color) 16%, var(--surface)); color: var(--ink); border-color: color-mix(in srgb, var(--cand-color) 40%, var(--line)); }
.pill--dot::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }

.section { padding-block: var(--sp-8); }
.eyebrow {
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: var(--step--2); font-weight: 700; color: var(--brand-ink);
}
.lead { font-size: var(--step-1); color: var(--ink-soft); line-height: 1.5; }
.muted { color: var(--ink-faint); }

/* ---------- View transition ---------- */
main { display: block; min-height: calc(100vh - var(--header-h) - 200px); }
.view { animation: viewIn var(--dur-3) var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Landing (minimal "door")
   ============================================================ */
.home {
  min-height: calc(100vh - var(--header-h) - 1px);
  display: grid; place-items: center;
  padding: var(--sp-6) var(--sp-5) var(--sp-8); text-align: center;
}
.home__inner { max-width: 40rem; display: flex; flex-direction: column; align-items: center; gap: var(--sp-5); }
.home__eyebrow {
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.16em;
  font-size: var(--step--2); font-weight: 700; color: var(--ink-faint);
}
.home__headline { font-size: var(--step-5); max-width: 15ch; letter-spacing: -0.035em; line-height: 1.02; }
.home__headline em { font-family: var(--font-serif); font-style: italic; font-weight: 500; color: var(--brand-ink); letter-spacing: -0.01em; }
.home__sub { color: var(--ink-soft); font-size: var(--step-0); line-height: 1.55; max-width: 44ch; }
.home__cta { margin-top: var(--sp-1); }

/* shared action row, reused on result/summary screens */
.hero__cta { margin-top: var(--sp-6); display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: center; }

/* ============================================================
   Race chooser
   ============================================================ */
.chooser__group { margin-top: var(--sp-6); }
.chooser__group h2 { font-size: var(--step-2); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.chooser__blurb { color: var(--ink-soft); margin-top: var(--sp-2); max-width: 62ch; }
.race-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-4); margin-top: var(--sp-4); }

.race-card {
  position: relative; display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-5); text-align: left; width: 100%;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2), border-color var(--dur-2);
}
.race-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
/* Prominent green completion badge in the card's top-right corner. */
.race-card__check {
  position: absolute; top: var(--sp-4); right: var(--sp-4); width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1rem; color: #fff;
  background: var(--good); box-shadow: 0 2px 10px color-mix(in srgb, var(--good) 50%, transparent);
}
.race-card__check svg { width: 1em; height: 1em; }
.race-card__title { font-family: var(--font-display); font-weight: 700; font-size: var(--step-1); letter-spacing: -0.02em; }
.race-card__seat { color: var(--ink-soft); font-size: var(--step--1); }
.race-card__meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: auto; padding-top: var(--sp-2); }
.race-card--done .race-card__title { padding-right: 2.4rem; }
.race-card__go { margin-top: var(--sp-3); display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--font-display); font-weight: 700; font-size: var(--step--1); color: var(--brand-ink); }
.race-card--go:hover .race-card__go .btn__arrow { transform: translateX(3px); }
.race-card--done { border-color: var(--good); box-shadow: 0 0 0 2px color-mix(in srgb, var(--good) 35%, transparent), var(--shadow-1); }
.pill--done { background: color-mix(in srgb, var(--good) 18%, var(--surface)); color: var(--ink); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.pill--progress { background: color-mix(in srgb, var(--gold) 16%, var(--surface)); color: var(--ink-soft); border-color: color-mix(in srgb, var(--gold) 42%, var(--line)); }

.ward-picker { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-top: var(--sp-3); }
.ward-picker label { font-weight: 600; color: var(--ink-soft); font-size: var(--step--1); }
.chip-select { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.ward-locate { margin-top: var(--sp-3); }
.ward-locate__row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.ward-locate__btn { padding: 0.5rem 1.1rem; font-size: var(--step--1); }
.ward-locate__or { color: var(--ink-faint); font-size: var(--step--1); }
.ward-locate__status { margin-top: var(--sp-2); font-size: var(--step--1); color: var(--ink-soft); max-width: 60ch; }
.ward-locate__status strong { color: var(--ink); }
.ward-locate__status:empty { display: none; }
.ward-locate__priv { margin-top: var(--sp-1); font-size: var(--step--2); color: var(--ink-faint); }
.chip {
  padding: 0.4rem 0.9rem; border-radius: var(--r-pill); border: 1.5px solid var(--line-strong);
  background: var(--surface); font-weight: 600; font-size: var(--step--1); color: var(--ink-soft);
  transition: all var(--dur-1);
}
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.chooser__bar {
  position: sticky; bottom: 0; z-index: 50; margin-top: var(--sp-7);
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding-block: var(--sp-4);
}
.chooser__bar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }

/* ============================================================
   Uncontested list
   ============================================================ */
.uncontested { margin-top: var(--sp-6); }
.uncontested__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.uncontested__item { padding: var(--sp-4); background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r); }
.uncontested__item h4 { font-family: var(--font-display); font-size: var(--step-0); }
.uncontested__item .win { color: var(--ink); font-weight: 700; }
.uncontested__item p { font-size: var(--step--1); color: var(--ink-soft); margin-top: 0.25rem; }

/* ============================================================
   Footer
   ============================================================ */
.site-footer { margin-top: var(--sp-9); border-top: 1px solid var(--line); background: var(--surface-2); }
.site-footer__inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--sp-6); padding-block: var(--sp-7); }
.site-footer h4 { font-family: var(--font-display); font-size: var(--step-0); margin-bottom: var(--sp-3); }
.footer-about { font-size: var(--step--1); max-width: 40ch; }
.site-footer a { display: block; color: var(--ink-soft); text-decoration: none; padding: 0.2rem 0; font-size: var(--step--1); }
.site-footer a:hover { color: var(--brand-ink); }
.site-footer__legal { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: var(--sp-4); color: var(--ink-faint); font-size: var(--step--2); }

@media (max-width: 760px) {
  .site-footer__inner { grid-template-columns: 1fr; gap: var(--sp-5); }
  /* Nav links collapse behind the menu button into a dropdown panel. */
  .nav-toggle { display: grid; }
  .site-nav__links {
    display: none; position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
    flex-direction: column; align-items: stretch; gap: 0.15rem; min-width: 200px;
    background: var(--surface); border: 1.5px solid var(--line-strong);
    border-radius: var(--r); box-shadow: var(--shadow-3); padding: var(--sp-2);
  }
  .site-nav__links.is-open { display: flex; }
  .site-nav__links .navlink { display: block; padding: 0.65rem 0.8rem; }
  .wordmark { font-size: var(--step-0); }
}

/* Post-election notice (only rendered after June 16, 2026). */
.stale-banner {
  background: var(--gold); color: #211a05; font-weight: 600;
  font-size: var(--step--1); text-align: center; padding: 0.6rem var(--sp-4);
}
