/* ─── OPENDISTRICTS V4 — v4.css ───────────────────────────────────────────────
   Design tokens + exact layout model from docs/V4-transition.md Sections 02-09
   Constraints: CSS transform + opacity only. No blur on map elements.
   No box-shadow on timeline cards. Never hard-code values outside this token set.
──────────────────────────────────────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════════
   SECTION 03 — DESIGN TOKENS
═══════════════════════════════════════════════════════════════════ */
:root {
  /* Ink (text) */
  --ink: #0D1117;
  --ink-mid: #30363D;
  --ink-sub: #57606A;
  --ink-ghost: #8B949E;

  /* Structure */
  --rule: #D0D7DE;
  --rule-faint: #EAEEF2;
  --bg: #F6F8FA;
  --white: #FFFFFF;

  /* Semantic colour */
  --primary: #1F6FEB;
  --danger: #CF222E;
  --warn: #9A6700;
  --ok: #1A7F37;
  --purple: #6E40C9;
  --map-base: #DDE1E7;

  /* Typography */
  --font-display: 'Syne', sans-serif;
  --font-data: 'DM Mono', monospace;

  /* Incident type fills — shades only, no primary hues */
  --fill-health: rgba(185, 28, 48, 0.16);
  /* crimson-rose     */
  --fill-infrastructure: rgba(146, 92, 12, 0.14);
  /* amber-ochre      */
  --fill-mobility: rgba(55, 65, 160, 0.12);
  /* slate-indigo     */
  --fill-safety: rgba(20, 108, 100, 0.12);
  /* teal-cyan        */
  --fill-weather: rgba(96, 50, 168, 0.12);
  /* violet-mauve     */
  --fill-emergency: rgba(168, 22, 38, 0.20);
  /* deep-scarlet     */

  /* Incident type border colours */
  --border-health: rgba(185, 28, 48, 0.52);
  --border-infrastructure: rgba(146, 92, 12, 0.44);
  --border-mobility: rgba(55, 65, 160, 0.38);
  --border-safety: rgba(20, 108, 100, 0.36);
  --border-weather: rgba(96, 50, 168, 0.38);
  --border-emergency: rgba(168, 22, 38, 0.56);

  /* Incident type solid hues (for text/badges — muted shades) */
  --hue-health: #B91C30;
  /* crimson-rose     */
  --hue-infrastructure: #925C0C;
  /* amber-ochre      */
  --hue-mobility: #3741A0;
  /* slate-indigo     */
  --hue-safety: #146C64;
  /* teal-cyan        */
  --hue-weather: #603294;
  /* violet-mauve     */
  --hue-emergency: #A81626;
  /* deep-scarlet     */
}

/* ═══════════════════════════════════════════════════════════════════
   RESET
═══════════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--map-base);
  font-family: var(--font-data);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font-data);
  cursor: pointer;
  background: none;
  border: none;
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 02 — LAYOUT ARCHITECTURE
   (Exact CSS model. Do not deviate from these rules.)
═══════════════════════════════════════════════════════════════════ */

/* TOP BAR */
#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  z-index: 50;
  background: rgba(13, 17, 23, 0.95);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
}

/* MAP CONTAINER — NEVER RESIZES */
#map {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  bottom: 60px;
  width: 100vw;
  z-index: 10;
  /* Trap Leaflet's internal z-indexes (400+) */
}

/* Leaflet tile desaturation */
#map .leaflet-tile-pane {
  filter: grayscale(100%) brightness(105%) contrast(88%);
}

/* LEFT TIMELINE — OVERLAY */
#timeline-panel {
  position: absolute;
  top: 44px;
  left: 0;
  bottom: 60px;
  width: clamp(200px, 22vw, 248px);
  z-index: 20;
  background: var(--white);
  border-right: 1.5px solid rgba(0, 0, 0, 0.1);
  transform: translateX(0);
  transition: transform 200ms ease-out;
  display: flex;
  flex-direction: column;
  overflow: visible;
  /* must stay visible so side-tab can protrude */
}

/* Clip overflow only on inner scroll/header, not panel itself */
#tl-header,
#tl-scroll {
  overflow: hidden;
}

#timeline-panel.hidden {
  transform: translateX(-100%);
}

/* ── Side toggle tab (shared) ────────────────────────────────── */
.panel-side-tab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 56px;
  background: var(--white);
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 0 6px 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--ink-ghost);
  transition: color 150ms, background 150ms, left 200ms ease-out, right 200ms ease-out;
  z-index: 50;
  padding: 0;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.08);
  line-height: 1;
}

.panel-side-tab:hover {
  color: var(--ink);
  background: var(--bg-2);
}

