:root {
  --bg: #101820;
  --panel: rgba(16, 24, 32, 0.82);
  --panel-2: rgba(22, 30, 38, 0.92);
  --surface: #1d2730;
  --line: #d7b42c;
  --accent: #72d572;
  --accent-strong: #b7ffb2;
  --text: #f3f7fb;
  --muted: #b8c2cc;
  --danger: #ff6f61;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(114, 213, 114, 0.16), transparent 24%),
    linear-gradient(180deg, #0a1116 0%, #121b22 100%);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(8,12,16,0.65);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
}

.eyebrow,
.pill {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-strong);
  font-size: 0.72rem;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-links a,
.button-link {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* ── Shell ──────────────────────────────────────────────────────────────────── */
.shell { padding: 1.5rem 2rem; }

/* ── Grids ──────────────────────────────────────────────────────────────────── */
.hero-grid,
.graph-grid,
.insight-grid {
  display: grid;
  gap: 1.25rem;
}

.hero-grid    { grid-template-columns: 1.4fr 1fr; }
.graph-grid   { grid-template-columns: repeat(2, minmax(0,1fr)); }
.insight-grid { grid-template-columns: repeat(2, minmax(0,1fr)); margin-top: 1.25rem; }

/* ── Panels ─────────────────────────────────────────────────────────────────── */
.hero-panel,
.chart-card,
.insight-card {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.24);
}

/* ── Map panel ──────────────────────────────────────────────────────────────── */
.map-panel {
  min-height: 520px;
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  overflow: hidden;
  position: relative;
}

.road-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.map-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(10,15,20,0.28), transparent 48%, rgba(10,15,20,0.24)),
    linear-gradient(180deg, rgba(10,15,20,0.16), transparent 26%, rgba(10,15,20,0.2));
}

.map-panel.is-video::after { display: none; }

.hero-copy,
.busiest-banner { position: relative; z-index: 3; }

/* ── Vehicle layer ──────────────────────────────────────────────────────────── */
.vehicle-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

/* ── Fullscreen button ──────────────────────────────────────────────────────── */
.fullscreen-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(10,12,16,0.72);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
  transition: background 0.15s, border-color 0.15s;
}

.fullscreen-btn:hover {
  background: rgba(114,213,114,0.18);
  border-color: rgba(114,213,114,0.6);
}

.fullscreen-btn svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* show expand icon by default, compress icon when fullscreen */
.fullscreen-btn .icon-compress { display: none; }
.map-panel.is-fullscreen .fullscreen-btn .icon-expand   { display: none; }
.map-panel.is-fullscreen .fullscreen-btn .icon-compress { display: block; }

/* fullscreen panel styles */
.map-panel.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 999 !important;
  border-radius: 0 !important;
  min-height: 100dvh !important;
  width: 100vw !important;
}

