/* Hondo Cabin: shared styles.
   Cold is the alarm here: ice blue marks freezing, the 32° line is the spine of "Right now" and of the chart.
   Light and dark are both chosen (not inverted); series colours are the dataviz palette, validated for both. */

@font-face {
  font-family: "Zilla Slab";
  src: url("/static/fonts/zilla-slab-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/static/fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}

:root {
  color-scheme: light;
  --page: #edf1ef;            /* frost */
  --surface: #f8faf9;         /* snow: chart and form surface */
  --ink: #17332a;             /* spruce */
  --ink-2: #4f5f59;           /* lichen: secondary text */
  --rule: #cdd7d3;
  --grid: #dfe6e3;
  --freeze: #2b68a8;          /* ice: the freezing line, readings below it, focus */
  --freeze-wash: rgba(43, 104, 168, 0.07);
  --lamp: #d8961f;            /* lamplight: someone is at the cabin (fills only) */
  --lamp-ink: #8a5a00;
  --lamp-wash: rgba(216, 150, 31, 0.16);
  --alert-ink: #b3362c;
  --alert-wash: rgba(179, 54, 44, 0.08);
  --ok-ink: #2f6b3a;
  --bar: #93a79f;             /* thermometer bars above freezing */
  --btn: #17332a;
  --btn-ink: #ffffff;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;

  --font-display: "Zilla Slab", Rockwell, "Roboto Slab", Georgia, serif;
  --font-text: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Type scale after The Elements of Typographic Style: 12 14 16 18 21 24 36 */
  --fs-12: 0.75rem; --fs-14: 0.875rem; --fs-16: 1rem; --fs-18: 1.125rem;
  --fs-21: 1.3125rem; --fs-24: 1.5rem; --fs-36: 2.25rem;
  --gutter: clamp(1rem, 3vw, 2rem);
  --measure: 70rem;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #10201b;          /* spruce at night */
    --surface: #162a23;
    --ink: #e3ece8;
    --ink-2: #a6b5af;
    --rule: #2d433a;
    --grid: #233830;
    --freeze: #7fb0e6;
    --freeze-wash: rgba(127, 176, 230, 0.09);
    --lamp: #e6ae45;
    --lamp-ink: #e6ae45;
    --lamp-wash: rgba(230, 174, 69, 0.13);
    --alert-ink: #f08a7e;
    --alert-wash: rgba(240, 138, 126, 0.11);
    --ok-ink: #8fd19a;
    --bar: #5f786e;
    --btn: #dfe9e4;
    --btn-ink: #10201b;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* components below set display; hidden must still win */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--fs-16);
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: var(--fs-36); letter-spacing: -0.005em; }
h2 { font-size: var(--fs-21); }
p, ul, ol { margin: 0; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--freeze); outline-offset: 2px; border-radius: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hint { color: var(--ink-2); font-size: var(--fs-14); }
.lede { color: var(--ink-2); font-size: var(--fs-18); max-width: 38em; }

/* ---------- site header ---------- */
.site-header {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 2.5rem;
  padding: 1rem max(var(--gutter), calc((100% - var(--measure)) / 2 + var(--gutter))) 0;
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-24);
  text-decoration: none; padding-bottom: 0.6rem;
}
.site-nav { display: flex; flex: 1; gap: 1.5rem; align-items: baseline; min-width: 0; }
.site-nav a {
  color: var(--ink-2); text-decoration: none; white-space: nowrap;
  padding: 0.25rem 0 0.6rem; border-bottom: 3px solid transparent;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.site-nav .logout { margin-left: auto; }
@media (max-width: 44rem) {
  .site-header { gap: 0; }
  .wordmark { padding-bottom: 0.25rem; }
  .site-nav { flex-basis: 100%; overflow-x: auto; gap: 1.25rem; scrollbar-width: none; }
  .site-nav .logout { margin-left: 0; }
}

.page { max-width: var(--measure); margin: 0 auto; padding: 1.75rem var(--gutter) 4rem; }
.page > h1 + * { margin-top: 0.5rem; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--btn); color: var(--btn-ink);
  border: 1px solid var(--btn); border-radius: var(--radius);
  padding: 0.55rem 1.1rem; min-height: 2.75rem;
}
.btn:hover { filter: brightness(1.15); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule); font-weight: 500; min-height: 2.25rem; padding: 0.3rem 0.8rem; }
.btn-quiet:hover { filter: none; border-color: var(--ink-2); }
.btn-danger { color: var(--alert-ink); }

