/* ============================================================
   WEATHER PAGE — extends the site design system (style.css).
   The base .rn-/.read-/.week-/.life-/.swim- rules still live in
   style.css; this file adds the redesign (alerts banner, hero
   chips, the next-hours rail, the week range rows, sparklines,
   swim verdict) and overrides where the old rules get in the way.
   Mobile first: the hero + next hours + week rows are the first
   two phone screens (one DOM order for every width — no CSS
   reordering — so reading order, focus order and visual order agree;
   My read follows the week rows).
============================================================ */

:root {
  --wx-rain: var(--teal);
  --wx-warm: var(--coral);
  --wx-good: #2E8A5F;
  --wx-fair: #D9A43A;
  --wx-night: var(--bg-subtle);
}
[data-theme="dark"] {
  /* Dark = lightness steps, not inverted cream. Accents ease off a notch. */
  --wx-rain: #5FB7C4;
  --wx-warm: #F08A66;
  --wx-good: #5DBB8A;
  --wx-fair: #E0B454;
  --wx-night: #0A1622;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------------- alerts: impossible to miss ---------------- */

.wx-alerts {
  border-bottom: 2px solid var(--coral);
  background: var(--coral-light);
  color: var(--ink);
}
.wx-alerts-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.wx-alerts-kicker {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--coral);
}
.wx-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}
.wx-alert-event {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
}
.wx-alert-head { font-size: var(--text-sm); color: var(--ink-2); flex-basis: 100%; }
.wx-alert-until { font-size: var(--text-xs); color: var(--ink-3); }
.wx-alerts-link { font-size: var(--text-sm); font-weight: 600; color: var(--coral); }
.wx-alerts-stale { font-size: var(--text-xs); opacity: .8; }

