/* PastWeather web — same look as the iOS app: dark, map-first, glass panels, cyan → violet accent. */
:root {
  --bg: #070914;
  --bg-top: #161e48;
  --accent: #4ad1ff;            /* Theme.accent  (0.29, 0.82, 1.0) */
  --accent2: #8f6bff;           /* Theme.accent2 (0.56, 0.42, 1.0) */
  --gradient: linear-gradient(135deg, var(--accent), var(--accent2));
  --text: #ffffff;
  --text2: rgba(255, 255, 255, 0.6);
  --text3: rgba(255, 255, 255, 0.4);
  --hairline: rgba(255, 255, 255, 0.10);
  --glass: rgba(22, 26, 48, 0.55);
  --field: rgba(255, 255, 255, 0.06);
  --err: #ff9f43;
  --tornado: #ff453a;
  --hail: #30d158;
  --wind: #0a84ff;
  --flood: #40c8e0;
  --radius: 24px;
  --brand: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  /* Indigo → near-black with a soft light pool, like the app icon's background. */
  background:
    radial-gradient(60vmax 45vmax at 50% 8%, rgba(18, 60, 120, 0.55), transparent 70%),
    radial-gradient(50vmax 40vmax at 85% 70%, rgba(143, 107, 255, 0.10), transparent 70%),
    linear-gradient(170deg, var(--bg-top) 0%, #0b0f26 40%, var(--bg) 100%);
  background-attachment: fixed;
}
button, input { font: inherit; }

.wrap {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) 28px;
}
#screen-home { max-width: 560px; }

/* ---------- Brand bar ---------- */
.brandbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: calc(8px + env(safe-area-inset-top)) 16px 9px;
  background: rgba(8, 10, 22, 0.55);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 0.5px solid var(--hairline);
}
.brandbar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
}
.brandbar img { filter: drop-shadow(0 0 6px rgba(74, 209, 255, 0.35)); }
.wordmark { font-family: var(--brand); letter-spacing: -0.01em; font-size: 23px; line-height: 1; }
.wordmark .past { font-weight: 500; color: rgba(255, 255, 255, 0.78); }
.wordmark .weather { font-weight: 700; color: #fff; }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 28px 0 22px; }
.hero-icon {
  display: block;
  margin: 0 auto 18px;
  border-radius: 22.5%;
  box-shadow: 0 0 0 0.5px var(--hairline), 0 14px 40px rgba(0, 0, 0, 0.5), 0 0 60px rgba(74, 209, 255, 0.18);
}
.hero h1.wordmark { margin: 0; font-size: clamp(2.2rem, 7vw, 2.8rem); }
.helper { margin: 10px auto 0; max-width: 34ch; font-size: 0.95rem; line-height: 1.45; color: var(--text2); }

/* ---------- Glass ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.35);
}
.form { padding: 18px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; min-width: 0; }
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }
.row .field.date { flex: 1.25; }
label, .panel-title, .step-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
}
input[type="text"] {
  width: 100%;
  min-width: 0;
  font-size: 1rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 13px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]::placeholder { color: var(--text3); }
input[type="text"]:focus {
  outline: none;
  border-color: rgba(74, 209, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(74, 209, 255, 0.18);
}
.input-icon { position: relative; }
.input-icon svg {
  position: absolute; left: 14px; top: 50%; translate: 0 -50%;
  width: 18px; height: 18px;
  fill: none; stroke: var(--text2); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
.input-icon input { padding-left: 42px; border-radius: 25px; }

/* Primary call-to-action: full-width gradient capsule. */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  margin-top: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--gradient);
  color: rgba(0, 0, 0, 0.9);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(74, 209, 255, 0.35);
  transition: transform 0.2s cubic-bezier(.3, 1.6, .5, 1), filter 0.15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.97); }
.btn:disabled { background: rgba(255, 255, 255, 0.12); color: rgba(0, 0, 0, 0.4); box-shadow: none; cursor: wait; }
.btn:focus-visible, .back:focus-visible, .step-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.error { color: var(--err); font-size: 0.9rem; line-height: 1.35; margin: 4px 0 10px; }
.footnote { margin: 18px 4px 0; font-size: 0.75rem; line-height: 1.5; color: var(--text3); text-align: center; }

/* ---------- Results ---------- */
.nav { display: flex; align-items: center; gap: 12px; margin: 2px 0 14px; }
.back {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s;
}
.back:active { transform: scale(0.92); }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.event { min-width: 0; }
#chip-main { font-size: 1.05rem; font-weight: 600; line-height: 1.3; }
.event .sub { margin-top: 3px; font-size: 0.8rem; color: var(--accent); }

