@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Syne:wght@700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Full-screen map ────────────────────────────── */
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: #b8c0cc;
}

/* ── Glass utility ──────────────────────────────── */
.glass {
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.6);
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
}

/* ── Top bar ────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 14px; left: 14px; right: 14px;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 50px;
  pointer-events: all;
}

.brand-wrap {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg,#1a3a80,#2a5fd4);
  display: grid; place-items: center;
  font-family: 'Syne', sans-serif; font-weight: 800; font-size: .85rem;
  color: #f5c842;
}
.brand-name {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 1rem; color: #111; letter-spacing: -.02em;
}
.brand-name em { color: #2a5fd4; font-style: normal; }

.searchbar {
  display: flex; align-items: center; gap: 8px;
  flex: 1; max-width: 340px;
  background: rgba(0,0,0,.06);
  border-radius: 50px; padding: 7px 16px;
  border: 1px solid rgba(0,0,0,.08);
  transition: background .15s;
}
.searchbar:focus-within { background: rgba(0,0,0,.09); }
.search-icon { width: 16px; height: 16px; color: #666; flex-shrink: 0; }
.searchbar input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; font-size: .9rem; color: #111;
}
.searchbar input::placeholder { color: #999; }

/* ── Left layer panel ───────────────────────────── */
.layer-panel {
  position: fixed;
  top: 50%; left: 14px;
  transform: translateY(-50%);
  z-index: 800;
  border-radius: 18px;
  padding: 8px 6px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 130px;
}

