/**
 * CivicTrace — shared tokens and the My Ballot experience.
 *
 * ONE IDENTITY. The map and candidate profiles ship the dark palette below;
 * My Ballot shipped a second, lighter one with a blue accent, so the product
 * changed character when a reader crossed from their ballot to the map. The
 * tokens here are the map's, with the nav bar's older `--ink-1/--panel` names
 * aliased on so the shared header renders unchanged.
 *
 * WHAT THE LAYOUT BORROWS. One task per viewport, a left-aligned column that
 * stops well short of the window edge, a rule-only input, and an accent used
 * for exactly three things: focus, the value the reader typed, and the current
 * nav item. Everything else is type and space.
 */

:root {
  --bg: #0b0e14; --bg-2: #11151d; --panel: #161b25; --panel-2: #1c2230;
  --panel-3: #212838;
  --line: #252c3a; --line-2: #1e2431;
  --ink: #eef2f8; --ink-2: #b9c2d1; --ink-3: #8a94a6;
  /* #646d7e elsewhere in the product. Raised here because this page uses it
     for real sentences -- the footnote, the coverage notes, the source line --
     and 3.7:1 is below AA for body text. 4.9:1 at this value. */
  --ink-4: #7a8394;
  --accent: #c25cf0; --accent-2: #f58fd6;
  --ok: #3fb9a3; --warn: #d9a441; --bad: #f3796a;
  --gA: #3fb9a3; --gB: #7cc26a; --gC: #d9c341; --gD: #e09a4e; --gF: #f3796a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
    Helvetica, Arial, sans-serif;

  /* Aliases for js/nav.js's stylesheet, which predates these names. */
  --ink-1: var(--ink); --panel-0: var(--panel);

  --col: 1120px;              /* the controlled content column */
  --gut: clamp(20px, 6vw, 104px);
  --r: 14px;                  /* one corner radius, everywhere */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.02em; }
button { font: inherit; color: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

/* Focus is visible on everything, and it is the accent, so "where am I" is one
   colour across the product. Never removed, only shaped. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px; border-radius: 4px;
}

.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;
}

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

/* =========================================================================
   1. ADDRESS SCREEN
   One question, one field, one button. The column is left-aligned and the
   block sits above centre, which is what makes the reference screens feel
   like a task rather than a form.
   ========================================================================= */

.entry {
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: 0 var(--gut);
}
.entry-mark {
  padding: 30px 0 0; font-size: 13px; font-weight: 800; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent);
}
.entry-main {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  max-width: var(--col); width: 100%; padding-bottom: 12vh;
}
.entry-eyebrow {
  margin: 0 0 14px; font-size: clamp(15px, 1.6vw, 19px); color: var(--ink-3);
}
.entry-q {
  margin: 0 0 clamp(28px, 5vh, 54px);
  font-size: clamp(30px, 5.2vw, 52px); font-weight: 800; line-height: 1.08;
  letter-spacing: -.03em; max-width: 16ch;
}
@media (min-width: 700px) { .entry-q { max-width: 22ch; } }

/* A rule, not a box. The typed value is the loudest thing on the screen. */
.field { position: relative; max-width: 900px; }
.field input {
  width: 100%; background: none; border: 0;
  border-bottom: 1px solid var(--ink-4);
  padding: 10px 2px 14px; color: var(--accent-2);
  font: 700 clamp(20px, 2.6vw, 32px)/1.35 var(--font); letter-spacing: -.02em;
  transition: border-color .18s ease;
}
.field input::placeholder {
  color: var(--ink-4); font-weight: 400; letter-spacing: -.01em;
}
.field input:focus { outline: none; border-bottom-color: var(--accent); }
.field input:focus-visible { outline: none; }
/* The rule thickens on focus as well as changing colour, so focus is not
   carried by hue alone. */
.field input:focus { border-bottom-width: 2px; padding-bottom: 13px; }

