/* =========================================================================
   2024 House Forecast - recreation
   Aesthetic: gallery / Apple-store. White space, hairlines, restraint.
   ========================================================================= */

:root {
  --bg:        #ffffff;
  --paper:     #fafafa;
  --ink:       #0f1115;
  --ink-soft:  #5b6068;
  --ink-faint: #9aa0a8;
  --line:      #e7e8ea;
  --line-2:    #d6d8db;

  /* Political palette - vibrant blue & coral-red */
  --dem:       #2e74d0;   /* vivid blue */
  --dem-deep:  #0d52bd;   /* deep blue */
  --gop:       #e24b38;   /* red */
  --gop-deep:  #b62d2d;   /* deep red */
  --toss:      #f1efec;

  --gold:      #b8902f;   /* tipping-point highlight */

  --maxw: 1180px;
  --ease: cubic-bezier(.22,.61,.36,1);

  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Archivo", var(--sans);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

/* ---------------------------------------------------------------- header */
header.site {
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
}
.site .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.brand {
  font-family: Helvetica, "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  transition: opacity .2s var(--ease);
}
.brand:hover { opacity: .6; }
.foot-brand { font-size: 14px; }

/* segmented control - Apple style */
.segmented {
  display: inline-flex;
  background: #f0f1f2;
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0; background: transparent;
  font-family: var(--sans);
  font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  color: var(--ink-soft);
  padding: 7px 15px; border-radius: 999px;
  cursor: pointer;
  transition: color .25s var(--ease), background .25s var(--ease), box-shadow .25s var(--ease);
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"] {
  background: #fff; color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.10), 0 0 0 .5px rgba(0,0,0,.04);
}

/* ---------------------------------------------------------------- hero */
.masthead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 36px; padding: 26px 0 14px; flex-wrap: wrap;
}
.mast-left { min-width: 280px; }
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 8px;
}
h1.title {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(26px, 4.4vw, 48px);
  line-height: 1.0;
  letter-spacing: -0.03em;
  margin: 0;
  white-space: nowrap;
}
.subtitle {
  margin: 9px 0 0; max-width: 540px;
  font-size: 13.5px; color: var(--ink-soft); font-weight: 400;
}
.frozen-inline {
  color: var(--ink-faint); white-space: nowrap;
}
.frozen-inline::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #9aa0a8; margin: 0 7px 1px 3px; vertical-align: middle;
}

/* ---------------------------------------------------------------- topline */
.topline {
  margin: 14px 0 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.verdict {
  flex: 1; text-align: center; padding: 0 18px;
  font-family: var(--display);
  font-weight: 700; font-size: clamp(15px, 1.9vw, 22px);
  letter-spacing: -0.02em; margin: 0; align-self: center;
}
.verdict em { font-style: normal; }
.verdict .lead-d { color: var(--dem); }
.verdict .lead-r { color: var(--gop); }

.seat-counts {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0;
}
.seat-side { display: flex; flex-direction: column; }
.seat-side.r { align-items: flex-end; }
.seat-label {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}
.seat-num {
  font-family: var(--display);
  font-weight: 800; font-size: clamp(34px, 5.2vw, 54px); line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.seat-side.d .seat-num { color: var(--dem); }
.seat-side.r .seat-num { color: var(--gop); }

/* the gauge */
.gauge { position: relative; height: 14px; }
.gauge-track {
  position: absolute; inset: 0; display: flex;
  border-radius: 999px; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.gauge-d { background: var(--dem); transition: width .7s var(--ease); }
.gauge-r { background: var(--gop); transition: width .7s var(--ease); }
.gauge-mid {
  position: absolute; top: -7px; bottom: -7px; left: 50%;
  width: 2px; background: var(--ink); transform: translateX(-50%);
}
.gauge-mid::after {
  content: "218 needed"; position: absolute; top: -22px; left: 50%;
  transform: translateX(-50%); white-space: nowrap;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-soft);
}

/* ---------------------------------------------------------------- map */
.map-section { padding: 14px 0 18px; }
.map-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 6px;
}
.map-head h2 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; margin: 0;
}
.map-note { font-size: 13px; color: var(--ink-faint); max-width: 360px; }

