/* ============================================================
   rankings-page.css — Layout for the dedicated State Rankings
   page (/states.html). The narrative split-card component
   on the landing page lives in rankings.css.
   ============================================================ */

.rankings-page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--space-7) + 64px) var(--space-5) var(--space-7);
}

.rankings-hero {
  max-width: 900px;
  margin: 0 0 var(--space-6);
}
.rankings-hero .eyebrow { margin-bottom: var(--space-3); }
.rankings-hero h1.display {
  font-size: clamp(40px, 6vw, 72px);
  margin-bottom: var(--space-4);
}
.rankings-hero .dek { max-width: 720px; margin-bottom: var(--space-4); }
.rankings-hero .meta {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--text-sm);
}
.rankings-hero .meta strong { color: var(--text); font-weight: 700; }

/* ── Section card ───────────────────────────────────────── */
.rp-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card-grad);
  padding: var(--space-5);
  backdrop-filter: blur(8px);
}
.rp-section { margin-top: var(--space-6); }
.rp-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}
.rp-section-title h2 {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: clamp(20px, 2vw, 28px);
  letter-spacing: -0.01em;
}
.rp-section-title .caption { color: var(--muted); font-size: var(--text-sm); }

.rp-filter {
  display: grid;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  max-width: 520px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.rp-filter label,
.rp-filter > span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.rp-filter input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-1);
  color: var(--text);
  font: 600 var(--text-sm) / 1 var(--font-body);
  letter-spacing: 0;
  text-transform: none;
  padding: 0 var(--space-4);
}
.rp-filter input::placeholder { color: var(--muted); }
.rp-filter input:focus-visible {
  outline: 2px solid var(--primary-bright);
  outline-offset: 3px;
  border-color: var(--primary);
}

/* ── KPI strip override (page uses six small KPIs) ──────── */
.rankings-page .kpi-strip {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.rankings-page .kpi-strip--five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .rankings-page .kpi-strip,
  .rankings-page .kpi-strip--five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .rankings-page .kpi-strip,
  .rankings-page .kpi-strip--five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* ── Sortable table ─────────────────────────────────────── */
.rp-table-wrap {
  max-height: 640px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.rp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.rp-table th,
.rp-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.rp-table th:nth-child(1),
.rp-table td:nth-child(1),
.rp-table th:nth-child(2),
.rp-table td:nth-child(2) { text-align: left; }
.rp-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-1);
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.rp-table thead th:hover { color: var(--primary-bright); }
.rp-table thead th[aria-sort="ascending"]::after  { content: " ▲"; color: var(--primary); }
.rp-table thead th[aria-sort="descending"]::after { content: " ▼"; color: var(--primary); }
.rp-table td.rank { color: var(--muted); width: 40px; }
.rp-table td.state-name { color: var(--text); font-weight: 700; }
.rp-table td.state-name .state-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.rp-table td.state-name .state-link:hover,
.rp-table td.state-name .state-link:focus-visible {
  color: var(--primary);
  border-bottom-color: var(--primary);
  outline: none;
}
.rp-table td.state-name .state-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 2px;
}
.rp-table td.state-name .abbr {
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-xs);
  margin-left: 0;
}
.rp-table td .muted { color: var(--muted); }
.rp-table tbody tr:hover { background: var(--primary-soft); }

/* MPO leaderboard: long region names would otherwise force horizontal scroll
   at the page's max width. Allow the MPO and State columns to wrap; keep all
   numeric/badge columns single-line so figures stay legible. */
#mpoTable { table-layout: auto; }
#mpoTable th,
#mpoTable td { padding: 10px 10px; }
#mpoTable th:nth-child(2),
#mpoTable td:nth-child(2),
#mpoTable th:nth-child(3),
#mpoTable td:nth-child(3) {
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
}
#mpoTable td:nth-child(2) { min-width: 220px; }
#mpoTable td.state-name .state-link { display: inline; }

/* ── Chart hosts ────────────────────────────────────────── */
.rp-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}
.rp-card--full { grid-column: 1 / -1; }
@media (max-width: 980px) {
  .rp-grid-2 { grid-template-columns: 1fr; }
}
.rp-plot { width: 100%; height: 480px; }
.rp-plot--tall { width: 100%; height: 880px; }

/* ── Methodology block ──────────────────────────────────── */
.rp-methodology { color: var(--muted); font-size: var(--text-sm); line-height: 1.6; }
.rp-methodology p { margin: 0 0 var(--space-3); max-width: 760px; }
.rp-methodology p strong { color: var(--text); font-weight: 700; }
.rp-methodology h3 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  margin: var(--space-5) 0 var(--space-2);
  max-width: 760px;
}
.rp-methodology h3:first-of-type { margin-top: 0; }
.rp-methodology ul {
  margin: 0 0 var(--space-3);
  padding-left: 1.25em;
  max-width: 760px;
}
.rp-methodology li { margin: 0 0 var(--space-1); }
.rp-methodology li strong { color: var(--text); font-weight: 700; }