.layer-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 0; background: transparent;
  border-radius: 12px; cursor: pointer;
  font: inherit; font-size: .88rem; font-weight: 500;
  color: #444;
  transition: background .15s, color .15s;
  text-align: left;
  width: 100%;
}
.layer-btn:hover { background: rgba(0,0,0,.07); color: #111; }
.layer-btn.active {
  background: #2a5fd4;
  color: #fff;
}
.layer-btn.sm { font-size: .82rem; padding: 8px 12px; color: #666; }
.layer-btn.sm:hover { color: #111; }
.l-icon { font-size: 1.1rem; flex-shrink: 0; }
.l-label { white-space: nowrap; }

.layer-sep {
  height: 1px; background: rgba(0,0,0,.08);
  margin: 4px 8px;
}

/* ── Right detail panel ─────────────────────────── */
.detail-panel {
  position: fixed;
  top: 76px; right: 14px; bottom: 84px;
  z-index: 800;
  border-radius: 20px;
  width: 290px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 16px;
}
.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 4px; }

.dp-header {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.dp-city {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 1.5rem; color: #111; letter-spacing: -.02em;
  line-height: 1.1;
}
.dp-region { font-size: .8rem; color: #888; margin-top: 2px; }
.dp-icon { font-size: 2.6rem; line-height: 1; }

.dp-temp-row {
  display: flex; align-items: baseline; gap: 12px;
}
.dp-temp {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 3.4rem; line-height: 1; color: #111;
  letter-spacing: -.04em;
}
.dp-temp-sub { font-size: .82rem; color: #777; }
.dp-temp-sub strong { color: #333; }

.dp-metrics {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dp-metric {
  background: rgba(0,0,0,.04);
  border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.dm-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: #888; }
.dp-metric strong { font-size: .95rem; font-weight: 600; color: #111; }

.dp-tabs {
  display: flex; gap: 4px;
  background: rgba(0,0,0,.06);
  border-radius: 10px; padding: 3px;
}
.dp-tab {
  flex: 1; padding: 7px;
  border: 0; background: transparent;
  border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .82rem; font-weight: 500;
  color: #666; transition: all .15s;
}
.dp-tab.active { background: #fff; color: #111; box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* Forecast cards */
.dp-forecast, .dp-hourly {
  display: flex; flex-direction: column; gap: 6px;
}
.dp-hourly { flex-direction: row; overflow-x: auto; gap: 8px; padding-bottom: 4px; }
.dp-hourly::-webkit-scrollbar { height: 3px; }
.dp-hourly::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }

.hidden { display: none !important; }

.fc-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(0,0,0,.04);
  border-radius: 12px;
}
.fc-day { font-size: .8rem; font-weight: 600; color: #555; min-width: 64px; }
.fc-icon { font-size: 1.3rem; }
.fc-temp { font-size: 1rem; font-weight: 700; color: #111; margin-left: auto; }
.fc-desc { font-size: .75rem; color: #888; flex: 1; text-align: right; }

.hc-card {
  flex-shrink: 0; min-width: 60px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 8px;
  background: rgba(0,0,0,.04);
  border-radius: 12px;
}
.hc-time { font-size: .72rem; color: #888; }
.hc-icon { font-size: 1.2rem; }
.hc-temp { font-size: .9rem; font-weight: 700; color: #111; }

.dp-footer {
  font-size: .75rem; color: #aaa; text-align: center;
  padding-top: 4px; border-top: 1px solid rgba(0,0,0,.07);
}

/* ── Bottom timeline ────────────────────────────── */
.timeline-bar {
  position: fixed;
  bottom: 14px; left: 14px; right: 14px;
  z-index: 800;
  border-radius: 18px;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px;
  height: 64px;
}

.tl-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.tl-step {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid rgba(0,0,0,.12); background: transparent;
  font-size: 1.1rem; color: #444; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s;
}
.tl-step:hover { background: rgba(0,0,0,.08); }
.tl-play {
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: #2a5fd4; color: #fff;
  font-size: .95rem; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(42,95,212,.35);
  transition: opacity .15s;
}
.tl-play:hover { opacity: .88; }
.tl-play:disabled { opacity: .4; cursor: not-allowed; }

.tl-slider-wrap {
  flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.tl-time-labels {
  display: flex; justify-content: space-between;
  font-size: .68rem; color: #888; padding: 0 2px;
  height: 14px; align-items: center;
}
.tl-time-labels span { white-space: nowrap; }

#timelineRange {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 4px;
  background: rgba(0,0,0,.12); outline: none; cursor: pointer;
}
#timelineRange::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #2a5fd4; cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
#timelineRange::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #2a5fd4; cursor: pointer;
  border: 2px solid #fff;
}
#timelineRange:disabled { opacity: .4; cursor: not-allowed; }

.tl-info { flex-shrink: 0; text-align: right; }
.tl-current-time { font-weight: 600; font-size: .88rem; color: #111; }
.tl-layer-name { font-size: .75rem; color: #888; margin-top: 2px; }

/* ── dBZ legend ─────────────────────────────────── */
.dbz-legend {
  position: fixed;
  bottom: 90px; right: 316px;
  z-index: 800;
  border-radius: 12px;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
}
.legend-lbl { font-size: .72rem; font-weight: 700; color: #555; }
.legend-gradient {
  width: 120px; height: 10px; border-radius: 4px;
  background: linear-gradient(to right, #0000ff, #00ffff, #00ff00, #ffff00, #ff8000, #ff0000);
}
.legend-scale {
  display: flex; justify-content: space-between;
  font-size: .65rem; color: #888;
  width: 120px; margin-top: 2px;
  position: absolute;
  bottom: 6px; left: 44px;
}

/* ── Leaflet overrides ──────────────────────────── */
.leaflet-control-zoom {
  margin-top: 80px !important;
  margin-left: 160px !important;
  border: none !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.15) !important;
  border-radius: 12px !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  width: 36px !important; height: 36px !important;
  line-height: 36px !important;
  background: rgba(255,255,255,.9) !important;
  color: #333 !important;
  font-size: 1rem !important;
  border: none !important;
  border-bottom: 1px solid rgba(0,0,0,.08) !important;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: #fff !important; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.75) !important;
  color: #888 !important;
  border-radius: 8px 0 0 0;
  font-size: .65rem !important;
  bottom: 68px !important;
}

/* ── City tooltip ───────────────────────────────── */
.leaflet-tooltip {
  background: rgba(255,255,255,.92) !important;
  border: 1px solid rgba(0,0,0,.1) !important;
  border-radius: 6px !important;
  color: #111 !important;
  font-size: .8rem !important;
  font-family: 'DM Sans', sans-serif !important;
  padding: 4px 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.12) !important;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
  .detail-panel { width: 250px; }
  .dbz-legend { right: 278px; }
}
@media (max-width: 700px) {
  .topbar { top: 8px; left: 8px; right: 8px; padding: 8px 12px; }
  .brand-name { display: none; }
  .detail-panel { right: 8px; top: 64px; bottom: 76px; width: 230px; }
  .layer-panel { left: 8px; }
  .timeline-bar { bottom: 8px; left: 8px; right: 8px; }
  .dbz-legend { display: none; }
}
@media (max-width: 500px) {
  .detail-panel { display: none; }
}

/* ── Locate button ──────────────────────────────────── */
.locate-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: transparent;
  display: grid; place-items: center;
  cursor: pointer; color: #666; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.locate-btn svg { width: 18px; height: 18px; }
.locate-btn:hover { background: rgba(0,0,0,.08); color: #2a5fd4; }
.locate-btn.locating { color: #888; animation: spin 1s linear infinite; }
.locate-btn.located { color: #2a5fd4; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── User location dot ──────────────────────────────── */
.loc-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #2a5fd4;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 6px rgba(42,95,212,.5);
  position: relative;
}
.loc-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(42,95,212,.2);
  animation: locpulse 2s ease-out infinite;
}
@keyframes locpulse {
  0%   { transform: scale(.6); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ── Timeline forecast segment ──────────────────────── */
.tl-time-labels {
  position: relative;
  height: 18px;
}
.tl-time-labels span {
  position: absolute;
  white-space: nowrap;
  font-size: .65rem;
  color: #888;
}

#timelineRange.has-forecast {
  background: linear-gradient(
    to right,
    rgba(42,95,212,.25) 0%,
    rgba(42,95,212,.25) var(--forecast-start, 70%),
    rgba(224,144,32,.25) var(--forecast-start, 70%),
    rgba(224,144,32,.25) 100%
  ) !important;
}

.forecast-badge {
  position: absolute;
  bottom: 28px;
  font-size: .62rem;
  font-weight: 700;
  color: #e09020;
  letter-spacing: .05em;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(255,255,255,.8);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(224,144,32,.3);
  pointer-events: none;
}

/* ── Now marker ─────────────────────────────────────── */
.now-marker {
  position: absolute;
  top: -6px;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.now-marker span {
  background: #2a5fd4;
  color: #fff;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 2px 5px;
  border-radius: 4px;
  white-space: nowrap;
}
.now-marker::after {
  content: '';
  width: 2px;
  height: 22px;
  background: #2a5fd4;
  border-radius: 0 0 2px 2px;
}

.tl-slider-wrap {
  position: relative;
}

/* Auto-refresh badge */
.radar-refresh-badge {
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(42,95,212,.9);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  z-index: 900;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.radar-refresh-badge.show { opacity: 1; }
