/* rain.report: phone-first weather page. Light and dark follow the device setting. */
:root {
  color-scheme: light dark;
  --bg: #eef2f6;
  --surface: #ffffff;
  --border: #dde3ea;
  --text: #0c1a2a;
  --text-2: #4a5866;
  --muted: #7b8794;
  --accent: #2a78d6;
  --deep: #0f3d6e;
  --wet: #2a78d6;
  --grid: #e8edf2;
  --warn-bg: #fff4d6;
  --warn-text: #6b4a00;
  --critical: #d03b3b;
  --alert-bg: #fdecec;
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1118;
    --surface: #141c26;
    --border: #253141;
    --text: #eef2f6;
    --text-2: #b5c0cc;
    --muted: #8593a3;
    --accent: #4b95ea;
    --deep: #0a2a4d;
    --wet: #4b95ea;
    --grid: #1f2a37;
    --warn-bg: #3a2e10;
    --warn-text: #f5d58a;
    --alert-bg: #3a1c1c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
h2 { font-size: 1.0625rem; margin: 0; }
.muted { color: var(--muted); font-size: .8125rem; }
.note { color: var(--muted); font-size: .8125rem; margin: 10px 0 0; }
.empty { color: var(--muted); padding: 12px 0; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--deep); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.125rem; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; fill: #7fc0ff; }
.place { display: flex; align-items: center; gap: 6px; min-width: 0; }
.place select {
  min-width: 0; max-width: 56vw; font: inherit; font-size: .9375rem; color: #fff;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 6px 8px;
}
.place select option, .place select optgroup { color: initial; }
#locate {
  flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; cursor: pointer;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 10px;
}
#locate svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
#locate .dot { fill: #fff; stroke: none; }
#locate.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.alerts { display: grid; gap: 1px; }
.alert {
  display: block; padding: 10px 16px; background: var(--alert-bg); color: var(--text);
  border-left: 4px solid var(--critical); text-decoration: none; font-size: .9375rem;
}
.alert strong { color: var(--critical); }
.banner { padding: 10px 16px; background: var(--warn-bg); color: var(--warn-text); font-size: .875rem; }

/* ---------- layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 12px 12px 24px; display: grid; gap: 12px; }
@media (min-width: 900px) {
  main { grid-template-columns: 1fr 1fr; padding: 20px; gap: 16px; }
  .now, .reports { grid-column: 1 / -1; }
  .map-card { grid-row: span 2; }
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.small-link { font-size: .8125rem; }

/* ---------- now ---------- */
.now {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border-radius: var(--radius); color: #fff;
  background: linear-gradient(135deg, #1b5fa8, #0f3d6e);
}
.now-place { font-size: 1rem; opacity: .9; }
.now-temp { font-size: 4rem; font-weight: 300; line-height: 1; margin: 4px 0; font-variant-numeric: tabular-nums; }
.now-short { font-size: 1.125rem; font-weight: 600; }
.now-hilo { font-size: .875rem; opacity: .85; margin-top: 2px; }
.now-icon { width: 120px; height: 120px; flex: 0 0 auto; margin: -12px -8px -12px 0; }
.now-icon.photo { width: 96px; height: 96px; margin: 0; border-radius: 18px; } /* NWS sun/cloud pictures */

/* ---------- rain near you ---------- */
.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 420px) { .totals { gap: 6px; } .total { padding: 8px 4px; } .total .tv { font-size: 1.125rem; } .total .tv small { display: none; } }
.total { background: var(--grid); border-radius: 12px; padding: 10px 8px; text-align: center; }
.total .tv { font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.total .tv small { font-size: .75rem; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.total .tl { font-size: .75rem; color: var(--text-2); }
.total.big { grid-column: 1 / -1; background: linear-gradient(135deg, rgba(42,120,214,.16), rgba(42,120,214,.06)); padding: 14px; }
.total.big .tv { font-size: 2.75rem; color: var(--wet); line-height: 1.1; }
.total.big .tl { font-size: .875rem; }
.nearest { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--border); }
.nearest li {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .875rem;
}
.g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-dist { color: var(--muted); font-size: .8125rem; }
.g-v { font-variant-numeric: tabular-nums; font-weight: 600; }
.g-v small { color: var(--muted); font-weight: 400; }

/* ---------- forecast ---------- */
.days { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.day {
  flex: 0 0 72px; scroll-snap-align: start; text-align: center;
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 4px;
}
.dname { font-size: .8125rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day img { width: 52px; height: 52px; margin: 0 0 -4px; }
.day img.photo { width: 44px; height: 44px; margin: 4px 0; border-radius: 8px; }
.temps b { font-weight: 700; }
.temps span { color: var(--text-2); }
.day .rain { font-size: .75rem; color: var(--muted); }
.day .rain.wet { color: var(--wet); font-weight: 700; }
.detail { margin-top: 10px; font-size: .875rem; color: var(--text-2); }
.detail p { margin: 6px 0 0; }
.detail strong { color: var(--text); }

/* ---------- map ---------- */
.seg { display: inline-flex; background: var(--grid); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button {
  font: inherit; font-size: .875rem; border: 0; background: transparent; color: var(--text-2);
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.period { display: flex; margin-bottom: 10px; overflow-x: auto; }
.seg.period button { flex: 1; padding: 5px 6px; }
.map-frame { position: relative; }
#rain-map { width: 100%; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: var(--grid); }
#radar-img { display: block; width: 100%; height: auto; border-radius: 12px; }
.rain-scale { width: 170px; }
.rain-scale .rs-bar { height: 10px; border-radius: 3px; }
.rain-scale .rs-ticks { display: grid; grid-template-columns: 1fr auto 1fr; margin-top: 2px; font-size: .75rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rain-scale .rs-title { color: var(--text); font-weight: 600; }
.rain-scale .rs-hi { text-align: right; }
.rain-basemap { filter: grayscale(.85) brightness(1.05) contrast(.9); }
@media (prefers-color-scheme: dark) { .rain-basemap { filter: grayscale(1) invert(1) brightness(.85) contrast(.9); } }
.rain-readout {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 800;
  width: min(300px, calc(100% - 110px)); height: 26px; padding: 4px 10px; border-radius: 13px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  box-shadow: 0 1px 4px rgba(0,0,0,.15); font: 12px/16px system-ui, -apple-system, sans-serif;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.rain-readout strong { color: var(--text); }
.rain-dots {
  display: flex; align-items: center; gap: 4px; cursor: pointer; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 7px; font: 12px/16px system-ui, -apple-system, sans-serif;
}
.rain-dots input { margin: 0; }

/* ---------- wettest ---------- */
.wettest { list-style: none; margin: 0; padding: 0; }
.wettest li { display: grid; grid-template-columns: minmax(0, 11em) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: .875rem; }
.w-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-bar { height: 10px; background: var(--grid); border-radius: 5px; overflow: hidden; }
.w-bar span { display: block; height: 100%; background: var(--wet); border-radius: 5px; }
.w-v { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3.2em; text-align: right; }

/* ---------- specialty reports ---------- */
.reports { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.report-btn {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.report-btn:hover { border-color: var(--accent); }
.report-btn small { display: block; color: var(--muted); font-size: .8125rem; }
.rb-icon { font-size: 1.75rem; }
.report-btn.soon { opacity: .6; }
@media (max-width: 520px) { .reports { grid-template-columns: 1fr; } }

.foot { max-width: 1100px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); color: var(--muted); font-size: .75rem; }