/* A row of mutually exclusive choices (time range, measure, unit, stream quality) */
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.seg > button, .seg > a {
  font: inherit; font-size: var(--fs-14); color: var(--ink-2); background: none; cursor: pointer;
  border: 0; border-left: 1px solid var(--rule); padding: 0.4rem 0.75rem; min-height: 2.25rem;
  display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap;
}
.seg > :first-child { border-left: 0; border-radius: var(--radius) 0 0 var(--radius); }
.seg > :last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.seg > button:hover, .seg > a:hover { color: var(--ink); }
/* the chosen option keeps its colours under the pointer too */
.seg > [aria-pressed="true"], .seg > [aria-current="page"],
.seg > [aria-pressed="true"]:hover, .seg > [aria-current="page"]:hover {
  background: var(--ink); color: var(--page); font-weight: 600;
}

/* Tabs: one per decoder */
.tabs { display: flex; gap: 2rem; border-bottom: 1px solid var(--rule); margin-top: 1.25rem; }
.tabs [role="tab"] {
  font: inherit; font-family: var(--font-display); font-size: var(--fs-21); font-weight: 600;
  color: var(--ink-2); background: none; border: 0; cursor: pointer;
  padding: 0.25rem 0 0.5rem; margin-bottom: -1px; border-bottom: 3px solid transparent;
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab-blurb { color: var(--ink-2); margin-top: 0.75rem; max-width: 46em; }

/* ---------- forms ---------- */
.stack-form { display: grid; gap: 0.35rem; max-width: 24rem; }
.stack-form label { font-weight: 600; margin-top: 0.6rem; }
.stack-form label:first-child, .stack-form input[type="hidden"] + label { margin-top: 0; }
.stack-form > div { margin-top: 1rem; }
input[type="text"], input[type="password"], input:not([type]), select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--ink-2); border-radius: var(--radius);
  padding: 0.55rem 0.7rem; min-height: 2.75rem; width: 100%;
}
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--ink); margin: 0; }

