/* State page (js/views/state.js). Owner: the race/state module agent.
   Loaded after app.css. Every class added here starts with .sv-; the county table, the dial and the map share the .rv- rules in race.css.
   Reuses the app.css components (.card, .btn, .seg-toggle, .chip, .kpis, table.data, .m-D/.m-R, ...) and the colour variables; colours that
   depend on a margin or a probability come from js/core/colors.js, not from CSS. */

.sv-head {
  margin-bottom: 12px;
}
.sv-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sv-kpis {
  margin-bottom: 16px;
}

/* ---- layout: map (sticky) on the left, cards on the right ---- */
.sv-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.44fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}
.sv-side {
  min-width: 0;
}
.sv-mapcard {
  position: sticky;
  top: calc(var(--topbar-h) + 12px);
}
.sv-layers {
  margin: 0 0 8px;
}
.sv-pick select {
  min-height: 32px;
  padding: 3px 8px;
  font-size: 13px;
}
.sv-map {
  min-height: 200px;
}
.sv-map .rv-map {
  max-height: min(62vh, 560px);
}
.sv-main {
  min-width: 0;
}
.sv-main > section + section {
  margin-top: 22px;
}
.sv-h {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.sv-h .muted {
  font-size: 13px;
  font-weight: 500;
}
.sv-hhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin-bottom: 10px;
}
.sv-hhead .sv-h {
  margin: 0;
}
.sv-hctl {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- cards ---- */
.sv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sv-grid-h {
  grid-template-columns: repeat(auto-fill, minmax(min(245px, 100%), 1fr));
  gap: 10px;
}
.sv-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.sv-card:hover,
.sv-card.is-hl {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.sv-card.is-hl {
  border-color: var(--accent);
}
.sv-card:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.sv-tier-core {
  box-shadow: inset 3px 0 0 var(--accent);
}
.sv-tier-watch {
  box-shadow: inset 3px 0 0 var(--grey);
}
.sv-card-link {
  display: block;
  height: 100%;
  padding: 11px 14px 12px;
  color: inherit;
  text-decoration: none;
}
.sv-card-link:hover {
  text-decoration: none;
}
.sv-card-link:focus-visible {
  outline: none;
}
.sv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sv-eyebrow {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.sv-district {
  color: var(--text);
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
}
.sv-title {
  margin: 4px 0 8px;
  font-size: 16px;
  font-weight: 700;
}
.sv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  margin-top: 6px;
}
.sv-card-sw .sv-body {
  margin-top: 0;
}
.sv-main-col {
  min-width: 0;
}
.sv-needle-col {
  display: flex;
  align-items: center;
}
.sv-matchup {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sv-cand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}
.sv-cname {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.sv-cn {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sv-cand-none {
  font-size: 13px;
}
.sv-cshare {
  color: var(--muted);
  font-size: 13px;
}
.sv-who {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 0 0 3px;
  font-size: 13.5px;
}
.sv-inc {
  flex: none;
  color: var(--muted);
  font-size: 10.5px;
  font-style: normal;
}
.sv-bar {
  display: flex;
  height: 6px;
  margin: 8px 0 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-3);
}
.sv-bar i {
  display: block;
  height: 100%;
}
.sv-bar-d {
  background: var(--d-fill);
}
.sv-bar-o {
  background: var(--grey);
}
.sv-bar-r {
  background: var(--r-fill);
}
.sv-read {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.35;
}
.sv-card-sw .sv-bar + .sv-read {
  margin-top: 2px;
}
.sv-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 9px;
  margin-top: 9px;
  font-size: 12.5px;
}
.sv-foot .tag {
  margin: 0;
}
.sv-pct {
  color: var(--muted);
}

/* ---- key counties ---- */
.sv-kc {
  margin-bottom: 16px;
}
.sv-kc-note {
  margin-bottom: 10px;
  font-size: 12.5px;
}
.sv-kc-more {
  margin: 10px 0 0;
  font-size: 13.5px;
}

/* ---- bottom row ---- */
.sv-bottom {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}
.sv-bcol {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.sv-stake h3 {
  margin: 0 0 6px;
  font-size: 14px;
}
.sv-stake + .sv-stake {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.sv-stake .rv-odds {
  margin-top: 6px;
  padding-top: 0;
  border-top: 0;
}
.sv-stake-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13.5px;
}
.sv-stake-note {
  margin-top: 10px;
  font-size: 12px;
}

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .sv-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sv-mapcard {
    position: static;
  }
  .sv-map .rv-map {
    max-height: 420px;
  }
}
@media (max-width: 900px) {
  .sv-bottom {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 760px) {
  .sv-grid,
  .sv-grid-h {
    grid-template-columns: minmax(0, 1fr);
  }
  .sv-hctl {
    width: 100%;
  }
  .sv-hctl .seg-toggle {
    flex: 1 1 auto;
  }
  .sv-hctl .seg-toggle button {
    flex: 1 1 auto;
  }
  .sv-layers {
    display: flex;
  }
  .sv-layers button {
    flex: 1 1 auto;
    padding-inline: 6px;
  }
  .sv-map .rv-map {
    max-height: 340px;
  }
  .sv-past-table th,
  .sv-past-table td {
    padding: 8px 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .sv-card {
    transition: none;
  }
}
