/* ============================================================================
   Doorbell design system
   House standard: named tokens, no Inter, no emoji-as-UI, 8px scale, one radius
   system, AA contrast, explicit shadows. See ~/.claude/skills/house-design.

   FONTS ARE SELF-HOSTED, and that is a POPIA decision as much as a speed one:
   pulling a webfont from a CDN on the VISITOR page would send a stranger's IP
   address to a third party before they have agreed to anything. Everything the
   visitor page loads comes from us.
   ============================================================================ */

@font-face {
  font-family: 'Manrope';
  src: url('/static/fonts/manrope.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;   /* never block the RING button on a font */
  font-style: normal;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/static/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  font-style: normal;
}

:root {
  color-scheme: light;

  --font-display: 'Bricolage Grotesque', Georgia, serif;
  --font-body: 'Manrope', 'Segoe UI', system-ui, sans-serif;

  /* Colour roles. Deliberately warm + deep teal - not slate, not violet, not cyan. */
  --foreground: #1c1a17;
  --surface: #f7f5f1;
  --surface-raised: #ffffff;
  --muted: #6b6259;          /* 5.1:1 on --surface - AA body */
  --border: #e4ded4;
  --primary: #0f5f52;        /* white on this = 7.6:1 */
  --primary-fg: #ffffff;
  --primary-hover: #0b4a40;
  --accent: #b8632a;         /* brass. white on this = 4.3:1 -> LARGE TEXT / UI ONLY */
  --danger: #a3261d;
  --danger-fg: #ffffff;
  --ok: #1d6b3f;

  /* 8px spacing scale - nothing off it */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;

  /* one radius system */
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 20px; --radius-full: 999px;

  /* named elevation */
  --shadow-sm: 0 1px 2px rgb(28 26 23 / .06);
  --shadow-md: 0 4px 16px rgb(28 26 23 / .09);
  --shadow-lg: 0 12px 40px rgb(28 26 23 / .14);
}

/* A doorbell gets used at night, outdoors, with the screen lighting someone's face.
   Dark mode is a real use case here, not decoration. color-scheme is set explicitly
   so Chrome-Android's force-dark cannot lighten these surfaces and collapse contrast. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --foreground: #f2efe9;
    --surface: #15140f;
    --surface-raised: #1f1d18;
    --muted: #a89e92;        /* 6.4:1 on --surface */
    --border: #34302a;
    --primary: #2f9d87;
    --primary-fg: #08130f;
    --primary-hover: #3fb69d;
    --accent: #d98748;
    --danger: #e8695c;
    --danger-fg: #1a0a08;
    --ok: #56c98a;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--foreground);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-3);
  font-weight: 700;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 var(--space-4); }
a { color: var(--primary); }

.muted { color: var(--muted); }
.small { font-size: 0.9375rem; }

/* ---------------------------------------------------------------- layout */
.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4) var(--space-16);
}
.wrap-wide { max-width: 960px; }

.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--space-3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------------------------------------------------------------- surfaces */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }

.notice {
  border-radius: var(--radius-md);
  padding: var(--space-4);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--primary) 7%, var(--surface-raised));
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.notice svg { flex: none; margin-top: 2px; color: var(--primary); }
.notice.warn { background: color-mix(in srgb, var(--accent) 10%, var(--surface-raised)); }
.notice.warn svg { color: var(--accent); }
.notice.bad { background: color-mix(in srgb, var(--danger) 9%, var(--surface-raised)); }
.notice.bad svg { color: var(--danger); }

