/* ============================================================
   styles.css — layout, glass cards, theme variables, map hero,
   alert banner, radar controls.
   Theme variables (--grad, --ink, --card-bg, etc.) are set at
   runtime by themes.js based on the current weather + time.
   ============================================================ */

* { box-sizing: border-box; }

:root {
  --grad: linear-gradient(180deg, #4a90d9 0%, #7ec8e3 100%);
  --ink: #10233a;
  --ink-soft: rgba(16, 35, 58, 0.68);
  --card-bg: rgba(255, 255, 255, 0.40);
  --card-border: rgba(255, 255, 255, 0.55);
  --accent: #2b6cb0;
  --scrim: rgba(255, 255, 255, 0.10);
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  transition: color 900ms ease;
}

/* ===== Alert banner ===== */
.alert-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #dc2626;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 300ms ease;
}
.alert-banner[hidden] { display: none; }
.alert-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-icon { font-size: 1.2rem; flex: 0 0 auto; }
.alert-text { flex: 1; line-height: 1.35; }
.alert-dismiss {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
}
.alert-dismiss:hover { opacity: 1; }

/* When alert is showing, push content down */
body.has-alert #app { padding-top: 52px; }

/* ===== Sky background ===== */
#sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
#sky-gradient {
  position: absolute;
  inset: 0;
  background: var(--grad);
  transition: background 1200ms ease;
}
#sky-gradient::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--scrim);
  pointer-events: none;
  transition: background 1200ms ease;
}
#celestial { position: absolute; inset: 0; pointer-events: none; }
#sky-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ===== Brand drifters ===== */
.brand-drift {
  position: absolute;
  white-space: nowrap;
  pointer-events: none;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.brand-drift-1 {
  top: 14%;
  font-size: 0.85rem;
  opacity: 0.55;
  animation: drift-ltr 50s linear infinite;
  animation-delay: -8s;
}
.brand-drift-2 {
  top: 42%;
  font-size: 1rem;
  opacity: 0.65;
  animation: drift-rtl 35s linear infinite;
  animation-delay: -15s;
}
.brand-drift-3 {
  top: 68%;
  font-size: 1.15rem;
  opacity: 0.75;
  animation: drift-ltr 22s linear infinite;
  animation-delay: -3s;
}
@keyframes drift-ltr {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(calc(100vw + 20%)); }
}
@keyframes drift-rtl {
  0%   { transform: translateX(100vw); }
  100% { transform: translateX(calc(-100% - 40px)); }
}

.orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  transition: opacity 1200ms ease;
}

/* ===== Foreground layout ===== */
#app {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Glass cards ===== */
.glass {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  transition: background 1200ms ease, border-color 1200ms ease;
}
.card { padding: 20px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-head h2 { margin: 0; font-size: 1.1rem; font-weight: 800; letter-spacing: 0.3px; }

/* ===== Top bar ===== */
.topbar {
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 8px;
  z-index: 5;
}
.search { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; }
.search input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.55);
  color: #10233a;
  font-size: 1rem;
}
.search input::placeholder { color: rgba(16, 35, 58, 0.55); }
button {
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 200ms ease, transform 120ms ease;
}
button:hover { background: rgba(255, 255, 255, 0.65); }
button:active { transform: scale(0.97); }

/* ===== Saved places ===== */
.search { position: relative; }
.place-star, .place-toggle {
  flex: 0 0 auto;
  width: 38px;
  padding: 0;
  text-align: center;
  font-size: 1.15rem;
  line-height: 38px;
}
.place-star.saved { color: #f59e0b; }
.place-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  z-index: 20;
  overflow: hidden;
}
.place-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.place-row:last-child { border-bottom: none; }
.place-name {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 14px;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: #10233a;
  cursor: pointer;
  border-radius: 0;
}
.place-name:hover { background: rgba(59, 130, 246, 0.08); }
.place-del {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 1.2rem;
  color: #b22;
  cursor: pointer;
  opacity: 0.5;
  border-radius: 0;
}
.place-del:hover { opacity: 1; background: rgba(178, 34, 34, 0.06); }
.place-empty {
  padding: 14px;
  text-align: center;
  color: rgba(16, 35, 58, 0.5);
  font-size: 0.9rem;
}

/* ===== Status line ===== */
.status {
  min-height: 1.2em;
  font-size: 0.9rem;
  padding: 0 4px;
  color: var(--ink-soft);
  transition: color 300ms ease;
}
.status.error { color: #b22; font-weight: 600; }
.status.ok { color: #1a7f4b; font-weight: 600; }

/* ===== Live Map (hero card) ===== */
.map-card {
  padding: 0;
  overflow: hidden;
}
.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  flex-wrap: wrap;
}
.map-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: 0.2px; }
.map-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.layer-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: 10px;
  background: var(--scrim);
  border: 1px solid transparent;
}
.layer-btn.active {
  background: rgba(255, 255, 255, 0.6);
  border-color: var(--card-border);
}