.entry-actions {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 26px; min-height: 46px;
}
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #0b0e14; border: 0; border-radius: 10px;
  padding: 13px 22px; font-size: 15px; font-weight: 700; letter-spacing: -.01em;
}
.btn:hover { background: #fff; }
.btn[disabled] { opacity: .32; cursor: not-allowed; }
.btn-ghost {
  background: none; color: var(--ink); border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--panel-2); border-color: var(--ink-4); }
.kbd-hint { font-size: 13.5px; color: var(--ink-3); }
.kbd-hint b {
  font-weight: 700; color: var(--ink-2); letter-spacing: .04em;
}
.entry-actions[data-ready="no"] { opacity: 0; pointer-events: none; }
.entry-actions[data-ready="yes"] { opacity: 1; transition: opacity .16s ease; }

.entry-privacy {
  margin: clamp(28px, 6vh, 56px) 0 0; max-width: 62ch;
  font-size: 13.5px; color: var(--ink-3); line-height: 1.6;
}
.entry-privacy b { color: var(--ink-2); font-weight: 650; }
.entry-privacy a { color: var(--ink-2); text-decoration: underline; }

.entry-foot {
  padding: 0 0 26px; display: flex; justify-content: space-between;
  align-items: center; gap: 16px; font-size: 12px; color: var(--ink-4);
}
.entry-step { display: flex; align-items: center; gap: 10px; }
.entry-step i {
  width: 34px; height: 1px; background: var(--line); display: inline-block;
}
.entry-err {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px;
  background: rgba(243, 121, 106, .1); border: 1px solid rgba(243, 121, 106, .38);
  font-size: 14px; color: var(--ink-2); max-width: 60ch;
}
.entry-err b { display: block; color: var(--ink); margin-bottom: 3px; }

/* ---- autocomplete -------------------------------------------------------
   The list hangs off the field, not off the page, so it moves with the input
   at every width and never has to be positioned by script. It is capped in
   height and scrolls, because a provider that returns eight matches must not
   push the privacy note off a phone screen. */
.ac {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  max-height: min(46vh, 360px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
}
.ac[hidden] { display: none; }
.ac li {
  display: flex; align-items: baseline; gap: 10px; justify-content: space-between;
  padding: 11px 12px; border-radius: 9px; cursor: pointer;
  font-size: 15.5px; color: var(--ink-2); line-height: 1.4;
}
/* Hover and keyboard land on the SAME visual state. Two different highlights
   for "the mouse is here" and "the keyboard is here" is how a reader ends up
   pressing Enter on the wrong address. */
.ac li:hover, .ac li.is-on { background: var(--panel-2); color: var(--ink); }
.ac li.is-on { box-shadow: inset 0 0 0 1px var(--line); }
/* The part the reader typed. Weight and colour, never colour alone. */
.ac mark {
  background: none; color: var(--accent-2); font-weight: 700;
}
.ac-line { min-width: 0; }
.ac-src {
  flex: none; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-4);
}

/* ---- the ambiguity chooser ---------------------------------------------
   Shown when more than one real address fits what was typed. Every row is an
   address a provider returned; none is preselected, because preselecting one
   is guessing with extra steps. */
.choices { list-style: none; margin: 4px 0 0; padding: 0; max-width: 56ch; }
.choices li { margin: 8px 0; }
.choices button {
  display: block; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 15.5px; line-height: 1.4;
}
.choices button:hover { background: var(--panel-2); border-color: var(--ink-4); color: var(--ink); }

/* ---- resolving ---------------------------------------------------------
   Real steps only, appended as they actually complete. Nothing here is on a
   timer, so a fast lookup shows this screen for a moment and moves on. */
.steps { list-style: none; margin: 0; padding: 0; max-width: 46ch; }
.steps li {
  display: flex; align-items: center; gap: 12px; padding: 7px 0;
  font-size: 15.5px; color: var(--ink-2);
}
.steps li .tick { width: 18px; color: var(--ok); font-size: 15px; flex: none; }
.steps li .step-detail {
  font-style: normal; color: var(--ink-4); font-size: 13px;
}
.steps li.miss { color: var(--ink-4); }
.steps li.miss .tick { color: var(--ink-4); }
.steps li.pend .tick { color: var(--ink-4); }