/* Timeline tab logic */
#timeline-panel~#tl-tab {
  left: clamp(200px, 22vw, 248px);
  border-left: none;
}

#timeline-panel.hidden~#tl-tab {
  left: 0;
}

/* AI tab logic */
#ai-panel~#ai-tab {
  right: 0;
  border-right: none;
  border-radius: 6px 0 0 6px;
  box-shadow: -2px 0 6px rgba(0, 0, 0, 0.08);
}

#ai-panel.open~#ai-tab {
  right: clamp(260px, 28vw, 300px);
}

/* RIGHT AI PANEL — OVERLAY */
#ai-panel {
  position: absolute;
  top: 44px;
  right: 0;
  bottom: 60px;
  width: clamp(260px, 28vw, 300px);
  z-index: 30;
  background: var(--white);
  border-left: 2px solid var(--primary);
  transform: translateX(100%);
  transition: transform 200ms ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#ai-panel.open {
  transform: translateX(0);
}

/* TIME AXIS — ALWAYS VISIBLE */
#time-axis {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 25;
  background: rgba(13, 17, 23, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: stretch;
}

/* HIERARCHY SELECTOR — FULL-SCREEN OVERLAY */
#hierarchy-selector {
  position: absolute;
  inset: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 150ms;
}

#hierarchy-selector.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex !important;
  /* override global .hidden */
}

#hierarchy-selector.fading {
  opacity: 0;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 04 — TOP BAR COMPONENTS
═══════════════════════════════════════════════════════════════════ */

#tb-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 12px;
  color: #FFFFFF;
  flex-shrink: 0;
  letter-spacing: 0.2px;
}

.tb-sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

#tb-district-label {
  flex-shrink: 0;
}

.tb-district-meta {
  font-size: 7px;
  font-weight: 500;
  color: var(--ink-ghost);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  line-height: 1;
}

.tb-district-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: #FFFFFF;
  line-height: 1.2;
}

.tb-spacer {
  flex: 1;
}

/* Generic top bar button */
.tb-btn {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.75);
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 150ms, color 150ms;
}

.tb-btn:hover {
  border-color: rgba(255, 255, 255, 0.44);
  color: #fff;
}

.tb-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.tb-btn.primary:hover {
  background: #1a60d4;
  border-color: #1a60d4;
}

/* Language selector (Infinite Swipe Pill) */
#tb-lang {
  width: 32px;
  height: 32px;
  background-color: transparent;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.4s;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

#tb-lang:hover {
  border-color: rgba(255, 255, 255, 0.44);
}

#tb-lang.expanded {
  width: 180px;
  /* Expands to the left because of tb-spacer */
  background-color: rgba(255, 255, 255, 0.08);
  /* Dark background when open */
  border-color: transparent;
}

.lang-track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
}

.lang-item {
  position: absolute;
  top: 0;
  left: -16px;
  /* Half of its own width */
  width: 32px;
  height: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--ink-ghost);
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0;
  /* Hidden by default when not expanded */
  transition: opacity 0.2s, font-size 0.2s, color 0.2s;
  will-change: transform;
  pointer-events: none;
}

#tb-lang.expanded .lang-item {
  opacity: 0.4;
}

#tb-lang .lang-item.active {
  opacity: 1;
  color: #fff;
}

#tb-lang.expanded .lang-item.active {
  color: var(--primary);
  font-size: 9px;
  font-weight: 700;
}

.lang-focus-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, border-color 0.3s;
}

#tb-lang.expanded .lang-focus-ring {
  border-color: var(--primary);
  opacity: 1;
}

/* Mode toggle */
#tb-mode {
  display: flex;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  overflow: hidden;
}

.mode-pill {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-ghost);
  padding: 5px 10px;
  border-radius: 0;
  transition: all 120ms;
}

.mode-pill.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.mode-pill:hover:not(.active) {
  color: rgba(255, 255, 255, 0.6);
}

/* Sync dot */
#sync-dot-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

#sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: dot-pulse 2.5s ease-in-out infinite;
  /* 0.4 Hz — compliant */
}

#sync-dot.historical {
  background: var(--ink-ghost);
  animation: none;
}

#sync-label {
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ok);
}

#sync-label.historical {
  color: var(--ink-ghost);
}

@keyframes dot-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 05 — LEFT TIMELINE PANEL
═══════════════════════════════════════════════════════════════════ */

/* Panel header — 44px */
#tl-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.tl-header-meta {
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-ghost);
  line-height: 1;
}

.tl-header-district {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.2;
}

/* Collapse chevron button */
.tl-collapse-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ink-ghost);
  border: 1px solid var(--rule);
  border-radius: 2px;
  flex-shrink: 0;
  transition: color 150ms, border-color 150ms;
  line-height: 1;
}