.map-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: radial-gradient(120% 90% at 50% -10%, #ffffff 0%, var(--paper) 100%);
  padding: 6px; overflow: hidden;
  display: flex; justify-content: center;
}
#map { display: block; width: 100%; height: auto; max-height: 56vh; margin: 0 auto; }

.district { stroke: #ffffff; stroke-width: .4; stroke-linejoin: round;
  transition: opacity .25s var(--ease); cursor: pointer; }
.district:hover { opacity: 1; }
.map-stage.dim .district:not(.hot) { opacity: .28; }
.district.hot { stroke: #ffffff; stroke-width: 1.7; }
.state-border { fill: none; stroke: #ffffff; stroke-width: 1.0;
  stroke-linejoin: round; pointer-events: none; }
.district.tipping { stroke: var(--gold); stroke-width: 1.6; }
/* lifted copy of the hovered district, drawn above everything */
.highlight { pointer-events: none; }
.highlight path { filter: drop-shadow(0 1px 5px rgba(0,0,0,.30)); }

/* legend */
.legend {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 22px;
}
.legend .scale {
  height: 12px; width: 320px; max-width: 60vw; border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line-2);
  background: linear-gradient(90deg,
    var(--gop-deep) 0%, var(--gop) 28%, #f1efec 50%, var(--dem) 72%, var(--dem-deep) 100%);
}
.legend .ends { display:flex; justify-content:space-between; width:320px; max-width:60vw;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--ink-faint); }
.legend .chip { display:inline-flex; align-items:center; gap:7px; font-size:12.5px; color:var(--ink-soft); }
.legend .chip i { width: 12px; height: 12px; border-radius: 3px; display:inline-block; }
.legend .chip.tip i { background: transparent; box-shadow: inset 0 0 0 2px var(--gold); }

/* tooltip */
.tip {
  position: fixed; z-index: 80; pointer-events: none;
  background: #ffffff; color: var(--ink);
  padding: 11px 13px; border-radius: 11px;
  font-size: 12.5px; line-height: 1.35;
  box-shadow: 0 10px 30px rgba(15,17,21,.14), 0 0 0 1px var(--line);
  opacity: 0; transform: translateY(4px);
  transition: opacity .14s var(--ease), transform .14s var(--ease);
  min-width: 150px; max-width: 240px;
}
.tip.on { opacity: 1; transform: translateY(0); }
.tip .t-code { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .01em; color: var(--ink); }
.tip .t-row { display:flex; justify-content:space-between; gap:14px; margin-top:6px; color: var(--ink-soft); }
.tip .t-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tip .t-bar { height:5px; border-radius:99px; margin-top:9px; background: var(--line); overflow:hidden; display:flex;}
.tip .t-bar i { display:block; height:100%; }
.tip .t-tip { margin-top:8px; font-size:11px; color: var(--gold); font-weight:700; letter-spacing:.04em; text-transform:uppercase; }

/* battleground list */
.battle { padding: 30px 0 10px; }
.battle h2 { font-family: var(--display); font-weight: 700; font-size: clamp(22px,3vw,30px);
  letter-spacing:-.02em; margin: 0 0 4px; }
