/* ===== Map-first homepage layout ===== */

html, body.map-body { height: 100%; margin: 0; overflow: hidden; }

.mapapp { position: relative; width: 100%; height: 100vh; height: 100dvh; --drawer-w: 0px; }
.mapapp.drawer-open { --drawer-w: 420px; }
@media (max-width: 760px) {
  .mapapp.drawer-open { --drawer-w: 100vw; }
}

.map-canvas { position: absolute; inset: 0; background: #0a1830; z-index: 1; }

/* Recolor plain OSM tiles into WeatherAccurate's own dark navy palette
   instead of depending on a paid dark-tile provider (CARTO's free dark
   basemap now requires a signup key). Classic CSS-invert dark-map trick. */
.leaflet-tile-pane {
  filter: invert(1) hue-rotate(190deg) brightness(0.82) contrast(0.92) saturate(0.55);
}
.leaflet-container { background: #0a1830; font-family: inherit; }
.leaflet-control-zoom a {
  background: rgba(10, 22, 45, 0.85) !important;
  color: var(--text-1) !important;
  border-color: var(--card-border) !important;
}
.leaflet-control-zoom a:hover { background: rgba(255,255,255,0.15) !important; }
.leaflet-control-attribution {
  background: rgba(5,15,30,0.65) !important;
  color: var(--text-muted) !important;
  backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: var(--accent) !important; }

.wa-grid-canvas { pointer-events: none; }

/* Selected-location marker: pulsing ring, distinct from a generic map pin */
.wa-pin { pointer-events: none; }
.wa-pin-dot {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-2); border: 2px solid #04182b;
  box-shadow: 0 0 0 0 rgba(55,224,196,0.6);
  animation: wa-pulse 1.8s ease-out infinite;
}
@keyframes wa-pulse {
  0% { box-shadow: 0 0 0 0 rgba(55,224,196,0.55); }
  70% { box-shadow: 0 0 0 16px rgba(55,224,196,0); }
  100% { box-shadow: 0 0 0 0 rgba(55,224,196,0); }
}

/* ===== Floating glass panels ===== */

.float-bar {
  position: absolute; z-index: 500;
  background: rgba(10, 22, 45, 0.72);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.top-bar {
  top: 16px; left: 16px; right: calc(16px + var(--drawer-w));
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  transition: right 0.28s ease;
}
.top-bar .brand { font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }

.search-wrap { position: relative; flex: 1; min-width: 160px; max-width: 440px; display: flex; gap: 8px; }
#searchInput {
  flex: 1; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.08); color: var(--text-1); font-size: 0.92rem;
}
#searchInput::placeholder { color: var(--text-muted); }
#geoBtn, .pill-btn {
  background: rgba(255,255,255,0.08); border: 1px solid var(--card-border);
  color: var(--text-1); border-radius: 9px; padding: 8px 12px; cursor: pointer; font-size: 0.92rem; white-space: nowrap;
}
#geoBtn:hover, .pill-btn:hover { background: rgba(255,255,255,0.16); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #12233f; border: 1px solid var(--card-border); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; z-index: 600;
}
.search-results .result-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 0.9rem; }
.search-results .result-item:last-child { border-bottom: none; }
.search-results .result-item:hover { background: rgba(63,176,255,0.15); }
.search-results .result-sub { color: var(--text-muted); font-size: 0.78rem; }
.search-results .empty { padding: 12px 14px; color: var(--text-muted); font-size: 0.86rem; }

/* Layer switcher: vertical pill stack, top-right */
.layer-switcher {
  top: 84px; right: calc(16px + var(--drawer-w));
  display: flex; flex-direction: column; gap: 4px; padding: 8px;
  transition: right 0.28s ease;
}
.layer-btn {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  color: var(--text-muted); padding: 8px 12px; cursor: pointer; font-size: 0.85rem; font-weight: 600;
  text-align: left; white-space: nowrap;
}
.layer-btn .ico { font-size: 1rem; }
.layer-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-1); }
.layer-btn.active { background: rgba(63,176,255,0.18); border-color: rgba(63,176,255,0.5); color: var(--text-1); }
.layer-btn.off.active { background: rgba(255,255,255,0.1); border-color: var(--card-border); }

