/* ── MRMS Pro — matches /v3/gdd_pro aesthetic ──────────────────────── */

:root {
  --bg: #FAFAF8;
  --card: #FEFEFE;
  --ink: #0f172a;
  --muted: #64748b;
  --ring: #E8E7E3;
  --brand: #047857;
  --brand-ink: #064e3b;
  --brand-tint: rgba(4, 120, 87, 0.08);
  --brand-tint-border: rgba(4, 120, 87, 0.30);
  --danger: #dc2626;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }
body.page {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.wrap { max-width: 1400px; margin: 0 auto; padding: 0 16px; }
.section { padding: 16px 0; }
.section--map { padding-top: 8px; padding-bottom: 24px; }

/* ── Title row ─────────────────────────────────────────────────────── */
.mv-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 8px 0 0; }
.h2 {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 1.5rem; font-weight: 800; margin: 0;
  display: flex; align-items: center; gap: 10px;
}
.h2 i { color: var(--brand); font-size: 1.25rem; }
.mv-subtitle { color: var(--muted); margin: 4px 0 0; font-size: 0.95rem; max-width: 720px; }

/* ── Controls card ─────────────────────────────────────────────────── */
.mv-controls {
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.mv-controls__row {
  display: flex; flex-wrap: wrap; gap: 16px;
  align-items: flex-end;
}
.mv-controls__field { display: flex; flex-direction: column; gap: 6px; }
.mv-controls__field--grow { flex: 1; min-width: 320px; }
.mv-controls__label {
  display: block;
  font-weight: 600; font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mv-controls__input {
  padding: 10px 14px;
  font-size: 15px;
  border: 2px solid var(--ring);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  transition: all 0.15s ease;
  min-width: 160px;
}
.mv-controls__input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}

/* ── Layer chips (compact toggle pills) ─────────────────────────────── */
.mv-chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.mv-chip {
  display: inline-flex; align-items: center;
  padding: 5px 10px;
  background: var(--bg);
  border: 1.5px solid var(--ring);
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.mv-chip input[type=checkbox] {
  /* Hide the checkbox — the chip's bg color shows checked state */
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.mv-chip:has(input:checked) {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-ink);
}
.mv-chip--tornado:has(input:checked) { border-color: var(--danger); background: #fef2f2; color: #991b1b; }
.mv-chip--hail:has(input:checked)    { border-color: #16a34a; background: #f0fdf4; color: #166534; }
.mv-chip--wind:has(input:checked)    { border-color: #2563eb; background: #eff6ff; color: #1e40af; }

/* ── Primary button ────────────────────────────────────────────────── */
.mv-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1.5px solid transparent;
  white-space: nowrap;
}
.mv-btn--primary {
  background: var(--brand); color: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.2);
}
.mv-btn--primary:hover {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.3);
  transform: translateY(-1px);
}
.mv-btn--primary:disabled {
  opacity: 0.5; cursor: not-allowed; transform: none;
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.1);
}
.mv-btn--ghost {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand-tint-border);
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.08);
}
.mv-btn--ghost:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.2);
}
.mv-btn--xs { padding: 5px 10px; font-size: 11px; border-radius: 8px; gap: 5px; }
.mv-btn--danger { color: var(--danger); border-color: rgba(220,38,38,0.3); }
.mv-btn--danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ── Status row (below the controls) ───────────────────────────────── */
.mv-controls__status-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ring);
  min-height: 20px;
  display: flex; flex-wrap: wrap; gap: 8px 16px;
  align-items: center;
}
.mv-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
}
.mv-hint {
  font-size: 12px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.mv-hint i { color: var(--brand); }
.mv-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--brand-tint);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: mv-spin 0.8s linear infinite;
  flex: 0 0 auto;
}
@keyframes mv-spin { to { transform: rotate(360deg); } }

/* ── Map shell (wraps map card + legend so legend can absolute-position
     at desktop width and flow below on mobile) ───────────────────────── */
.mv-map-shell { position: relative; }

.mv-map-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* Glassy "click map to zoom/scroll" hint pill — top-right of the map.
   Hidden once the user clicks the map (handled in viewer-lite.js). */
.mv-scroll-hint {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 600;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  white-space: nowrap;
}

/* Glassy "Reset view" pill — bottom-left of the map. */
.mv-reset-view-btn {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  white-space: nowrap;
}
.mv-reset-view-btn:hover {
  background: rgba(15, 23, 42, 0.75);
}
.mv-reset-view-btn:active {
  transform: translateY(1px);
}

