/* ============================================
   STATE OF US POLITICS — Style System
   ============================================ */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&display=swap');

/* --- Design Tokens --- */
:root {
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;

  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);

  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
}

/* --- Light Mode (Default) --- */
:root, [data-theme="light"] {
  --color-bg:             #f5f4f0;
  --color-surface:        #ffffff;
  --color-surface-2:      #fafaf8;
  --color-surface-offset: #eeedea;
  --color-divider:        #ddd;
  --color-border:         #d4d1ca;

  --color-text:           #1a1a1a;
  --color-text-muted:     #6b6b6b;
  --color-text-faint:     #aaa;
  --color-text-inverse:   #f9f8f4;

  --color-primary:        #1a3a5c;
  --color-primary-hover:  #0f2944;

  --color-red:            #c0392b;
  --color-red-bg:         #fdf2f2;
  --color-red-light:      #e74c3c;
  --color-blue:           #2980b9;
  --color-blue-bg:        #ebf5fb;
  --color-blue-light:     #3498db;

  --color-accent:         #d4a03c;
  --color-accent-bg:      #fef9f0;

  --color-success:        #27ae60;
  --color-warning:        #f39c12;
  --color-danger:         #e74c3c;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.1);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --color-bg:             #111111;
  --color-surface:        #1a1a1a;
  --color-surface-2:      #222222;
  --color-surface-offset: #1e1e1e;
  --color-divider:        #333;
  --color-border:         #444;

  --color-text:           #e0e0e0;
  --color-text-muted:     #999;
  --color-text-faint:     #666;
  --color-text-inverse:   #1a1a1a;

  --color-primary:        #5b9bd5;
  --color-primary-hover:  #4a8bc5;

  --color-red:            #e74c3c;
  --color-red-bg:         #2a1515;
  --color-red-light:      #ff6b6b;
  --color-blue:           #5dade2;
  --color-blue-bg:        #152535;
  --color-blue-light:     #7ec8e3;

  --color-accent:         #f0c75e;
  --color-accent-bg:      #2a2415;

  --color-success:        #2ecc71;
  --color-warning:        #f1c40f;
  --color-danger:         #ff6b6b;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #111111;
    --color-surface:        #1a1a1a;
    --color-surface-2:      #222222;
    --color-surface-offset: #1e1e1e;
    --color-divider:        #333;
    --color-border:         #444;
    --color-text:           #e0e0e0;
    --color-text-muted:     #999;
    --color-text-faint:     #666;
    --color-text-inverse:   #1a1a1a;
    --color-primary:        #5b9bd5;
    --color-primary-hover:  #4a8bc5;
    --color-red:            #e74c3c;
    --color-red-bg:         #2a1515;
    --color-red-light:      #ff6b6b;
    --color-blue:           #5dade2;
    --color-blue-bg:        #152535;
    --color-blue-light:     #7ec8e3;
    --color-accent:         #f0c75e;
    --color-accent-bg:      #2a2415;
    --color-success:        #2ecc71;
    --color-warning:        #f1c40f;
    --color-danger:         #ff6b6b;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  }
}

/* ============================================
   Layout
   ============================================ */

.page-wrapper {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

@media (max-width: 640px) {
  .page-wrapper {
    padding: 0 var(--space-4);
  }
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: oklch(from var(--color-bg) l c h / 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-divider);
  padding: var(--space-4) 0;
}

.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0 var(--space-4);
  }
}

.site-logo {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-date {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.theme-toggle:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

/* --- Hero --- */
.hero {
  padding: clamp(var(--space-12), 6vw, var(--space-20)) 0;
  text-align: center;
  border-bottom: 1px solid var(--color-divider);
}

.hero-label {
  font-size: var(--text-xs);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.hero-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 56ch;
  margin: 0 auto var(--space-6);
  line-height: 1.6;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.hero-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Sections --- */
.section {
  padding: clamp(var(--space-10), 5vw, var(--space-20)) 0;
  border-bottom: 1px solid var(--color-divider);
}

.section:last-of-type {
  border-bottom: none;
}

.section-header {
  margin-bottom: var(--space-8);
}

.section-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.section-intro {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 65ch;
  margin-top: var(--space-3);
  line-height: 1.7;
}

/* --- Market Cards --- */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-5);
}

@media (max-width: 700px) {
  .market-grid {
    grid-template-columns: 1fr;
  }
}

.market-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: box-shadow var(--transition-interactive), border-color var(--transition-interactive);
}

.market-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}

.market-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.market-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
  flex: 1;
}