.map-container {
  height: 55vh;
  min-height: 300px;
  max-height: 600px;
}
.leaflet-container { background: #0b1a2b; }

.radar-controls {
  padding: 10px 18px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.radar-controls button {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 10px;
  min-width: 36px;
}
.radar-time {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  min-width: 60px;
}
.map-note {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin-left: auto;
}

/* Fullscreen map */
.map-card:-webkit-full-screen,
.map-card:fullscreen {
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
}
.map-card:-webkit-full-screen .map-container,
.map-card:fullscreen .map-container {
  flex: 1;
  height: auto;
  max-height: none;
}

/* ===== Current conditions ===== */
.current-main { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.current-temp { font-size: 5rem; font-weight: 300; line-height: 1; display: flex; }
.current-temp .deg { font-size: 2.2rem; font-weight: 300; margin-top: 6px; }
.current-meta .place { font-size: 1.3rem; font-weight: 700; }
.current-meta .cond { font-size: 1.05rem; color: var(--ink-soft); }
.current-meta .feels { font-size: 0.95rem; color: var(--ink-soft); }

.current-stats {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 10px;
}
.stat {
  background: var(--scrim);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-soft); font-weight: 600; }
.stat span:last-child { font-size: 1.1rem; font-weight: 700; }

/* ===== Moon panel ===== */
.moon-panel { margin-top: 16px; display: flex; align-items: center; gap: 14px; }
.moon-panel[hidden] { display: none; }
.moon-icon {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.45);
}
.moon-phase { font-weight: 700; }
.moon-illum, .moon-times { font-size: 0.88rem; color: var(--ink-soft); }

/* ===== Message of the day ===== */
.motd { padding: 14px 18px; }
.motd-text { font-size: 1.06rem; font-weight: 600; line-height: 1.45; }

/* ===== Graph ===== */
.range-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 6px 10px; font-size: 0.82rem; border-radius: 10px;
  background: var(--scrim); border: 1px solid transparent;
}
.tab.active { background: rgba(255, 255, 255, 0.6); border-color: var(--card-border); }
.graph-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
#graph-host svg { display: block; }
.graph-readout { margin-top: 10px; font-size: 0.9rem; font-weight: 500; color: var(--ink-soft); min-height: 1.2em; }

/* ===== Precipitation ===== */
.precip-days { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.precip-day .pd-head { display: flex; justify-content: space-between; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; }
.precip-day .pd-head .pd-sum { color: var(--ink-soft); font-weight: 500; }

/* ===== Air quality ===== */
.aqi-host { display: flex; flex-direction: column; gap: 10px; }
.aqi-badge {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 14px; font-weight: 700;
  color: #10233a;
}
.aqi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }

/* ===== Ad slot ===== */
.ad { cursor: pointer; }
.ad-kicker { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.ad-title { font-size: 1.4rem; font-weight: 800; margin: 2px 0; }
.ad-sub { color: var(--ink-soft); }

/* ===== Misc ===== */
.fine { font-size: 0.78rem; color: var(--ink-soft); }
.center { text-align: center; }

@media (max-width: 520px) {
  .topbar { padding: 14px 10px; flex-wrap: wrap; }
  .gear-menu { position: fixed; top: 64px; right: 12px; }
  .current-temp { font-size: 4rem; }
  .map-container { height: 45vh; min-height: 260px; }
  .map-note { display: none; }
}

/* ===== Back link (marine page) ===== */
.back-link {
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.45);
  transition: background 200ms ease;
  flex: 0 0 auto;
}
.back-link:hover { background: rgba(255, 255, 255, 0.65); }

/* ===== Marine conditions grid ===== */
.marine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.marine-map { height: 35vh; min-height: 240px; max-height: 450px; }

