/* ==========================================================================
   Modes (engine/modes.js, engine/controller.js): the audience and album
   frame, the lobby card, the password gate, and the controller.
   All in Be Vietnam Pro Medium, like the deck.
   ========================================================================== */

[hidden] { display: none !important; }

.shell, .lobby, .gate, .ctl, .screen-badge {
  font-family: var(--font);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.shell button, .gate button, .ctl button, .ctl select, .lobby button, .lobby input, .gate input {
  font-family: inherit;
  font-weight: inherit;
  color: inherit;
}
.shell svg, .lobby svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- The framed view (audience, album) ----------
   Landscape: a 16:9 frame, the bar below it (logo left, slide nav centred).
   Portrait (phones): logo on top, a frame filling the space, the nav below.
   Before the start (is-bleed) the frame fills the screen, nothing around it. */
.shell {
  --pad: clamp(10px, 1.6vw, 26px);
  --bar: clamp(66px, 6vw, 92px);
  --nav: clamp(40px, 3.3vw, 50px);
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--bar);
  padding: var(--pad) var(--pad) 0;
  background: var(--bg);
}
.shell-top { display: none; }
.shell-main {
  container-type: size;
  min-height: 0;
  display: grid;
  place-items: center;
}
.shell-frame {
  position: relative;
  width: min(100cqw, 100cqh * 16 / 9);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  border-radius: 18px;
  border: 1.5px solid rgba(255, 255, 255, .14);
  background: var(--bg);
}
.shell-frame > #deck { position: absolute; inset: 0; }

.shell.is-bleed { padding: 0; grid-template-rows: minmax(0, 1fr); }
.shell.is-bleed .shell-top,
.shell.is-bleed .shell-bar,
.shell.is-bleed .shell-corner,
.shell.is-bleed .shell-return,
.shell.is-bleed .shell-toast { display: none; }
.shell.is-bleed .shell-frame { width: 100%; height: 100%; aspect-ratio: auto; border: 0; border-radius: 0; }

/* The bar is as wide as the frame, so the logo lines up with its left edge. */
.shell-bar {
  justify-self: center;
  width: min(100%, (100dvh - var(--pad) - var(--bar)) * 16 / 9);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.shell-logo { display: block; width: auto; height: clamp(22px, 2.1vw, 32px); }
.shell-bar .shell-logo { justify-self: start; }

.shell-nav { display: flex; align-items: center; gap: clamp(8px, .8vw, 12px); }
.nav-arrow {
  width: var(--nav);
  height: var(--nav);
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: #111 !important;
  cursor: pointer;
  transition: background .2s, color .2s, transform .15s;
}
.nav-arrow svg { width: 46%; height: 46%; }
.nav-arrow:active { transform: scale(.94); }
.nav-arrow:disabled { background: #262626; color: #5c5c5c !important; cursor: default; transform: none; }
.nav-live,
.nav-label {
  height: var(--nav);
  min-width: calc(var(--nav) * 2.3);
  padding: 0 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, .08);
  color: #fff;
  font-size: clamp(13px, 1vw, 16px);
  letter-spacing: .14em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.nav-label { letter-spacing: .05em; }
.nav-live i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff3b30;
  animation: live-pulse 1.8s ease-out infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, .6); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(255, 59, 48, 0); }
}
.shell[data-view="live"] .nav-label,
.shell:not([data-view="live"]) .nav-live { display: none; }