.notice { border-left: 4px solid; padding: 0.6rem 0.9rem; margin: 1rem 0; max-width: 40rem; background: var(--surface); }
.notice-error { border-color: var(--alert-ink); }
.notice-ok { border-color: var(--ok-ink); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; scrollbar-color: var(--rule) transparent; }
.data-table { border-collapse: collapse; width: 100%; font-size: var(--fs-16); }
.data-table th, .data-table td { text-align: left; padding: 0.55rem 1rem 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.data-table thead th { font-size: var(--fs-14); font-weight: 600; color: var(--ink-2); border-bottom-color: var(--ink-2); }
.data-table tbody th { font-weight: 600; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .actions { text-align: right; }
.you { color: var(--ink-2); font-weight: 400; }
.panel { margin-top: 2.5rem; }
.panel > h2 + * { margin-top: 0.75rem; }

/* ---------- login ---------- */
.login { max-width: 26rem; margin: 0 auto; padding: 14vh var(--gutter) 4rem; }
.login .wordmark { display: block; padding: 0; margin-bottom: 2.5rem; border-bottom: 2px solid var(--freeze); width: max-content; }
.login h1 { font-size: var(--fs-36); }
.login .lede { margin: 0.4rem 0 1.5rem; font-size: var(--fs-16); }

/* ---------- "Right now": every sensor on one thermometer scale, the freezing line through all of them ---------- */
.now-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.75rem 2rem; }
.now-state { margin-top: 0.6rem; color: var(--ink-2); max-width: 46em; }
.now-state .occupied::before {
  content: ""; display: inline-block; width: 0.65em; height: 0.65em; border-radius: 50%;
  background: var(--lamp); margin-right: 0.4em; vertical-align: 0.05em;
}
.ladder { --freeze-at: 0.25; margin-top: 2rem; max-width: 52rem; }
.ladder-row, .ladder-scale {
  display: grid; grid-template-columns: minmax(6.5rem, 12rem) minmax(5rem, 1fr) 5.5rem;
  column-gap: 1.25rem; align-items: center;
}
.ladder-row > *, .ladder-scale > * { padding: 0.5rem 0; }
.ladder-row > .track, .ladder-scale > .track { padding: 0; align-self: stretch; position: relative; }
/* One continuous freezing line: every row draws its own segment at the same x */
.ladder .track::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 2px;
  left: calc(var(--freeze-at) * 100% - 1px); background: var(--freeze);
}
.ladder-scale { font-size: var(--fs-12); color: var(--ink-2); }
.ladder-scale > .track { min-height: 2.25rem; }
.ladder-scale .tick { position: absolute; bottom: 0.4rem; transform: translateX(-50%); white-space: nowrap; }
.ladder-scale .tick:first-child { transform: none; }
.ladder-scale .tick:last-child { transform: translateX(-100%); }
.ladder-scale .tick.freeze { color: var(--freeze); font-weight: 700; bottom: 0.4rem; background: var(--page); padding: 0 0.3rem; }
.ladder-row .name { line-height: 1.25; }
.ladder-row .name a { font-weight: 600; text-decoration: none; }
.ladder-row .name a:hover { text-decoration: underline; }
.ladder-row .sub { display: block; font-size: var(--fs-14); color: var(--ink-2); }
.ladder-row .bar {
  position: absolute; left: 0; top: 50%; height: 8px; margin-top: -4px;
  width: calc(var(--v) * 100%); min-width: 8px; background: var(--bar); border-radius: 0 4px 4px 0;
}
.ladder-row .reading {
  font-family: var(--font-display); font-weight: 600; font-size: var(--fs-24);
  text-align: right; white-space: nowrap; line-height: 1.1;
}
.ladder-row.is-freezing .bar { background: var(--freeze); }
.ladder-row.is-freezing .reading { color: var(--freeze); }
.ladder-row .reading small { font-family: var(--font-text); font-size: var(--fs-14); font-weight: 400; color: var(--ink-2); }
@media (max-width: 36rem) {
  .ladder-scale .tick:not(.freeze) { display: none; }   /* too narrow for three labels: keep the freezing one */
}
@media (max-width: 30rem) {
  .ladder-row, .ladder-scale { grid-template-columns: minmax(5.5rem, 7.5rem) minmax(3rem, 1fr) 4.5rem; column-gap: 0.75rem; }
  .ladder-row .reading { font-size: var(--fs-21); }
}
.quiet { margin-top: 3rem; max-width: 52rem; }
.quiet-list { list-style: none; padding: 0; margin-top: 0.75rem; }
.quiet-list li { padding: 0.5rem 0; border-top: 1px solid var(--rule); }
.quiet-list li:last-child { border-bottom: 1px solid var(--rule); }
.quiet-list strong { font-weight: 600; }

