/* Ring Hub — dark, quiet, with one memorable thing: the arched door frame around the camera. */

@font-face {
  font-family: "Bricolage";
  src: url("/fonts/bricolage/bricolage-grotesque-latin-standard-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/fonts/atkinson/atkinson-hyperlegible-next-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson";
  src: url("/fonts/atkinson/atkinson-hyperlegible-next-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  /* Colour: blacks and greys, plus two signal colours that always mean the same thing */
  --night: #000000;
  --surface: #19191a;
  --raised: #262628;
  --line: #38383b;
  --text: #ededed;
  --muted: #a3a3a8;
  --porch: #f2b33d;   /* doorbell pressed */
  --dusk: #93a9c9;    /* motion */
  --live: #f2555a;    /* live video only */
  --ok: #7fbf8e;

  --display: "Bricolage", ui-sans-serif, system-ui, sans-serif;
  --body: "Atkinson", ui-sans-serif, system-ui, sans-serif;

  /* Type scale, ratio 1.25 */
  --t-sm: 0.875rem;
  --t-base: 1rem;
  --t-md: 1.25rem;
  --t-lg: 1.5625rem;
  --t-xl: 1.953rem;

  --gap: 1rem;
  --radius: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--night);
  color: var(--text);
  font: 400 var(--t-base)/1.5 var(--body);
  font-variant-numeric: tabular-nums;
}
.sprite { display: none; }
svg { width: 1.35em; height: 1.35em; flex: none; }
img { display: block; max-width: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: inherit; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 4px; }

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 0.75rem) 1rem calc(var(--safe-bottom) + 2rem);
}
.boot { color: var(--muted); padding: 30vh 0; text-align: center; }

/* ---------- Buttons ---------- */
button { font: inherit; color: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0 1.25rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--raised); color: var(--text);
  font-weight: 700; cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 100ms ease;
}
.btn:hover { background: #303033; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; cursor: progress; }
.btn-primary { background: var(--text); color: var(--night); border-color: var(--text); }
.btn-primary:hover { background: #ffffff; }
.btn-live { background: #d6363c; border-color: #d6363c; color: #fff; }  /* 4.7:1 with white text */
.btn-live:hover { background: #c22d33; }
.btn-quiet { background: transparent; }
.btn-danger { color: #ff9a9d; }
.btn-small { min-height: 44px; padding: 0 1rem; font-size: var(--t-sm); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  transition: background-color 150ms ease;
}
.icon-btn:hover { background: var(--raised); }
.icon-btn[aria-pressed="true"] { background: var(--text); color: var(--night); }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: 1rem;
}
.wordmark { font-family: var(--display); font-size: var(--t-md); font-weight: 700; }
.wordmark-sub { color: var(--muted); font-size: var(--t-sm); }

/* ---------- Home layout ---------- */
.home { display: grid; gap: 2rem; }
@media (min-width: 960px) {
  .home { grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr); align-items: start; gap: 3rem; }
  .door { position: sticky; top: 1rem; }
}

/* ---------- The door: arched frame around the camera ---------- */
.door { display: grid; gap: 1rem; }
.door-name { font-size: var(--t-xl); font-weight: 700; }

.door-wrap {
  --arch: 50% 50% 14px 14px / 21% 21% 14px 14px;
  position: relative;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--arch);
  transition: border-color 600ms ease, box-shadow 600ms ease;
}
.door-wrap.is-live { border-color: var(--live); }
.door-wrap.rang {
  border-color: var(--porch);
  box-shadow: 0 0 0 1px var(--porch), 0 0 48px -6px rgba(242, 179, 61, 0.55);
}
.arch {
  position: relative;
  aspect-ratio: 16 / 10.5;
  border-radius: var(--arch);
  background: var(--surface);
  overflow: hidden;
  isolation: isolate;
}
.arch img, .arch video, .arch canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.arch video { background: #000; }
.arch-empty {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 0.5rem;
  padding: 2rem 3rem; text-align: center; color: var(--muted);
}
.arch-empty strong { color: var(--text); font-family: var(--display); font-size: var(--t-md); font-weight: 600; }

.frame-note {
  position: absolute; left: 50%; bottom: 0.75rem; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  background: rgba(0, 0, 0, 0.72); font-size: var(--t-sm); white-space: nowrap;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); }
@media (prefers-reduced-motion: no-preference) {
  .live-dot { animation: pulse 1.6s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.35; } }

.door-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.door-controls .btn { flex: 1 1 auto; }
@media (min-width: 520px) { .door-controls .btn { flex: 0 0 auto; } }

.facts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; color: var(--muted); font-size: var(--t-sm); }
.fact { display: inline-flex; align-items: center; gap: 0.45rem; }
.fact b { color: var(--text); font-weight: 700; }
.fact.warn b { color: var(--porch); }
.battery-bar {
  width: 26px; height: 12px; border: 1.5px solid currentColor; border-radius: 3px; padding: 1.5px; position: relative;
}
.battery-bar::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; background: currentColor; border-radius: 1px; }
.battery-bar i { display: block; height: 100%; background: currentColor; border-radius: 1px; }
.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i { width: 3px; background: var(--line); border-radius: 1px; }
.bars i:nth-child(1) { height: 4px; } .bars i:nth-child(2) { height: 7px; }
.bars i:nth-child(3) { height: 10px; } .bars i:nth-child(4) { height: 12px; }
.bars i.on { background: var(--text); }

