/* Layout: the page frame, the seven-day grid, and the loading/error panels.
   Responsive refinement lands in US3. */

.frame {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}

/* The page body must never scroll sideways, whatever a card contains. */
html,
body {
  overflow-x: hidden;
}

/* Sprites scale with the viewport but never exceed their design size. */
.sprite {
  width: clamp(2.5rem, 9vw, 3rem);
  height: clamp(2.5rem, 9vw, 3rem);
}

/* --- Masthead ------------------------------------------------------------ */

.masthead {
  text-align: center;
  margin-bottom: 1.75rem;
}

.masthead__title {
  /* The pixel font is very wide; scale fluidly so the title never forces the
     page wider than 320px. */
  font-size: clamp(0.8rem, 4.5vw, 1.25rem);
  line-height: 1.6;
  margin-bottom: 0.85rem;
}

.masthead__location {
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.masthead__subtitle {
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* --- Forecast grid ------------------------------------------------------- */

/* Narrow screens: one card per row, laid out horizontally so a day reads
   left-to-right like a list entry. */
.forecast {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* The grid item is the <li>; the button inside it is the card. A single-cell
   grid here makes the button fill the slot, so cards in a row stay equal
   height now that the card is a control rather than the list item itself. */
.day-slot {
  display: grid;
}

.day {
  display: grid;
  grid-template-columns: auto auto 1fr;
  grid-template-areas:
    'header art temps'
    'condition condition temps';
  align-items: center;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 1rem;
}

.day__header {
  grid-area: header;
  min-width: 5rem;
}

.day__art {
  grid-area: art;
  justify-self: start;
}

.day__condition {
  grid-area: condition;
  font-size: 0.75rem;
}

.day__temps {
  grid-area: temps;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: flex-end;
}

/* Wider screens: the week becomes a row of vertical cards. auto-fit means the
   column count follows the available width on its own — 2 up on a large phone,
   7 across on a desktop — without a breakpoint for every step. */
@media (min-width: 34rem) {
  .forecast {
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  }

  .day {
    grid-template-columns: 1fr;
    grid-template-areas:
      'header'
      'art'
      'condition'
      'temps';
    justify-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
  }

  .day__header {
    min-width: 0;
  }

  .day__art {
    justify-self: center;
  }

  .day__temps {
    justify-content: center;
  }
}

.day__temp {
  /* Reserve room for four characters so "-12°" never reflows the card. */
  min-width: 3.25ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.day__temp--max {
  font-size: 1.05rem;
}

.day__temp--min {
  font-size: 0.85rem;
}

.day__weekday {
  font-size: 0.8rem;
}

.day__date {
  font-size: 0.7rem;
  margin-top: 0.2rem;
}

/* --- Loading and error panels -------------------------------------------- */

.panel {
  text-align: center;
  padding: 3rem 1rem;
}

.panel__art {
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  margin-bottom: 1rem;
}

.panel__message {
  font-size: 0.85rem;
  line-height: 1.7;
}

.panel__hint {
  font-size: 0.75rem;
  margin-top: 0.75rem;
}

/* --- Current conditions panel (004) -------------------------------------- */

/* One hero statement, not another table of rows competing with the daily
   detail below it (VS-001). The sprite and temperature sit side by side, the
   condition under them, and the five supporting values wrap beneath. */
.current {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.5rem;
  padding: 1rem 1.15rem 1.15rem;
  margin-bottom: 1.5rem;
}

/* Empty when there is no reading worth showing (FR-010). Collapse it entirely
   so the page looks exactly as it did before this feature. */
.current:empty {
  display: none;
}

.current__heading {
  grid-column: 1 / -1;
  font-size: clamp(0.62rem, 3vw, 0.8rem);
  line-height: 1.6;
  margin-bottom: 0.35rem;
}

.current__art {
  grid-column: 1;
  display: flex;
  align-items: center;
}

/* The panel's sprite is the largest on the page — this is the one place a
   daytime sun at 22:00 would be unmistakable, which is why the night variants
   exist (FR-015). */
.current__art .sprite {
  width: clamp(3.25rem, 15vw, 4.5rem);
  height: clamp(3.25rem, 15vw, 4.5rem);
}

/* FR-003: the most prominent number on the page. The forecast bar's
   temperatures sit at 1.05rem, so the floor here is deliberately well above
   them even at 320px. VS-006: must survive "-19°" uncropped, hence the fluid
   middle term rather than a fixed size. */
.current__temp {
  grid-column: 2;
  font-size: clamp(2.25rem, 13vw, 3.5rem);
  line-height: 1.05;
  white-space: nowrap;
}

.current__condition {
  grid-column: 2;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
}

/* The five supporting values span the full width below the hero, so they read
   as subordinate to it rather than beside it. */
.current__list {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.4rem 1rem;
  margin-top: 0.65rem;
  padding-top: 0.75rem;
}

.current__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.current__label {
  font-size: 0.65rem;
}

.current__value {
  font-size: 0.72rem;
  white-space: nowrap;
}

/* The observation stamp and the staleness line both span the full width below
   the values, so they read as statements about the whole panel. */
.current__observed,
.current__note,
.current__stale {
  grid-column: 1 / -1;
  font-size: 0.65rem;
  line-height: 1.6;
}

.current__observed {
  margin-top: 0.5rem;
}

.current__note {
  margin-top: 0.15rem;
}

.current__stale {
  margin-top: 0.35rem;
  padding: 0.4rem 0.55rem;
}

/* Very narrow screens (FR-018, VS-006). At 320px the hero, the sprite and a
   two-column value grid cannot all hold their width, so the sprite and the
   temperature stack and the values drop to a single column. The alternative —
   letting the grid stay two-wide — is what pushes "-19°" off the edge. */
@media (max-width: 22rem) {
  .current {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    padding: 0.85rem 0.75rem 1rem;
  }

  .current__temp,
  .current__condition {
    grid-column: 1;
  }

  .current__list {
    grid-template-columns: 1fr;
  }

  .current__row {
    /* Left-aligned labels with right-aligned values stay readable in a single
       column; centring them would leave the numbers wandering. */
    text-align: left;
    width: 100%;
  }
}

/* --- Notices and colophon ------------------------------------------------ */

.notice {
  font-size: 0.7rem;
  line-height: 1.7;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

.freshness {
  font-size: 0.7rem;
  text-align: center;
  margin-top: 1.25rem;
}

.colophon {
  font-size: 0.65rem;
  text-align: center;
  margin-top: 2rem;
  line-height: 1.8;
}

/* --- Utilities ----------------------------------------------------------- */

.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;
}

/* --- Selected-day detail -------------------------------------------------- */
/* Sits directly below the bar (FR-002); the freshness stamp stays after it. */

.detail {
  margin-top: 1.25rem;
  padding: 1rem;
}

.detail__heading {
  font-size: 0.75rem;
  line-height: 1.6;
  margin-bottom: 0.9rem;
  text-align: center;
}

/* Narrow screens: one label/value pair per row, label left, value right. The
   pair stays on one line so nine rows do not become eighteen at 320px. */
.detail__list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem;
}

.detail__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0.25rem;
}

.detail__label {
  font-size: 0.7rem;
}

.detail__value {
  font-size: 0.8rem;
  text-align: right;
  /* Values line up column-wise as the visitor switches days. */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.detail__empty {
  font-size: 0.75rem;
  line-height: 1.7;
  text-align: center;
  padding: 1.5rem 0.5rem;
}

@media (min-width: 34rem) {
  .detail {
    padding: 1.25rem 1.5rem;
  }

  .detail__heading {
    font-size: 0.85rem;
  }
}

/* Wider screens: exactly three columns of three, so nine rows stop being a
   long scroll. The count is pinned rather than auto-fit because the row
   separators in theme.css key off nth-child(3n+1) — a variable column count
   would put the rules in the wrong places. */
@media (min-width: 48rem) {
  .detail__list {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.15rem 1.5rem;
  }
}

/* At the narrowest widths the label and value can collide; let the pair wrap
   rather than force the page to scroll sideways (FR-016). */
@media (max-width: 22rem) {
  .detail {
    padding: 0.85rem 0.6rem;
  }

  .detail__row {
    flex-wrap: wrap;
    gap: 0 0.5rem;
  }

  .detail__value {
    white-space: normal;
  }
}

/* --- Skip link ------------------------------------------------------------ */
/* Every hour tile is an ordinary Tab stop, which is correct but means ~24 of
   them. This is the escape hatch, and the reason no roving-tabindex widget was
   built (FR-018a, research R9). Hidden until focused, fully visible while it
   holds focus. */

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

.skip-link:focus-visible,
.skip-link:focus {
  position: static;
  display: block;
  width: auto;
  height: auto;
  margin: 1rem 0 0;
  padding: 0.6rem 0.75rem;
  overflow: visible;
  clip: auto;
  font-size: 0.7rem;
  text-align: center;
}

/* --- Hourly strip --------------------------------------------------------- */
/* Sits directly below the daily detail (FR-001). Scrolls within itself and
   never lets the page scroll sideways (FR-021). */

.hours-region {
  margin-top: 1.25rem;
}

.hours {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 0.25rem;
  /* The strip owns its overflow. This is what keeps sideways movement inside
     the component instead of on the page (FR-021, SC-005). */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  /* Momentum scrolling on touch without hijacking vertical page scroll. */
  overscroll-behavior-x: contain;
}

.hour-slot {
  display: flex;
}

/* 2.5rem tiles, and the arithmetic is worth writing down because the obvious
   answer is wrong. At 320px the page keeps 1rem of padding each side, leaving
   288px — but the strip is not 288px wide: its region border takes 4px and its
   own padding another 8px, leaving 276px of actual track.

     40px tiles + 4px gaps -> 6 fit in 260px, with 16px to spare
     48px tiles + 4px gaps -> only 5 fit

   So six-at-320px (SC-010) needs 40px, not the 48px a naive 288 ÷ 6 suggests.
   The 16px of slack shows a sliver of the seventh tile, which is also the
   cheapest possible answer to "more hours exist that way" (VS-006). */
.hour {
  flex: 0 0 2.5rem;
  display: grid;
  gap: 0.15rem;
  justify-items: center;
  padding: 0.4rem 0.1rem;
  width: 2.5rem;
}

/* The narrow --mono face, not --pixel: "16:00" is five characters and must
   stay a full clock time at 48px wide (VS-005). */
.hour__time {
  font-size: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.hour__art {
  width: 1.25rem;
  height: 1.25rem;
}

.hour__temp,
.hour__rain {
  font-size: 0.6rem;
  font-variant-numeric: tabular-nums;
}

.hours__empty {
  font-size: 0.75rem;
  line-height: 1.7;
  text-align: center;
  padding: 1.5rem 0.5rem;
}

/* Roomier tiles once there is width for them; the strip still scrolls, since
   24 hours never fit at any supported width. */
@media (min-width: 34rem) {
  .hour {
    flex-basis: 3.5rem;
    width: 3.5rem;
    padding: 0.5rem 0.15rem;
  }

  .hour__time,
  .hour__temp,
  .hour__rain {
    font-size: 0.65rem;
  }

  .hour__art {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* --- Chosen-hour panel ---------------------------------------------------- */
/* Sits directly below the strip (FR-007). Content below the strip, never
   above: that placement is why re-rendering this panel cannot shift the
   timeline the visitor is pointing at. */

.hour-detail {
  margin-top: 0.5rem;
  padding: 1rem;
  /* Load-bearing, and the least obvious rule in this file.

     The nine rows are fixed in number, but not in height: "Thunderstorm with
     heavy hail" wraps to two lines at 320px where "Clear" does not. Without a
     floor, choosing an hour changes the document height, the browser clamps
     the scroll position of a visitor near the page bottom, and the page moves
     under them — with no scroll call made anywhere. Reserving the space is the
     whole fix (research R7a, the second half of FR-013). */
  min-height: 17rem;
}

/* Focused only as the skip link's destination; it is not a tab stop itself, so
   it must not advertise a focus ring the way an interactive control would. */
.hour-detail:focus {
  outline: none;
}

.hour-detail__heading {
  font-size: 0.7rem;
  line-height: 1.6;
  margin-bottom: 0.9rem;
  text-align: center;
}

.hour-detail__list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.15rem;
}

.hour-detail__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.25rem;
}

.hour-detail__label {
  font-size: 0.7rem;
}

.hour-detail__value {
  font-size: 0.75rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 34rem) {
  .hour-detail {
    padding: 1.25rem 1.5rem;
    /* Wider rows wrap less, so less space needs reserving. */
    min-height: 15rem;
  }

  .hour-detail__heading {
    font-size: 0.8rem;
  }
}

/* Three columns of three, matching the daily table's shape at this width. */
@media (min-width: 48rem) {
  .hour-detail__list {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.15rem 1.5rem;
  }

  .hour-detail {
    min-height: 9rem;
  }
}

@media (max-width: 22rem) {
  .hour-detail {
    padding: 0.85rem 0.6rem;
    /* Narrower still: assume more rows wrap, not fewer. */
    min-height: 19rem;
  }

  .hour-detail__row {
    flex-wrap: wrap;
    gap: 0 0.5rem;
  }
}