/* Glassy zoom +/- pill (overrides Leaflet's default white box) */
.mv-map-card .leaflet-control-zoom {
  border: 0 !important;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.mv-map-card .leaflet-control-zoom a,
.mv-map-card .leaflet-control-zoom a:link,
.mv-map-card .leaflet-control-zoom a:visited {
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  border: 0;
  border-bottom: 1px solid rgba(255,255,255,0.18);
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 18px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.mv-map-card .leaflet-control-zoom a:last-child {
  border-bottom: 0;
}
.mv-map-card .leaflet-control-zoom a:hover {
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
}
#mv-map {
  width: 100%;
  /* Fill the remaining viewport below the site nav + title + controls.
     Budget: ~80 site-header + ~60 title + ~160 controls + ~40 padding = 340.
     Min-height floor keeps the map usable on short viewports. */
  height: calc(100vh - 380px);
  min-height: 520px;
}

/* ── Legend (desktop: overlay bottom-right of map, wide enough to read) ── */
.mv-legend {
  position: absolute;
  bottom: 12px; right: 12px;
  z-index: 500;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(4px);
  padding: 10px 14px;
  border: 1px solid var(--ring);
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.4;
  width: 380px;
  max-width: calc(100% - 24px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.mv-legend h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.mv-legend h4:not(:first-child) { margin-top: 10px; }
.mv-legend .swatch {
  display: inline-block;
  width: 12px; height: 12px;
  vertical-align: middle;
  margin-right: 6px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.08);
}
.mv-legend .row {
  margin-bottom: 2px;
  display: flex; align-items: center;
  font-size: 11px;
}

/* ── Storm report markers (unchanged glyph shapes) ─────────────────── */
.mv-marker { display: block; }
.mv-marker--tornado {
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 14px solid var(--danger);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}
.mv-marker--hail {
  border-radius: 50%;
  background: #16a34a;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.mv-marker--wind {
  background: #2563eb;
  border: 1.5px solid #fff;
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.mv-popup { font-size: 12px; line-height: 1.45; }
.mv-popup b { text-transform: capitalize; color: var(--brand-ink); }

/* ── Full-screen loading overlay (matches gdd_pro .gdd-loading) ────── */
.mv-loading {
  position: fixed; inset: 0;
  z-index: 8000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(248,250,252,0.7);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.mv-loading--active { opacity: 1; pointer-events: auto; }
.mv-loading__spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: mv-spin 0.8s linear infinite;
}
.mv-loading__text {
  font-size: 14px; font-weight: 600;
  color: var(--muted);
}

/* ── User location bullseye (pulsing blue dot) ─────────────────────── */
.mv-user-dot { background: none !important; border: none !important; pointer-events: none; }
.mv-user-dot .mv-user-dot__ring {
  position: absolute; top: 0; left: 0;
  width: 24px; height: 24px;
  border: 2px solid #2563eb;
  border-radius: 50%;
  box-sizing: border-box;
  animation: mv-user-pulse 1.6s ease-out infinite;
}
.mv-user-dot .mv-user-dot__core {
  position: absolute; top: 8px; left: 8px;
  width: 8px; height: 8px;
  background: #2563eb;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
}
@keyframes mv-user-pulse {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ── Drop-pin marker ────────────────────────────────────────────────── */
.mv-pin { background: none !important; border: none !important; }
.mv-pin i {
  font-size: 32px;
  color: var(--brand);
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}

/* ── Pin popup timeline ─────────────────────────────────────────────── */
.leaflet-popup-content-wrapper:has(.mv-pin-popup) { border-radius: 10px; }
.mv-pin-popup { font-size: 12px; line-height: 1.4; min-width: 280px; }
.mv-pin-popup__header {
  font-weight: 700; color: var(--brand-ink);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.mv-pin-popup__header i { color: var(--brand); }
.mv-pin-popup__stats {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 11px; color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ring);
}
.mv-pin-popup__stats b { color: var(--ink); font-size: 12px; }
.mv-pin-popup__table {
  width: 100%; border-collapse: collapse;
  font-size: 11px;
}
.mv-pin-popup__table th {
  text-align: left; padding: 4px 6px;
  color: var(--muted); font-weight: 600;
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--ring);
}
.mv-pin-popup__table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(232,231,227,0.5);
}
.mv-pin-popup__table td:nth-child(2),
.mv-pin-popup__table td:nth-child(3) { font-variant-numeric: tabular-nums; }
.mv-pin-popup__table tr:last-child td { border-bottom: none; }
.mv-pin-popup__muted { color: var(--muted); }
.mv-pin-popup__empty { padding: 8px 0; color: var(--muted); font-style: italic; }
/* Notable-days collapsible section */
.mv-pin-popup__details { margin-top: 6px; }
.mv-pin-popup__details summary {
  cursor: pointer; font-size: 11px; font-weight: 600;
  color: var(--brand); user-select: none;
  margin-bottom: 4px;
}
.mv-pin-popup__details summary:hover { text-decoration: underline; }
.mv-pin-popup__details .mv-pin-popup__table { max-height: 200px; overflow-y: auto; display: block; }
.mv-pin-popup__details .mv-pin-popup__table thead,
.mv-pin-popup__details .mv-pin-popup__table tbody { display: table; width: 100%; table-layout: fixed; }

/* ── Mini bar chart (inside pin popup) ─────────────────────────────── */
.mv-chart { position: relative; margin: 8px 0; }
.mv-chart__bars {
  display: flex;
  align-items: flex-end;
  height: 70px;
  gap: 0;
  border-bottom: 1px solid var(--ring);
  border-left: 1px solid var(--ring);
  padding-left: 1px;
}
.mv-chart__col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  height: 100%;
  cursor: default;
}
.mv-chart__fill {
  background: #3b82f6;
  min-height: 0;
  border-radius: 1px 1px 0 0;
  transition: height 0.15s ease;
}
.mv-chart__fill--hail {
  background: linear-gradient(to top, #3b82f6 40%, #16a34a);
}
.mv-chart__dot {
  width: 100%; max-width: 6px; height: 4px;
  background: #dc2626;
  border-radius: 1px;
  margin: 2px auto 0;
  flex: 0 0 auto;
}
.mv-chart__axis {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  padding-top: 3px;
  line-height: 1;
}
.mv-chart__scale {
  position: absolute;
  top: -2px; left: 0;
  font-size: 9px;
  color: var(--muted);
  background: rgba(255,255,255,0.85);
  padding: 0 2px;
  line-height: 1;
}
.mv-chart__legend {
  display: flex;
  gap: 10px;
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
  justify-content: center;
}
.mv-chart__swatch {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 1px;
  vertical-align: middle;
  margin-right: 2px;
}
.mv-chart__swatch--rain { background: #3b82f6; }
.mv-chart__swatch--hail { background: linear-gradient(to top, #3b82f6, #16a34a); }
.mv-chart__swatch--dot  { background: #dc2626; border-radius: 50%; width: 6px; height: 6px; }

.mv-pin-popup__footer {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--ring);
  display: flex; gap: 6px; flex-wrap: wrap;
}

/* ── Pin detail panel (expanded view below map) ────────────────────── */
.mv-pin-panel {
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.mv-pin-panel__topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ring);
}
.mv-pin-panel__title {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 1.1rem; font-weight: 800;
  color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.mv-pin-panel__title i { color: var(--brand); }
.mv-pin-panel__actions { display: flex; gap: 8px; }
.mv-pin-panel__stats {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}
.mv-pin-panel__stat {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: var(--bg);
  border: 1px solid var(--ring);
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--ink);
}
.mv-pin-panel__stat b { color: var(--brand); font-weight: 700; }
.mv-pin-panel__chart-wrap { margin-bottom: 16px; }
.mv-pin-panel__chart-wrap .mv-chart__bars { height: 100px; }

/* Full-width report table inside the panel */
.mv-pin-panel__table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.mv-pin-panel__table th {
  text-align: left; padding: 8px 10px;
  color: var(--muted); font-weight: 600;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--ring);
  position: sticky; top: 0; background: var(--card);
}
.mv-pin-panel__table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(232,231,227,0.5);
}
.mv-pin-panel__table tr:hover td { background: var(--bg); }
.mv-pin-panel__table-wrap {
  max-height: 400px; overflow-y: auto;
  border: 1px solid var(--ring);
  border-radius: 10px;
  margin-top: 12px;
}
.mv-pin-panel__section-label {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 16px 0 6px;
}
.mv-pin-panel__muted { color: var(--muted); }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .mv-controls { padding: 16px; }
  .mv-controls__row { gap: 12px; }
  .mv-controls__input { min-width: 0; width: 100%; }
  .mv-controls__field { min-width: 140px; }
  .mv-controls__field--grow { flex: 1 1 100%; min-width: 0; }
  /* Give the map more vertical room since the legend is no longer overlaid */
  #mv-map { height: 60vh; min-height: 360px; }
  /* Legend: break out of overlay, render as a full-width card below the map */
  .mv-legend {
    position: static;
    top: auto; right: auto; bottom: auto;
    margin-top: 12px;
    max-width: none;
    width: 100%;
    font-size: 12px;
    background: var(--card);
    backdrop-filter: none;
    padding: 14px 16px;
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  /* Hide the click-to-zoom hint on touch — touchstart immediately enables it */
  .mv-scroll-hint { display: none; }
  .h2 { font-size: 1.25rem; }
}
