/* Airyn live demo — projector-first. Single dark theme on purpose:
   the page is only ever shown on a stage screen, so it commits to one
   look rather than following the viewer's OS preference. */

:root {
  --bg:        #0B1211;
  --bg-2:      #121C1A;
  --line:      #22302D;
  --ink:       #E8F1EE;
  --muted:     #7E948F;
  --hum:       #3CC1B3;
  --hum-dim:   rgba(60, 193, 179, 0.16);
  --co2:       #E5943C;
  --co2-dim:   rgba(229, 148, 60, 0.16);
  --voc:       #9B8CF0;
  --ok:        #3CC1B3;
  --warn:      #E5943C;
  --stale:     #6B7D79;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --num: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* Must outrank the display rules below: .gate and .stage both set `display`,
   which would otherwise beat the UA stylesheet's [hidden] and leave the login
   overlay covering the live page forever. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

/* ── Sign in ──────────────────────────────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(1100px 620px at 50% 12%, #16302C 0%, var(--bg) 62%);
  padding: 24px;
  z-index: 40;
}
.gate-card {
  width: min(420px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gate-mark {
  font-size: 0.72rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--hum);
  font-weight: 700;
}
.gate-card h1 { margin: 6px 0 0; font-size: 1.7rem; letter-spacing: -0.02em; }
.gate-sub { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.gate-card label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-top: 10px;
}
.gate-card input {
  background: #0C1614;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 1rem;
  font-family: var(--sans);
}
.gate-card input:focus-visible { outline: 2px solid var(--hum); outline-offset: 1px; }
.gate-card button {
  margin-top: 20px;
  background: var(--hum);
  color: #06201C;
  border: 0;
  border-radius: 8px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--sans);
  cursor: pointer;
}
.gate-card button:disabled { opacity: 0.55; cursor: progress; }
.gate-card button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.gate-error {
  margin-top: 12px;
  color: var(--co2);
  font-size: 0.86rem;
  line-height: 1.5;
}

/* ── Stage ────────────────────────────────────────────────────────── */
.stage {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: clamp(14px, 2.2vh, 26px) clamp(16px, 2.4vw, 40px);
  gap: clamp(10px, 1.8vh, 22px);
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark {
  font-size: clamp(0.8rem, 1.5vw, 1rem);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--hum);
  font-weight: 700;
}
.brand-sub {
  font-size: clamp(0.72rem, 1.2vw, 0.9rem);
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.top-right { display: flex; align-items: center; gap: 10px; }

.chip {
  font-size: clamp(0.66rem, 1.1vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.chip-state { background: #17302C; color: var(--muted); border: 1px solid var(--line); }
.chip-state.live { background: rgba(60,193,179,0.14); color: var(--hum); border-color: rgba(60,193,179,0.4); }
.chip-state.poll { background: rgba(229,148,60,0.14); color: var(--co2); border-color: rgba(229,148,60,0.4); }
.chip-state.stale { background: #1C2522; color: var(--stale); border-color: var(--line); }
.chip-breath {
  background: var(--hum);
  color: #06201C;
  animation: chipPop 420ms cubic-bezier(.2,.9,.3,1.4);
}
@keyframes chipPop { from { transform: scale(0.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ── Readouts ─────────────────────────────────────────────────────── */
.readouts {
  display: grid;
  grid-template-columns: 1.35fr 1.35fr 1fr 1fr;
  gap: clamp(10px, 1.4vw, 20px);
  align-items: stretch;
}
.ro {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: clamp(10px, 1.6vh, 18px) clamp(12px, 1.4vw, 22px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  transition: border-color 160ms ease, background 160ms ease;
}
.ro-label {
  font-size: clamp(0.64rem, 1vw, 0.78rem);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 600;
}
.ro-value {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  display: flex;
  align-items: baseline;
  gap: 0.18em;
  white-space: nowrap;
}
.ro-unit { font-size: 0.34em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.ro-primary .ro-value { font-size: clamp(2.6rem, 8.2vw, 6.4rem); }
.ro-secondary .ro-value { font-size: clamp(1.6rem, 3.6vw, 3rem); }
#roHum .ro-value { color: var(--hum); }
#roCo2 .ro-value { color: var(--co2); }
#roVoc .ro-value { color: var(--voc); }
#roTemp .ro-value { color: var(--ink); }
#roHum.hot { border-color: var(--hum); background: rgba(60,193,179,0.09); }
.spark { width: 100%; height: clamp(22px, 3.4vh, 40px); margin-top: auto; display: block; }

/* ── Chart ────────────────────────────────────────────────────────── */
.chartwrap {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}
#chart { display: block; width: 100%; height: 100%; }
.empty-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: clamp(0.85rem, 1.6vw, 1.05rem);
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ── Status ───────────────────────────────────────────────────────── */
.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.status-left { display: flex; gap: clamp(16px, 3vw, 44px); flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat b {
  font-family: var(--num);
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.95rem, 1.9vw, 1.35rem);
  font-weight: 700;
  color: var(--ink);
}
#freshVal.ok { color: var(--ok); }
#freshVal.warn { color: var(--warn); }
#freshVal.stale { color: var(--stale); }
.stat-l {
  font-size: clamp(0.58rem, 0.9vw, 0.7rem);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.keys { font-size: 0.68rem; color: var(--stale); letter-spacing: 0.06em; }
kbd {
  font-family: var(--num);
  background: #17211F;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  margin-right: 2px;
  color: var(--muted);
}

/* Breath flash — a brief wash, never covering the numbers */
.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(900px 520px at 50% 34%, rgba(60,193,179,0.30), rgba(60,193,179,0) 70%);
  opacity: 0;
  z-index: 30;
}
.flash.on { animation: flash 900ms ease-out; }
@keyframes flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .flash.on { animation: none; }
  .chip-breath { animation: none; }
}

@media (max-width: 900px) {
  .readouts { grid-template-columns: 1fr 1fr; }
  .keys { display: none; }
}
