/*
  Layout, Typografie und Zustaende. Enthaelt bewusst keine literale Farbe --
  alles Farbige kommt aus theme.css. Pruefbar mit:
  grep -nE '#[0-9a-fA-F]{3,8}|rgba?\(' styles.css
*/

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, var(--bg-wash-a), transparent 38%),
    linear-gradient(315deg, var(--bg-wash-b), transparent 34%),
    var(--bg-page);
  color: var(--ink);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: currentColor;
}

.app-shell {
  width: min(960px, calc(100% - 24px));
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 10px 0 18px;
}

/* ---------------------------------------------------------------- Topbar */

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.topbar-identity {
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.45rem, 2.2vw, 2.05rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1rem, 1.35vw, 1.2rem);
  line-height: 1.12;
}

.station,
.observed-time,
.section-heading p,
.status-text {
  color: var(--ink-muted);
}

.station,
.observed-time {
  margin-bottom: 0;
  font-size: 0.82rem;
}

/* --------------------------------------------------------- Theme-Toggle */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-sunken);
  padding: 3px;
}

.theme-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 9px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.theme-option:hover {
  color: var(--ink);
}

.theme-option[aria-checked="true"] {
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  color: var(--accent-strong);
}

/* --------------------------------------------- Refresh-Button / Seitenlink */

.refresh-button,
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--ink);
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.nav-link {
  text-decoration: none;
  white-space: nowrap;
}

.refresh-button:hover,
.nav-link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.nav-link .icon {
  width: 1.05rem;
  height: 1.05rem;
  color: var(--accent);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.refresh-button .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.is-loading .refresh-icon {
  animation: spin 900ms linear infinite;
  transform-origin: 50% 50%;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------- Fokusring */

:where(button, a, select, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Der Graph ist selbst fokussierbar und sitzt in einem Panel mit
   overflow: hidden -- ein Ring nach aussen waere abgeschnitten. */
.history-chart:focus-visible {
  outline-offset: -3px;
}

/* Fuer Beschriftungen, die nur Screenreader brauchen. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------- Status / Fehler */

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin-bottom: 8px;
  padding: 0;
  font-size: 0.84rem;
}

.status-text {
  margin: 0;
  min-width: 0;
}

.status-icon {
  display: none;
  width: 1rem;
  height: 1rem;
  color: var(--danger);
}

.status-retry {
  border: 1px solid var(--danger-line);
  border-radius: 7px;
  background: transparent;
  color: var(--danger);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-retry:hover {
  background: var(--danger-soft);
}

/* Fehler wird nicht allein ueber Farbe signalisiert (WCAG 1.4.1), sondern
   zusaetzlich ueber Icon, Flaeche und Rahmen. */
.status-line.error {
  border: 1px solid var(--danger-line);
  border-radius: 9px;
  background: var(--danger-soft);
  padding: 6px 10px;
}

.status-line.error .status-text {
  color: var(--danger);
  font-weight: 700;
}

.status-line.error .status-icon {
  display: block;
}

/* ------------------------------------------------------------------ Main */

main {
  display: grid;
  gap: 10px;
  min-width: 0;
}

/* ------------------------------------------------------ Aktuell-Sektion */

.current-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  min-height: 176px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.current-main {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: clamp(12px, 2vw, 18px);
}

.current-head {
  min-width: 0;
}

.current-readout {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-width: 0;
}

.temperature-lockup {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--accent-strong);
}

.temperature-lockup span:first-child {
  font-size: clamp(2.45rem, 5.2vw, 3.75rem);
  font-weight: 850;
  line-height: 0.9;
}

.temperature-lockup span:last-child {
  margin-top: 3px;
  color: var(--warm);
  font-size: clamp(0.86rem, 1.35vw, 1.05rem);
  font-weight: 800;
}

.condition-label {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  font-size: clamp(0.9rem, 1.3vw, 1.05rem);
  font-weight: 700;
}

.current-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.current-metrics article,
.hour-card,
.day-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-sunken);
}

.current-metrics article {
  min-height: 48px;
  min-width: 0;
  padding: 8px 10px;
  overflow: hidden;
}

.current-metrics span,
.hour-card span,
.day-card span {
  display: block;
  color: var(--ink-muted);
  font-size: 0.74rem;
}

.current-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: clamp(0.82rem, 1vw, 0.92rem);
  line-height: 1.15;
}

.condition-visual {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 12px;
  background:
    linear-gradient(180deg, var(--accent-soft), transparent 70%),
    var(--surface-accent);
  border-left: 1px solid var(--line);
}