.tl-collapse-btn:hover {
  color: var(--ink);
  border-color: var(--ink-mid);
}



/* Scroll area */
#tl-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

/* ── SPINE ── */
.tl-spine {
  position: relative;
  padding: 0 10px 0 28px;
  /* left offset creates space for spine + node */
}

.tl-spine::before {
  /* THE SPINE LINE */
  content: "";
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  /* MINIMUM 2px */
  background: var(--rule);
}

/* ── CARD ── */
.tl-card {
  position: relative;
  margin-bottom: 16px;
  cursor: pointer;
  transition: opacity 150ms;
}

/* NODE DOT — ON THE SPINE */
.tl-card::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 14px;
  width: 10px;
  height: 10px;
  /* MINIMUM 10px */
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--rule);
  z-index: 2;
}

.tl-card.cat-health::before {
  border-color: var(--hue-health);
}

.tl-card.cat-infrastructure::before {
  border-color: var(--hue-infrastructure);
}

.tl-card.cat-mobility::before {
  border-color: var(--hue-mobility);
}

.tl-card.cat-safety::before {
  border-color: var(--hue-safety);
}

.tl-card.cat-weather::before {
  border-color: var(--hue-weather);
}

.tl-card.cat-emergency::before {
  border-color: var(--hue-emergency);
}

/* STRING CONNECTOR between nodes */
.tl-card::after {
  content: "";
  position: absolute;
  left: -16px;
  top: 24px;
  bottom: -16px;
  width: 1.5px;
  background: var(--rule-faint);
  z-index: 1;
}

.tl-card:last-child::after {
  display: none;
}

/* CARD INNER — FLAT, NOT ELEVATED */
.tl-card-inner {
  position: relative;
  border: 1.5px solid var(--rule);
  border-radius: 2px;
  /* MAXIMUM 2px */
  background: var(--white);
  overflow: hidden;
  /* NO box-shadow. Cards are flat. */
}

/* LEFT SEVERITY BAND — 3px full height */
.tl-card-inner::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.tl-card.cat-health .tl-card-inner::before {
  background: var(--hue-health);
}

.tl-card.cat-infrastructure .tl-card-inner::before {
  background: var(--hue-infrastructure);
}

.tl-card.cat-mobility .tl-card-inner::before {
  background: var(--hue-mobility);
}

.tl-card.cat-safety .tl-card-inner::before {
  background: var(--hue-safety);
}

.tl-card.cat-weather .tl-card-inner::before {
  background: var(--hue-weather);
}

.tl-card.cat-emergency .tl-card-inner::before {
  background: var(--hue-emergency);
}

/* FOCUS STATE */
.tl-card.focused .tl-card-inner {
  border-color: var(--ink);
  /* Still NO box-shadow. Border darkens. */
}

.tl-card.dimmed {
  opacity: 0.32;
  pointer-events: none;
}

/* CARD HEAD */
.tl-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px 6px 12px;
  /* left 12 to clear severity band */
}

/* SVG thumbnail */
.tl-thumb {
  width: 28px;
  height: 24px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 1px;
}

.tl-thumb svg {
  width: 100%;
  height: 100%;
}

.tl-meta {
  flex: 1;
  min-width: 0;
}

.tl-loc-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.tl-time {
  font-size: 8px;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--ink-ghost);
  letter-spacing: 0.4px;
  margin-top: 1px;
}

/* Event summary */
.tl-summary {
  font-size: 9.5px;
  font-weight: 300;
  color: var(--ink-sub);
  line-height: 1.45;
  padding: 0 10px 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tl-summary-wrap {
  padding-bottom: 8px;
}

.tl-view-more {
  display: none;
  font-size: 8.5px;
  font-weight: 500;
  color: var(--primary);
  padding: 4px 10px 0 12px;
  letter-spacing: 0.2px;
}

.tl-card.has-overflow:not(.focused) .tl-view-more {
  display: block;
}

.tl-card.focused .tl-summary {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}

/* Details section — hidden until focused */
.tl-details {
  display: none;
  background: var(--bg);
  border-top: 1px solid var(--rule-faint);
  padding: 8px 10px 8px 12px;
}

/* Time Machine States */
.tl-card.tl-hidden {
  display: none !important;
}

.tl-card.tl-historical-dim {
  opacity: 0.4;
  filter: grayscale(1);
  transition: opacity 150ms, filter 150ms;
}

.tl-card.tl-historical-dim:hover {
  opacity: 0.7;
  filter: grayscale(0.5);
}

.tl-card.tl-current {
  opacity: 1;
  filter: none;
  box-shadow: -2px 0 0 var(--primary);
  /* Highlight current ones slightly */
}

.tl-card.focused .tl-details {
  display: block;
}

.tl-detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  align-items: baseline;
}