.market-volume {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.market-outcomes {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.outcome-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.outcome-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  min-width: 100px;
  flex-shrink: 0;
}

.outcome-bar-track {
  flex: 1;
  height: 24px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.outcome-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 var(--space-2);
  min-width: fit-content;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.outcome-bar-fill.red {
  background: var(--color-red);
  color: #fff;
}

.outcome-bar-fill.blue {
  background: var(--color-blue);
  color: #fff;
}

.outcome-bar-fill.neutral {
  background: var(--color-text-muted);
  color: #fff;
}

.outcome-bar-fill.accent {
  background: var(--color-accent);
  color: var(--color-text);
}

.outcome-bar-fill.green {
  background: var(--color-success);
  color: #fff;
}

.outcome-pct {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.outcome-pct-outside {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}

/* --- Spotlight / Featured Card --- */
.spotlight {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  margin-bottom: var(--space-8);
}

@media (max-width: 640px) {
  .spotlight {
    padding: var(--space-5);
  }
}

.spotlight-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  align-items: center;
}

@media (max-width: 768px) {
  .spotlight-grid {
    grid-template-columns: 1fr;
  }
}

.spotlight-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.spotlight-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-4);
}

.spotlight-candidates {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.candidate-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.candidate-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  min-width: 140px;
}

@media (max-width: 480px) {
  .candidate-name {
    min-width: 100px;
    font-size: var(--text-xs);
  }
}

.candidate-bar-track {
  flex: 1;
  height: 28px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.candidate-bar {
  height: 100%;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 var(--space-2);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.candidate-bar span {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* --- KPI Row --- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
}

.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.kpi-value.red { color: var(--color-red); }
.kpi-value.blue { color: var(--color-blue); }
.kpi-value.green { color: var(--color-success); }
.kpi-value.accent { color: var(--color-accent); }

.kpi-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Donut Charts --- */
.donut-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.donut-chart {
  position: relative;
  width: 160px;
  height: 160px;
}

.donut-chart svg {
  transform: rotate(-90deg);
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-center-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.donut-center-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* --- Callout Box --- */
.callout {
  background: var(--color-accent-bg);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-4) var(--space-5);
  margin: var(--space-6) 0;
}

.callout-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.callout-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* --- Timeline --- */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-divider);
}

.timeline-item {
  position: relative;
  margin-bottom: var(--space-6);
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-8) + 6px);
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 2px solid var(--color-bg);
}

.timeline-dot.red { background: var(--color-red); }
.timeline-dot.green { background: var(--color-success); }
.timeline-dot.accent { background: var(--color-accent); }

.timeline-date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-1);
}

.timeline-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.timeline-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* --- Inline Probability Badge --- */
.prob-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.prob-badge.high { background: var(--color-red-bg); color: var(--color-red); }
.prob-badge.medium { background: var(--color-accent-bg); color: var(--color-accent); }
.prob-badge.low { background: var(--color-blue-bg); color: var(--color-blue); }

/* --- Senate Map / Balance --- */
.balance-bar {
  display: flex;
  height: 36px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--space-4) 0;
}

.balance-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.balance-segment.dem { background: var(--color-blue); }
.balance-segment.rep { background: var(--color-red); }
.balance-segment.toss { background: var(--color-text-faint); }

.balance-legend {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* --- Two Column Layout --- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* --- Table --- */
.data-table {
  width: 100%;
  font-size: var(--text-sm);
}

.data-table thead {
  border-bottom: 2px solid var(--color-divider);
}

.data-table th {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  text-align: left;
  padding: var(--space-3) var(--space-3);
}

.data-table td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* --- Nav Tabs --- */
.section-nav {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.section-nav a {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  white-space: nowrap;
}

.section-nav a:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

/* --- Footer --- */
.site-footer {
  padding: var(--space-10) 0 var(--space-8);
  text-align: center;
  border-top: 1px solid var(--color-divider);
}

.footer-text {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.7;
}

.footer-text a {
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-text a:hover {
  color: var(--color-text);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Stagger children */
.stagger > * {
  opacity: 0;
}

.stagger.visible > *:nth-child(1) { animation: fadeInUp 0.4s 0.05s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(2) { animation: fadeInUp 0.4s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(3) { animation: fadeInUp 0.4s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(4) { animation: fadeInUp 0.4s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(5) { animation: fadeInUp 0.4s 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(6) { animation: fadeInUp 0.4s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(7) { animation: fadeInUp 0.4s 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger.visible > *:nth-child(8) { animation: fadeInUp 0.4s 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