.condition-icon {
  width: min(104px, 100%);
  height: auto;
  aspect-ratio: 1;
  color: var(--accent);
  fill: currentColor;
}

/* Der Wolkenkoerper etwas zurueckgenommen, damit Sonne bzw. Niederschlag
   in den kombinierten Icons lesbar bleiben. */
.condition-icon .icon-cloud,
.icon .icon-cloud {
  opacity: 0.72;
}

/* --------------------------------------------------- Prognose / Ausblick */

.forecast-section,
.days-section {
  padding: 6px 0 0;
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-bottom: 6px;
}

.section-heading > div {
  min-width: 0;
}

.section-heading > p {
  margin-bottom: 0;
  font-size: 0.82rem;
  text-align: right;
}

.forecast-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.forecast-controls p {
  margin-bottom: 0;
  font-size: 0.82rem;
  text-align: right;
}

/* Gegenstueck zur Tagesauswahl: fuehrt zurueck auf die Standardansicht.
   aria-pressed spiegelt, ob diese Ansicht gerade aktiv ist -- gleiche
   Zustandslogik wie bei .day-card. */
.now-button {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.now-button:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.now-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ------------------------------------------------------------------ Chart */

.chart-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  margin-bottom: 8px;
  height: 150px;
  max-width: 100%;
  min-width: 0;
  min-height: 150px;
  overflow: hidden;
}

.temperature-chart {
  display: grid;
  place-items: center;
  width: 100%;
  height: 150px;
  min-width: 0;
  min-height: 150px;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.temperature-chart svg {
  display: block;
  width: 100%;
  height: 150px;
  min-height: 150px;
}

.chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-area {
  fill: url(#chartAreaGradient);
}

.chart-area-from {
  stop-color: var(--chart-area-from);
}

.chart-area-to {
  stop-color: var(--chart-area-to);
}

.chart-line {
  fill: none;
  stroke: var(--chart-line);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.chart-dot {
  fill: var(--chart-dot);
  stroke: var(--chart-dot-halo);
  stroke-width: 1.5;
}

.chart-label {
  fill: var(--chart-label);
  font-size: 10px;
  font-weight: 700;
}

/* Hover-Elemente: standardmaessig versteckt, erst bei Mauskontakt sichtbar. */
.chart-guide,
.chart-hover-dot,
.chart-tooltip {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.temperature-chart.is-hovering .chart-hover-dot,
.temperature-chart.is-hovering .chart-tooltip,
.history-chart.is-hovering .chart-hover-dot,
.history-chart.is-hovering .chart-tooltip {
  opacity: 1;
}

/* Die Hilfslinie bleibt zurueckgenommen, damit sie die Kurve nicht ueberlagert.
   Der Wert gehoert in den Hover-Zustand: als Teil der Basisregel wuerde er die
   Grundeinstellung opacity: 0 ueberschreiben und die Linie dauerhaft bei x=0
   stehen lassen. */
.temperature-chart.is-hovering .chart-guide,
.history-chart.is-hovering .chart-guide {
  opacity: 0.5;
}

.chart-guide {
  stroke: var(--chart-line);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-hover-dot {
  fill: var(--chart-dot);
  stroke: var(--chart-dot-halo);
  stroke-width: 2;
}

.chart-tooltip-box {
  fill: var(--tooltip-bg);
  stroke: var(--line);
  stroke-width: 1;
}

.chart-tooltip-time {
  fill: var(--chart-label);
  font-size: 9px;
  font-weight: 700;
}

.chart-tooltip-temp {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

/* ------------------------------------------------------- Stundenprognose */

.hourly-track {
  display: grid;
  grid-auto-columns: minmax(108px, 1fr);
  grid-auto-flow: column;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
}

/* Scroll-Affordance: nur solange rechts noch etwas kommt. Das Attribut setzt
   app.js beim Scrollen und bei Groessenaenderungen. */
/* black/transparent ist hier eine Alpha-Rampe der Maske, keine Themefarbe. */
.hourly-track[data-overflow="end"] {
  mask-image: linear-gradient(
    90deg,
    black 0,
    black calc(100% - 40px),
    transparent
  );
}

.hour-card {
  display: flex;
  flex-direction: column;
  min-height: 96px;
  min-width: 0;
  padding: 8px;
  scroll-snap-align: start;
}

.hour-card time {
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 800;
}

.hour-icon {
  width: 1.35rem;
  height: 1.35rem;
  margin: 5px 0 2px;
  color: var(--accent);
}

.hour-card strong {
  display: block;
  margin: 0 0 4px;
  font-size: 0.98rem;
  line-height: 1;
}

.hour-card span + span {
  margin-top: 3px;
}

.placeholder {
  color: var(--ink-subtle);
}

/* ------------------------------------------------------------ Tageskarten */

.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 7px;
  min-width: 0;
}

.day-card {
  min-height: 74px;
  min-width: 0;
  padding: 8px;
  overflow: hidden;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.day-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.day-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Die Selektoren sind bewusst auf .day-card gescopet: die generische Regel
   `.day-card span` weiter oben ist gleich spezifisch und wuerde sonst
   display/Farbe dieser Bausteine ueberschreiben. */
.day-card .day-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.day-card .day-name {
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 700;
}

.day-icon {
  width: 1.3rem;
  height: 1.3rem;
  color: var(--accent);
}

.day-card strong {
  display: block;
  margin: 5px 0 4px;
  font-size: 0.88rem;
}

.day-card span + span {
  margin-top: 2px;
}

/*
  Min/Max-Balken. --range-start und --range-end sind Prozentwerte relativ zur
  Spanne aller sichtbaren Tage und werden inline in renderDaySummaries gesetzt.
*/
.day-card .range-bar {
  display: block;
  position: relative;
  height: 5px;
  margin: 6px 0 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.day-card .range-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--range-start, 0%);
  right: calc(100% - var(--range-end, 100%));
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--warm));
}

/* ====================================================================== */
/* Historienseite                                                         */
/* ====================================================================== */

/* ------------------------------------------------------------ Filterzeile */

/* Eine Filterzeile ueber allem, was sie einschraenkt: Ort und Zeitraum gelten
   fuer Kennzahlen, Diagramm und Tabelle gleichermassen. */
.filter-bar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.filter-label .icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--accent);
}

.select-control {
  min-height: 38px;
  min-width: 210px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--ink);
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 700;
  transition: border-color 160ms ease;
}