/* Captions and full screen, in the frame's top-right corner */
.shell-corner {
  position: absolute;
  top: clamp(8px, 1.1vw, 16px);
  right: clamp(8px, 1.1vw, 16px);
  z-index: 60;
  display: flex;
  gap: clamp(6px, .6vw, 10px);
}
.shell-btn {
  width: clamp(34px, 2.8vw, 46px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(16, 16, 16, .5);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #fff;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.shell-btn svg { width: 52%; height: 52%; }
.shell-btn[aria-pressed="true"] { background: #fff; color: #111 !important; }

/* Looking at an earlier slide: the way back */
.shell-return {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 1.5vw, 22px);
  z-index: 60;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  height: clamp(36px, 2.8vw, 44px);
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #111 !important;
  font-size: clamp(13px, 1vw, 15px);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.shell-return i { width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; }
.shell[data-view="past"] .shell-return { display: inline-flex; }

.shell-toast {
  position: absolute;
  top: clamp(10px, 1.3vw, 18px);
  left: 50%;
  z-index: 60;
  transform: translate(-50%, -6px);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 16, 16, .75);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 14px;
  color: var(--ink-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.shell-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (orientation: portrait) {
  .shell {
    --bar: 88px;
    --nav: 48px;
    grid-template-rows: 64px minmax(0, 1fr) var(--bar);
  }
  .shell-top { display: flex; align-items: center; }
  .shell-top .shell-logo { height: 26px; }
  .shell-frame { width: 100cqw; height: 100cqh; aspect-ratio: auto; }
  .shell-bar { width: 100%; grid-template-columns: 1fr; justify-items: center; }
  .shell-bar .shell-logo { display: none; }
}

/* ---------- Lobby: before the start, or when the server can't be reached ---------- */
.lobby {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 24px;
}
.lobby-card {
  width: min(520px, 100%);
  padding: clamp(26px, 3vw, 40px);
  border-radius: 20px;
  background: rgba(255, 255, 255, .28);
  border: 1px solid rgba(255, 255, 255, .38);
  -webkit-backdrop-filter: blur(22px) saturate(1.15);
  backdrop-filter: blur(22px) saturate(1.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 30px 80px rgba(0, 0, 0, .22);
  color: #fff;
  text-align: center;
}
.lobby-text { margin: 0; font-size: clamp(19px, 2vw, 26px); line-height: 1.4; text-wrap: balance; }
.lobby-form {
  margin: clamp(20px, 2.4vw, 28px) 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 5px 5px 22px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.lobby-input {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;   /* 16 px: phones don't zoom in on focus */
  color: #141414 !important;
}
.lobby-input::placeholder { font-style: italic; color: #8b8b8b; }
.lobby-go {
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #141414;
  color: #fff;
  cursor: pointer;
}
.lobby-go svg { width: 20px; height: 20px; }
.lobby-note { margin: 16px 0 0; font-size: 15px; line-height: 1.45; color: rgba(255, 255, 255, .9); }

/* ---------- Password gate (?m=p, ?m=c) ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, #181818, #0a0a0a 70%);
  color: var(--ink);
}
.gate-card { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.gate-logo { width: auto; height: 30px; margin-bottom: 14px; }
.gate-title { margin: 0; font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: var(--ink-dim); }
.gate-input {
  width: 100%;
  padding: 16px 0 16px .55em;
  border-radius: 16px;
  border: 1.5px solid var(--line-strong);
  background: #141414;
  font-size: 32px;
  letter-spacing: .55em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.gate-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.gate-input::placeholder { color: var(--ink-ghost); }
.gate-note { margin: 0; min-height: 1.4em; font-size: 14px; color: var(--ink-dim); }
.gate-note.is-error { color: var(--accent); }

/* ---------- Presentation screen: shown only when the server is lost ---------- */
.screen-badge {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 150;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 16, 16, .82);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}
.screen-badge.is-on { opacity: 1; }

/* ---------- Controller (?m=c): built for a phone held in one hand ---------- */
html[data-mode="controller"] #deck { display: none; }
.ctl {
  --prompt: 30px;
  position: fixed;
  inset: 0;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding:
    max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
}
.ctl-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ctl-logo { width: auto; height: 20px; }
.ctl-conn { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-dim); white-space: nowrap; }
.ctl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.ctl-dot.is-on { background: var(--success); }
.ctl-sep { width: 1px; height: 12px; margin: 0 4px; background: var(--line-strong); }
.ctl-room { position: relative; }
.ctl-room summary { list-style: none; cursor: pointer; }
.ctl-room summary::-webkit-details-marker { display: none; }
.ctl-room[open] summary { color: var(--ink); }
.ctl-room p {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 5;
  width: min(260px, 80vw);
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1b1b1b;
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  color: var(--ink-soft);
  line-height: 1.5;
  white-space: normal;
  -webkit-user-select: text;
  user-select: text;
}

.ctl-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.ctl-where { min-width: 0; }
.ctl-label { font-size: clamp(40px, 12vw, 64px); line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.ctl-state { margin-top: 8px; font-size: 14px; line-height: 1.35; color: var(--ink-dim); }
.ctl-timer {
  flex: none;
  padding: 8px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #141414;
  font-size: clamp(32px, 9vw, 48px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color .3s, background .3s, border-color .3s;
}
.ctl-timer.is-idle { color: var(--ink-dim) !important; }
.ctl-timer.is-close { color: #ffc14d !important; border-color: rgba(255, 193, 77, .4); }
.ctl-timer.is-over { color: #fff !important; background: var(--accent-deep); border-color: var(--accent-deep); }

/* Teleprompter: what is said now, then (smaller) what comes after the next swipe */
.ctl-prompt {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 20px;
  border-radius: 18px;
  background: #121212;
  border: 1px solid var(--line);
  -webkit-user-select: text;
  user-select: text;
}
.ctl-tools { display: flex; align-items: center; justify-content: space-between; }
.ctl-cap { font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--ink-faint); }
.ctl-size { display: flex; gap: 6px; }
.ctl-size button { width: 40px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: #1b1b1b; font-size: 14px; cursor: pointer; }
.ctl-now { margin: 8px 0 22px; font-size: var(--prompt); line-height: 1.38; color: var(--ink); }
.ctl-next { margin: 8px 0 0; font-size: calc(var(--prompt) * .7); line-height: 1.42; color: var(--ink-dim); }
.ctl-quiet { font-style: italic; color: var(--ink-faint); }

/* The swipe pad: the face follows the finger; underneath, the action it will
   take (coral once far enough to count). */
.ctl-controls { display: flex; flex-direction: column; gap: 12px; }
.ctl-swipe {
  position: relative;
  height: clamp(96px, 16vh, 130px);
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #101010;
  touch-action: none;
  cursor: grab;
  transition: opacity .3s;
}
.ctl-swipe:active { cursor: grabbing; }
.ctl-swipe.is-off { opacity: .45; }
.ctl-under {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 22px;
  font-size: 16px;
  color: var(--ink-soft);
  white-space: nowrap;
  opacity: 0;
  transition: background .18s, color .18s;
}
.ctl-under.is-back { justify-content: flex-start; }
.ctl-under.is-next { justify-content: flex-end; }
.ctl-swipe[data-dir="back"] .is-back,
.ctl-swipe[data-dir="next"] .is-next { opacity: 1; }
.ctl-swipe.is-armed[data-dir="next"] .is-next { background: var(--accent-deep); color: #fff; }
.ctl-swipe.is-armed[data-dir="back"] .is-back { background: #3d3d3d; color: #fff; }
.ctl-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: inherit;
  background: #1d1d1d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .34s cubic-bezier(.2, .9, .25, 1.12), background .2s;
  will-change: transform;
}
.ctl-face-main { font-size: clamp(22px, 6vw, 30px); font-weight: 500; }
.ctl-face-hint { font-size: 13px; letter-spacing: .02em; color: var(--ink-dim); }
.ctl-swipe.is-sent .ctl-face { background: #2a2a2a; }

.ctl-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--ink-dim); }
.ctl-more label { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; }
.ctl-more select {
  flex: 1;
  min-width: 0;
  max-width: 340px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #161616;
  font-size: 14px;
}
.ctl-more button {
  flex: none;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: none;
  font-size: 14px;
  color: var(--ink-dim) !important;
  cursor: pointer;
}
.ctl.is-offline .ctl-label,
.ctl.is-offline .ctl-prompt { opacity: .5; }

@media (max-width: 420px) {
  .ctl-logo { display: none; }
}
@media (min-width: 900px) {
  .ctl { padding: 28px 40px; }
}