/* ---------- temperatures ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; margin-top: 1.5rem; }
.chart-status { margin-top: 0.9rem; min-height: 1.5em; color: var(--ink-2); font-size: var(--fs-14); }
.chart-frame {
  position: relative; margin-top: 0.4rem; height: clamp(20rem, 58vh, 34rem);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 0.75rem 0.5rem 0.25rem 0.25rem; touch-action: none; transition: opacity 0.2s;
}
.chart-frame.is-loading { opacity: 0.55; }
.chart-frame canvas { display: block; width: 100%; height: 100%; }
.chart-help { margin-top: 0.5rem; }
.chart-key { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; margin-top: 0.5rem; font-size: var(--fs-14); color: var(--ink-2); }
.chart-key .swatch { display: inline-block; width: 1.4em; height: 0.9em; vertical-align: -0.1em; margin-right: 0.4em; border-radius: 2px; }
.swatch.occupied { background: var(--lamp-wash); box-shadow: inset 0 0 0 1px var(--lamp); }
.swatch.relay { height: 0.35em; vertical-align: 0.15em; background: var(--alert-ink); }
.swatch.freezing { background: var(--freeze-wash); border-top: 2px solid var(--freeze); }
.sensors { margin-top: 2.5rem; }
.sensors h2 + * { margin-top: 0.5rem; }
.sensor-table td.show, .sensor-table th.show { width: 2.5rem; padding-right: 0.5rem; }
.sensor-table .key {
  display: inline-block; width: 1.6rem; vertical-align: 0.3em; margin-right: 0.6rem;
  border-top: 3px solid var(--key-color, var(--ink));
}
.sensor-table .key.dashed { border-top-style: dashed; }
.sensor-table tr.is-hidden th, .sensor-table tr.is-hidden td:not(.show) { color: var(--ink-2); }
.sensor-table tr.is-hidden .key { opacity: 0.35; }
.sensor-table .low-battery { color: var(--alert-ink); font-weight: 700; }
.sensor-table .stale { color: var(--ink-2); }
.sensor-table label { cursor: pointer; }
.sensor-table th, .sensor-table td { white-space: nowrap; }   /* narrow screens scroll the table sideways */
.sensor-table .when-inline { display: none; }
@media (max-width: 36rem) {
  /* phones: "when" moves under the latest value so low and high fit on screen */
  .sensor-table .col-when { display: none; }
  .sensor-table .when-inline { display: block; font-size: var(--fs-12); color: var(--ink-2); }
  .sensor-table th, .sensor-table td { padding-right: 0.6rem; }
  .sensor-table .key { width: 1rem; margin-right: 0.4rem; }
}
.table-actions { display: flex; gap: 0.75rem; margin-top: 0.75rem; }