.select-control:hover {
  border-color: var(--accent);
}

.select-control:disabled {
  cursor: wait;
  opacity: 0.62;
}

/* ------------------------------------------------------ Zeitraum-Segmente */

.segmented {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-sunken);
  padding: 3px;
}

.segment {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-muted);
  padding: 8px 13px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  transition:
    background 160ms ease,
    color 160ms ease;
}

.segment:hover {
  color: var(--ink);
}

.segment[aria-checked="true"] {
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  color: var(--accent-strong);
}

/* --------------------------------------------------------- Messwert-Tabs */

.metric-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.metric-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.metric-tab .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.metric-tab:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.metric-tab[aria-checked="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ------------------------------------------------------------ Kennzahlen */

.stats-section,
.chart-section {
  padding: 6px 0 0;
  min-width: 0;
}

/* 240px als Mindestbreite ergibt auf dem Desktop drei Spalten -- bei sechs
   Karten also zwei volle Reihen statt einer angebrochenen. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  min-width: 0;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-sunken);
  min-width: 0;
  padding: 10px 12px;
  overflow: hidden;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.stat-label .icon {
  width: 0.95rem;
  height: 0.95rem;
  color: var(--accent);
}

/* Proportionale Ziffern: tabular-nums laesst grosse Zahlen locker wirken und
   lohnt erst, wo Werte untereinander stehen -- also in der Tabelle. */
.stat-value {
  display: block;
  margin: 6px 0 3px;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  line-height: 1.1;
}

.stat-detail {
  display: block;
  color: var(--ink-subtle);
  font-size: 0.74rem;
  line-height: 1.35;
}

.empty-note {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  color: var(--ink-muted);
  padding: 14px 16px;
  font-size: 0.86rem;
  line-height: 1.5;
  text-wrap: pretty;
}

/* --------------------------------------------------------- Verlaufsgraph */

.history-chart-panel {
  height: 260px;
  min-height: 260px;
}

/* Innen 100% statt erneut 260px: das Panel rechnet mit border-box, seine
   Innenhoehe ist also um die Rahmenstaerke kleiner -- sonst schnitte
   overflow: hidden die unterste Achsenbeschriftung an. */
.history-chart {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.history-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.history-chart .empty-note {
  border: 0;
  background: transparent;
  text-align: center;
}

/* Streuband aus Min und Max je Bucket -- macht sichtbar, welche Spanne hinter
   einem zusammengefassten Mittelwert steckt. */
.chart-band {
  fill: var(--chart-band);
}

.chart-bar {
  fill: var(--chart-bar);
}

/* Nur die Extremwerte tragen eine feste Beschriftung. Der Halo aus
   paint-order haelt sie ueber Linie und Band lesbar. */
.chart-value-label {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 800;
  paint-order: stroke;
  stroke: var(--chart-dot-halo);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.chart-note {
  fill: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
}

/* Zweitweg zum Wert neben dem Tooltip: bleibt stehen, funktioniert per
   Tastatur und wird von Screenreadern vorgelesen (aria-live). */
.chart-readout {
  margin: 7px 2px 0;
  min-height: 20px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------- Tagestabelle */

.table-wrap {
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
}

.data-table thead th {
  background: var(--surface-sunken);
  color: var(--ink-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody th {
  color: var(--accent-strong);
  font-weight: 700;
}

/* Gleich breite Ziffern, damit die Spalten untereinander fluchten. */
.data-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .condition-cell {
  padding-right: 0;
}

.data-table .condition-cell .day-icon {
  display: block;
  color: var(--accent);
}

.data-table .table-empty {
  color: var(--ink-muted);
  padding: 16px 12px;
  text-align: center;
  white-space: normal;
}

/* Kein Skeleton beim Nachladen: der vorherige Stand bleibt gedimmt stehen,
   damit nichts springt. Skeletons gibt es nur beim allerersten Aufbau. */
.history-shell.is-loading:not(.is-initial) main {
  opacity: 0.55;
  transition: opacity 160ms ease;
}

/* ---------------------------------------------------------- Ladezustand */

/* Skeletons nur beim allerersten Laden -- ein Refresh soll die bereits
   sichtbaren Werte nicht ausblenden. */
.app-shell.is-initial.is-loading .value {
  border-radius: 6px;
  background: var(--skeleton);
  color: transparent;
}

.app-shell.is-initial.is-loading .temperature-lockup span:last-child,
.app-shell.is-initial.is-loading .condition-visual {
  opacity: 0.35;
}

@media (prefers-reduced-motion: no-preference) {
  .app-shell.is-initial.is-loading .value {
    background: linear-gradient(
      90deg,
      var(--skeleton) 0%,
      var(--skeleton-shine) 50%,
      var(--skeleton) 100%
    );
    background-size: 220% 100%;
    animation: shimmer 1400ms ease-in-out infinite;
  }
}

@keyframes shimmer {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

/* ------------------------------------------------------------ Responsive */

/*
  Der One-Screen-Look bleibt, aber nur wenn das Fenster hoch genug ist.
  Darunter scrollt die Seite normal, statt Inhalt abzuschneiden.

  Ausgenommen ist die Historienseite: sie bringt Tabelle und Kennzahlen mit und
  ist auf Scrollen ausgelegt. Deshalb haengt jede Regel hier an
  html:not([data-page="history"]) -- sonst wuerde ihr das overflow: hidden den
  Inhalt abschneiden.
*/
@media (min-width: 861px) and (min-height: 760px) {
  html:not([data-page="history"]),
  html:not([data-page="history"]) body {
    height: 100%;
  }

  html:not([data-page="history"]) body {
    overflow-y: hidden;
  }

  html:not([data-page="history"]) .app-shell {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100svh;
    overflow: hidden;
  }

  html:not([data-page="history"]) main {
    align-content: start;
    grid-template-rows: auto auto auto;
    overflow: hidden;
  }

  html:not([data-page="history"]) .forecast-section {
    display: grid;
    grid-template-rows: auto auto auto;
    overflow: hidden;
  }

  html:not([data-page="history"]) .hourly-track {
    align-content: start;
    overflow-y: hidden;
  }

  html:not([data-page="history"]) .days-section {
    overflow: hidden;
  }
}

@media (max-width: 860px) {
  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .section-heading > p,
  .forecast-controls p {
    text-align: left;
  }

  .forecast-controls {
    margin-top: 6px;
  }

  .current-section {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .condition-visual {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px;
  }

  .condition-icon {
    width: 76px;
  }

  .day-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 960px);
    padding-top: 10px;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .theme-option span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .theme-option {
    padding: 7px 11px;
  }

  .refresh-button,
  .nav-link {
    flex: 1;
  }

  .filter-field,
  .select-control,
  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
    padding: 8px 6px;
  }

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

  .current-main {
    padding: 12px;
  }

  .temperature-lockup span:first-child {
    font-size: clamp(2.4rem, 13vw, 3.5rem);
  }

  .current-metrics {
    grid-template-columns: 1fr;
  }

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

  .forecast-section,
  .days-section {
    padding-top: 6px;
  }
}

/* ------------------------------------------------------- Reduced Motion */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .refresh-button:hover,
  .day-card:hover {
    transform: none;
  }
}