/* Legend, bottom-left */
.legend { left: 16px; bottom: 22px; padding: 12px 14px; min-width: 200px; }
.legend-title { font-size: 0.78rem; font-weight: 700; margin-bottom: 8px; }
.legend-bar { height: 10px; border-radius: 6px; margin-bottom: 4px; }
.legend-ticks { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--text-muted); }

/* Timeline, bottom-center */
.timeline {
  bottom: 22px; left: calc((100% - var(--drawer-w)) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  width: min(560px, calc(100vw - 260px - var(--drawer-w)));
  transition: left 0.28s ease, width 0.28s ease;
}
#timelinePlay {
  background: var(--accent); color: #04182b; border: none; border-radius: 50%;
  width: 30px; height: 30px; flex-shrink: 0; cursor: pointer; font-size: 0.8rem;
}
.tl-label { font-size: 0.78rem; white-space: nowrap; min-width: 92px; }
.tl-range { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }
#tlSlider { flex: 1; accent-color: var(--accent); }

/* Places overlay */
.places-overlay {
  position: absolute; inset: 0; z-index: 800;
  background: rgba(5, 12, 25, 0.55);
  align-items: flex-start; justify-content: flex-start;
  padding: 84px 0 0 16px;
}
/* The [hidden] attribute only beats a same-specificity `display` rule when
   there isn't one — so display:flex must live here, not on the base class,
   or the overlay keeps intercepting clicks while "hidden". */
.places-overlay:not([hidden]) { display: flex; }
.places-card {
  width: 280px; max-height: calc(100vh - 120px); overflow-y: auto;
  background: rgba(12, 26, 48, 0.95); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.places-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.places-header h3 { margin: 0; font-size: 1rem; }
.places-card .sidebar-section { margin-bottom: 18px; }
.places-card .sidebar-section h4 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 0 0 8px; }

/* ===== Slide-in detail drawer ===== */

.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; max-width: 100vw;
  background: linear-gradient(180deg, #0d223f, #0a1830 60%);
  border-left: 1px solid var(--card-border);
  box-shadow: -14px 0 30px rgba(0,0,0,0.35);
  transform: translateX(100%); transition: transform 0.28s ease;
  z-index: 700; overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-inner { padding: 18px; display: flex; flex-direction: column; gap: 16px; }

.drawer-header { display: flex; align-items: flex-start; gap: 10px; }
.drawer-header .drawer-title { flex: 1; min-width: 0; }
.drawer-header h1 { margin: 0; font-size: 1.3rem; line-height: 1.25; }
.drawer-header p { margin: 4px 0 0; font-size: 0.85rem; }
.location-actions { display: flex; gap: 6px; flex-shrink: 0; }
#favBtn.active { color: var(--warn); border-color: var(--warn); }
.updated-line { margin-top: -8px; }

@media (max-width: 760px) {
  .drawer { width: 100%; }

  .top-bar { flex-wrap: wrap; row-gap: 8px; }
  .search-wrap { order: 3; max-width: none; width: 100%; }

  /* Icon-only horizontal strip, docked under the (now two-row) top bar
     instead of the bottom — the bottom is already legend + timeline, and
     three floating panels stacked there has no room on a phone screen. */
  .layer-switcher {
    top: 112px; right: 12px; left: auto; bottom: auto;
    flex-direction: row; padding: 6px; gap: 2px;
  }
  .layer-btn { padding: 8px; }
  .layer-btn .label-text { display: none; }

  .timeline { bottom: 14px; width: calc(100vw - 24px); padding: 8px 12px; }
  .legend { left: 12px; bottom: 70px; min-width: 160px; padding: 10px 12px; }
}
