/* =============================================================================
   The Sweeney Model: design system
   Playful and bold, election-native: campaign buttons, yard signs, stickers.
   Boldness lives in the hero dot grids, buttons and pop-ups; the rest is calm.
   ============================================================================= */

/* Header fonts, loaded here so every page has them whatever its body font:
   Playfair Display for the site title, Lexend for the navigation tabs. */
@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700&family=Playfair+Display:wght@700;800&display=swap");

:root {
  /* palette */
  --ink:        #1B2433;
  --ink-soft:   #5A6578;
  --paper:      #FFFFFF;
  --mist:       #F2F7FB;
  --line:       #DCE5EE;

  --sky:        #2E9BE6;
  --sky-deep:   #1468B8;
  --sky-pale:   #D6ECFB;
  --red:        #E8453C;
  --red-deep:   #B8261F;
  --red-pale:   #FBD9D5;
  --sun:        #FFC93C;
  --sun-pale:   #FFF1C2;

  /* rating scale */
  --solid-d:  var(--sky-deep);
  --likely-d: var(--sky);
  --lean-d:   #92CDF4;
  --tossup:   #FFD966;
  --lean-r:   #F5A8A1;
  --likely-r: var(--red);
  --solid-r:  var(--red-deep);

  /* type */
  --display: "Archivo", "Arial Black", "Helvetica Neue", sans-serif;
  --body: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;   /* methodology uses Times, contact uses Fraunces (page-level) */

  /* modular scale, ratio 1.25 */
  --step--1: 0.8rem;
  --step-0:  1rem;
  --step-1:  1.25rem;
  --step-2:  1.563rem;
  --step-3:  1.953rem;
  --step-4:  2.441rem;
  --step-5:  3.815rem;

  /* shape */
  --radius-pill: 999px;
  --radius-card: 14px;
  --outline: 2.5px solid var(--ink);
  --pop-shadow: 6px 6px 0 var(--ink);
  --btn-shadow: 3px 3px 0 var(--ink);
}

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

html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }   /* stop iPhone Safari enlarging text in wide tables */
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ---------- type ---------- */
.display, h1, h2 {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-3); }
h3 { font-family: var(--body); font-size: var(--step-1); font-weight: 700; margin: 0; }
p  { max-width: 68ch; margin: 0 0 1em; }
.muted { color: var(--ink-soft); }
.dem { color: var(--sky-deep); }
.rep { color: var(--red-deep); }

a { color: var(--sky-deep); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; box-shadow: 0 0 0 5px var(--ink); }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.section { padding: 56px 0; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: 0; }

/* ---------- masthead ---------- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 16px;
            padding: 18px 0; flex-wrap: wrap; }
.wordmark { font-family: "Playfair Display", "Didot", "Bodoni 72", Georgia, "Times New Roman", serif;
            font-weight: 800; font-size: calc(var(--step-1) * 1.25); letter-spacing: 0.005em; line-height: 1;
            text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 12px; }
.wordmark .ballot { width: 26px; height: 26px; border-radius: 50%; background: var(--sun);
                    border: var(--outline); position: relative; }
.wordmark .ballot::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px;
                           border: solid var(--ink); border-width: 0 3px 3px 0; transform: rotate(45deg); }
/* fixed header font on every page: never inherits the page's body font */
.nav { display: flex; gap: 26px; font-family: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
       font-weight: 600; font-size: 1.05rem; letter-spacing: 0.01em; }