.tl-detail-label {
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--ink-ghost);
  letter-spacing: 0.8px;
  width: 52px;
  flex-shrink: 0;
}

.tl-detail-value {
  font-size: 8.5px;
  font-weight: 400;
  color: var(--ink-mid);
  flex: 1;
}

/* Source verification tag */
.tl-source-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 8px;
  font-weight: 400;
  color: var(--ok);
}

/* ── Phase 2 additions ───────────────────────────────────────── */

/* Event title row — between card-head and summary */
.tl-title-row {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink);
  padding: 0 10px 4px 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Incident type pill badge in card head (top-right) */
.tl-type-pill {
  font-size: 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 2px 5px;
  border-radius: 1px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 1px;
}

.cat-pill-health {
  background: rgba(185, 28, 48, 0.12);
  color: var(--hue-health);
}

.cat-pill-infrastructure {
  background: rgba(146, 92, 12, 0.12);
  color: var(--hue-infrastructure);
}

.cat-pill-mobility {
  background: rgba(55, 65, 160, 0.12);
  color: var(--hue-mobility);
}

.cat-pill-safety {
  background: rgba(20, 108, 100, 0.10);
  color: var(--hue-safety);
}

.cat-pill-weather {
  background: rgba(96, 50, 168, 0.12);
  color: var(--hue-weather);
}

.cat-pill-emergency {
  background: rgba(168, 22, 38, 0.14);
  color: var(--hue-emergency);
}

/* Empty timeline state */
.tl-empty-state {
  padding: 24px 12px;
  font-size: 10px;
  font-weight: 400;
  color: var(--ink-ghost);
  text-align: center;
  line-height: 1.6;
}

/* AI context badge (event-bound vs general indicator) */
.ai-context-badge {
  display: inline-block;
  font-size: 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 6px;
  border-radius: 1px;
  margin-top: 4px;
}

.ai-context-badge.event {
  background: rgba(207, 34, 46, 0.12);
  color: var(--danger);
}

.ai-context-badge.general {
  background: rgba(31, 111, 235, 0.08);
  color: var(--primary);
}

.tl-source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 06 — MAP ELEMENTS
═══════════════════════════════════════════════════════════════════ */

/* Custom zoom controls */
#map-zoom-controls {
  position: absolute;
  right: 60px;
  bottom: 60px;
  /* above time axis */
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.zoom-btn {
  width: 64px;
  height: 64px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 40px;
  font-weight: 300;
  color: var(--ink-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms, color 120ms;
  line-height: 1;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.zoom-btn:hover {
  border-color: var(--ink-mid);
  color: var(--ink);
}

.zoom-btn:active {
  transform: scale(0.95);
}

/* Environmental overlays — Only when env-active class is present
   env-active requires: mode=live AND connectionStatus=live AND !isHistorical */
.env-rain,
.env-haze {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms;
}

.env-scanner {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms;
  z-index: 2;
  mix-blend-mode: screen;
}

#map.env-active .env-scanner {
  opacity: 1;
  background: conic-gradient(from 0deg at 50% 50%, transparent 0deg, transparent 270deg, rgba(31, 111, 235, 0.05) 350deg, rgba(31, 111, 235, 0.25) 360deg);
  animation: radar-sweep 8s linear infinite;
}

@keyframes radar-sweep {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

#map.env-active .env-rain {
  opacity: 1;
  background: repeating-linear-gradient(175deg,
      transparent 0px, transparent 6px,
      rgba(130, 170, 210, 0.28) 6px, rgba(130, 170, 210, 0.28) 7.5px);
  animation: rain-fall 0.8s linear infinite;
  /* 1.25 Hz — compliant */
  z-index: 4;
}

@keyframes rain-fall {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 0 20px;
  }
}

#map.env-active .env-haze {
  opacity: 1;
  /* Simplified for performance */
  background: radial-gradient(ellipse 80% 60% at 50% 50%,
      rgba(190, 170, 110, 0.15) 0%, transparent 70%);
  animation: haze-shift 5s ease-in-out infinite alternate;
  /* 0.1 Hz — compliant */
  z-index: 3;
  will-change: opacity;
}

@keyframes haze-shift {
  0% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}

/* ── Incident-type kinetic animations (NO BREATHING) ──────────────────────────── */

/* Kinetic flow for boundaries */
@keyframes kinetic-flow {
  0% {
    stroke-dashoffset: 48;
  }

  100% {
    stroke-dashoffset: 0;
  }
}