/* =========================================================================
   2. BALLOT
   ========================================================================= */

.wrap { max-width: var(--col); margin: 0 auto; padding: 0 20px 96px; }

.masthead { padding: clamp(26px, 5vw, 48px) 0 0; }
.masthead h1 {
  font-size: clamp(30px, 4.4vw, 46px); line-height: 1.05; letter-spacing: -.03em;
  margin: 0 0 10px;
}
.masthead .when { font-size: 16px; color: var(--ink-2); }
.masthead .where {
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline;
}
.masthead .where b { font-size: 17px; font-weight: 650; }
.masthead .where span { font-size: 14px; color: var(--ink-3); }

/* ---- coverage strip: three words, then a disclosure -------------------- */
.cov {
  margin: 26px 0 0; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); overflow: hidden;
}
.cov > summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  display: flex; align-items: center; gap: 10px 22px; flex-wrap: wrap;
}
.cov > summary::-webkit-details-marker { display: none; }
/* An h2: it is a top-level section of the ballot, and jumping H1 -> H4 leaves
   a screen-reader user with a hole in the outline. */
.cov h2 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 700; margin-right: auto;
}
.cov .pill {
  display: inline-flex; align-items: baseline; gap: 7px; font-size: 13px;
  color: var(--ink-3);
}
.cov .pill b { font-weight: 650; }
.cov .pill.ok b { color: var(--ok); }
.cov .pill.part b { color: var(--warn); }
.cov .pill.na b { color: var(--ink-4); }
.cov .more { font-size: 12.5px; color: var(--accent-2); }
.cov-body { padding: 4px 18px 18px; border-top: 1px solid var(--line-2); }
.cov-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 14px;
}
.cov-row:last-of-type { border-bottom: 0; }
.cov-row i { font-style: normal; color: var(--ink-3); }
.cov-row i.ok { color: var(--ok); }
.cov-row i.part { color: var(--warn); }
.cov-note {
  margin: 12px 0 0; font-size: 13px; color: var(--ink-3); line-height: 1.6;
}

/* ---- sections ----------------------------------------------------------- */
.sec { margin-top: 42px; }
.sec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline;
  gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.sec > summary::-webkit-details-marker { display: none; }
.sec h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .13em;
  font-weight: 750; color: var(--ink-2);
}
.sec .count { font-size: 12.5px; color: var(--ink-4); margin-left: auto; }
.sec-empty { padding: 18px 0; font-size: 14px; color: var(--ink-3); }

/* ---- race card ---------------------------------------------------------- */
.race {
  margin-top: 20px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel); overflow: hidden;
}
.race-head { padding: 18px 20px 14px; }
.race-office {
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-3); font-weight: 700;
}
.race-title { font-size: 22px; margin: 5px 0 0; letter-spacing: -.02em; }
.race-meta {
  margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px 10px;
  align-items: center;
}
.tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink-2);
}
.tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
}
.tag.live::before { background: var(--ok); }
.tag.upcoming::before { background: var(--warn); }
.tag.gap::before { background: var(--ink-4); }
.race-note {
  margin: 12px 20px 0; padding: 10px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2);
}

.cands { border-top: 1px solid var(--line-2); }
.cand {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px;
  padding: 18px 20px; border-bottom: 1px solid var(--line-2);
  align-items: start;
}
.cand-main { min-width: 0; }
.cand:last-child { border-bottom: 0; }
.avatar {
  width: 44px; height: 44px; border-radius: 12px; object-fit: cover;
  background: var(--panel-3); display: flex; align-items: center;
  justify-content: center; font-size: 14px; font-weight: 700;
  color: var(--ink-3); border: 1px solid var(--line);
}
.cand-name {
  font-size: 21px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
}
.cand-sub {
  margin-top: 4px; font-size: 13.5px; color: var(--ink-3);
  display: flex; flex-wrap: wrap; gap: 4px 10px;
}
.cand-sub .best {
  color: var(--accent-2); font-weight: 650;
}

