/* ===== Design tokens ===== */
:root {
  --font-display: 'Montserrat', Arial, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.2vw, 0.9375rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --text-lg: clamp(1.05rem, 0.95rem + 0.4vw, 1.25rem);
  --text-xl: clamp(1.35rem, 1.1rem + 0.9vw, 1.9rem);

  --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;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-full: 9999px;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --header-h: 68px;
}

:root, [data-theme="light"] {
  /* Matched to bambricksellsflorida.com — sky-blue brand palette */
  --navy: #54a4e4;        /* site brand blue (header, buttons, accents) */
  --navy-deep: #3d87c4;   /* darker hover shade */
  --aqua: #a9d3f0;        /* light sky accent */
  --alabaster: #ffffff;   /* white body, like the site */
  --surface: #ffffff;
  --surface-2: #f0f0f8;   /* site utility-bar tint */
  --surface-alt: #f4f7fb;
  --text: #181818;        /* site near-black body text */
  --text-muted: #8c8c8c;  /* site meta/date gray */
  --border: #d8e5f2;
  --divider: #e6eef7;
  --launch: #d4373a;      /* firework red */
  --launch-glow: rgba(212,55,58,0.35);
  --gold: #f5a623;        /* site star/rating gold */
  --shadow-sm: 0 1px 3px rgba(15,26,46,0.08);
  --shadow-md: 0 4px 16px rgba(15,26,46,0.10);
  --shadow-lg: 0 12px 34px rgba(15,26,46,0.16);
}

[data-theme="dark"] {
  --navy: #6fb4ec;
  --navy-deep: #54a4e4;
  --aqua: #8ec4ea;
  --alabaster: #0e1524;
  --surface: #16203400;
  --surface: #172033;
  --surface-2: #1d2942;
  --surface-alt: #1a2438;
  --text: #e6ecf7;
  --text-muted: #97a2ba;
  --border: #2d3a55;
  --divider: #263349;
  --launch: #ff5d60;
  --launch-glow: rgba(255,93,96,0.4);
  --gold: #e8c14a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg: 0 12px 34px rgba(0,0,0,0.55);
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text);
  background: var(--alabaster);
  line-height: 1.55;
  min-height: 100dvh;
  overflow: hidden;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; line-height: 1.15; letter-spacing: 0.01em; }
button { cursor: pointer; background: none; border: none; color: inherit; font: inherit; transition: all var(--transition); }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: var(--radius-sm); }
select, input { font: inherit; color: inherit; }