.battle p.lede { color: var(--ink-soft); max-width: 620px; margin: 0 0 26px; font-size: 15.5px; }
.bg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow:hidden;
}
.bg-cell { background:#fff; padding: 15px 16px; transition: background .2s var(--ease); cursor:default; }
.bg-cell:hover { background: var(--paper); }
.bg-code { font-family: var(--display); font-weight: 700; font-size: 16px; letter-spacing:.01em; }
.bg-cell.tipping .bg-code::after {
  content:"tipping point"; font-family:var(--sans); font-size:9.5px; font-weight:600;
  letter-spacing:.04em; color: var(--ink-faint); margin-left:6px; white-space:nowrap;
  vertical-align:middle; }
.bg-margin { font-size: 13px; font-weight:600; margin-top:7px; font-variant-numeric: tabular-nums; }
.bg-margin.d { color: var(--dem); } .bg-margin.r { color: var(--gop); }
.bg-prob { font-size: 11.5px; color: var(--ink-faint); margin-top:2px; }
.bg-meter { height:4px; margin-top:10px; border-radius:99px; background:#eee; overflow:hidden; display:flex; }

/* ---------------------------------------------------------------- footer */
footer.site { border-top: 1px solid var(--line); margin-top: 48px; padding: 28px 0 44px; }
footer.site .tech-note:last-child, footer.site > *:last-child { margin-bottom: 0; }
body { padding-bottom: 26px; }   /* ~1/4 inch of breathing room at the very bottom */
footer .wrap.foot-grid { display:flex; justify-content:space-between; align-items:flex-start; flex-wrap:wrap; gap:20px; }
footer a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-2); }
footer a:hover { border-color: var(--ink); }
.foot-brand { border-bottom: 0; }
.foot-note { font-size: 10.5px; line-height: 1.5; color: var(--ink-soft); max-width: 720px; margin: 0; }
.tech-note { font-size: 10px; line-height: 1.55; color: var(--ink-faint); max-width: 720px; margin: 9px 0 0; }

/* shapefile-update stamp under the map */
.shapefile-stamp {
  margin: 12px 2px 0; font-size: 11px; letter-spacing: .04em;
  color: var(--ink-faint); display: inline-flex; align-items: center; gap: 7px;
}
.shapefile-stamp::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--dem); display: inline-block;
}

@media (max-width: 720px) {
  .site .wrap { height:auto; padding-top:10px; padding-bottom:10px; flex-direction:column; gap:10px; }
  .segmented button { padding:6px 11px; font-size:11.5px; }
  .masthead { padding: 18px 0 12px; gap: 16px; }
  h1.title { white-space: normal; }
  .controls { width: 100%; }
  #map { max-height: none; }
}

/* footer text stack + very-small-print boundary note */
.foot-text { max-width: 680px; }
.boundary-note {
  font-size: 10.5px; line-height: 1.5; color: var(--ink-faint);
  margin: 8px 0 0; opacity: .85;
}

/* ---------------------------------------------------------------- controls */
.controls { margin: 0; width: 660px; max-width: 100%; }
.slider-row { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.slider-row .ballot { flex: 1 1 195px; min-width: 190px; }
.ballot-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 7px;
}
.ballot-head label {
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint); white-space: nowrap;
}
.ballot-head output { white-space: nowrap; }
#gb-val, #mail-val, #econ-val {
  font-family: var(--display); font-weight: 800; font-size: 18px;
  letter-spacing: -.02em; color: #6b7280; font-variant-numeric: tabular-nums;
}
input[type="range"]#gb-slider, input[type="range"]#mail-slider, input[type="range"]#econ-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px; border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--line-2) 0%, #c8ccd1 55%, #6b7280 100%);
}
#gb-slider::-webkit-slider-thumb, #mail-slider::-webkit-slider-thumb, #econ-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: #6b7280; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .12s var(--ease); margin-top: 0;
}
#gb-slider::-webkit-slider-thumb:hover, #mail-slider::-webkit-slider-thumb:hover, #econ-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
#gb-slider::-moz-range-thumb, #mail-slider::-moz-range-thumb, #econ-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #6b7280;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28);
}
.ctrl-note {
  font-size: 10.5px; line-height: 1.5; color: #b3b8bf;   /* very small, light gray */
  margin: 9px 0 0; max-width: 440px;
}