.panel { overflow: hidden; margin-bottom: 14px; }
.panel-title { padding: 14px 16px 10px; }
#map { height: clamp(300px, 52vh, 620px); width: 100%; background: #0d1020; }

.map-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
}
.map-opt {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 0.88rem; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--text); cursor: pointer; user-select: none;
}
/* iOS-style switch */
.map-opt input {
  appearance: none; -webkit-appearance: none;
  position: relative; flex: none;
  width: 42px; height: 26px; margin: 0;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: background 0.2s;
}
.map-opt input::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.map-opt input:checked { background: var(--accent); }
.map-opt input:checked::after { transform: translateX(16px); }
.map-opt input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.legend { display: flex; align-items: center; gap: 8px; color: var(--text3); }
.legend-unit { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; }
.legend-scale { width: 160px; }
/* IEM N0Q palette sampled at 5 dBZ steps (15...70), same stops as the app's RadarLegend. */
.legend-bar {
  height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, #8787e3, #6767c3, #3263c6, #224386, #00c600, #008600,
                                     #ffc600, #ff8600, #d40000, #a50000, #c600c6, #860086); /* mrms.js STOPS, 15–70 dBZ */
}
.legend-ticks { position: relative; height: 12px; margin-top: 2px; font-size: 9px; font-weight: 500; font-variant-numeric: tabular-nums; }
.legend-ticks b { position: absolute; top: 0; translate: -50% 0; font-weight: inherit; }
.legend-ticks b:first-child { translate: 0 0; }
.legend-ticks b:last-child { translate: -100% 0; }

.step-block { padding: 12px 16px 14px; border-top: 1px solid var(--hairline); }
.step-label { margin-bottom: 10px; }
.step-rows { display: flex; flex-direction: column; gap: 8px; }
.step-row { display: flex; gap: 8px; }
.step-btn {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s, transform 0.2s;
}
.step-btn:hover { background: rgba(74, 209, 255, 0.16); }
.step-btn:active { transform: scale(0.94); }
.reset-link {
  display: block; width: 100%;
  margin-top: 10px; padding: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 0.88rem; font-weight: 600; color: var(--accent);
}

.reports { list-style: none; margin: 0; padding: 0 0 4px; }
.reports li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: start;
  padding: 12px 16px;
  border-top: 1px solid var(--hairline);
  font-size: 0.92rem;
  line-height: 1.35;
}
.reports li > * { grid-column: 2; }
.reports li::before {
  content: "";
  grid-column: 1;
  grid-row: 1 / span 5;
  width: 10px; height: 10px; margin-top: 4px;
  border-radius: 50%;
  background: var(--dot, #8e8e93);
  box-shadow: 0 0 8px var(--dot, transparent);
}
.reports li.tornado { --dot: var(--tornado); }
.reports li.hail { --dot: var(--hail); }
.reports li.wind { --dot: var(--wind); }
.reports li.flood { --dot: var(--flood); }
.reports .comments {
  margin-top: 4px; font-size: 0.78rem; line-height: 1.4; color: var(--text3);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.field-note { margin: 10px 2px 0; font-size: 0.8rem; color: var(--text3); }
.reports .type { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dot, var(--text2)); }
.reports .meta { color: var(--text2); font-size: 0.8rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.muted { margin: 0; padding: 4px 16px 16px; color: var(--text2); font-size: 0.9rem; }

/* ---------- Leaflet in dark glass ---------- */
.leaflet-container { font: inherit; background: #0d1020; }
.leaflet-bar { border: 1px solid var(--hairline) !important; border-radius: 12px !important; overflow: hidden; box-shadow: none !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: rgba(22, 26, 48, 0.8) !important; color: #fff !important;
  border-bottom-color: var(--hairline) !important;
}
.leaflet-control-attribution { background: rgba(8, 10, 22, 0.6) !important; color: var(--text3) !important; }
.leaflet-control-attribution a { color: var(--text2) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(22, 26, 48, 0.92); color: #fff;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.leaflet-popup-content-wrapper { border: 1px solid var(--hairline); border-radius: 16px; }
.leaflet-popup-content { margin: 12px 14px; line-height: 1.4; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text2); }

.hidden { display: none !important; }

/* ---------- Layout ---------- */
@media (max-width: 639px) {
  #map { height: 300px; }
  .legend-scale { width: 140px; }
}
@media (min-width: 900px) {
  .row { gap: 16px; }
  .reports { display: grid; grid-template-columns: 1fr 1fr; }
  .reports li:nth-child(odd) { border-right: 1px solid var(--hairline); }
  .step-rows { flex-direction: row; gap: 16px; }
  .step-row { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
