/* ==========================================================================
   US MIDTERMS 2026 - MODERN MOBILE-FIRST DESIGN SYSTEM (VANILLA CSS)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Color Palette */
  --bg-dark: #0a0e17;
  --bg-surface: #111827;
  --bg-card: #182234;
  --bg-card-hover: #1f2b42;
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(59, 130, 246, 0.5);

  --text-main: #f9fafb;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --dem-blue: #3b82f6;
  --dem-blue-bg: rgba(59, 130, 246, 0.15);
  --rep-red: #ef4444;
  --rep-red-bg: rgba(239, 68, 68, 0.15);
  --toss-amber: #f59e0b;
  --toss-amber-bg: rgba(245, 158, 11, 0.15);
  --ind-purple: #a855f7;

  --brand-primary: #2563eb;
  --brand-glow: rgba(37, 99, 235, 0.35);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --nav-height: 64px;
}

/* Light Theme Variables */
body.light-theme {
  --bg-dark: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(37, 99, 235, 0.4);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --dem-blue: #2563eb;
  --dem-blue-bg: rgba(37, 99, 235, 0.1);
  --rep-red: #dc2626;
  --rep-red-bg: rgba(220, 38, 38, 0.1);
  --toss-amber: #d97706;
  --toss-amber-bg: rgba(217, 119, 6, 0.1);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 20px);
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container Limit */
.app-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 1024px) {
  .app-container {
    max-width: 1080px;
  }
}

/* Announcement Banner */
.announcement-banner {
  background: linear-gradient(90deg, #1e293b, #0f172a);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fbbf24;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

body.light-theme .app-header {
  background: rgba(255, 255, 255, 0.9);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--dem-blue), var(--rep-red));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--brand-glow);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-text .sub {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  font-size: 0.72rem;
  font-weight: 700;
  color: #ef4444;
  text-transform: uppercase;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

/* Bottom Tab Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(17, 24, 39, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.light-theme .bottom-nav {
  background: rgba(255, 255, 255, 0.94);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  gap: 3px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  min-width: 60px;
}

.nav-item .nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--dem-blue);
  background: var(--dem-blue-bg);
}

/* Card Components */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.badge-dem { background: var(--dem-blue-bg); color: var(--dem-blue); border: 1px solid rgba(59,130,246,0.3); }
.badge-rep { background: var(--rep-red-bg); color: var(--rep-red); border: 1px solid rgba(239,68,68,0.3); }
.badge-toss { background: var(--toss-amber-bg); color: var(--toss-amber); border: 1px solid rgba(245,158,11,0.3); }

/* Balance of Power Bar */
.balance-bar-container {
  margin: 14px 0 8px;
}

.balance-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.bar-track {
  height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  overflow: hidden;
  background: #334155;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.bar-segment-dem {
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  height: 100%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

.bar-segment-toss {
  background: #f59e0b;
  height: 100%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-segment-rep {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
  height: 100%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
}

/* Battleground Grid */
.race-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .race-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.race-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.race-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.race-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.state-flag {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: var(--font-heading);
}

.prob-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* Candidate Dossier Head-to-Head */
.candidate-showdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.candidate-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  position: relative;
}

.candidate-photo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 8px;
  border: 2px solid var(--border);
  background: #1e293b;
}

.candidate-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.candidate-party {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 2px;
}

/* News List */
.news-item {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.news-item:hover {
  border-color: var(--border-focus);
}

.news-source {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--dem-blue);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.news-title {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-main);
}

.news-time {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ==========================================================================
   INTERACTIVE US CARTOGRAM MAP COMPONENT & STATE DRAWER
   ========================================================================== */

.cartogram-wrapper {
  overflow-x: auto;
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  -webkit-overflow-scrolling: touch;
}

.cartogram-grid {
  display: grid;
  grid-template-columns: repeat(11, 32px);
  grid-template-rows: repeat(8, 32px);
  gap: 5px;
  margin: 0 auto;
  user-select: none;
}

@media (min-width: 480px) {
  .cartogram-grid {
    grid-template-columns: repeat(11, 38px);
    grid-template-rows: repeat(8, 38px);
    gap: 6px;
  }
}

.cartogram-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 7px;
  cursor: pointer;
  background: #334155;
  color: #fff;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.cartogram-tile:hover {
  transform: translateY(-2px) scale(1.1);
  z-index: 5;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.cartogram-tile.active-state {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
  transform: scale(1.15);
  z-index: 10;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.6);
}

.tile-dem {
  background: linear-gradient(135deg, #1d4ed8, #3b82f6);
  border-color: rgba(59, 130, 246, 0.4);
}

.tile-rep {
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  border-color: rgba(239, 68, 68, 0.4);
}

.tile-toss {
  background: linear-gradient(135deg, #b45309, #f59e0b);
  border-color: rgba(245, 158, 11, 0.5);
}

.tile-dim {
  background: #1e293b;
  color: #64748b;
  border-color: rgba(255, 255, 255, 0.04);
  opacity: 0.45;
}

.tile-dim:hover {
  opacity: 0.8;
}

.cartogram-empty {
  visibility: hidden;
  pointer-events: none;
}

/* State Details Drawer */
.state-drawer {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.drawer-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-body {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.legend-box {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

.legend-dem { background: var(--dem-blue); }
.legend-rep { background: var(--rep-red); }
.legend-toss { background: var(--toss-amber); }
.legend-dim { background: #334155; }

/* Admin Studio Styles */
.admin-badge {
  background: #8b5cf6;
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
}
.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Search Bar */
.search-container {
  margin-bottom: 16px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.92rem;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
}

/* ============================================================
   Interactive US Cartogram Map Components (Overview, Senate, House)
   ============================================================ */
.cartogram-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0;
  margin: 10px 0;
  display: flex;
  justify-content: center;
}

.cartogram-grid {
  display: grid;
  grid-template-columns: repeat(11, 32px);
  grid-template-rows: repeat(8, 32px);
  gap: 5px;
  user-select: none;
}

@media (max-width: 480px) {
  .cartogram-grid {
    grid-template-columns: repeat(11, 26px);
    grid-template-rows: repeat(8, 26px);
    gap: 3px;
  }
}

.cartogram-empty {
  visibility: hidden;
}

.cartogram-tile {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-heading);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@media (max-width: 480px) {
  .cartogram-tile {
    font-size: 0.62rem;
  }
}

.cartogram-tile:hover {
  transform: scale(1.15);
  z-index: 10;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.cartogram-tile.active-state {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
  transform: scale(1.18);
  z-index: 20;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
}

.cartogram-tile.tile-dem {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #ffffff;
  border-color: rgba(96, 165, 250, 0.5);
}

.cartogram-tile.tile-rep {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: #ffffff;
  border-color: rgba(248, 113, 113, 0.5);
}

.cartogram-tile.tile-toss {
  background: linear-gradient(135deg, #b45309, #d97706);
  color: #ffffff;
  border-color: rgba(251, 191, 36, 0.5);
}

.cartogram-tile.tile-dim {
  background: rgba(30, 41, 59, 0.6);
  color: #64748b;
  border-color: rgba(255, 255, 255, 0.04);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 10px;
  justify-content: center;
  align-items: center;
}

.legend-box {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}

.legend-box.legend-dem { background: var(--dem-blue); }
.legend-box.legend-rep { background: var(--rep-red); }
.legend-box.legend-toss { background: #d97706; }
.legend-box.legend-dim { background: #334155; }

.state-drawer {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 12px;
  animation: drawerSlide 0.2s ease-out;
}

@keyframes drawerSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 6px;
}

.drawer-title {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

.drawer-body {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}