/* The score is a block, not a sentence: the number, then /100, then the letter
   band as a small label. It was the other way round -- a 32px letter over a
   12px score -- which made two candidates ten points apart look identical on
   the one screen built for choosing between them. */
.grade {
  min-width: 92px; text-align: center; padding: 8px 10px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line); align-self: start;
}
.grade .lab {
  font-size: 9px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4); font-weight: 700;
}
.grade b {
  display: block; font-size: 30px; line-height: 1.05; font-weight: 850;
  letter-spacing: -.035em; font-variant-numeric: tabular-nums;
}
.grade .val { font-size: 12px; color: var(--ink-3); }
.grade .ltr {
  display: block; margin-top: 4px; font-size: 10px; font-weight: 650;
  color: var(--ink-3);
}
.fact.fact-total { border-top: 1px solid var(--line); border-bottom: 0;
  margin-top: 6px; padding-top: 10px; }
.fact.fact-total > b { font-weight: 800; font-variant-numeric: tabular-nums; }
.grade.g-A b { color: var(--gA); } .grade.g-B b { color: var(--gB); }
.grade.g-C b { color: var(--gC); } .grade.g-D b { color: var(--gD); }
.grade.g-F b { color: var(--gF); }
.grade.g-none { min-width: 118px; max-width: 150px; }
.grade.g-none .lab { white-space: normal; }
.grade.g-none b { font-size: 13.5px; font-weight: 650; color: var(--ink-2);
  letter-spacing: 0; line-height: 1.35; padding: 4px 0; }

.facts { margin-top: 14px; }
.fact {
  display: flex; justify-content: space-between; gap: 16px; padding: 7px 0;
  border-bottom: 1px solid var(--line-2); font-size: 13.5px;
}
.fact:last-child { border-bottom: 0; }
.fact > span { color: var(--ink-3); }
.fact > b { font-weight: 600; text-align: right; }
.fact > b.ok { color: var(--ok); }
.fact > b.warn { color: var(--warn); }
.fact > b.unknown { color: var(--ink-4); font-weight: 500; font-style: normal; }

.fact-note {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-3); line-height: 1.6; max-width: 68ch;
}
.fact-note b { color: var(--ink-2); font-weight: 650; }
.cand-acts { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.lnk {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink-2); text-decoration: none;
}
.lnk:hover { border-color: var(--ink-4); color: var(--ink); text-decoration: none; }

.race-foot {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 14px 20px; border-top: 1px solid var(--line-2);
  background: var(--panel-2);
}
.race-foot .src { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }

/* ---- source drawer / dialog -------------------------------------------- */
dialog.sheet {
  width: min(620px, calc(100vw - 32px)); max-height: 84vh; padding: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(4, 6, 10, .72); }