/* Digital blip for markers */
@keyframes digital-blip {
  0% {
    transform: scale(0.6);
    stroke-opacity: 1;
    fill-opacity: 0.8;
  }

  30% {
    transform: scale(1.6);
    stroke-opacity: 0;
    fill-opacity: 0;
  }

  100% {
    transform: scale(0.6);
    stroke-opacity: 0;
    fill-opacity: 0;
  }
}

/* Base states */
.leaflet-interactive.cat-health-path,
.leaflet-interactive.cat-emergency-path,
.leaflet-interactive.cat-infrastructure-path,
.leaflet-interactive.cat-mobility-path {
  animation-play-state: paused;
}

/* If it is a polygon (we add polygon-path class in JS) */
#map.live-mode .leaflet-interactive.polygon-path.cat-health-path,
#map.live-mode .leaflet-interactive.polygon-path.cat-emergency-path {
  stroke-dasharray: 8 16;
  animation: kinetic-flow 0.8s linear infinite;
  animation-play-state: running;
}

#map.live-mode .leaflet-interactive.polygon-path.cat-infrastructure-path,
#map.live-mode .leaflet-interactive.polygon-path.cat-mobility-path {
  stroke-dasharray: 4 20;
  animation: kinetic-flow 1.2s linear infinite;
  animation-play-state: running;
}

/* If it is a marker (we add marker-path class in JS) */
#map.live-mode .leaflet-interactive.marker-path.cat-health-path,
#map.live-mode .leaflet-interactive.marker-path.cat-emergency-path {
  animation: digital-blip 1s cubic-bezier(0.1, 0.9, 0.2, 1) infinite;
  animation-play-state: running;
}

#map.live-mode .leaflet-interactive.marker-path.cat-infrastructure-path,
#map.live-mode .leaflet-interactive.marker-path.cat-mobility-path,
#map.live-mode .leaflet-interactive.marker-path.cat-safety-path,
#map.live-mode .leaflet-interactive.marker-path.cat-weather-path {
  animation: digital-blip 2s cubic-bezier(0.1, 0.9, 0.2, 1) infinite;
  animation-play-state: running;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 09 — RIGHT AI PANEL
═══════════════════════════════════════════════════════════════════ */

/* Collapse sliver */
#ai-sliver {
  position: absolute;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 48px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-right: none;
  border-radius: 4px 0 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--ink-ghost);
  cursor: pointer;
  transition: color 120ms;
  z-index: 1;
}

#ai-sliver:hover {
  color: var(--ink);
}

/* Panel header */
#ai-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

#ai-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

#ai-active-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: dot-pulse 2.0s ease-in-out infinite;
  /* 0.5 Hz — compliant */
}

#ai-header-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}

.ai-close-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-ghost);
  transition: color 120ms, border-color 120ms;
}

.ai-close-btn:hover {
  color: var(--ink);
  border-color: var(--ink-mid);
}

/* Context bar */
#ai-context-bar {
  padding: 7px 12px;
  border-bottom: 1px solid var(--rule-faint);
  flex-shrink: 0;
}

#ai-context-bar.general {
  background: var(--bg);
}

#ai-context-bar.event-bound {
  background: rgba(207, 34, 46, 0.06);
  border: 1px solid rgba(207, 34, 46, 0.22);
}

#ai-context-text {
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-ghost);
}

#ai-context-bar.event-bound #ai-context-text {
  color: var(--danger);
}

/* Intent section */
#ai-intent-section {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  scrollbar-width: thin;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-section-label {
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-ghost);
  margin-bottom: 4px;
}

.ai-intents {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-intents.hidden {
  display: none;
}

/* Intent card */
.intent-card {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 2px;
  background: var(--white);
  transition: border-color 120ms;
}

.intent-card:hover {
  border-color: var(--primary);
}

.intent-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink);
  line-height: 1.3;
}

.intent-sub {
  font-size: 8.5px;
  font-weight: 300;
  color: var(--ink-ghost);
  margin-top: 2px;
  line-height: 1.4;
}

/* Result area */
#ai-result {
  border-top: 1px solid var(--rule-faint);
  padding: 10px 12px;
  flex-shrink: 0;
}

#ai-result.hidden {
  display: none;
}

#ai-result-source {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.result-verified-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

#ai-result-source-text {
  font-size: 8px;
  font-weight: 500;
  color: var(--ok);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

#ai-result-body {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--ink-mid);
  line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION 07 — TIME AXIS
═══════════════════════════════════════════════════════════════════ */

/* Left controls zone: 100px */
#ta-controls {
  width: 104px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  /* Reduced gap slightly to fit 3 buttons nicely */
  padding: 0 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.ta-ctrl-btn {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 2px;
  transition: color 120ms, border-color 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  min-width: 24px;
}

