/* SadCall: lobby + a full-screen call that works first on a phone. */

[hidden] { display: none !important; }

.ic {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

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

/* the whole lobby fits one phone screen: no scrolling */
.lobby {
  width: min(100% - 32px, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 72px) 0 calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.lobby .kit-title { font-size: clamp(2.2rem, 9vw, 3.4rem); }
.lobby .kit-sub { margin-top: 6px; }

.join-form {
  margin-top: clamp(16px, 3vh, 28px);
  padding: clamp(14px, 4vw, 20px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(237, 230, 218, 0.035), rgba(237, 230, 218, 0.012));
  display: grid;
  gap: clamp(10px, 2vh, 16px);
}

.mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}
.mode__btn {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-2);
  font: 500 0.95rem/1 var(--display);
  cursor: pointer;
}
.mode__btn[aria-checked="true"] { background: color-mix(in oklab, var(--accent) 22%, var(--panel)); color: var(--ink); }

.field { display: grid; gap: 7px; }
.field span { font: 400 12px/1.3 var(--mono); color: var(--ink-2); }
.field em { font-style: normal; color: var(--dim); }
.field input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.2 var(--display); /* 16px: iOS doesn't zoom into the field */
}
.field input::placeholder { color: var(--dim); }
.field input:focus { outline: 2px solid color-mix(in oklab, var(--accent) 75%, var(--ink)); outline-offset: 2px; border-color: transparent; }
.field input[aria-invalid="true"] { border-color: color-mix(in oklab, var(--danger) 70%, var(--line)); }

.form-error { margin: 0; color: #f0a796; font-size: 0.95rem; }
.form-error:empty { display: none; }

.join-form .kit-btn { width: 100%; min-height: 50px; }
.join-form .kit-btn[disabled] { opacity: 0.6; pointer-events: none; }

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

body.in-call { overflow: hidden; }
body.in-call > .back { display: none; }

.call {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  background: #050608;
  overflow: hidden;
}

.stage { position: absolute; inset: 0; }

.remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #050608;
  display: block;
}
.remote.is-screen { object-fit: contain; }

.remote-off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 50% at 50% 40%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 70%), #07080a;
}
.remote-off span {
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px solid var(--line);
  font: 600 3rem/1 var(--display);
  color: var(--ink);
  text-transform: uppercase;
}

/* waiting room: the sad logo, the code, the invite */
.wait {
  position: absolute;
  inset: 0;
  padding: 24px 24px calc(120px + env(safe-area-inset-bottom));
  align-content: center;
  justify-items: center;
  gap: 10px;
  text-align: center;
  background: radial-gradient(70% 50% at 50% 30%, color-mix(in oklab, var(--accent) 12%, transparent), transparent 70%), var(--bg);
  transition: opacity 0.5s ease;
}
.wait.is-leaving { opacity: 0; pointer-events: none; }
.wait__logo { width: min(48vw, 220px); }
.wait__logo .logo { width: 100%; }
.wait__text { margin: 6px 0 0; color: var(--ink-2); }
.wait__code {
  margin: 0;
  font: 400 clamp(1.5rem, 7vw, 2.2rem)/1.2 var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink);
  user-select: all;
  -webkit-user-select: all;
}
.wait__code:empty { display: none; }
.wait__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
.wait__actions .kit-btn, .wait__actions .kit-ghost { min-height: 46px; }
.wait__actions .kit-ghost { font-size: 14px; }
.wait__actions .ic { width: 18px; height: 18px; }
.wait.is-guest .wait__actions,
.wait.is-guest .wait__code { display: none; }

.unmute {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 14px 22px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: 600 1rem/1 var(--display);
  cursor: pointer;
}

.topbar {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
  right: calc(clamp(96px, 26vw, 220px) + 24px);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.pill {
  padding: 7px 12px 7px 24px;
  position: relative;
  border-radius: 999px;
  background: rgba(11, 13, 16, 0.78);
  color: var(--ink-2);
  font: 400 12px/1.2 var(--mono);
  white-space: nowrap;
}
.pill::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--dim);
}
.pill[data-state="connecting"]::before { background: #e2a83b; }
.pill[data-state="live"]::before { background: #6cc48a; }
.pill[data-state="unstable"]::before,
.pill[data-state="error"]::before { background: var(--danger); }
.who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 600;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
.who__muted { color: #f0a796; width: 18px; height: 18px; }

/* my own video, small, in the corner */
.pip {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 12px;
  width: clamp(96px, 26vw, 220px);
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  background: #111418;
  box-shadow: 0 0 0 1px rgba(237, 230, 218, 0.14), 0 16px 30px -12px rgba(0, 0, 0, 0.9);
  z-index: 2;
}
@media (orientation: landscape) { .pip { aspect-ratio: 16 / 9; } }
.pip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pip.is-mirrored video { transform: scaleX(-1); }
.pip__off {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  color: var(--dim);
  font: 400 11px/1.3 var(--mono);
  background: #111418;
}

.controls {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 10px;
  border-radius: 999px;
  background: rgba(11, 13, 16, 0.82);
  box-shadow: 0 0 0 1px var(--line), 0 20px 40px -20px rgba(0, 0, 0, 0.9);
  z-index: 3;
}
.ctl {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  background: #1a1f26;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s, transform 0.2s var(--ease-out);
}
.ctl:active { transform: scale(0.94); }
@media (hover: hover) { .ctl:hover { background: color-mix(in oklab, var(--accent) 22%, #1a1f26); } }
.ctl[data-lit="true"] { background: var(--ink); color: var(--bg); }
.ctl--end { background: var(--danger); color: #fff; }
@media (hover: hover) { .ctl--end:hover { background: #ea7f6a; } }
@media (max-width: 360px) { .controls { gap: 8px; } .ctl { width: 48px; height: 48px; } }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 100px);
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: 500 14px/1.3 var(--display);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease-out);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* short screens (iPhone SE, landscape): tighter still */
@media (max-height: 700px) {
  .lobby { padding-top: calc(env(safe-area-inset-top) + 64px); }
  .lobby .kit-sub { display: none; }
  .field input { min-height: 44px; padding-block: 10px; }
  .wait { gap: 6px; }
  .wait__logo { width: min(36vw, 150px); }
}
/* landscape phones only: a portrait phone with its keyboard open is short too, but narrow */
@media (max-height: 500px) and (min-width: 600px) {
  .lobby { padding: 12px 0 8px; justify-content: flex-start; width: min(100% - 2 * 150px, 480px); }
  .join-form { gap: 8px; margin-top: 10px; }
  .lobby .kit-title { font-size: 1.8rem; }
  .join-form { grid-template-columns: 1fr 1fr; align-items: end; }
  .mode, .form-error, .join-form .kit-btn { grid-column: 1 / -1; }
  .wait__logo { display: none; }
  .field em { display: none; }
}
