/* ============================================================
   state-page.css — Per-state deep-dive page layout.
   Page chrome leans on rankings-page.css (.rp-card, .rp-table,
   .rp-section-title); this file just adds the hero, the figure,
   the rank pills, the map frame, and the empty state.
   ============================================================ */

.state-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--space-7) + 64px) var(--space-5) var(--space-7);
}

/* ── Hero ───────────────────────────────────────────────── */
.sp-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  column-gap: var(--space-6);
  row-gap: var(--space-3);
  align-items: start;
  margin-bottom: var(--space-6);
}
.sp-back {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
  text-decoration: none;
  width: max-content;
}
.sp-back:hover,
.sp-back:focus-visible { color: var(--primary-bright); outline: none; }

/* Left column: eyebrow → title → dek (stacked, left-aligned) */
.sp-hero .eyebrow {
  grid-column: 1;
  margin: 0;
}
.sp-hero h1.display {
  grid-column: 1;
  font-size: clamp(40px, 6vw, 76px);
  margin: 0;
  line-height: 1.02;
  /* No max-width — let it fill the left column so it doesn't squish */
}
.sp-hero .dek {
  grid-column: 1;
  max-width: 56ch;
  margin: 0;
}

/* Right column: big figure card, right-aligned, bottom-aligned with the dek */
.sp-hero-figure {
  grid-column: 2;
  grid-row: 2 / span 3;
  justify-self: end;
  align-self: end;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(79, 140, 255, 0.07), rgba(79, 140, 255, 0.02));
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  backdrop-filter: blur(8px);
  width: 100%;
  max-width: 380px;
}
.sp-hero-figure-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.sp-hero-figure-value.figure {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(56px, 7vw, 88px);
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.sp-hero-figure-value .sp-unit {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.32em;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-left: var(--space-2);
  vertical-align: super;
}
.sp-hero-figure-grade {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-top: 1px solid var(--line);
  padding-top: var(--space-3);
}
.sp-grade-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ── Rank pills ─────────────────────────────────────────── */
.sp-rank-pills {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.sp-pill {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: rgba(79, 140, 255, 0.04);
  font-size: var(--text-sm);
  color: var(--text-soft);
}
.sp-pill strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.sp-pill .sp-pill-meta {
  color: var(--muted);
  font-size: var(--text-xs);
}

@media (max-width: 820px) {
  .sp-hero { grid-template-columns: 1fr; }
  .sp-hero h1.display { font-size: clamp(36px, 9vw, 56px); }
  .sp-hero-figure {
    grid-column: 1;
    grid-row: auto;
    justify-self: stretch;
    max-width: none;
  }
}

/* ── KPI strip override ─────────────────────────────────── */
.state-page .kpi-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
/* Detail pages (county / MPO) ship 6 KPIs; render as a clean 3+3
   instead of an awkward 4+2 wrap. */
.state-page .kpi-strip--six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
@media (max-width: 1280px) {
  .state-page .kpi-strip--six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .state-page .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .state-page .kpi-strip,
  .state-page .kpi-strip--six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Excess waiters (shared across state / county / MPO) ── */
.sp-excess {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
.sp-excess-figure {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(3rem, 7vw, 5.25rem);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.sp-excess-text {
  margin: 0;
  font-family: var(--font-body);
  color: var(--muted);
  font-size: var(--text-base, 1rem);
  max-width: 60ch;
}

/* ── Sections ───────────────────────────────────────────── */
.sp-section { margin-top: var(--space-6); }

/* ── Map ────────────────────────────────────────────────── */
.sp-map-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
}
.sp-map {
  width: 100%;
  height: 620px;
  background: var(--surface-1);
}
@media (max-width: 720px) {
  .sp-map { height: 460px; }
}
.sp-map-legend {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: var(--space-3);
  background: var(--map-glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  backdrop-filter: blur(10px);
  max-width: 220px;
}
.sp-map-legend-title {
  width: 100%;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.sp-los-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--hover-tint);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s ease, border-color .15s ease, background .15s ease;
}
.sp-los-toggle .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.sp-los-toggle[aria-pressed="false"] {
  opacity: 0.4;
  background: transparent;
}
.sp-los-toggle:hover { border-color: var(--primary); }
.sp-map-note {
  color: var(--muted);
  font-size: var(--text-sm);
  margin: var(--space-3) 0 0;
}

/* ── Mapbox dark popup ──────────────────────────────────── */
.sp-map .mapboxgl-popup-content {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.sp-map .mapboxgl-popup-tip { border-top-color: var(--surface-2); }
.sp-map .mapboxgl-popup-close-button { color: var(--muted); }
.sp-map .mapboxgl-ctrl { background: var(--surface-2); }
.sp-map .mapboxgl-ctrl-group button .mapboxgl-ctrl-icon { filter: var(--map-ctrl-icon-filter); }
.sp-popup-row { display: flex; gap: var(--space-2); align-items: baseline; }
.sp-popup-row .label { color: var(--muted); font-size: var(--text-xs); letter-spacing: 0.06em; }
.sp-popup-row .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── Empty / error state ────────────────────────────────── */
.sp-empty {
  max-width: 720px;
  margin: var(--space-7) auto;
  text-align: center;
}
.sp-empty .eyebrow { color: var(--gold); margin-bottom: var(--space-3); }
.sp-empty .dek { margin: 0 auto var(--space-5); }
.sp-empty code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-1);
  color: var(--text);
}

/* ── Table wrap (no sticky max-height on this page — table is short) ─ */
.state-page .rp-table-wrap { max-height: none; }
