/* ========================================
   MATA — Make America Trump-free Again
   Brand Stylesheet · Defiant Ember
   ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #0a0e1a;
  color: #e0e0e0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ──────────────────────────── */

header {
  text-align: center;
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(232, 112, 32, 0.08);
}

.header-logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.header-flag {
  width: 208px;
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  margin-top: -1.5rem;
}

.site-logo {
  display: block;
  max-width: 620px;
  width: 100%;
  height: auto;
}

.mission {
  color: #b0b8cc;
  margin-top: 1rem;
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
  font-weight: 400;
}

.source {
  color: #4a4f5e;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  letter-spacing: 0.02em;
}

.source a {
  color: #e87020;
  text-decoration: none;
  font-weight: 500;
}

.source a:hover {
  text-decoration: underline;
  color: #f0923e;
}

/* ── Tabs ────────────────────────────── */

.tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  background: rgba(10, 14, 26, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  border-bottom: 1px solid rgba(232, 112, 32, 0.08);
}

.tab {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #6b7280;
  padding: 0.6rem 2.2rem;
  font-family: 'Instrument Sans', 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tab:hover {
  background: rgba(232, 112, 32, 0.06);
  border-color: rgba(232, 112, 32, 0.2);
  color: #c8cede;
}

.tab.active {
  background: rgba(232, 112, 32, 0.12);
  border-color: rgba(232, 112, 32, 0.4);
  color: #e87020;
}

/* ── Data Explainer ──────────────────── */

.data-explainer {
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem 1.5rem 1.2rem;
  text-align: center;
}

.data-explainer p {
  font-size: 1.05rem;
  color: #b0b8cc;
  line-height: 1.6;
}

.data-explainer a {
  color: #e87020;
  text-decoration: none;
  font-weight: 600;
}

.data-explainer a:hover {
  text-decoration: underline;
  color: #f0923e;
}

/* ── Main Content ────────────────────── */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.race-section {
  display: none;
}

.race-section.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  font-family: 'Instrument Sans', 'Inter', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: #c8cede;
  letter-spacing: 0.02em;
}

/* ── Chamber Control Summary ─────────── */

.control-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.control-bar .party-odds {
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

.control-bar .dem {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.25);
}

.control-bar .rep {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.25);
}

/* ── Control Tooltip ─────────────────── */

.control-tooltip-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: default;
}

.control-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 240px;
  padding: 0.7rem 0.85rem;
  background: #151a2e;
  color: #b0b8cc;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.5;
  border: 1px solid rgba(232, 112, 32, 0.15);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 200;
  pointer-events: none;
}

.control-tooltip::before {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 40px;
  width: 12px;
  height: 12px;
  background: #151a2e;
  border-right: 1px solid rgba(232, 112, 32, 0.15);
  border-bottom: 1px solid rgba(232, 112, 32, 0.15);
  transform: rotate(45deg);
}

.control-tooltip-wrap:hover .control-tooltip {
  display: block;
}

/* ── Race Grid ───────────────────────── */

.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

/* ── Race Card ───────────────────────── */

.race-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.race-card:hover {
  border-color: rgba(232, 112, 32, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.race-card.tossup {
  border-color: rgba(232, 112, 32, 0.25);
  box-shadow: 0 0 24px rgba(232, 112, 32, 0.04);
}

.race-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #e8e8ee;
  margin-bottom: 0.15rem;
}

.race-type {
  font-size: 0.72rem;
  color: #4a4f5e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-bottom: 0.8rem;
}

/* ── Probability Bar ─────────────────── */

.prob-bar-container {
  margin-bottom: 0.6rem;
}

.prob-bar {
  display: flex;
  height: 34px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}

.prob-bar .dem-fill {
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  min-width: 0;
  transition: width 0.6s ease;
}

.prob-bar .rep-fill {
  background: linear-gradient(90deg, #b91c1c, #ef4444);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  min-width: 0;
  transition: width 0.6s ease;
}

.prob-bar .dem-fill span,
.prob-bar .rep-fill span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

/* ── Candidate Labels ────────────────── */

.candidates {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  gap: 0.5rem;
}

.candidates .dem-label {
  color: #60a5fa;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidates .rep-label {
  color: #f87171;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Primary Candidates (TBD races) ──── */

.primary-candidates {
  font-size: 0.72rem;
  line-height: 1.7;
  font-weight: 500;
  margin-top: 0.3rem;
}

.primary-candidates.dem-primary {
  color: #60a5fa;
}

.primary-candidates.rep-primary {
  color: #f87171;
  text-align: right;
}

.primary-candidates a {
  color: inherit;
  text-decoration: none;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}

.primary-candidates a:hover {
  opacity: 1;
  text-decoration: underline;
}

.primary-candidates span {
  opacity: 0.5;
}

/* ── Card Footer ─────────────────────── */

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
}

.dem-support-link {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #60a5fa;
  text-decoration: none;
  padding: 0.25rem 0.65rem;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.06);
  transition: all 0.25s ease;
}

.dem-support-link:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93bbfd;
}