.wx-alerts-severe { background: #B3261E; border-bottom-color: #7F1A14; color: #fff; }
.wx-alerts-severe .wx-alerts-kicker,
.wx-alerts-severe .wx-alerts-link,
.wx-alerts-severe .wx-alert-head,
.wx-alerts-severe .wx-alert-until { color: rgba(255,255,255,0.92); }
.wx-alerts-moderate { background: #F6C453; border-bottom-color: #C99A1E; color: #2B2000; }
.wx-alerts-moderate .wx-alerts-kicker,
.wx-alerts-moderate .wx-alerts-link { color: #6B4E00; }
.wx-alerts-moderate .wx-alert-head,
.wx-alerts-moderate .wx-alert-until { color: #4A3800; }
[data-theme="dark"] .wx-alerts-moderate { background: #5A4410; border-bottom-color: #E0B454; color: #FBF0D0; }
[data-theme="dark"] .wx-alerts-moderate .wx-alerts-kicker,
[data-theme="dark"] .wx-alerts-moderate .wx-alerts-link { color: #F2CB6A; }
[data-theme="dark"] .wx-alerts-moderate .wx-alert-head,
[data-theme="dark"] .wx-alerts-moderate .wx-alert-until { color: #E9DBB3; }
.wx-alerts-minor { background: var(--teal-light); border-bottom-color: var(--teal); }
.wx-alerts-minor .wx-alerts-kicker, .wx-alerts-minor .wx-alerts-link { color: var(--teal); }

/* ---------------- hero ---------------- */

.rn-hero-inner { padding: var(--space-6) var(--space-5) var(--space-4); }

.rn-title {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-3);
  margin-bottom: var(--space-2);
}

.rn-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  column-gap: var(--space-3);
  row-gap: 0;
  font-size: var(--text-lg);
}
.rn-big { font-size: 3.6rem; letter-spacing: -0.02em; }
.rn-desc { font-family: var(--font-display); font-size: var(--text-xl); color: var(--ink); }
.rn-feels { font-family: var(--font-body); font-size: var(--text-sm); color: var(--ink-3); }

.rn-chips {
  margin-top: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}
.rn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  font-size: var(--text-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
a.rn-chip:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.rn-chip-aqi-moderate { border-color: var(--wx-fair); }
.rn-chip-aqi-unhealthy-for-sensitive-groups,
.rn-chip-aqi-unhealthy,
.rn-chip-aqi-very-unhealthy,
.rn-chip-aqi-hazardous { border-color: var(--coral); color: var(--coral); font-weight: 600; }

.wx-arrow {
  display: inline-block;
  font-weight: 700;
  line-height: 1;
  color: var(--teal);
  transform-origin: 50% 55%;
}

.rn-sub { margin-top: var(--space-3); font-size: var(--text-sm); }
.rn-sub strong { color: var(--ink); font-weight: 600; }

.rn-changed {
  margin: var(--space-2) auto 0;
  max-width: 64ch;
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.rn-changed-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin-right: 2px;
}
.rn-changed-when { color: var(--ink-4); }

.rn-sun-arc { margin-top: var(--space-3); }

/* ---------------- the next hours ---------------- */

.hours-section {
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
.hours-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-5);
}
.hours-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.hours-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--ink);
}
.hours-stamp { font-size: var(--text-xs); color: var(--ink-4); }

.hours-story {
  font-family: var(--font-display);
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--ink);
  margin: var(--space-2) 0 var(--space-4);
  max-width: 70ch;
}

.hr-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.hr-scroll:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.hr-track {
  position: relative;
  display: flex;
  align-items: stretch;
  width: max-content;
  min-width: 100%;
  padding: var(--space-2) var(--space-2) var(--space-2);
}

.hr-cell {
  flex: 0 0 62px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-2) 0 var(--space-1);
  scroll-snap-align: start;
  border-radius: var(--radius-md);
  font-variant-numeric: tabular-nums;
  position: relative;
  z-index: 1; /* above the chart's area fill, below its line */
}
.hr-cell.is-night { background: var(--wx-night); }
.hr-cell.is-now {
  background: var(--teal-light);
  box-shadow: inset 0 0 0 1px var(--teal);
}
.hr-cell.is-midnight { border-left: 1px dashed var(--line); border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.hr-cell.is-midnight .hr-time { color: var(--ink); font-weight: 700; }

.hr-time { font-size: var(--text-xs); font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.is-now .hr-time { color: var(--teal); text-transform: uppercase; letter-spacing: 0.06em; }
.hr-glyph { font-size: 1.15rem; line-height: 1.4; }
.hr-band { display: block; height: 46px; width: 100%; }
.hr-temp { font-weight: 700; font-size: var(--text-base); color: var(--ink); }
.hr-pop { font-size: var(--text-xs); font-weight: 600; color: var(--wx-rain); min-height: 1.1em; opacity: .75; }
.hr-pop.is-wet { opacity: 1; }
.hr-wind {
  font-size: var(--text-xs);
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 1.1em;
}
.hr-wind .wx-arrow { color: var(--ink-4); font-size: 0.9rem; }

.hr-sun { flex-basis: 56px; }
.hr-sun .hr-time { color: var(--coral); }
.hr-sunrise .hr-time { color: var(--wx-fair); }
.hr-sun-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hr-chart {
  position: absolute;
  left: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}
.hr-chart .hr-line { fill: none; stroke: var(--wx-warm); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hr-chart .hr-area { fill: var(--wx-warm); opacity: 0.08; }
.hr-chart .hr-rain { fill: var(--wx-rain); opacity: 0.35; }
.hr-chart .hr-now-dot { fill: var(--bg-raised); stroke: var(--wx-warm); stroke-width: 2; }

.hours-models {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-2);
  max-width: 80ch;
  line-height: 1.55;
}
.hours-models-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
  margin-right: 4px;
}

/* ---------------- My read — unchanged, a touch tighter ---------------- */
.read-inner { padding: var(--space-6) var(--space-5); }

/* ---------------- the week ahead: range rows ---------------- */

.week-inner { padding: var(--space-6) var(--space-5) var(--space-6); }
.week-head { margin-bottom: var(--space-4); }
.week-sub { margin-bottom: 0; }

.week-grid {
  display: block; /* override the old 7-column grid */
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.wk-row { border-bottom: 1px solid var(--line-soft); }
.wk-row:last-child { border-bottom: none; }
.wk-row.is-today { background: var(--teal-light); }
.wk-row.is-open { background: var(--bg-subtle); }
.wk-row.is-today.is-open { background: var(--teal-light); }

.wk-main {
  width: 100%;
  display: grid;
  grid-template-columns: 64px 28px 40px 38px minmax(80px, 1fr) 38px minmax(0, 1.6fr) 14px;
  grid-template-areas: "day glyph pop lo bar hi call caret";
  align-items: center;
  column-gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  min-height: 50px;
}
.wk-main:hover { background: rgba(46,125,138,0.06); }
.wk-main:focus-visible { outline: 2px solid var(--teal); outline-offset: -2px; }

.wk-day { grid-area: day; display: flex; flex-direction: column; line-height: 1.15; }
.wk-day-name { font-weight: 700; font-size: var(--text-sm); color: var(--ink); }
.is-today .wk-day-name { color: var(--teal); }
.wk-day-date { font-size: var(--text-xs); color: var(--ink-4); }
.wk-glyph { grid-area: glyph; font-size: 1.25rem; line-height: 1; text-align: center; }
.wk-pop { grid-area: pop; font-size: var(--text-xs); font-weight: 700; color: var(--wx-rain); text-align: right; font-variant-numeric: tabular-nums; }
.wk-lo { grid-area: lo; font-size: var(--text-sm); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.wk-hi { grid-area: hi; font-size: var(--text-base); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.wk-caret { grid-area: caret; color: var(--ink-4); font-size: 1.1rem; transition: transform .15s ease; justify-self: end; }
.is-open .wk-caret { transform: rotate(90deg); }

.wk-track {
  grid-area: bar;
  position: relative;
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}
[data-theme="dark"] .wk-track { background: #10233A; box-shadow: inset 0 0 0 1px #1E3551; }
.wk-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.wk-now {
  position: absolute;
  top: 50%;
  width: 12px; height: 12px;
  margin-left: -6px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--bg-raised);
  box-shadow: 0 0 0 2px var(--ink);
}
[data-theme="dark"] .wk-now { box-shadow: 0 0 0 2px var(--ink); }

.wk-model-chip {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--ink-3);
  border: 1px dashed var(--line);
  border-radius: var(--radius-full);
  padding: 0 6px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.wk-call {
  grid-area: call;
  font-size: var(--text-sm);
  color: var(--ink-2);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.wk-call-steve { font-family: var(--font-display); color: var(--ink); }

.wk-more {
  padding: 0 var(--space-4) var(--space-4) calc(64px + var(--space-4) + var(--space-2));
}
.wk-more p { font-size: var(--text-sm); line-height: 1.65; color: var(--ink); }
.wk-more p + p { margin-top: var(--space-2); }
.wk-nightwet { color: var(--wx-rain); font-weight: 600; }
.wk-model { color: var(--ink-2); }
.wk-nws { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px dashed var(--line); }
.wk-nws-label {
  font-size: var(--text-xs) !important;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: var(--space-1);
}

/* ---------------- life scores: window + sparkline ---------------- */

.life-inner { padding: var(--space-6) var(--space-5); }
.life-sub { margin-bottom: var(--space-4); }
.life-window { font-style: normal; font-weight: 600; color: var(--ink-2); }
.life-spark-wrap { margin-top: var(--space-2); }
.life-spark { display: block; width: 100%; height: 30px; }
.life-spark .spark-window { fill: var(--wx-good); opacity: 0.14; }
.life-spark .spark-area { fill: var(--ink-4); opacity: 0.12; }
.life-spark .spark-line { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linejoin: round; }
.life-spark .spark-now { fill: var(--coral); }
.life-great .life-spark .spark-line, .life-good .life-spark .spark-line { stroke: var(--wx-good); }
.life-fair .life-spark .spark-line { stroke: var(--wx-fair); }
.life-skip .life-spark .spark-line { stroke: var(--coral); }
.life-spark-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.life-deep-link {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--coral);
  text-decoration: none;
}
.life-deep-link:hover { text-decoration: underline; }

/* ---------------- swim: verdict + condition chips ---------------- */

.swim-inner { padding: var(--space-6) var(--space-5); }
.swim-head { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.swim-head .swim-title { margin-bottom: 0; }
.swim-verdict {
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  color: #fff;
  background: var(--ink-3);
}
.swim-v-good { background: var(--wx-good); }
.swim-v-fair { background: var(--wx-fair); color: #2B2000; }
.swim-v-bad  { background: var(--coral); }
.swim-conditions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.swim-cond {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
}
.swim-cond-k { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-4); }
.swim-cond-v { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.swim-cond-note { border: 0; background: none; color: var(--ink-4); font-size: var(--text-xs); padding-left: 0; }

/* ---------------- sources, moved to the bottom ---------------- */
.sources-section {
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
}
.sources-section .rn-sources {
  max-width: 860px;
  margin: 0 auto;
  padding: var(--space-5);
  border-top: 0;
}

/* ---------------- mobile ---------------- */
@media (max-width: 720px) {
  /* The NWS period sentence repeats what the story and the week rows say. */
  .rn-sub { display: none; }

  .rn-hero-inner { padding: var(--space-5) var(--space-4) var(--space-3); }
  .rn-big { font-size: 3rem; }
  .rn-desc { font-size: var(--text-lg); }
  .rn-chip { font-size: var(--text-xs); padding: 2px 8px; }
  .rn-sub { font-size: var(--text-xs); }

  .hours-inner { padding: var(--space-5) var(--space-4) var(--space-4); }
  .hours-story { font-size: var(--text-base); }
  .hr-cell { flex-basis: 56px; }
  .hr-sun { flex-basis: 52px; }
  .hr-band { height: 40px; }

  .week-inner, .life-inner, .swim-inner, .read-inner { padding: var(--space-5) var(--space-4); }
  .wk-main {
    grid-template-columns: 52px 24px 34px 32px minmax(60px, 1fr) 34px 12px;
    grid-template-areas:
      "day glyph pop lo bar hi caret"
      "call call call call call call call";
    row-gap: 2px;
    padding: var(--space-2) var(--space-3);
  }
  .wk-call { font-size: var(--text-xs); -webkit-line-clamp: 2; }
  .wk-more { padding-left: var(--space-3); }
  .wk-model-chip { display: none; }
  .swim-name { min-width: 7em; }
  /* Beach rows: name + status on one line, the sample time underneath. */
  .swim-row { flex-wrap: wrap; }
  .swim-status { flex: 1 1 auto; }
  .swim-when { flex-basis: 100%; padding-left: calc(1.2em + var(--space-3)); }
}

@media (max-width: 400px) {
  .wk-main { grid-template-columns: 46px 22px 30px 30px minmax(50px, 1fr) 30px 10px; column-gap: 6px; }
}