/* ---------- camera ---------- */
.camera-page { max-width: var(--measure); margin: 0 auto; padding: 1.25rem var(--gutter) 2rem; }
.camera-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem 1.5rem; margin-bottom: 1rem; }
.camera-frame { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: var(--ar, 16 / 9); max-height: calc(100vh - 11rem); margin: 0 auto; }
.camera-frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
#message {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 1.25rem; color: #fff; font-weight: 600; pointer-events: none;
  text-shadow: 0 0 6px #000;
}
#lang-icon {
  display: none; position: absolute; top: 4rem; right: 1rem; width: 2rem; height: 2rem; cursor: pointer;
  background: center / 80% no-repeat url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA1MCIgZmlsbD0iI2ZmZiIgeG1sbnM6dj0iaHR0cHM6Ly92ZWN0YS5pby9uYW5vIj48cGF0aCBkPSJNMzguNSAzMy45bC0xLjktMS42YzIuNS0yLjkgMy44LTYuMyAzLjgtOS45IDAtMy4xLTEtNi4xLTIuOS04LjhsMi4xLTEuNWMyLjIgMy4xIDMuNCA2LjYgMy40IDEwLjItLjEgNC4zLTEuNiA4LjMtNC41IDExLjZ6TTUuNiAyMy4yaC0zYy0uNSAwLTEgLjUtMSAxLjF2MTAuNWMwIC42LjQgMS4xIDEgMS4xaDNjLjIgMCAuMyAwIC40LjFsMTMuOCA3LjhjLjYuNCAxLjQtLjIgMS40LTFWMTYuM2MwLS44LS44LTEuMy0xLjQtMUw2LjEgMjMuMWMtLjIuMS0uMy4xLS41LjF6bTIxLTE2LjlMMTIuOCAxNGMtLjEuMS0uMy4xLS40LjFoLTNjLS41IDAtMSAuNS0xIDEuMVYyMGwxMi4yLTYuOGExLjM2IDEuMzYgMCAwIDEgMS41IDBjLjUuMy44LjguOCAxLjV2MTcuOWwzLjcgMi4xYy42LjQgMS40LS4yIDEuNC0xVjcuMmMuMS0uOC0uNy0xLjMtMS40LS45em0xNi41IDMwLjJsLTEuOS0xLjZjMy4xLTMuNyA0LjctOCA0LjctMTIuNSAwLTQtMS4zLTcuOC0zLjctMTEuMmwyLjEtMS41YzIuNyAzLjggNC4yIDguMiA0LjIgMTIuNy0uMiA1LjEtMiA5LjktNS40IDE0LjF6TTM1IDMxLjFsLTItMS42YzEuNy0yLjEgMi42LTQuNiAyLjYtNy4yIDAtMi40LS44LTQuNy0yLjItNi43bDItMS41YzEuOCAyLjUgMi43IDUuMyAyLjcgOC4yIDAgMy4yLTEuMSA2LjItMy4xIDguOHoiLz48L3N2Zz4=");
}
#lang-list { display: none; position: absolute; top: 100%; right: 0; background: var(--surface); color: var(--ink); border: 1px solid var(--rule); }
#lang-icon:hover #lang-list { display: block; }
#lang-list div { padding: 0.35rem 1rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
/* Own full screen (the frame, not the bare video) so pinch-zoom works; camera.js does the zoom */
.cam-tools { position: absolute; top: 0.75rem; right: 0.75rem; z-index: 2; display: flex; gap: 0.5rem; transition: opacity 0.3s; }
.cam-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; height: 2.75rem; padding: 0 0.7rem;
  border: 0; border-radius: 999px; background: rgb(0 0 0 / 0.55); color: #fff; cursor: pointer;
  font: 600 var(--fs-14) var(--font-text); font-variant-numeric: tabular-nums;
}
.cam-btn:hover { background: rgb(0 0 0 / 0.75); }
.cam-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.cam-btn svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cam-btn .fs-off, .camera-frame.is-full .cam-btn .fs-on { display: none; }
.camera-frame.is-full .cam-btn .fs-off { display: block; }
.camera-frame.is-full { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; touch-action: none; user-select: none; }
.camera-frame.is-full.zoomed { cursor: grab; }
.camera-frame.is-full.tools-hidden .cam-tools { opacity: 0; pointer-events: none; }
.camera-frame.is-full video { will-change: transform; }
.camera-hint { margin-top: 0.5rem; color: var(--ink-2); font-size: var(--fs-14); text-align: center; }

/* ---------- recordings: a contact sheet per day ---------- */
.day { margin-top: 2.25rem; }
.day h2 .count { font-family: var(--font-text); font-size: var(--fs-14); font-weight: 400; color: var(--ink-2); margin-left: 0.5rem; }
.clips {
  list-style: none; padding: 0; margin-top: 0.75rem;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1.5rem 1rem;
}
.clip-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--grid); border-radius: 3px; overflow: hidden; }
.clip-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.clip-flag {
  position: absolute; left: 0.5rem; bottom: 0.5rem; right: 0.5rem; width: max-content; max-width: calc(100% - 1rem);
  background: var(--page); color: var(--ink); font-size: var(--fs-14); font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 3px;
}
.clip-thumb.is-processing img { opacity: 0.45; }
.clip-time { margin-top: 0.4rem; font-weight: 600; }
.clip-time a { text-decoration: none; }
.clip-time a:hover { text-decoration: underline; }
.clip-meta { font-size: var(--fs-14); color: var(--ink-2); }
.clip-download { margin-left: 0.5rem; }
.empty { margin-top: 2rem; color: var(--ink-2); max-width: 36em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
