/* AuraGuard caregiver page.
 *
 * Mobile-first on purpose: the design's beta exit criterion is "a caregiver on a
 * phone away from the house". This is NOT the elderly device UI - the audience
 * is an adult using their own phone, so normal affordances apply and the giant
 * touch targets of the device kiosk would just waste space here.
 */
:root {
  --bg: #0b1b2b;
  --panel: #10263c;
  --ink: #ffffff;
  --muted: #a9c0d4;
  --accent: #1763ad;
  --ok: #1b7f3b;
  --bad: #a52121;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.screen { display: none; height: 100%; flex-direction: column; }
.screen.active { display: flex; }

.center {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem; padding: 1.5rem; text-align: center;
}

.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.25rem;
  /* Respect notches and home indicators - this lives on phones. */
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

h1 { font-size: 1.6rem; margin-bottom: .25rem; }
h2 { font-size: 1.4rem; }
.lead { color: var(--muted); }
.hint { color: var(--muted); font-size: .95rem; max-width: 28rem; }
.error { color: #ff9a9a; margin-top: .75rem; }

#pair-screen { justify-content: center; align-items: center; padding: 2rem 1.5rem; gap: .75rem; text-align: center; }

form { display: flex; flex-direction: column; gap: .75rem; width: 100%; max-width: 20rem; margin-top: 1rem; }

input {
  font: inherit; font-size: 1.4rem; letter-spacing: .12em; text-align: center;
  text-transform: uppercase;
  padding: .85rem 1rem; border-radius: var(--radius);
  border: 2px solid #2b4d6d; background: var(--panel); color: var(--ink);
}
input:focus { outline: 3px solid var(--accent); outline-offset: 2px; }

button { font: inherit; cursor: pointer; border: 0; border-radius: var(--radius); color: var(--ink); }
button:disabled { opacity: .45; cursor: not-allowed; }

.primary { background: var(--accent); padding: .9rem 1.4rem; font-weight: 600; }
.danger  { background: var(--bad);    padding: .9rem 1.4rem; font-weight: 600; }
.link    { background: none; color: var(--muted); text-decoration: underline; padding: .5rem; }

.call {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem; width: 12rem; height: 12rem; border-radius: 50%;
  background: var(--ok); font-size: 1.3rem; font-weight: 700;
}
.call .glyph { font-size: 2.6rem; }
.call:disabled { background: #3a4e5e; }

.presence { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .95rem; }
.presence .dot { width: .7rem; height: .7rem; border-radius: 50%; background: #6b7b88; }
.presence[data-state="online"]  .dot { background: #35d06a; }
.presence[data-state="offline"] .dot { background: #8b8b8b; }
.device-name { font-weight: 600; }

/* Call screen: remote fills, self-view floats. */
#call-screen { position: relative; background: #000; }
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#local-video {
  position: absolute; right: 1rem; width: 7.5rem; aspect-ratio: 4/3;
  top: calc(1rem + env(safe-area-inset-top));
  border-radius: 10px; border: 2px solid rgba(255,255,255,.85);
  object-fit: cover; background: #111;
}
.call-overlay {
  position: absolute; left: 0; right: 0;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.timer { background: rgba(0,0,0,.55); padding: .25rem .7rem; border-radius: 999px; font-variant-numeric: tabular-nums; }
.round { width: 4.5rem; height: 4.5rem; border-radius: 50%; display: grid; place-items: center; }
.round .glyph { font-size: 1.8rem; transform: rotate(135deg); }

@media (min-width: 40rem) {
  #local-video { width: 11rem; }
  .call { width: 14rem; height: 14rem; }
}

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