/* ============================================================
   Stormwatch — time-of-day "sky" design system (ported from the
   launch-window seed, adapted to the storm tracker). The sky/canvas
   follows the visitor's local hour; storm-SEVERITY colors and the
   cyan identity stay constant. "Day" is a cool overcast (weather-
   appropriate), not the cheerful daylight of the sky sites.
   ============================================================ */

:root {
  /* storm severity — semantic, constant across every phase */
  --major: #ef4060;
  --hur: #ff6b35;
  --ts: #f5b62a;
  --td: #4aa3df;
  --ex: #9aa7b0;
  --ok: #34d39a;
  --radius: 15px;

  /* shared texture images, selected per phase via --tex */
  --stars:
    radial-gradient(1px 1px at 24px 38px, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 130px 90px, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 80px 160px, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1.5px 1.5px at 190px 50px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 30px 200px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 160px 180px, rgba(255, 255, 255, 0.35), transparent);
  --grid:
    linear-gradient(rgba(20, 60, 120, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 60, 120, 0.05) 1px, transparent 1px);
  --stars2:
    radial-gradient(1.4px 1.4px at 60px 70px, rgba(255, 255, 255, 0.95), transparent),
    radial-gradient(1.6px 1.6px at 160px 30px, rgba(190, 225, 255, 0.9), transparent),
    radial-gradient(1.2px 1.2px at 110px 150px, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(1.5px 1.5px at 24px 120px, rgba(200, 235, 255, 0.85), transparent),
    radial-gradient(1.3px 1.3px at 225px 110px, rgba(255, 255, 255, 0.9), transparent),
    radial-gradient(1.5px 1.5px at 285px 180px, rgba(190, 225, 255, 0.85), transparent);
}

/* ---- DUSK (default / fallback) ---- */
:root, :root[data-theme="dusk"] {
  --bg: #0b0a1f;
  --head-bg: rgba(11, 10, 31, 0.6);
  --card: rgba(255, 255, 255, 0.045);
  --chip: rgba(255, 255, 255, 0.05);
  --line: rgba(255, 255, 255, 0.10);
  --ink: #e9eefb; --muted: #a6b0cf; --strong: #ffffff;
  --accent: #38bdf8; --on-accent: #04222e;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.40);
  --sky:
    radial-gradient(900px 480px at 50% 122%, rgba(255, 150, 60, 0.10), transparent 62%),
    radial-gradient(1100px 720px at 50% -12%, #261658 0%, #160e38 42%, #0b0a1f 100%);
  --tex: var(--stars); --tex-opacity: 0.5; --tex-size: 220px 220px; --tex2-opacity: 0.7;
  --sweep-color: rgba(56, 189, 248, 0.45);
}

/* ---- NIGHT ---- */
:root[data-theme="night"] {
  --bg: #06050e;
  --head-bg: rgba(6, 5, 14, 0.62);
  --card: rgba(255, 255, 255, 0.05);
  --chip: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.10);
  --ink: #eef2fb; --muted: #a4adcf; --strong: #ffffff;
  --accent: #56c8ff; --on-accent: #04222e;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.50);
  --sky:
    radial-gradient(800px 500px at 50% 120%, rgba(80, 70, 140, 0.14), transparent 60%),
    radial-gradient(1200px 820px at 50% -10%, #12122e 0%, #0a0a1c 45%, #06050e 100%);
  --tex: var(--stars); --tex-opacity: 0.75; --tex-size: 200px 200px; --tex2-opacity: 0.95;
  --sweep-color: rgba(86, 200, 255, 0.45);
}

/* ---- DAWN (rosy) ---- */
:root[data-theme="dawn"] {
  --bg: #241641;
  --head-bg: rgba(36, 22, 65, 0.55);
  --card: rgba(255, 255, 255, 0.06);
  --chip: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.13);
  --ink: #f4eef6; --muted: #d2bdd0; --strong: #ffffff;
  --accent: #7fd6ff; --on-accent: #04222e;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  --sky:
    radial-gradient(1300px 760px at 50% 116%, rgba(255, 158, 110, 0.48), rgba(255, 120, 155, 0.24) 36%, rgba(150, 110, 195, 0.12) 60%, transparent 76%),
    radial-gradient(1100px 840px at 50% -8%, #412c63 0%, #30214f 46%, #241641 100%);
  --tex: var(--stars); --tex-opacity: 0.26; --tex-size: 220px 220px; --tex2-opacity: 0.42;
  --sweep-color: rgba(255, 150, 105, 0.55);
}

/* ---- DAY (cool overcast — serious, not cheerful) ---- */
:root[data-theme="day"] {
  --bg: #e6edf2;
  --head-bg: rgba(230, 237, 242, 0.72);
  --card: #ffffff;
  --chip: rgba(12, 42, 64, 0.05);
  --line: rgba(20, 45, 75, 0.12);
  --ink: #13283a; --muted: #5a6f7e; --strong: #0b2230;
  --accent: #0369a1; --on-accent: #ffffff;
  --shadow: 0 12px 30px rgba(20, 50, 80, 0.12);
  --sky: radial-gradient(1000px 560px at 50% -10%, #cdd9e4 0%, #dde6ee 45%, #e6edf2 100%);
  --tex: var(--grid); --tex-opacity: 0.5; --tex-size: 38px 38px; --tex2-opacity: 0;
  --sweep-color: rgba(3, 105, 161, 0.30);
}

* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink);
  background-color: var(--bg);
  background-image: var(--sky);
  background-attachment: fixed; background-repeat: no-repeat; min-height: 100vh;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.7s ease, color 0.5s ease;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: var(--tex-opacity, 0.5);
  background-image: var(--tex); background-size: var(--tex-size, 220px 220px);
  transition: opacity 0.6s ease;
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: var(--stars2); background-size: 300px 300px;
  opacity: var(--tex2-opacity, 0);
  animation: twinkle 4.2s ease-in-out infinite;
  transition: opacity 0.6s ease;
}
@keyframes twinkle { 0%, 100% { opacity: var(--tex2-opacity, 0); } 50% { opacity: calc(var(--tex2-opacity, 0) * 0.35); } }

/* shooting stars (dark phases only) */
.sky-fx { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.sky-fx i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.55); opacity: 0; }
.sky-fx i::after { content: ""; position: absolute; top: 50%; left: 2px; width: 92px; height: 1px; transform: translateY(-50%); background: linear-gradient(90deg, rgba(255, 255, 255, 0.55), transparent); }
.sky-fx i:nth-child(1) { top: 8%;  left: 80%; animation: shoot 11s ease-in 4s infinite; }
.sky-fx i:nth-child(2) { top: 16%; left: 94%; animation: shoot 16s ease-in 10s infinite; }
@keyframes shoot {
  0%   { opacity: 0; transform: translate(0, 0) rotate(-29deg); }
  2%   { opacity: 1; }
  10%  { opacity: 0; transform: translate(-340px, 190px) rotate(-29deg); }
  100% { opacity: 0; transform: translate(-340px, 190px) rotate(-29deg); }
}
[data-theme="day"] .sky-fx { display: none; }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 18px; }
h1, h2, h3 { line-height: 1.14; margin: 0; }
.accent { color: var(--accent); }
b { color: var(--strong); }

