/* airtemp - a single calm status card. Mobile-first, light/dark aware.
   The --accent colour is set by app.js from the current temperature (cold blue
   through to hot red); the value here is the neutral fallback before JS runs. */

:root {
  --accent: #1f9d57;
  --humidity: #5f7fb8;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #5c626b;
  --line: #e4e7ec;
  --warn-bg: #fff4e5;
  --warn-text: #7a4a00;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #171b22;
    --text: #eceef1;
    --muted: #9aa2ad;
    --humidity: #7f9bd0;
    --line: #262c36;
    --warn-bg: #2a2213;
    --warn-text: #f0c67a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: 1rem;
  padding: 1.25rem;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.card {
  width: 100%;
  max-width: 27rem;
  align-self: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 4vw, 2rem);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.device {
  margin: 0;
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.toggle {
  flex: none;
  font: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.toggle:hover {
  color: var(--text);
  border-color: var(--muted);
}

.reading {
  text-align: center;
  margin: 0.5rem 0 1.25rem;
}

.temp {
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0.06em;
}

.temp__value {
  font-size: clamp(3.75rem, 22vw, 6rem);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.temp__unit {
  font-size: clamp(1.25rem, 6vw, 1.9rem);
  font-weight: 600;
  color: var(--accent);
  margin-top: 0.5em;
}

.humidity {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.humidity__value {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.meta__item {
  text-align: center;
}

.meta__key {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.meta__val {
  margin: 0;
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.trend {
  position: relative;
  margin: 1.1rem 0 0;
}

.trend__canvas {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.trend__caption {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.trend__tip {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}

.trend__legend {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  display: flex;
  gap: 1.1rem;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.trend__legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  display: inline-block;
}

.swatch--temp {
  background: var(--accent);
}

.swatch--hum {
  background: var(--humidity);
}

.note {
  margin: 1rem 0 0;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  font-size: 0.82rem;
}

.note--warn {
  background: var(--warn-bg);
  color: var(--warn-text);
}

.foot {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  margin: 0;
}

:where(a, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