/* ===== Emergency / Coast Guard ===== */
.emergency-card { text-align: center; padding: 14px 18px; }
.sos-btn {
  background: #dc2626;
  color: #fff;
  border: 2px solid #b91c1c;
  border-radius: 16px;
  padding: 14px 28px;
  font-size: 1.1rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 200ms ease, transform 120ms ease;
}
.sos-btn:hover { background: #b91c1c; }
.sos-btn:active { transform: scale(0.97); }
.sos-icon { font-size: 1.4rem; }
.sos-text { font-size: 1rem; }
.sos-hint { font-size: 0.82rem; color: var(--ink-soft); margin-top: 8px; }

/* SOS confirmation overlay */
.sos-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sos-overlay[hidden] { display: none; }
.sos-confirm {
  background: #1a1a2e;
  border: 2px solid #dc2626;
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  color: #fff;
}
.sos-confirm-icon { font-size: 3rem; margin-bottom: 12px; }
.sos-confirm-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 8px; }
.sos-confirm-number { font-size: 1.8rem; font-weight: 700; color: #ef4444; margin: 8px 0; }
.sos-confirm-name { font-size: 1rem; color: rgba(255, 255, 255, 0.8); font-weight: 600; }
.sos-confirm-region { font-size: 0.88rem; color: rgba(255, 255, 255, 0.55); margin-top: 2px; }
.sos-countdown { font-size: 1.1rem; margin: 16px 0; color: rgba(255, 255, 255, 0.9); }
.sos-cancel-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  padding: 12px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}
.sos-cancel-btn:hover { background: rgba(255, 255, 255, 0.25); }
.sos-call-911 {
  display: block;
  margin: 12px auto 0;
  color: #ef4444;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}
.sos-call-911:hover { color: #f87171; }

/* ===== VHF note ===== */
.vhf-note { font-size: 0.95rem; line-height: 1.5; color: var(--ink); }

/* ===== Marine alert items ===== */
.marine-alert-item { padding: 10px 0; border-bottom: 1px solid var(--card-border); }
.marine-alert-item:last-child { border-bottom: none; }
.marine-alert-event { font-weight: 700; font-size: 0.95rem; }
.marine-alert-headline { font-size: 0.88rem; color: var(--ink-soft); margin-top: 2px; }

/* ===== Fire counts ===== */
.fires-section { text-align: center; }
.fires-btn {
  background: rgba(127, 29, 29, 0.15);
  color: var(--ink);
  border: 1px solid rgba(127, 29, 29, 0.3);
  border-radius: 14px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 200ms ease;
}
.fires-btn:hover { background: rgba(127, 29, 29, 0.25); }
.fires-panel { margin-top: 14px; text-align: center; }
.fires-warning { padding: 12px 0; }
.fires-warn-icon { font-size: 2rem; margin: 0 0 8px; }
.fires-warn-text {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.5;
  max-width: 400px;
  margin: 0 auto 14px;
}
.fires-show-btn {
  background: rgba(127, 29, 29, 0.2);
  color: var(--ink);
  border: 1px solid rgba(127, 29, 29, 0.35);
  border-radius: 12px;
  padding: 10px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease;
}
.fires-show-btn:hover { background: rgba(127, 29, 29, 0.35); }
.fires-close-btn {
  background: rgba(255, 255, 255, 0.35);
  color: var(--ink);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 8px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background 200ms ease;
}
.fires-close-btn:hover { background: rgba(255, 255, 255, 0.55); }
.fires-total { margin: 12px 0; }
.fires-count { font-size: 2.4rem; font-weight: 800; display: block; }
.fires-label { font-size: 0.9rem; color: var(--ink-soft); display: block; margin-top: 2px; }
.fires-level {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 14px;
  border-radius: 20px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}
.fires-breakdown {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 14px 0;
}
.fires-country { display: flex; align-items: center; gap: 6px; }
.fires-flag { font-size: 1.3rem; }
.fires-country-name { font-size: 0.9rem; font-weight: 600; }
.fires-country-count { font-size: 1.1rem; font-weight: 800; }
.fires-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.4;
  max-width: 400px;
  margin: 8px auto 0;
}
.fires-loading { font-size: 0.95rem; color: var(--ink-soft); padding: 16px 0; }
.fires-error { font-size: 0.9rem; color: #dc2626; padding: 12px 0; }

/* ===== Gear menu ===== */
.gear-wrap {
  position: relative;
  flex: 0 0 auto;
}
.gear-menu[hidden] { display: none; }
.gear-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--card-bg);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 20;
  min-width: 160px;
}
.gear-menu button,
.gear-link {
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
.gear-link {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 200ms ease;
}
.gear-link:hover { background: rgba(255, 255, 255, 0.65); }

/* ===== Install banner ===== */
.install-banner[hidden] { display: none; }
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  z-index: 9999;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
}
.install-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}
.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-text strong {
  font-size: 1rem;
}
.install-text span {
  font-size: 0.82rem;
  opacity: 0.7;
}
.install-btn {
  padding: 8px 20px;
  background: #4fc3f7;
  color: #1a1a2e;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.install-dismiss {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px 8px;
}

/* ===== Compass overlay ===== */
.compass-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 15, 30, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
}
.compass-overlay[hidden] { display: none; }
.compass-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.compass-close:hover { background: rgba(255,255,255,0.1); }
.compass-body {
  text-align: center;
  color: #fff;
}
.compass-rose {
  width: 280px;
  height: 280px;
  margin: 0 auto 24px;
  transition: transform 150ms ease-out;
}
.compass-rose svg { width: 100%; height: 100%; }
.compass-heading {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.compass-msg {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.55);
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Respect reduced-motion at the CSS level too */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; }
  .brand-drift { animation: none !important; opacity: 0 !important; }
}