.site-head { border-bottom: 1px solid var(--line); background: var(--head-bg); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.head-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 800; }
.brand-mark { font-size: 1.35rem; }
.brand-name { letter-spacing: -.02em; font-size: 1.15rem; }
.header-right { display: inline-flex; align-items: center; gap: 10px; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--accent); cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle:active { transform: scale(0.92); }
.head-tag { font-size: .76rem; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); padding: 4px 10px; border-radius: 999px; }

.hero { padding: 32px 0 14px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 850; letter-spacing: -.03em; }
.hero .sub { color: var(--muted); max-width: 56ch; margin: 11px 0 0; }
.hero em { color: var(--ink); font-style: italic; }

/* area summary */
.area-wrap { margin: 18px 0; }
.btn { font: inherit; font-weight: 700; border-radius: 11px; padding: 11px 18px; cursor: pointer; border: 1.5px solid transparent; transition: .15s; text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: var(--chip); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.loc-note { margin-left: 12px; color: var(--muted); font-size: .85rem; }
.area { border-radius: var(--radius); padding: 15px 17px; border: 1px solid var(--line); background: var(--card); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.area b { color: var(--strong); }
.area-sub { display: block; margin-top: 7px; font-size: .78rem; color: var(--muted); }
.area-sub a, .area a { color: var(--accent); }
.area.ok { border-color: rgba(52, 211, 154, 0.35); }
.area.watch { border-color: rgba(245, 182, 42, 0.5); background: rgba(245, 182, 42, 0.08); }
.area.alert { border-color: rgba(239, 64, 96, 0.6); background: rgba(239, 64, 96, 0.1); }

/* map */
.map-wrap { margin: 6px 0 22px; }
.map { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.basin { display: block; width: 100%; height: auto; }
.basin .city { fill: #9fbdca; font-size: 11px; font-family: system-ui, sans-serif; }
.basin .city.you { fill: #fff; font-weight: 700; }
.basin .s-lab { fill: #fff; font-size: 13px; font-weight: 700; font-family: system-ui, sans-serif; }
.basin .mv { stroke: rgba(255,255,255,.6); stroke-width: 2; }
.storm-dot.sev-major { fill: var(--major); }
.storm-dot.sev-hur { fill: var(--hur); }
.storm-dot.sev-ts { fill: var(--ts); }
.storm-dot.sev-td { fill: var(--td); }
.storm-dot.sev-ex { fill: var(--ex); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: .76rem; color: var(--muted); }
.legend i.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; vertical-align: middle; }
.dot.major { background: var(--major); } .dot.hur { background: var(--hur); } .dot.ts { background: var(--ts); } .dot.td { background: var(--td); }
.leg-arrow { color: var(--muted); }

/* storm cards */
.storms { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.storm { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border-left: 4px solid var(--td); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.storm.sev-major { border-left-color: var(--major); }
.storm.sev-hur { border-left-color: var(--hur); }
.storm.sev-ts { border-left-color: var(--ts); }
.storm.sev-td { border-left-color: var(--td); }
.storm.sev-ex { border-left-color: var(--ex); }
.s-head { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; }
.s-badge { flex: none; width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 850; font-size: 1rem; color: #fff; background: var(--td); }
.sev-major .s-badge { background: var(--major); } .sev-hur .s-badge { background: var(--hur); } .sev-ts .s-badge { background: var(--ts); color: #3a2a00; } .sev-td .s-badge { background: var(--td); } .sev-ex .s-badge { background: var(--ex); }
.s-name h3 { font-size: 1.2rem; }
.s-name span { color: var(--muted); font-size: .85rem; }
.s-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.st { background: var(--chip); border-radius: 9px; padding: 9px 11px; }
.st-v { display: block; font-weight: 750; font-variant-numeric: tabular-nums; }
.st-l { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 1px; }
.near { margin-top: 12px; padding: 9px 12px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: .9rem; }
.near.warn { background: rgba(239, 64, 96, 0.14); }
.s-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 13px; flex-wrap: wrap; }
.upd { font-size: .74rem; color: var(--muted); }
.s-foot a { color: var(--accent); font-size: .82rem; text-decoration: none; }
.s-foot a:hover { text-decoration: underline; }

/* quiet / empty */
.quiet { grid-column: 1 / -1; text-align: center; padding: 38px 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.quiet-ico { font-size: 2.6rem; }
.quiet h2 { font-size: 1.4rem; margin: 8px 0; }
.quiet p { color: var(--muted); max-width: 48ch; margin: 0 auto 16px; }

/* about */
.about { margin: 36px 0 8px; }
.about h2 { font-size: 1.3rem; margin-bottom: 14px; }
.why { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.why li { color: var(--muted); padding-left: 26px; position: relative; }
.why li::before { content: "🌀"; position: absolute; left: 0; font-size: .9rem; }
.why strong { color: var(--ink); }
.disclaimer { color: var(--muted); font-size: .8rem; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.disclaimer a { color: var(--accent); }

.site-foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 22px 0; color: var(--muted); font-size: .85rem; text-align: center; }

/* theme-change sweep + toast (shared with the seed) */
.theme-sweep {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: radial-gradient(circle at var(--ox, 50%) var(--oy, 8%), var(--sweep-color), transparent 55%);
  opacity: 0; will-change: opacity, transform;
  animation: theme-sweep 0.85s ease forwards;
}
@keyframes theme-sweep { 0% { opacity: 0; transform: scale(0.5); } 30% { opacity: 0.95; } 100% { opacity: 0; transform: scale(1.5); } }
.theme-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(8px);
  z-index: 10000; pointer-events: none;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.82rem; font-weight: 700; color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  opacity: 0; animation: theme-toast 1.8s ease forwards;
}
@keyframes theme-toast {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  12%, 70% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(8px); }
}

.ad-slot { display: none !important; }

@media (max-width: 540px) { .storms { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