/* ── Signals ────────────────────────────────────────────────────────────────── */
.signal {
  position: absolute;
  z-index: 3;
  width: 30px;
  padding: 4px 4px 6px;
  border-radius: 10px;
  background: rgba(10,12,16,0.86);
  border: 1px solid rgba(255,255,255,0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.signal .light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0.22;
  background: #36424f;
}

.signal .timer {
  font-style: normal;
  font-size: 0.66rem;
  color: #dbe5f0;
}

.signal.state-red    .light.red    { opacity:1; background:#ff5b5b; box-shadow:0 0 10px rgba(255,91,91,0.9); }
.signal.state-yellow .light.yellow { opacity:1; background:#ffd34d; box-shadow:0 0 10px rgba(255,211,77,0.9); }
.signal.state-green  .light.green  { opacity:1; background:#66e178; box-shadow:0 0 10px rgba(102,225,120,0.9); }

.signal-north { top: 12%;    left: 53%; }
.signal-east  { top: 47%;    right: 13%; }
.signal-south { bottom: 13%; left: 46%; }
.signal-west  { top: 41%;    left: 12%; }

/* ── Vehicles ───────────────────────────────────────────────────────────────── */
.vehicle {
  position: absolute;
  width: 26px;
  height: auto;
  opacity: 0.95;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.45));
}

.lane-west-east   { transform: rotate(0deg); }
.lane-east-west   { transform: rotate(180deg); }
.lane-north-south { transform: rotate(90deg); }
.lane-south-north { transform: rotate(-90deg); }

/* ── Hero copy ──────────────────────────────────────────────────────────────── */
.hero-copy {
  max-width: 460px;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(8,12,16,0.42);
  backdrop-filter: blur(2px);
}

.hero-copy h2 {
  margin: 0 0 0.35rem;
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.road-switcher {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.road-chip {
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  background: rgba(6,10,14,0.7);
  white-space: nowrap;
}

.road-chip.active {
  border-color: rgba(114,213,114,0.8);
  color: #d9ffd7;
  box-shadow: 0 0 0 1px rgba(114,213,114,0.3) inset;
}

.hero-copy p,
.stats-panel p,
.insight-card p,
.graphs-hero p {
  color: var(--muted);
  line-height: 1.55;
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
}

/* ── Busiest banner ─────────────────────────────────────────────────────────── */
.busiest-banner {
  align-self: flex-start;
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(10,16,22,0.76);
  border: 1px solid rgba(255,255,255,0.1);
}

.busiest-banner span,
.stat-card span { color: var(--muted); font-size: 0.9rem; }
.busiest-banner strong { font-size: 1.4rem; }
.busiest-banner em { color: var(--accent-strong); font-style: normal; }

/* ── Stats panel ────────────────────────────────────────────────────────────── */
.stats-panel { padding: 1.5rem; }

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

.stats-header h3 { margin: 0; font-size: clamp(0.95rem, 2vw, 1.1rem); }

.stats-grid { display: grid; gap: 0.9rem; }

/* 2-column stat cards on wider stats panel */
@media (min-width: 961px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  padding: 1rem;
  border-radius: 18px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.06);
}

.stat-card.active {
  border-color: rgba(114,213,114,0.55);
  box-shadow: inset 0 0 0 1px rgba(114,213,114,0.2);
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  margin: 0.1rem 0 0.55rem;
}

.meter {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--line));
}

/* ── Insight cards ──────────────────────────────────────────────────────────── */
.insight-card,
.chart-card { padding: 1.4rem; }

/* ── Graphs page ────────────────────────────────────────────────────────────── */
.graphs-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.graphs-hero h2 { margin: 0; font-size: clamp(1.1rem, 3vw, 1.6rem); }

.chart-card canvas {
  width: 100% !important;
  height: 300px !important;
}

/* ── Tablet: 600–960px ──────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .shell { padding: 1rem; }

  .hero-grid,
  .graph-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .graphs-hero { flex-direction: column; align-items: flex-start; }

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

  .map-panel { min-height: 380px; }

  .hero-copy { max-width: 100%; }
}

/* ── Mobile: ≤ 600px ────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Topbar */
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    gap: 0.6rem;
  }

  .topbar > div { width: 100%; }

  .nav-links {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-links a,
  .button-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
  }

  /* Shell */
  .shell { padding: 0.75rem; }

  /* Map panel — shorter on mobile so stats are visible without scrolling */
  .map-panel {
    min-height: 260px;
    padding: 1rem;
    border-radius: 16px;
  }

  /* Road switcher — scrollable row on very small screens */
  .road-switcher {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 0.4rem;
    scrollbar-width: none;
  }
  .road-switcher::-webkit-scrollbar { display: none; }

  .road-chip {
    font-size: 0.76rem;
    padding: 0.35rem 0.7rem;
    flex-shrink: 0;
  }

  /* Hero copy */
  .hero-copy {
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
  }

  .hero-copy h2 { font-size: 1rem; }
  .hero-copy > p { display: none; } /* hide description on tiny screens */

  /* Busiest banner */
  .busiest-banner {
    padding: 0.65rem 0.8rem;
    border-radius: 14px;
  }
  .busiest-banner strong { font-size: 1.1rem; }

  /* Signals — scale down */
  .signal { width: 22px; padding: 3px 3px 5px; gap: 3px; }
  .signal .light { width: 9px; height: 9px; }
  .signal .timer { font-size: 0.58rem; }

  /* Stats panel */
  .stats-panel { padding: 1rem; border-radius: 16px; }

  .stats-header { gap: 0.6rem; }
  .stats-header h3 { font-size: 0.95rem; }

  /* 2-column stat cards on mobile too */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

  .stat-card { padding: 0.75rem; border-radius: 14px; }
  .stat-card strong { font-size: 1.5rem; margin-bottom: 0.4rem; }
  .stat-card span { font-size: 0.8rem; }

  /* Insight cards */
  .insight-grid { grid-template-columns: 1fr; margin-top: 0.75rem; }
  .insight-card { padding: 1rem; border-radius: 16px; }
  .insight-card h3 { font-size: 0.95rem; }

  /* Graphs page */
  .graphs-hero { gap: 0.75rem; }
  .graphs-hero h2 { font-size: 1.1rem; }

  .chart-card { padding: 1rem; border-radius: 16px; }
  .chart-card h3 { font-size: 0.95rem; margin: 0 0 0.75rem; }
  .chart-card canvas { height: 220px !important; }
}