/* ---------------------------------------------------------------- controls */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-6);
  min-height: 48px;                 /* thumb target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  background: var(--primary);
  color: var(--primary-fg);
  text-decoration: none;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
.btn-secondary:hover { background: color-mix(in srgb, var(--foreground) 6%, transparent); }
.btn-danger { background: var(--danger); color: var(--danger-fg); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, black); }
.btn-block { width: 100%; }

:where(a, button, input, select, textarea):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

label { display: block; font-weight: 600; margin-bottom: var(--space-2); font-size: 0.9375rem; }
input[type=text], input[type=email], input[type=time], input[type=number], select {
  font: inherit;
  width: 100%;
  padding: var(--space-3);
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--foreground);
}
.field + .field { margin-top: var(--space-4); }

.pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: 0.8125rem; font-weight: 700; letter-spacing: .02em;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
}
.pill-live { color: var(--primary-fg); background: var(--primary); border-color: transparent; }
.pill-quiet { color: var(--primary); border-color: var(--primary); }
.pill-paused { color: var(--accent); border-color: var(--accent); }

.code {
  font-family: 'Geist Mono', ui-monospace, 'Cascadia Mono', monospace;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: .18em;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  word-break: break-all;
}

/* ------------------------------------------------------- the visitor page */
/* Deliberately NOT a card grid. One page, one job, one enormous button. */
.door-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  max-width: 520px;
  margin: 0 auto;
  gap: var(--space-6);
}
.door-name {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 7vw, 2.5rem);
  font-weight: 700;
  text-align: center;
  margin: 0;
}

.ring-btn {
  width: 100%;
  min-height: 168px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: var(--primary-fg);
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform .06s ease, background .15s ease;
}
.ring-btn:hover { background: var(--primary-hover); }
.ring-btn:active { transform: scale(.985); }
.ring-btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.ring-btn svg { width: 48px; height: 48px; }

/* Audio-only is a first-class choice, not a fallback link. */
.ring-alt {
  width: 100%;
  min-height: 56px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--foreground);
  font: inherit; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  cursor: pointer;
}
.ring-alt:hover { background: color-mix(in srgb, var(--foreground) 5%, var(--surface-raised)); }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.pulsing { animation: pulse 1.4s ease-in-out infinite; }

/* --------------------------------------------------------------- the call */
.stage {
  position: relative;
  background: #0d0c0a;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
}
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage .self {
  position: absolute; right: var(--space-3); bottom: var(--space-3);
  width: 27%; max-width: 132px; aspect-ratio: 3/4;
  border-radius: var(--radius-md); overflow: hidden;
  border: 2px solid rgb(255 255 255 / .5);
  box-shadow: var(--shadow-md);
  background: #000;
}
.stage .self video { object-fit: cover; }
.stage-note {
  position: absolute; inset-inline: 0; bottom: 0;
  padding: var(--space-3);
  background: linear-gradient(to top, rgb(0 0 0 / .75), transparent);
  color: #fff; font-size: 0.9375rem; text-align: center;
}
.call-controls { display: flex; gap: var(--space-3); margin-top: var(--space-4); }
.call-controls .btn { flex: 1; }

/* ------------------------------------------------------------- dashboard */
.door-row {
  display: flex; gap: var(--space-4); align-items: flex-start;
  padding: var(--space-4) 0;
  border-top: 1px solid var(--border);
}
.door-row:first-of-type { border-top: none; }

.ring-list { list-style: none; padding: 0; margin: 0; }
.ring-list li {
  display: flex; gap: var(--space-3); align-items: center;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
}
.ring-list li:first-child { border-top: none; }
.ring-list .when { color: var(--muted); font-variant-numeric: tabular-nums; }

.qr-holder {
  background: #fff;                 /* a QR must be dark-on-light to scan, in any theme */
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  display: grid; place-items: center;
}
.qr-holder svg { width: 100%; max-width: 260px; height: auto; display: block; }

/* Incoming call banner - the one place that should grab the eye. */
.incoming {
  border: 2px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--surface-raised));
}

.icon { width: 20px; height: 20px; flex: none; }
.icon-lg { width: 28px; height: 28px; }

@media print {
  /* The rotation page is meant to be printed and stuck to a wall. */
  .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: none; box-shadow: none; padding: 0; }
  .qr-holder { border: 1px solid #000; }
}
