/* The Weather tile, drawn by js/weather-tile/weather-tile.js into .weather-widget-mount.
   It sits on the tile's own sheet on every look, with no painted sky: colour is kept for the
   picture, the rain and the temperatures. Nothing here loops, so it costs nothing while it
   waits. What shows follows the tile's size: details go first, then days, then the line. */
:is(.weather-tile-panel, .weather-panel) {
  --wx-rain: #6db6ff;
  --wx-track: color-mix(in srgb, var(--text) 12%, transparent);
  --wx-now: color-mix(in srgb, var(--text) 7%, transparent);
}
.weather-tile-panel {
  padding: 0;
  overflow: hidden;
}
/* White clouds vanish on a light sheet: the pictures take a darker sky. */
:root[data-appearance="light"] :is(.weather-tile-panel, .weather-panel) {
  --wx-rain: #1a6fd0;
  --wx-now: color-mix(in srgb, var(--text) 6%, transparent);
  --sky-cloud-top: #c3d0e6;
  --sky-cloud-low: #8195b8;
  --sky-moon-top: #aebbdc;
  --sky-moon-low: #7c8db8;
  --sky-drop: #2f80d8;
  --sky-flake: #6f9bd6;
  --sky-haze: #8094b4;
}

.weather-widget-mount {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: inherit;
  container-type: size;
  overflow: hidden;
}
.weather-tile-root {
  --wx-gap: clamp(8px, 3cqmin, 14px);
  --wx-day: clamp(28px, max(8cqmin, 6cqh), 40px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: var(--wx-gap);
  height: 100%;
  min-height: 0;
  padding: clamp(12px, 4.4cqmin, 16px);
  color: var(--text);
}
.weather-tile-card {
  appearance: none;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.weather-tile-card:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.weather-tile--stale { opacity: 0.85; }

/* ── Now ── */
.weather-now {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "place place art"
    "temp lines art"
    "next next next";
  align-items: center;
  column-gap: clamp(8px, 3cqmin, 14px);
  width: 100%;
}
.weather-tile-root:not(.has-body) .weather-now { flex: 1 1 auto; align-content: center; }
.weather-now-place {
  grid-area: place;
  overflow: hidden;
  color: var(--muted-text);
  font-size: clamp(12px, 3.4cqmin, 15px);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.weather-now-temp {
  grid-area: temp;
  font-size: clamp(40px, 19cqmin, 92px);
  font-weight: 600;
  line-height: 1.05;
}
.weather-now-lines {
  grid-area: lines;
  display: grid;
  gap: 2px;
  min-width: 0;
  font-size: clamp(12px, 3.2cqmin, 14px);
  line-height: 1.25;
}
.weather-now-condition { font-weight: 600; }
.weather-now-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  color: var(--muted-text);
}
.weather-now-art {
  grid-area: art;
  display: block;
  width: clamp(52px, 25cqmin, 120px);
  aspect-ratio: 1;
}
.weather-now-art svg,
.weather-hour-art svg,
.weather-fc-art svg,
.weather-compact-icon svg { display: block; width: 100%; height: 100%; }
.weather-now-next {
  grid-area: next;
  margin-top: clamp(4px, 1.6cqmin, 8px);
  overflow: hidden;
  color: var(--muted-text);
  font-size: clamp(12px, 3.2cqmin, 14px);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.weather-now-next.is-wet { color: var(--wx-rain); }

/* ── Body: whatever the room left ── */
.weather-tile-body {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--wx-gap);
  min-width: 0;
  min-height: 0;
  cursor: pointer;
}

/* ── The next hours: one column each, in a grid one row high. Columns are at least --wx-col
   wide and share what is left; the ones that wrap land in rows of no height and are clipped,
   so a narrow tile keeps fewer hours whole instead of squeezing all of them. ── */
.weather-hours {
  --wx-col: clamp(46px, 13cqmin, 64px);
  --wx-hour-art: clamp(28px, 8.4cqmin, 46px);
  --wx-hour-temp: clamp(16px, 4.6cqmin, 24px);
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--wx-col), 1fr));
  grid-auto-rows: 0;
  grid-template-rows: auto;
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
}
.weather-hour {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1.3cqmin, 7px);
  min-width: 0;
  padding: clamp(6px, 1.8cqmin, 9px) 2px;
  border-radius: 12px;
}
/* The hour under way is the one the big number is about: it says so with a soft well. */
.weather-hour.is-now { background: var(--wx-now); }
.weather-hour-time {
  color: var(--muted-text);
  font-size: clamp(12px, 3.1cqmin, 14px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.weather-hour.is-now .weather-hour-time { color: var(--text); }
.weather-hour-art { display: block; width: var(--wx-hour-art); height: var(--wx-hour-art); }
.weather-hour-temp {
  font-size: var(--wx-hour-temp);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.1;
}
.weather-hour-rain {
  min-height: 1.2em;
  color: var(--wx-rain);
  font-size: clamp(11px, 2.8cqmin, 13px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1.2;
}

/* ── The next days. A flex column that wraps, in a box that hides the wrap: whole rows stay,
   the ones without room leave rather than get cut. ── */
.weather-forecast--rows {
  flex: 0 1000 auto;
  display: flex;
  flex-flow: column wrap;
  min-height: var(--wx-day);
  overflow: hidden;
}
.weather-fc-row {
  box-sizing: border-box;
  display: grid;
  /* The name asks for its width and stops at a third, so a narrow tile keeps its temperatures. */
  grid-template-columns: minmax(max(3em, min(var(--wx-name, 0px), 34%)), 0.9fr) 24px 2.3em minmax(44px, 3fr) 2.3em;
  align-items: center;
  gap: clamp(6px, 2cqmin, 10px);
  width: 100%;
  height: var(--wx-day);
}
.weather-fc-day {
  overflow: hidden;
  font-size: clamp(12px, 3cqmin, 14px);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.weather-fc-art { width: 24px; height: 24px; }
.weather-fc-min,
.weather-fc-max {
  font-size: clamp(12px, 3cqmin, 14px);
  font-variant-numeric: tabular-nums;
}
.weather-fc-min { color: var(--muted-text); text-align: right; }
.weather-fc-max { color: var(--text); font-weight: 600; }
.weather-fc-bar {
  position: relative;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--wx-track);
}
.weather-fc-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 8px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--cold), var(--warm));
}
