/* Weather strip — per-day forecast for the Western route.
   Injected via quartz.config.yaml additionalHead. Renders only on the route
   page (see weather.js, which guards on <body data-slug>). */

.weather-widget {
  margin: 2rem 0;
  padding: 1rem 1.15rem;
  border: 1px solid var(--lightgray);
  border-radius: 8px;
  background: var(--highlight);
}

.weather-widget-heading {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.weather-widget-note {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--darkgray);
}

.weather-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* First column is the condition glyph, then day, date, place, rain, sun, temp. */
.weather-row {
  display: grid;
  /* Fixed tracks sized to their content, with the overnight place taking the
     slack. "Tokushima"/"Matsuyama" were wrapping because `auto` on the sun
     column let the 1fr place column shrink below its longest word. */
  grid-template-columns:
    max-content  max-content  minmax(7.5rem, 1fr)
    minmax(7rem, max-content) minmax(5.5rem, max-content)
    minmax(4.5rem, max-content) max-content;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border-top: 1px solid var(--lightgray);
  font-size: 0.92rem;
}

.weather-cond {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.weather-cond-icon {
  font-size: 1rem;
  line-height: 1;
}

.weather-cond-label {
  font-size: 0.85rem;
}

.weather-row:first-child {
  border-top: none;
}

.weather-day {
  font-weight: 600;
}

.weather-date,
.weather-cond {
  color: var(--darkgray);
  font-size: 0.85rem;
}

.weather-place {
  font-weight: 500;
}

.weather-temp {
  font-family: var(--font-code, monospace);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Column headers — hidden on mobile where the rows stack instead. */
.weather-head {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--darkgray);
  padding-bottom: 0.45rem;
  border-top: none;
}

.weather-rain,
.weather-sun {
  font-size: 0.8rem;
  color: var(--darkgray);
  white-space: nowrap;
}

/* Severe weather (thunderstorm) gets a warning tone. */
.weather-cond[data-state="warn"] {
  color: #b45309;
}

/* A 40%+ chance of rain is worth noticing before setting off. */
.weather-rain[data-state="warn"] {
  color: #b45309;
  font-weight: 600;
}

/* Mobile: two lines per day, no columns.
   Line 1 — day + conditions + temp (the primary scan)
   Line 2 — date · place · rain · sun (muted metadata)

   Selectors are prefixed with `.weather-widget` so they beat the base
   `.weather-row` grid rule on specificity, not source order. Previously both
   had the same specificity, so this mobile block was leaking onto desktop and
   flattening the table. */
/* Mobile: two lines per day.
   line 1 — day · conditions · temp
   line 2 — date · place · rain · sun
   Flat DOM order is preserved from desktop; `order` moves each child, so the
   same markup serves both layouts without a wrapper element. Prefixed with
   .weather-widget so it beats the base .weather-row grid on specificity —
   previously both were equally specific and the mobile rules leaked onto
   desktop, flattening the table into a run-on line. */
/* Mobile: two lines per day.
   line 1 — day | conditions | temp
   line 2 — date | place | rain | sun

   Flat DOM order (shared with the desktop grid) is preserved; every child is
   placed into its own explicit cell. An earlier grid-template-areas attempt
   put .weather-day and .weather-cond in one area, and stacked rain/sun in one
   column, so the cells overlapped.

   Prefixed with .weather-widget so these beat the base `.weather-row` grid on
   specificity — when both were equally specific the mobile rules leaked onto
   desktop and flattened the table into one run-on line. */
@media (max-width: 760px) {
  .weather-widget .weather-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    column-gap: 0.5rem;
    row-gap: 0.25rem;
    padding: 0.55rem 0;
    align-items: baseline;
  }

  .weather-widget .weather-row .weather-day {
    grid-column: 1;
    grid-row: 1;
  }
  .weather-widget .weather-row .weather-cond {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .weather-widget .weather-row .weather-temp {
    grid-column: 4;
    grid-row: 1;
    text-align: right;
  }

  .weather-widget .weather-row .weather-date {
    grid-column: 1;
    grid-row: 2;
  }
  .weather-widget .weather-row .weather-place {
    grid-column: 2;
    grid-row: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .weather-widget .weather-row .weather-rain {
    grid-column: 3;
    grid-row: 2;
    text-align: right;
  }
  .weather-widget .weather-row .weather-sun {
    grid-column: 4;
    grid-row: 2;
    text-align: right;
  }

  .weather-widget .weather-row .weather-date,
  .weather-widget .weather-row .weather-place,
  .weather-widget .weather-row .weather-rain,
  .weather-widget .weather-row .weather-sun {
    font-size: 0.75rem;
    color: var(--darkgray);
    white-space: nowrap;
  }
  .weather-widget .weather-row .weather-place {
    color: var(--secondary);
    font-weight: 500;
  }
  .weather-widget .weather-row .weather-rain[data-state="warn"] {
    color: #b45309;
    font-weight: 600;
  }

  /* A two-line row cannot carry a column header, and every value states its
     own unit (% rain, mm, h sun, degrees), so drop it on phones. */
  .weather-widget .weather-head {
    display: none;
  }
}

/* Very narrow: the place name needs room more than sun does, so sun goes. */
@media (max-width: 360px) {
  .weather-widget .weather-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .weather-widget .weather-row .weather-sun {
    display: none;
  }
  .weather-widget .weather-row .weather-rain {
    grid-column: 3;
  }
  .weather-widget .weather-row .weather-temp {
    grid-column: 3;
  }
  .weather-widget .weather-row .weather-rain {
    grid-row: 3;
    text-align: left;
  }
}