.ta-ctrl-btn:hover {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.35);
}

.ta-ctrl-btn.playing {
  color: #fff;
  border-color: var(--primary);
}

/* Main timeline area: fills remaining width */
#ta-main {
  flex: 1;
  position: relative;
  /* overflow: hidden; Removed to allow labels to breathe */
  display: flex;
  flex-direction: column;
}

/* Ruler layer: 32px */
#ta-ruler {
  height: 32px;
  position: relative;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  /* overflow: hidden; Removed to allow labels to breathe */
}

/* Density ribbon: 32px */
#ta-ribbon {
  height: 32px;
  position: relative;
  display: flex;
}

/* Segments are injected as <div class="ribbon-seg"> by JS */
.ribbon-seg {
  height: 100%;
  flex-shrink: 0;
  transition: background-color 300ms;
}

/* Playhead */
#ta-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  pointer-events: none;
  z-index: 10;
}

#ta-playhead-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #FFFFFF;
}

#ta-playhead-handle {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 28px;
  background: #FFFFFF;
  border-radius: 4px;
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 100ms;
}

#ta-playhead-handle:hover {
  transform: translateX(-50%) scale(1.1);
}

#ta-playhead-handle:active {
  cursor: grabbing;
  transform: translateX(-50%) scale(0.95);
}

/* Post-playhead overlay (historical mode) */
#ta-ribbon::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
  /* set by JS */
  background: rgba(0, 0, 0, 0.45);
  pointer-events: none;
  transition: width 150ms;
}

/* Tick marks in ruler */
.ta-tick-major {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.25);
}

.ta-tick-minor {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 6px;
  background: rgba(255, 255, 255, 0.10);
}

.ta-tick-label {
  position: absolute;
  bottom: 2px;
  /* Lifted slightly to fit 2 lines if needed */
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.ta-date {
  font-size: 8px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.ta-time {
  font-size: 7px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
}



/* ═══════════════════════════════════════════════════════════════════
   SECTION 10 — HIERARCHY SELECTOR
═══════════════════════════════════════════════════════════════════ */

/* Hide side tabs when hierarchy selector is open */
#hierarchy-selector:not(.hidden)~.panel-side-tab {
  display: none !important;
}

#hierarchy-selector {
  background: rgba(13, 17, 23, 0.97);
  z-index: 500;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#hierarchy-selector.hidden {
  display: none !important;
}

#hs-inner {
  width: min(900px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Tier 1 header */
#hs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#hs-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: #FFFFFF;
}

.hs-close-btn {
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  transition: color 120ms;
}

.hs-close-btn:hover {
  color: #fff;
}

/* Search input */
#hs-search-wrap {
  margin-bottom: 14px;
}

#hs-search {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  padding: 9px 12px;
  font-family: var(--font-data);
  font-size: 12px;
  color: #FFFFFF;
  outline: none;
}

#hs-search::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

#hs-search:focus {
  border-color: var(--primary);
}

/* Tier 1 Body: split map and search/stats */
#hs-tier1-body {
  display: flex;
  gap: 20px;
  height: calc(92vh - 120px);
}

/* Left: Map Container */
#hs-india-map {
  flex: 1.8;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#hs-india-svg {
  width: 100%;
  height: 100%;
}

/* Right: Panel (Search + Stats) */
#hs-right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* State Paths (Optimized for performance) */
.india-state-path {
  fill: rgba(255, 255, 255, 0.06);
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 1;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
  /* Intentionally no transition or filter to guarantee instantaneous 60fps hover on massive SVGs */
}

.india-state-path:not(.unsupported):hover,
.india-state-path.hovered {
  fill: rgba(31, 111, 235, 0.25);
  stroke: #1F6FEB;
  stroke-width: 1.5;
}

.india-state-path.selected {
  fill: rgba(31, 111, 235, 0.4);
  stroke: #1F6FEB;
  stroke-width: 2;
}

/* Search filtering states */
.india-state-path.search-dim {
  fill: rgba(255, 255, 255, 0.02);
  stroke: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.india-state-path.unsupported {
  fill: rgba(255, 255, 255, 0.02);
  stroke: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.india-state-path.unsupported:hover {
  fill: rgba(255, 255, 255, 0.05);
  stroke: rgba(255, 255, 255, 0.1);
}

.india-state-path.search-match {
  fill: rgba(31, 111, 235, 0.3);
  stroke: #1F6FEB;
  stroke-width: 2;
  filter: drop-shadow(0 0 6px rgba(31, 111, 235, 0.5));
}

.state-label {
  fill: rgba(255, 255, 255, 0.5);
  font-family: var(--font-data);
  font-size: 14px;
  text-anchor: middle;
  pointer-events: none;
  transition: fill 150ms;
}

.state-label.active {
  fill: #fff;
  font-weight: bold;
}

/* State Stats Bar (appears below search) */
#hs-state-stats-bar {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transform: translateY(0);
  opacity: 1;
  transition: transform 250ms ease-out, opacity 250ms ease-out;
}

#hs-state-stats-bar.slide-out {
  transform: translateY(-10px);
  opacity: 0;
}