/* ---------------------------------------------------------------- data bar */
.data-bar {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 11px; color: var(--ink-faint); flex-wrap: wrap;
}
.data-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--ink-faint); text-decoration: underline;
  text-underline-offset: 2px; text-decoration-color: var(--line-2);
  transition: color .2s var(--ease);
}
.data-link:hover { color: var(--ink-soft); text-decoration-color: var(--ink-faint); }
.data-sep { color: var(--line-2); }
.data-stamp { margin-left: auto; color: #c2c6cc; }
@media (max-width: 560px){ .data-stamp { margin-left: 0; width: 100%; } }

/* toast / flash */
.flash {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px; box-shadow: 0 12px 34px rgba(0,0,0,.24);
  opacity: 0; pointer-events: none; z-index: 90; transition: opacity .25s var(--ease), transform .25s var(--ease);
  max-width: 90vw;
}
.flash.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- simulator */
.sim { padding: 8px 0 4px; }
.sim h2 { font-family: var(--display); font-weight: 700; font-size: clamp(22px,3vw,30px);
  letter-spacing:-.02em; margin: 0 0 4px; }
.sim .lede { color: var(--ink-soft); max-width: 640px; margin: 0 0 22px; font-size: 15.5px; }
.sim-controls { display: flex; gap: 20px; max-width: 820px; margin-bottom: 24px; flex-wrap: wrap; align-items: flex-end; }
.sim-controls .ballot { flex: 1 1 195px; min-width: 190px; }
#sim-mu-val, #sim-sig-val, #sim-mail-val, #sim-econ-val {
  font-family: var(--display); font-weight: 800; font-size: 18px;
  letter-spacing: -.02em; color: #6b7280; font-variant-numeric: tabular-nums;
}
input[type="range"]#sim-mu, input[type="range"]#sim-sig, input[type="range"]#sim-mail, input[type="range"]#sim-econ {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px; border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, var(--line-2) 0%, #c8ccd1 55%, #6b7280 100%);
}
#sim-mu::-webkit-slider-thumb, #sim-sig::-webkit-slider-thumb, #sim-mail::-webkit-slider-thumb, #sim-econ::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: #6b7280; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.28);
  transition: transform .12s var(--ease);
}
#sim-mu::-webkit-slider-thumb:hover, #sim-sig::-webkit-slider-thumb:hover, #sim-mail::-webkit-slider-thumb:hover, #sim-econ::-webkit-slider-thumb:hover { transform: scale(1.2); }
#sim-mu::-moz-range-thumb, #sim-sig::-moz-range-thumb, #sim-mail::-moz-range-thumb, #sim-econ::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #6b7280; border: 2px solid #fff;
}
.sim-charts { display: flex; gap: 24px; flex-wrap: wrap; }
.sim-panel {
  flex: 1 1 340px; min-width: 300px;
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px 6px;
  background: radial-gradient(120% 90% at 50% -10%, #fff 0%, var(--paper) 100%);
}
.sim-phead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 2px 6px; }
.sim-cham { font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: -.02em; color: var(--ink); }
.sim-odds { font-family: var(--sans); font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.sim-med { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
#sim-house, #sim-senate { display: block; width: 100%; height: auto; }

/* Resimulate button (matches the gray control aesthetic) */
.sim-controls { align-items: flex-end; }
.resim-btn {
  font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: .02em;
  color: var(--ink); background: #fff; border: 1px solid var(--line-2);
  padding: 8px 15px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .1s var(--ease);
}
.resim-btn:hover { border-color: #6b7280; box-shadow: 0 2px 10px rgba(0,0,0,.10); }
.resim-btn:active { transform: translateY(1px); }
.resim-btn:disabled { opacity: .5; cursor: default; }

/* ---------------------------------------------------------------- chamber tabs */
.eyebrow .ch-tab { cursor: pointer; color: var(--ink-faint); transition: color .15s var(--ease); }
.eyebrow .ch-tab:hover { color: var(--ink-soft); }
.eyebrow .ch-tab.is-on { color: var(--ink); }
.eyebrow .ch-sep { color: var(--line-2); }
/* Senate state fills */
.senate-state { stroke: #fff; stroke-width: 0.6; cursor: pointer; }
.senate-state.hot { stroke: #fff; stroke-width: 1.2; }