/* ===== Header ===== */
.site-header {
  height: var(--header-h);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  gap: var(--space-4);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-logo-wrap {
  width: 44px; height: 44px; flex-shrink: 0;
  background: #fff; border-radius: 10px;
  display: grid; place-items: center; padding: 4px;
  box-shadow: var(--shadow-sm);
}
.brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text { display: flex; align-items: baseline; gap: 0.35em; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: var(--text-sm); letter-spacing: 0.02em; white-space: nowrap; }
.brand-sub { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; color: var(--aqua); white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: var(--space-4); }
.header-title { text-align: right; }
.header-title h1 { font-size: var(--text-lg); font-weight: 800; }
.header-title p { font-family: var(--font-body); font-size: var(--text-xs); text-transform: none; color: var(--aqua); font-weight: 500; letter-spacing: 0; }
.weather-btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: rgba(255,255,255,0.14); color: #fff;
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase;
  font-size: var(--text-xs); letter-spacing: 0.03em;
  padding: 0.6em 1em; border-radius: var(--radius-full);
  border: 1.5px solid rgba(255,255,255,0.4);
}
.weather-btn svg { width: 16px; height: 16px; }
.weather-btn:hover { background: rgba(255,255,255,0.26); }
.weather-btn.active { background: #fff; color: var(--navy); border-color: #fff; }

.theme-toggle {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  display: grid; place-items: center; color: #fff;
  background: rgba(255,255,255,0.12);
}
.theme-toggle:hover { background: rgba(255,255,255,0.22); }

/* ===== Layout ===== */
.layout { display: flex; height: calc(100dvh - var(--header-h)); }
.sidebar {
  width: 400px; flex-shrink: 0;
  background: var(--alabaster);
  border-right: 1px solid var(--divider);
  overflow-y: auto;
  padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }

/* ===== Panels ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.panel-head h2 { font-size: var(--text-sm); color: var(--navy); display: flex; align-items: center; gap: var(--space-2); }
.panel-head h2 svg { width: 17px; height: 17px; }
.reset-btn { font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.reset-btn:hover { color: var(--navy); }
.count-badge { background: var(--navy); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: var(--text-xs); padding: 0.15em 0.6em; border-radius: var(--radius-full); min-width: 24px; text-align: center; }

/* ===== Filters ===== */
.filter-group { margin-bottom: var(--space-4); }
.filter-group:last-child { margin-bottom: 0; }
.filter-label { display: block; font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: var(--text-xs); color: var(--text-muted); letter-spacing: 0.04em; margin-bottom: var(--space-2); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  font-size: var(--text-xs); font-weight: 600;
  padding: 0.4em 0.75em;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  background: var(--surface);
  display: inline-flex; align-items: center; gap: 0.35em;
}
.chip svg { width: 14px; height: 14px; }
.chip:hover { border-color: var(--navy); color: var(--navy); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filter-checkbox { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; cursor: pointer; }
.filter-checkbox input { width: 17px; height: 17px; accent-color: var(--navy); cursor: pointer; }
.sort-select {
  width: 100%; padding: 0.55em 0.75em;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); font-size: var(--text-sm); cursor: pointer;
}

/* ===== Event list ===== */
.list-panel { flex: 0 0 auto; }
.event-list { display: flex; flex-direction: column; gap: var(--space-2); max-height: 460px; overflow-y: auto; padding-right: 2px; }
.event-card {
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  background: var(--surface);
  transition: all var(--transition);
  border-left: 3px solid var(--aqua);
}
.event-card:hover { border-color: var(--navy); border-left-color: var(--navy); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.event-card.active { border-color: var(--navy); border-left-color: var(--launch); background: var(--surface-alt); box-shadow: var(--shadow-md); }
.event-card.no-fireworks { border-left-color: var(--text-muted); }
.ec-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-1); }
.ec-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); text-transform: none; line-height: 1.25; color: var(--text); }
.ec-time { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xs); color: var(--launch); white-space: nowrap; display: flex; align-items: center; gap: 0.25em; }
.ec-time.no-fw { color: var(--text-muted); }
.ec-meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }
.ec-meta span { display: inline-flex; align-items: center; gap: 0.3em; }
.ec-meta svg { width: 12px; height: 12px; }
.ec-tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-2); }
.tag { font-size: 0.7rem; font-weight: 600; padding: 0.15em 0.5em; border-radius: var(--radius-sm); text-transform: uppercase; letter-spacing: 0.02em; }
.tag.area { background: var(--navy); color: #fff; }
.tag.parking-public { background: rgba(67,122,34,0.14); color: #2e6b12; }
.tag.parking-paid { background: rgba(212,160,23,0.16); color: #97710a; }
.tag.parking-mixed { background: var(--surface-2); color: var(--navy); }
[data-theme="dark"] .tag.parking-public { color: #7fc25a; }
[data-theme="dark"] .tag.parking-paid { color: var(--gold); }

/* ===== Traffic ===== */
.traffic-intro { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-3); }
.traffic-list { display: flex; flex-direction: column; gap: var(--space-2); }
.traffic-item {
  border: 1px solid var(--divider); border-radius: var(--radius-md);
  padding: var(--space-3); font-size: var(--text-xs);
  border-left: 3px solid var(--gold); background: var(--surface);
}
.traffic-item.high { border-left-color: var(--launch); }
.traffic-item.medium { border-left-color: var(--gold); }
.traffic-item.low { border-left-color: var(--aqua); }
.ti-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-1); }
.ti-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xs); text-transform: none; color: var(--text); line-height: 1.25; }
.ti-sev { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; padding: 0.1em 0.45em; border-radius: var(--radius-sm); white-space: nowrap; }
.ti-sev.high { background: var(--launch); color: #fff; }
.ti-sev.medium { background: var(--gold); color: #3a2c00; }
.ti-sev.low { background: var(--aqua); color: #0f3d3c; }
.ti-detail { color: var(--text-muted); line-height: 1.5; }

/* ===== Footer ===== */
.sidebar-footer { padding: var(--space-2) var(--space-1) var(--space-4); }
.disclaimer { font-size: 0.7rem; color: var(--text-muted); line-height: 1.5; margin-bottom: var(--space-2); }
.attribution { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; }

/* ===== Map markers ===== */
.marker {
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 150ms ease;
}
.marker:hover { transform: scale(1.18); z-index: 5; }
.marker-launch {
  width: 30px; height: 30px; border-radius: var(--radius-full);
  background: var(--launch); color: #fff;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 4px var(--launch-glow), var(--shadow-md);
}
.marker-launch svg { width: 16px; height: 16px; }
.marker-launch.dimmed { opacity: 0.25; filter: grayscale(0.6); }
.marker-launch.selected { transform: scale(1.3); z-index: 6; box-shadow: 0 0 0 6px var(--launch-glow), var(--shadow-lg); }
.marker-view {
  width: 15px; height: 15px; border-radius: var(--radius-full);
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}
.marker-view.public { background: #43a022; }
.marker-view.paid { background: var(--gold); }

/* ===== Popup ===== */
.maplibregl-popup { max-width: 320px !important; }
.maplibregl-popup-content {
  border-radius: var(--radius-lg) !important;
  padding: 0 !important;
  box-shadow: var(--shadow-lg) !important;
  background: var(--surface) !important;
  border: 1px solid var(--divider);
  overflow: hidden;
  font-family: var(--font-body);
}
.maplibregl-popup-close-button { font-size: 20px !important; color: #fff !important; padding: 2px 8px !important; z-index: 3; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.popup {
  color: var(--text);
}
.popup-head { background: var(--navy); color: #fff; padding: var(--space-3) var(--space-4); }
.popup-head.no-fw { background: var(--text-muted); }
.popup-title { font-family: var(--font-display); font-weight: 700; font-size: var(--text-sm); line-height: 1.25; margin-bottom: 0.15em; }
.popup-host { font-size: var(--text-xs); color: var(--aqua); }
.popup-body { padding: var(--space-3) var(--space-4) var(--space-4); }
.popup-row { display: flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-xs); margin-bottom: var(--space-2); color: var(--text); }
.popup-row svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--navy); margin-top: 1px; }
.popup-row strong { color: var(--text); font-weight: 600; }
.popup-blurb { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.5; margin: var(--space-2) 0 var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--divider); }
.popup-tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-bottom: var(--space-3); }
.popup-access { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-1) 0 var(--space-3); }
.access-tag { font-size: 0.68rem; font-weight: 600; padding: 0.18em 0.5em; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--navy); display: inline-flex; align-items: center; gap: 0.25em; }
.access-tag svg { width: 11px; height: 11px; color: var(--navy); }
.popup-links { display: flex; flex-direction: column; gap: var(--space-1); }
.popup-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  background: var(--navy); color: #fff; font-family: var(--font-display); font-weight: 700;
  text-transform: uppercase; font-size: var(--text-xs); letter-spacing: 0.03em;
  padding: 0.6em 1em; border-radius: var(--radius-md); text-decoration: none !important;
}
.popup-btn:hover { background: var(--navy-deep); }
.popup-btn.secondary { background: var(--surface-2); color: var(--navy); }
.popup-btn.secondary:hover { background: var(--aqua); color: #0f3d3c; }
.popup-btn svg { width: 14px; height: 14px; }
.popup-sources { font-size: 0.68rem; color: var(--text-muted); margin-top: var(--space-2); }
.popup-sources a { color: var(--navy); }
.popup-flag { font-size: 0.66rem; font-weight: 600; color: #2e6b12; display: inline-flex; align-items: center; gap: 0.25em; margin-top: var(--space-1); }
[data-theme="dark"] .popup-flag { color: #7fc25a; }
.popup-flag svg { width: 11px; height: 11px; }

/* ===== Weather panel ===== */
.weather-panel {
  position: absolute; top: var(--space-4); left: var(--space-4);
  width: 340px; max-width: calc(100% - 2 * var(--space-4));
  background: var(--surface); border: 1px solid var(--divider);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 12; overflow: hidden;
  animation: wpIn 220ms cubic-bezier(0.16,1,0.3,1);
}
@keyframes wpIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.wp-head { display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: #fff; padding: var(--space-3) var(--space-4); }
.wp-head h2 { font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); }
.wp-head h2 svg { width: 17px; height: 17px; }
.wp-close { color: #fff; display: grid; place-items: center; width: 26px; height: 26px; border-radius: var(--radius-sm); }
.wp-close:hover { background: rgba(255,255,255,0.2); }
.wp-close svg { width: 16px; height: 16px; }

.forecast-strip { display: flex; gap: var(--space-2); padding: var(--space-3); }
.wp-loading { font-size: var(--text-xs); color: var(--text-muted); padding: var(--space-3); }
.day-card {
  flex: 1; border: 1px solid var(--divider); border-radius: var(--radius-md);
  padding: var(--space-3); background: var(--surface-alt);
}
.dc-day { font-family: var(--font-display); font-weight: 700; font-size: var(--text-xs); text-transform: uppercase; color: var(--navy); letter-spacing: 0.03em; }
.dc-icon { font-size: 1.7rem; line-height: 1; margin: var(--space-1) 0; }
.dc-temp { font-family: var(--font-display); font-weight: 700; font-size: var(--text-base); color: var(--text); }
.dc-temp span { color: var(--text-muted); font-weight: 400; font-size: var(--text-xs); }
.dc-cond { font-size: 0.72rem; color: var(--text-muted); margin: 2px 0 var(--space-2); line-height: 1.3; min-height: 2.2em; }
.dc-fireworks {
  border-top: 1px dashed var(--border); padding-top: var(--space-2); margin-top: auto;
}
.dc-fw-label { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-muted); display: flex; align-items: center; gap: 0.3em; }
.dc-fw-label svg { width: 11px; height: 11px; }
.dc-fw-val { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); line-height: 1.1; margin-top: 1px; }
.rain-low { color: #2e9e4f; }
.rain-med { color: var(--gold); }
.rain-high { color: var(--launch); }

.radar-controls { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-top: 1px solid var(--divider); background: var(--surface-2); }
.radar-play { width: 34px; height: 34px; border-radius: var(--radius-full); background: var(--navy); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.radar-play:hover { background: var(--navy-deep); }
.radar-play svg { width: 16px; height: 16px; }
.radar-track { flex: 1; min-width: 0; }
.radar-time { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
#radarSlider { width: 100%; accent-color: var(--navy); cursor: pointer; }
.radar-legend { font-size: 0.66rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.3em; white-space: nowrap; }
.rl-swatch { width: 34px; height: 8px; border-radius: 4px; display: inline-block; background: linear-gradient(90deg,#7fd0f0,#2e9e4f,#f5c542,#f5a623,#d4373a); }
.wp-note { font-size: 0.7rem; color: var(--text-muted); padding: var(--space-2) var(--space-3) var(--space-3); line-height: 1.45; }

/* ===== Legend ===== */
.map-legend {
  position: absolute; bottom: var(--space-4); right: var(--space-4);
  background: var(--surface); border: 1px solid var(--divider);
  border-radius: var(--radius-md); padding: var(--space-3);
  box-shadow: var(--shadow-md); font-size: var(--text-xs); z-index: 10;
}
.legend-title { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: 0.7rem; color: var(--navy); margin-bottom: var(--space-2); letter-spacing: 0.04em; }
.legend-item { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 0.35em; color: var(--text); }
.legend-item:last-child { margin-bottom: 0; }
.legend-dot { width: 13px; height: 13px; border-radius: var(--radius-full); border: 2px solid #fff; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.legend-dot.launch { background: var(--launch); }
.legend-dot.viewing { background: var(--navy); }
.legend-swatch { width: 13px; height: 13px; border-radius: var(--radius-full); flex-shrink: 0; }
.legend-swatch.public { background: #43a022; }
.legend-swatch.paid { background: var(--gold); }

/* ===== Mobile ===== */
.mobile-list-toggle {
  position: absolute; bottom: var(--space-4); left: var(--space-4);
  background: var(--navy); color: #fff; z-index: 11;
  padding: 0.7em 1.1em; border-radius: var(--radius-full);
  font-family: var(--font-display); font-weight: 700; text-transform: uppercase; font-size: var(--text-xs);
  box-shadow: var(--shadow-lg); display: none; align-items: center; gap: var(--space-2);
}
.mobile-list-toggle svg { width: 16px; height: 16px; }

@media (max-width: 860px) {
  body { overflow: auto; }
  .layout { flex-direction: column; height: auto; }
  .site-header { flex-wrap: wrap; height: auto; padding: var(--space-3) var(--space-4); gap: var(--space-2); }
  .header-title { text-align: left; }
  .map-wrap { order: -1; height: 55vh; min-height: 340px; position: relative; }
  #map { position: absolute; }
  .sidebar { width: 100%; height: auto; border-right: none; border-top: 1px solid var(--divider); }
  .event-list { max-height: none; }
  .mobile-list-toggle { display: inline-flex; }
  .map-legend { bottom: auto; top: var(--space-3); right: var(--space-3); padding: var(--space-2); }
  .weather-btn span { display: none; }
  .weather-btn { padding: 0.6em; }
  .weather-panel { top: var(--space-3); left: var(--space-3); width: calc(100% - 2 * var(--space-3)); max-width: 360px; }
}