.notice {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  background: var(--surface); display: grid; gap: 0.75rem;
}
.notice.error { border-color: #6b2f31; }
.notice p { color: var(--muted); }
.notice strong { color: var(--text); }

/* ---------- Doorbell alert banner ---------- */
.ringing {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: 0.9rem 1rem;
  border: 1px solid var(--porch); border-radius: var(--radius);
  background: #241c0c;
}
.ringing p { font-weight: 700; display: flex; align-items: center; gap: 0.6rem; }
.ringing p svg { color: var(--porch); }

/* ---------- History ---------- */
.history { display: grid; gap: 1rem; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.history-head h2 { font-size: var(--t-lg); }

.filter { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.filter button {
  min-height: 40px; padding: 0 0.9rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-size: var(--t-sm); font-weight: 700; cursor: pointer;
}
.filter button[aria-pressed="true"] { background: var(--raised); color: var(--text); }

.day h3 {
  font-size: var(--t-sm); font-family: var(--body); font-weight: 700; color: var(--muted);
  padding: 0.5rem 0; position: sticky; top: 0; background: var(--night); z-index: 1;
}
.events { list-style: none; margin: 0; padding: 0; }
.event {
  display: grid; grid-template-columns: 4.25rem 1fr auto; align-items: center; gap: 0.9rem;
  width: 100%; min-height: 64px; padding: 0.5rem 0;
  border: 0; border-top: 1px solid var(--surface); background: none; text-align: left; cursor: pointer;
}
.event:hover .event-what { text-decoration: underline; text-underline-offset: 3px; }
.event-time { font-weight: 700; font-size: var(--t-md); font-family: var(--display); }
.event-what { display: flex; align-items: center; gap: 0.5rem; }
.event-what svg { width: 1.15em; height: 1.15em; }
.event.ding .event-what svg { color: var(--porch); }
.event.motion .event-what svg { color: var(--dusk); }
.event-ago { display: block; color: var(--muted); font-size: var(--t-sm); }
.thumb {
  width: 88px; aspect-ratio: 16 / 10; border-radius: 6px; overflow: hidden; background: var(--surface);
  display: grid; place-items: center; color: var(--muted); font-size: 0.75rem;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.event.fresh { animation: arrive 900ms ease-out; }
@keyframes arrive { from { background: #241c0c; } }
@media (prefers-reduced-motion: reduce) { .event.fresh { animation: none; } }

.empty { color: var(--muted); padding: 2rem 0; }
.more { justify-self: start; }

/* ---------- Forms, sign-in and settings ---------- */
.card-page { max-width: 440px; margin: 10vh auto 0; display: grid; gap: 1.5rem; }
.card-page h1 { font-size: var(--t-xl); }
.lede { color: var(--muted); }

.form { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.35rem; }
.field label { font-weight: 700; font-size: var(--t-sm); }
.field .help { color: var(--muted); font-size: var(--t-sm); }
input[type="text"], input[type="password"], textarea, select {
  width: 100%; min-height: 48px; padding: 0.7rem 0.9rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 96px; resize: vertical; font-size: var(--t-sm); word-break: break-all; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.form-error { color: #ff9a9d; font-size: var(--t-sm); min-height: 1.3em; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.check { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--text); }

.settings { max-width: 720px; display: grid; gap: 2.5rem; }
.settings-top { display: flex; align-items: center; gap: 0.75rem; }
.settings-top h1 { font-size: var(--t-xl); }
.section { display: grid; gap: 1rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.section h2 { font-size: var(--t-lg); }
.section > p { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.5rem; color: var(--muted); }
.steps strong { color: var(--text); }
code, .code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.1em 0.4em;
  word-break: break-all;
}
.code { display: block; padding: 0.75rem 0.9rem; color: var(--text); }

.people { list-style: none; margin: 0; padding: 0; }
.people li {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.75rem 0; border-top: 1px solid var(--surface);
}
.people .who b { display: block; }
.people .who span { color: var(--muted); font-size: var(--t-sm); }

.version { color: var(--muted); font-size: var(--t-sm); }
.foot { margin-top: 3rem; display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: var(--t-sm); }
.demo-tag { color: var(--porch); }

/* ---------- Snapshot viewer ---------- */
.viewer {
  width: min(100vw - 2rem, 1100px); max-height: calc(100dvh - 2rem);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--night); color: var(--text);
}
.viewer::backdrop { background: rgba(0, 0, 0, 0.82); }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0.5rem 0.5rem 1rem; }
.viewer-title { font-size: var(--t-md); }
.viewer img { width: 100%; height: auto; max-height: calc(100dvh - 7rem); object-fit: contain; background: #000; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 1.25rem); transform: translateX(-50%);
  max-width: calc(100vw - 2rem); padding: 0.75rem 1.1rem; border-radius: 10px;
  background: var(--text); color: var(--night); font-weight: 700; z-index: 10;
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