.sheet-head {
  display: flex; align-items: flex-start; gap: 16px; padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h3 { font-size: 19px; }
.sheet-head p { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); }
.sheet-close {
  margin-left: auto; background: none; border: 1px solid var(--line);
  border-radius: 9px; width: 32px; height: 32px; color: var(--ink-3);
  font-size: 17px; line-height: 1;
}
.sheet-body { padding: 18px 22px 24px; overflow: auto; }
.kv {
  display: grid; grid-template-columns: minmax(140px, 34%) 1fr; gap: 10px 18px;
  font-size: 13.5px;
}
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- comparison --------------------------------------------------------- */
.cmp { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cmp th, .cmp td {
  text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}
.cmp thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.cmp th.rowlab { color: var(--ink-3); font-weight: 500; width: 34%; }
.cmp td.unknown { color: var(--ink-4); }
.cmp td.ok { color: var(--ok); }
.cmp td.warn { color: var(--warn); }
.cmp .cname { font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.cmp .cparty { font-size: 12.5px; color: var(--ink-3); font-weight: 400; }

/* ---- districts + explore ------------------------------------------------ */
.districts { margin-top: 34px; }
.districts > summary {
  list-style: none; cursor: pointer; font-size: 13px; text-transform: uppercase;
  letter-spacing: .13em; font-weight: 750; color: var(--ink-2);
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline;
}
.districts > summary .count {
  margin-left: auto; font-size: 12.5px; letter-spacing: 0; text-transform: none;
  font-weight: 400; color: var(--ink-4);
}
.districts > summary::-webkit-details-marker { display: none; }
/* Three groups — where you live, what you vote in, your school districts —
   separated by space rather than by a label nobody needs. */
.dist-group { padding: 6px 0; border-bottom: 1px solid var(--line-2); }
.dist-group:last-of-type { border-bottom: 0; }
.dist-row {
  display: flex; justify-content: space-between; gap: 16px; padding: 7px 0;
  font-size: 14.5px; align-items: baseline;
}
.dist-name { color: var(--ink); }
/* Shown only where there is real contrary evidence about a district. */
.dist-warn {
  color: var(--warn); font-size: 12.5px; font-weight: 650; text-align: right;
}
.dist-alert {
  border-left: 2px solid var(--warn); padding-left: 12px; margin-top: 14px;
}
.dist-tech { margin-top: 16px; }
.dist-tech > summary {
  cursor: pointer; font-size: 12.5px; color: var(--accent-2);
  list-style: none; padding: 6px 0;
}
.dist-tech > summary::-webkit-details-marker { display: none; }
.dist-tech > summary::before { content: "\25b8  "; }
.dist-tech[open] > summary::before { content: "\25be  "; }
.dist-tech code { font-size: 11.5px; overflow-wrap: anywhere; }
/* A button that reads as a link: it opens a dialog, so it must be a button. */
.linkish {
  background: none; border: 0; padding: 0; color: var(--accent-2);
  font: inherit; text-decoration: underline; cursor: pointer;
}

.explore {
  margin-top: 46px; padding: 26px 24px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--panel);
}
.explore h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .13em;
  color: var(--ink-3);
}
.explore p { margin: 8px 0 18px; font-size: 17px; color: var(--ink-2); }

.footnote {
  margin-top: 34px; font-size: 13px; color: var(--ink-4); line-height: 1.65;
  max-width: 72ch;
}

/* =========================================================================
   3. MOBILE
   The address screen keeps its whole viewport; the ballot stacks. Nothing
   below is a shrunken desktop table.
   ========================================================================= */
@media (max-width: 720px) {
  .entry-main { padding-bottom: 6vh; }
  .cand { grid-template-columns: 40px minmax(0, 1fr); }
  .avatar { width: 40px; height: 40px; }
  /* The grade becomes a summary bar across the foot of the card: the name has
     to stay beside the avatar, and a 74px block in a 40px-wide column does not
     work at this width. */
  .grade {
    grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px;
    min-width: 0; max-width: none; text-align: left; margin-top: 4px;
  }
  .grade b { font-size: 26px; }
  .grade .lab { align-self: center; }
  .grade .ltr { margin-top: 0; align-self: center; }
  .race-foot { flex-direction: column; align-items: stretch; }
  .race-foot .src { margin-left: 0; }
  .lnk, .btn { min-height: 44px; }
  .cmp, .cmp thead, .cmp tbody, .cmp tr, .cmp th, .cmp td { display: block; }
  .cmp thead { display: none; }
  .cmp tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .cmp th.rowlab { width: auto; padding-bottom: 2px; }
  .cmp td::before {
    content: attr(data-cand); display: block; font-size: 11px;
    text-transform: uppercase; letter-spacing: .1em; color: var(--ink-4);
    margin-bottom: 2px;
  }
  .cmp td { border-bottom: 0; padding-top: 4px; }
}
