/*
 * Matches the iOS app's chassis: near-black, restrained, one hot red reserved
 * for the recording state. The guest should feel they've landed somewhere
 * deliberate, because a stranger's video link is a low-trust moment.
 */

:root {
  --bg: #0a0a0c;
  --surface: #16161a;
  --raised: #1f1f25;
  --hairline: rgba(255, 255, 255, 0.1);
  --text: #f5f5f7;
  --text-2: #8a8a94;
  --text-3: #5a5a64;
  --rec: #f53226;
  --live: #30d158;
  --info: #0a84ff;
  --radius: 14px;
  --radius-lg: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; display: flex; }
.hidden { display: none !important; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

/* ------------------------------------------------------------- lobby */

.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--text-2);
  margin-bottom: 28px;
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--rec);
  box-shadow: 0 0 0 3px rgba(245, 50, 38, 0.18);
}

h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; text-align: center; }
.sub { color: var(--text-2); font-size: 14px; margin: 0 0 20px; text-align: center; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.18em;
  background: var(--raised);
  padding: 3px 9px;
  border-radius: 7px;
  color: var(--text);
}

.preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
#selfPreview {
  width: 100%; height: 100%; object-fit: cover;
  /* Mirrored, because looking at an unmirrored image of yourself is
     disorienting. The host's recording of you is not mirrored. */
  transform: scaleX(-1);
}
.preview-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 14px;
}

.notice {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--rec);
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 16px;
}
.notice strong { color: var(--text); display: block; margin-bottom: 2px; }

.controls { width: 100%; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.field input {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--text);
  padding: 13px 14px;
  font-size: 16px; /* 16px or iOS zooms the page on focus */
}
.field input:focus { outline: 2px solid var(--info); outline-offset: 1px; }

button { font: inherit; cursor: pointer; border: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.primary {
  width: 100%;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 17px;
  min-height: 52px;
  border-radius: var(--radius);
}
.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 600;
  min-height: 52px;
  padding: 0 28px;
  border-radius: var(--radius);
  margin-top: 20px;
}
.hint { color: var(--text-3); font-size: 12px; margin: 12px 0 0; text-align: center; }

/* -------------------------------------------------------------- call */

#call { max-width: none; padding: 0; }

.remote-wrap { position: relative; flex: 1; width: 100%; background: #000; }
#remoteVideo { width: 100%; height: 100%; object-fit: cover; }

.remote-waiting {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-2); font-size: 15px;
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--text-2);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Permanent, not dismissible. The guest agreed to being recorded and should be
   able to confirm it is still happening at any moment. */
.rec-pill {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  display: flex; align-items: center; gap: 7px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(245, 50, 38, 0.5);
  color: var(--text);
  font-size: 12px; font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
}
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rec);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }

#selfPip {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 96px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transform: scaleX(-1);
  background: #000;
}

.call-controls {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  background: var(--bg);
}
.round {
  min-width: 92px;
  min-height: 52px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
}
.round.off { background: rgba(255, 255, 255, 0.28); }
.round.danger { background: var(--rec); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  .spinner, .rec-dot { animation: none; }
}