.nav a { color: var(--ink); text-decoration: none; padding-bottom: 2px; border-bottom: 3px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { border-bottom-color: var(--sun); }

/* ---------- buttons (campaign-button feel) ---------- */
.btn {
  font: 700 var(--step-0)/1 var(--body);
  color: var(--ink);
  background: var(--paper);
  border: var(--outline);
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  box-shadow: var(--btn-shadow);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover  { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.primary { background: var(--sun); }

/* ---------- toggle chips (model views) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font: 700 var(--step--1)/1 var(--body);
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  padding: 9px 14px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--sun); }

/* ---------- 100-dot simulation grid (the hero) ---------- */
.odds { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 40px; }
.odds-headline { font-family: var(--display); font-stretch: 125%; font-weight: 850;
                 font-size: var(--step-3); line-height: 1.1; margin: 0 0 18px; }
.odds-headline .n { font-size: var(--step-5); display: block; line-height: 1; }
/* the label always reserves two lines, so side-by-side dot grids start level */
.odds-headline .lab { display: block; min-height: 2.2em; }
.dotgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; max-width: 320px; }
.dot { aspect-ratio: 1; border-radius: 50%; background: var(--line);
       transition: background-color .35s ease; }
.dot.d { background: var(--sky); }
.dot.r { background: var(--red); }
.odds-foot { margin-top: 14px; color: var(--ink-soft); font-size: var(--step--1); }

/* ---------- rating chips ---------- */
.rating { display: inline-block; font: 700 var(--step--1)/1 var(--body); padding: 6px 10px;
          border-radius: 6px; color: var(--ink); }
.rating.solid-d  { background: var(--solid-d);  color: #fff; }
.rating.likely-d { background: var(--likely-d); color: #fff; }
.rating.lean-d   { background: var(--lean-d); }
.rating.tossup   { background: var(--tossup); }
.rating.lean-r   { background: var(--lean-r); }
.rating.likely-r { background: var(--likely-r); color: #fff; }
.rating.solid-r  { background: var(--solid-r);  color: #fff; }

/* ---------- pop-up race card ---------- */
.popcard {
  background: var(--paper);
  border: var(--outline);
  border-radius: var(--radius-card);
  box-shadow: var(--pop-shadow);
  max-width: 560px;
  overflow: hidden;
}
.popcard header { padding: 18px 22px; border-bottom: var(--outline); }
.popcard header.lead-d { background: var(--sky-pale); }
.popcard header.lead-r { background: var(--red-pale); }
.popcard header.lead-t { background: var(--sun-pale); }
.popcard .body { padding: 20px 22px; }
.popcard .who { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.popcard .who .pct { font-family: var(--display); font-stretch: 125%; font-weight: 900; font-size: var(--step-4); line-height: 1; }

/* win-probability bar */
.probbar { display: flex; height: 14px; border-radius: var(--radius-pill); overflow: hidden;
           border: 2px solid var(--ink); margin: 12px 0 4px; }
.probbar .d { background: var(--sky); }
.probbar .r { background: var(--red); }

/* vote-share interval bar: nested bands 95 / 80 / 50, median tick */
.interval { position: relative; height: 46px; margin: 18px 0 8px; }
.interval .track { position: absolute; left: 0; right: 0; top: 18px; height: 10px; background: var(--mist); border-radius: 5px; }
.interval .band { position: absolute; top: 14px; height: 18px; border-radius: 9px; cursor: help; }
.interval .band.b95 { background: var(--band-light); }
.interval .band.b80 { background: var(--band-mid); top: 12px; height: 22px; border-radius: 11px; }
.interval .band.b50 { background: var(--band-dark); top: 10px; height: 26px; border-radius: 13px; }
.interval .median { position: absolute; top: 4px; width: 3px; height: 38px; background: var(--ink); border-radius: 2px; }
.interval .fifty { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed var(--ink-soft); }
.interval .fifty span { position: absolute; top: -18px; left: -12px; font-size: var(--step--1); color: var(--ink-soft); }
.interval-axis { display: flex; justify-content: space-between; font-size: var(--step--1); color: var(--ink-soft); }
.tip { position: absolute; z-index: 5; background: var(--ink); color: #fff; font-size: var(--step--1);
       padding: 8px 10px; border-radius: 8px; pointer-events: none; white-space: nowrap;
       transform: translate(-50%, -110%); opacity: 0; transition: opacity .12s ease; }
.tip.show { opacity: 1; }

/* ---------- style-guide helpers ---------- */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.swatch { border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; }
.swatch .chip-color { height: 72px; }
.swatch .meta { padding: 10px 12px; font-size: var(--step--1); }
.swatch .meta b { display: block; font-size: var(--step-0); }
.scale-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* phones: the links get their own row under the title and scroll sideways if needed */
@media (max-width: 760px) {
  .masthead { flex-wrap: wrap; row-gap: 10px; }
  .nav { width: 100%; gap: 20px; font-size: .98rem; overflow-x: auto; white-space: nowrap;
         scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .nav::-webkit-scrollbar { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: var(--step-4); }
  .odds-headline { font-size: var(--step-2); }
  .odds-headline .n { font-size: var(--step-4); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* links to outside sources (poll releases, market pages): quiet until hovered, with a small arrow */
a.src-link { white-space: nowrap; color: inherit; text-decoration: underline dotted; text-decoration-color: var(--ink-soft); text-underline-offset: 3px; }
a.src-link:hover, a.src-link:focus { text-decoration: underline solid; color: var(--sky-deep); }
/* "opens in a new tab" icon (a box with an arrow leaving it), drawn as a shape: a text arrow becomes a blue
   emoji tile on iPhones and reads like a market trend */
a.src-link::after { content: ""; display: inline-block; width: .62em; height: .62em; margin-left: .25em; vertical-align: .05em;
  background-color: currentColor; opacity: .45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6'/%3E%3Cpath d='M20 4l-9 9'/%3E%3Cpath d='M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") no-repeat center / contain; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 4h6v6'/%3E%3Cpath d='M20 4l-9 9'/%3E%3Cpath d='M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") no-repeat center / contain; }
a.src-link:hover::after, a.src-link:focus::after { opacity: .9; }

/* seat charts: tap/hover readout; chart text isn't selectable (a tap shouldn't start a text selection) */
.hist-readout { min-height: 1.6em; margin: 4px 0 6px; font-weight: 600; font-size: var(--step--1); color: var(--ink); }
.hist-readout .muted { font-weight: 400; }
svg text { -webkit-user-select: none; user-select: none; }
svg .hit { fill: transparent; cursor: pointer; }