#hs-state-stats-bar.hidden {
  display: none;
}

#hs-state-stats-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

#hs-state-stats-action {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.hs-enter-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-family: var(--font-data);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 150ms, transform 150ms;
}

.hs-enter-btn:hover {
  background: #2f81f7;
  transform: translateY(-1px);
}

.hs-enter-btn:active {
  background: #0969da;
  transform: translateY(0);
}

/* Tier 2 */
#hs-tier2,
#hs-tier1 {
  width: 100%;
}

#hs-tier2.hidden {
  display: none;
}

#hs-t2-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.hs-back-btn {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.6);
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 2px;
  transition: color 120ms;
}

.hs-back-btn:hover {
  color: #fff;
}

#hs-t2-state-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex: 1;
}

#hs-t2-body {
  display: flex;
  gap: 16px;
  height: calc(92vh - 120px);
  position: relative;
  /* Context for sliding panel */
}

#hs-district-map-wrap {
  flex: 1;
  /* Take up remaining or full space */
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#hs-district-svg {
  width: 100%;
  height: 100%;
}

/* District polygon base styles (JS overrides on hover/active) */
.dist-poly {
  fill: rgba(255, 255, 255, 0.06);
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1;
  cursor: pointer;
  transition: fill 120ms, stroke 120ms;
}

.dist-poly:hover {
  fill: rgba(31, 111, 235, 0.20);
  stroke: #1F6FEB;
}

.dist-poly.active {
  fill: rgba(31, 111, 235, 0.15);
  stroke: #1F6FEB;
  stroke-width: 1.5;
}

.dist-alert-dot {
  fill: var(--danger);
  pointer-events: none;
}

/* Authentic GeoJSON map styling */
.hdist-poly {
  fill: rgba(255, 255, 255, 0.04);
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 0.5;
  cursor: pointer;
  transition: fill 120ms, stroke 120ms, stroke-width 120ms;
}

.hdist-poly.active,
.hdist-poly:not(.unsupported):hover {
  fill: rgba(31, 111, 235, 0.20);
  stroke: #1F6FEB;
  stroke-width: 1.5;
}

.hdist-lbl {
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 500;
  fill: rgba(255, 255, 255, 0.5);
  transition: fill 120ms, font-weight 120ms;
  text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.8);
}

.hdist-lbl.active {
  fill: #fff;
  font-weight: 700;
}

.hdist-alert-dot {
  fill: var(--danger);
  stroke: #0a0e17;
  stroke-width: 1.5px;
}

/* District Stats Sidebar (slides in from right, content-sized) */
#hs-district-stats {
  width: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
  /* size to content, not to parent height */
  display: flex;
  flex-direction: column;
  background: rgba(10, 14, 23, 0.85);
  border: 1px solid transparent;
  border-radius: 6px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    border-color 0.4s;
}

#hs-district-stats.open {
  width: 240px;
  padding: 20px 16px;
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.1);
}

#hs-stats-content {
  width: 206px;
  /* 240 - 32px padding - 2px borders */
  min-width: 206px;
  display: flex;
  flex-direction: column;
  /* height NOT set — wraps content */
}

#hs-stats-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px 0;
  text-align: center;
}

#hs-stats-data {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.hs-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.04);
  padding: 8px;
  border-radius: 2px;
}

.hs-stat-row strong {
  font-family: var(--font-data);
  font-weight: 500;
  color: #fff;
}

.hs-stat-row strong.danger-text {
  color: var(--danger);
  font-weight: 700;
}

#hs-stats-action {
  margin-top: 16px;
}

.hs-district-action-btn {
  width: 100%;
  padding: 10px;
  background: rgba(31, 111, 235, 0.1);
  border: 1px solid rgba(31, 111, 235, 0.4);
  border-radius: 4px;
  color: #58a6ff;
  font-family: var(--font-data);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms, transform 100ms;
}

.hs-district-action-btn:hover {
  background: rgba(31, 111, 235, 0.25);
  border-color: #58a6ff;
  color: #fff;
  transform: translateY(-1px);
}

