/* Light theme only, always -- deliberately does not follow OS dark mode.
   Plotly draws chart text (titles/legend/axis labels) with colors set in
   JS, independent of this stylesheet, so a page that flips dark via
   prefers-color-scheme leaves chart text stranded at its hardcoded dark
   color on a now-dark background -- effectively invisible. Simplest fix is
   to just not offer dark mode until the charts are made theme-aware too. */
:root {
  color-scheme: light;
  /* Warm palette derived from a reference swatch (F7F2F6 / C6B295 / B4843E /
     998477 / 6C8C92) instead of the previous cool blue/white/gray theme.
     --accent and --text-secondary are darkened from their reference swatches
     (B4843E, 998477) -- the swatches themselves read under 3.3:1 against
     both surfaces below, well short of the ~4.3:1 the old blue accent had
     against its background; darkening them restores that same text
     legibility. --state-data-fill (teal) is left at its reference value
     since it's only ever used as a large map fill, not text, so the lower
     3:1 non-text contrast floor applies instead.
     Payer chart colors (PAYER_COLORS in dashboard.js) are intentionally
     unchanged -- they're a data-encoding convention used consistently
     across every chart, independent of this UI chrome palette. */
  --surface: #f0ebe4;
  --surface-raised: #f7f2f6;
  --text-primary: #241f1a;
  --text-secondary: #6e5f53;
  --text-muted: #92857a;
  --border: #ded0be;
  --accent: #8a5d28;
  --accent-soft: #efe0cb;
  --state-fill: #c9bba8;
  --state-fill-hover: #b7a78f;
  --state-data-fill: #6c8c92;
  --state-data-fill-hover: #4f6e74;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

.screen {
  min-height: 100vh;
  width: 100%;
  transition: opacity 0.8s ease;
}
.hidden {
  display: none !important;
}
.screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
.screen.fade-in {
  opacity: 0;
  animation: fadeIn 0.8s ease forwards;
}
@keyframes fadeIn {
  to { opacity: 1; }
}

/* ---------------------------------------------------------------- map -- */
#map-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}

.map-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin: 0 0 24px;
}

#us-map {
  width: 100%;
  max-width: 960px;
}
#us-map svg {
  width: 100%;
  height: auto;
  display: block;
}

.state {
  fill: var(--state-fill);
  stroke: var(--surface);
  stroke-width: 1;
  transition: fill 0.2s ease;
}
.state.has-data {
  fill: var(--state-data-fill);
  cursor: pointer;
}
.state.has-data:hover {
  fill: var(--state-data-fill-hover);
}
.state.no-data {
  cursor: default;
}

.map-footnote {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 16px;
}

/* ----------------------------------------------------------- dashboard -- */
#dashboard-view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  overflow-x: hidden;
}

.dash-header {
  margin-bottom: 24px;
}
.back-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0 0 12px;
  display: inline-block;
}
.back-link:hover { text-decoration: underline; }

.dash-title h1 {
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.key-facts {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.key-facts li {
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.key-facts strong {
  color: var(--text-primary);
  font-weight: 600;
}
/* Matches PAYER_COLORS in js/dashboard.js -- keep in sync. */
/* Plain class for non-strong elements (e.g. table headers); the
   strong.payer-* form matches .key-facts strong's specificity and wins on
   source order so payer coloring still applies inside .key-facts too. */
.payer-commercial, strong.payer-commercial { color: #2a78d6; }
.payer-medicare, strong.payer-medicare { color: #eb6834; }
.payer-medical, strong.payer-medical { color: #1baf7a; }

.caveat-bubble {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fef6e0;
  border: 1px solid #f0dca0;
  color: #6b5405;
  font-size: 0.88rem;
  line-height: 1.5;
}
.caveat-bubble strong { font-weight: 600; }

.chart-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.chart-controls input[type="range"] {
  accent-color: var(--accent);
  width: 200px;
}
.chart-controls .n-value {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 1.5em;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.kpi-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.kpi-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.viz-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.viz-tab {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.viz-tab:hover {
  border-color: var(--accent);
}
.viz-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

#regular-dashboard,
.spotlight {
  transition: transform 280ms ease-in-out;
}
#regular-dashboard.no-transition,
.spotlight.no-transition {
  transition: none !important;
}
#regular-dashboard.slide-hidden-left,
.spotlight.slide-hidden-left {
  transform: translateX(-100%);
}
#regular-dashboard.slide-hidden-right,
.spotlight.slide-hidden-right {
  transform: translateX(100%);
}

.chart-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.chart {
  width: 100%;
  min-height: 440px;
}

.chart-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 8px 2px 0;
  min-height: 1.2em;
}

.detail-panel {
  margin-top: 16px;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.detail-header h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
.detail-close:hover { color: var(--text-primary); }
.detail-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.detail-table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.detail-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.detail-table td.num, .detail-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.detail-table tr:last-child td { border-bottom: none; }

/* ------------------------------------------------------------- spotlight -- */
/* The spotlight tab stays visually flagged even when inactive, so it reads
   as a distinct kind of content rather than a fifth peer chart. */
.viz-tab.spotlight-tab {
  border-color: #e0b356;
  background: #fdf6e7;
  color: #7a5c12;
  font-weight: 600;
}
.viz-tab.spotlight-tab:hover {
  border-color: #c9922c;
}
.viz-tab.spotlight-tab.active {
  background: #10192b;
  border-color: #10192b;
  color: #f0a93a;
}
.spotlight-tab-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f0a93a;
  margin-right: 7px;
  vertical-align: middle;
}

.spotlight {
  padding: 36px 32px 40px;
  border-radius: 16px;
  background: #10192b;
  color: #f2f1ed;
}
.spotlight-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #10192b;
  background: #f0a93a;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}
.spotlight-header h2 {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.spotlight-header .subtitle {
  color: #c3c2b7;
  max-width: 680px;
  margin: 0 0 8px;
}

.spotlight-headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.spotlight-stat {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 18px 20px;
}
.spotlight-stat-label {
  font-size: 0.82rem;
  color: #c3c2b7;
  margin-bottom: 6px;
}
.spotlight-stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.spotlight-chart-card {
  background: var(--surface-raised);
  border-radius: 12px;
  padding: 16px;
}

.spotlight-coverage {
  font-size: 0.85rem;
  color: #c3c2b7;
  margin: 14px 2px 0;
}

.spotlight-subhead {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 32px 0 14px;
}

.exposure-table-wrap {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px 14px;
  overflow-x: auto;
}
.exposure-table-wrap .detail-table th {
  color: #c3c2b7;
  border-bottom-color: rgba(255, 255, 255, 0.12);
}
.exposure-table-wrap .detail-table td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
  color: #f2f1ed;
}

.methodology {
  margin-top: 24px;
  font-size: 0.88rem;
  color: #c3c2b7;
}
.methodology summary {
  cursor: pointer;
  color: #f0a93a;
  font-weight: 600;
  margin-bottom: 10px;
}
.methodology p {
  margin: 0 0 10px;
  line-height: 1.6;
}

@media (max-width: 640px) {
  #dashboard-view { padding: 20px 14px 48px; }
  .viz-tab { flex: 1 1 auto; text-align: center; }
  .spotlight { padding: 24px 18px 28px; }
}