/* ── Closeness Badge ─────────────────── */

.closeness-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
}

.closeness-badge.tossup {
  background: rgba(232, 112, 32, 0.12);
  color: #e87020;
  border: 1px solid rgba(232, 112, 32, 0.3);
}

.closeness-badge.lean {
  background: rgba(168, 85, 247, 0.1);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.closeness-badge.likely {
  background: rgba(100, 116, 139, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(100,116,139,0.25);
}

.closeness-badge.safe {
  background: rgba(50, 60, 80, 0.25);
  color: #64748b;
  border: 1px solid rgba(100,116,139,0.12);
}

/* ── Held Badge (D-Held / R-Held / Open) ── */

.held-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
  margin-left: 0.4rem;
}

.held-badge.dem-held {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.held-badge.rep-held {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.held-badge.ind-held {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.held-badge.open-held {
  background: rgba(100, 116, 139, 0.1);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.25);
}

/* ── Margin Badges ──────────────────── */

.margin-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
  margin-left: 0.3rem;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.margin-badge:hover {
  opacity: 0.8;
}

.margin-badge.dem-margin {
  background: rgba(59, 130, 246, 0.10);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.20);
}

.margin-badge.rep-margin {
  background: rgba(239, 68, 68, 0.10);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.20);
}

/* ── Volume ──────────────────────────── */

.volume {
  font-size: 0.7rem;
  color: #4a4f5e;
  text-align: right;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

/* ── Loading & Error ─────────────────── */

.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: #4a4f5e;
  font-size: 1rem;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid #1e2336;
  border-top-color: #e87020;
  border-radius: 50%;
  margin-left: 0.5rem;
  vertical-align: middle;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: #f87171;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: 10px;
}

/* ── How You Can Help ────────────────── */

.help-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0.75rem;
}

.help-bar h2 {
  font-family: 'Instrument Sans', 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #c8cede;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
  text-align: center;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

.help-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 1.1rem;
  text-align: center;
  transition: border-color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.help-card:hover {
  border-color: rgba(232, 112, 32, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.help-card .icon {
  display: block;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.help-card h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e0e0e0;
  margin-bottom: 0.35rem;
}

.help-card p {
  font-size: 0.76rem;
  color: #6b7280;
  line-height: 1.5;
}

.help-card a {
  color: #e87020;
  text-decoration: none;
  font-weight: 600;
}

.help-card a:hover {
  text-decoration: underline;
  color: #f0923e;
}

@media (max-width: 900px) {
  .help-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 500px) {
  .help-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .help-card {
    padding: 0.9rem 0.7rem;
  }
}

/* ── Footer ──────────────────────────── */

footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: #3a3f4e;
  font-size: 0.75rem;
  border-top: 1px solid rgba(232, 112, 32, 0.06);
  letter-spacing: 0.01em;
}

/* ── Responsive ──────────────────────── */

@media (max-width: 600px) {
  header {
    padding: 1.5rem 1rem 1rem;
  }

  .mission {
    font-size: 0.95rem;
  }

  .header-logo-row {
    flex-direction: column;
    gap: 0;
  }

  .header-flag {
    width: 80px;
    margin-top: 0;
    margin-bottom: -0.5rem;
  }

  .race-grid {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .tabs {
    padding: 0.75rem 1rem;
  }

  .tab {
    padding: 0.5rem 1.5rem;
    font-size: 0.85rem;
  }
}