.hs-district-action-btn:active {
  transform: translateY(0);
  background: rgba(31, 111, 235, 0.35);
}

#hs-stats-action:hover {
  background: rgba(34, 197, 94, 0.15);
  color: #fff;
}

.dist-list-row {
  padding: 8px 10px;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 120ms;
}

.dist-list-row:hover {
  background: rgba(255, 255, 255, 0.06);
}

.dist-list-row.active {
  background: rgba(31, 111, 235, 0.12);
}

.dist-list-name {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.dist-list-alert {
  font-size: 9px;
  color: var(--danger);
}

/* ═══════════════════════════════════════════════════════════════════
   GLOBAL UTILITIES
═══════════════════════════════════════════════════════════════════ */

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════
   LIVE MODE ACTIVE STATES
   Applied when #map has class live-mode (via JS setMode)
═══════════════════════════════════════════════════════════════════ */

/* LIVE pill highlight in top bar */
#mode-live.active {
  background: rgba(26, 127, 55, 0.18);
  color: #3fb950;
}

/* Top bar subtle green border when live mode active */
body.live-active #topbar {
  border-bottom: 1px solid rgba(26, 127, 55, 0.30);
}

/* Density ribbon shimmer in Live Mode (spec §4) */
body.live-active #ta-ribbon {
  animation: ribbon-shimmer 3s ease-in-out infinite alternate;
}

@keyframes ribbon-shimmer {
  0% {
    filter: brightness(1.0);
  }

  100% {
    filter: brightness(1.06);
  }
}

/* Playhead stronger glow in Live Mode (spec §4) */
body.live-active #ta-playhead-line {
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* ═══════════════════════════════════════════════════════════════════
   PERFORMANCE OPTIMIZATIONS (Issue 4)
   Reduce layout reflow, enable GPU compositing hints
═══════════════════════════════════════════════════════════════════ */

/* Prevent timeline scroll from affecting map layout */
#tl-scroll {
  contain: layout style;
  overflow-anchor: none;
}

/* GPU-hint for animated Leaflet SVG paths.
   Applied by JS via _applyCatClass. Reduces main-thread paint cost. */
.leaflet-interactive.cat-health-path,
.leaflet-interactive.cat-emergency-path,
.leaflet-interactive.cat-infrastructure-path,
.leaflet-interactive.cat-mobility-path {
  will-change: stroke-opacity;
}

/* Timeline cards: contain painting to their box */
.tl-card-inner {
  contain: layout style paint;
}

/* Env overlays: already use opacity, add compositing hint */
.env-rain,
.env-haze {
  will-change: opacity;
}

/* ═══════════════════════════════════════════════════════════════════
   SETTINGS SIDEBAR PANEL — Bottom Left
═══════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════
   SETTINGS TRAY PANEL (Bottom Center Pull-up)
═══════════════════════════════════════════════════════════════════ */

#settings-tray-container {
  position: absolute;
  bottom: 0;
  /* Attach directly to the bottom of the map (above the 60px time axis via structural flow) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  /* Let clicks pass through container */
}

/* The small pull tab sitting on top */
.tray-pull-tab {
  pointer-events: auto;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  padding: 4px 20px;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}

.tray-pull-tab:hover {
  color: #fff;
  background: rgba(48, 54, 61, 0.95);
}

.tray-pull-tab[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.tray-pull-tab svg {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* The actual expanding panel */
#settings-panel {
  pointer-events: auto;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  overflow-y: auto;
  overflow-x: hidden;
  width: 90vw;
  max-width: 600px;
  /* Allows 2-3 columns easily */
  max-height: 45vh;
  /* Prevents escaping the top of the viewport */
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.5);
}

/* Custom dark scrollbars for the settings panel */
#settings-panel::-webkit-scrollbar {
  width: 6px;
}

#settings-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 8px 0 0;
}

#settings-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

#settings-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

#settings-panel.hidden {
  max-height: 0;
  opacity: 0;
  border-width: 0;
  overflow: hidden;
  /* Hide scrollbars physically when animating away */
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 16px 24px;
}

/* Settings Toggle Switch (Reused from previous) */
.setting-toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-data);
  color: #fff;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.05);
  /* Button-like appearance */
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s;
}

.setting-toggle-label:hover {
  background: rgba(255, 255, 255, 0.1);
}

.setting-toggle-label input[type="checkbox"] {
  display: none;
}

.setting-toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  transition: background 0.3s;
  flex-shrink: 0;
}

.setting-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.setting-toggle-label input[type="checkbox"]:checked+.setting-toggle-switch {
  background: #1F6FEB;
}

.setting-toggle-label input[type="checkbox"]:checked+.setting-toggle-switch::after {
  transform: translateX(16px);
}