/* ============================================================
   The room — dark theatre. Video reads better on near-black,
   and the tonal flip from the cream marketing site makes
   "you are in the conversation now" feel like a real threshold.
   ============================================================ */

body.night {
  background: var(--night);
  color: var(--night-text);
}
body.night .input {
  background: rgba(255, 255, 255, .05);
  border-color: var(--night-edge);
  color: var(--night-text);
}
body.night .input:focus { border-color: var(--ember); background: rgba(255, 255, 255, .08); }
body.night .field > span { color: #9b8d80; }
body.night .btn--ghost { --btn-fg: var(--night-text); border-color: var(--night-edge); }
body.night .btn--ghost:hover { border-color: var(--night-text); }
body.night .btn { --btn-bg: var(--night-text); --btn-fg: var(--night); }

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

/* --------------------------------------------------------------- pre-join */
.prejoin {
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: center;
  padding: clamp(1.5rem, 4vw, 3rem) var(--gut);
  max-width: 1080px;
  margin-inline: auto;
  width: 100%;
}
@media (max-width: 880px) { .prejoin { grid-template-columns: 1fr; padding-top: 2rem; } }

.prejoin h1 {
  font-size: clamp(2rem, 4.4vw, 3.1rem);
  margin-bottom: .8rem;
  color: var(--night-text);
}
.prejoin__sub { color: #a29486; font-size: 1.02rem; max-width: 42ch; margin-bottom: 1.9rem; }

.preview-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--night-2);
  border: 1px solid var(--night-edge);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9);
}
.preview-frame video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-frame__tag {
  position: absolute; left: .8rem; bottom: .8rem;
  font-size: .7rem; letter-spacing: .13em; text-transform: uppercase;
  color: #b8a99a;
  background: rgba(19, 16, 16, .7);
  padding: .3rem .6rem; border-radius: 2px;
}

.notice {
  border-left: 2px solid var(--ember);
  padding: .7rem 0 .7rem 1rem;
  margin: 1.5rem 0;
  font-size: .9rem;
  color: #a2948e;
}
.err { color: #ff9a80; font-size: .9rem; margin-top: .9rem; }

/* ------------------------------------------------------------------- room */
.room { flex: 1; display: flex; flex-direction: column; padding: var(--gut); gap: 1rem; }

.stage {
  position: relative;
  flex: 1;
  min-height: 44dvh;
  background: var(--night-2);
  border: 1px solid var(--night-edge);
  border-radius: 5px;
  overflow: hidden;
  transition: box-shadow .4s var(--ease);
}
.room.recording .stage { box-shadow: inset 0 0 0 2px var(--live); }

#remoteVid { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--night-2); }

.self {
  position: absolute;
  right: 1rem; bottom: 1rem;
  width: clamp(112px, 19vw, 210px);
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--night-edge);
  box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .85);
  background: var(--night-3);
}
.self video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.stage__status {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 1rem; color: #9c8e80;
  pointer-events: none;
  text-align: center; padding: 1rem;
}
.stage__label {
  position: absolute; left: 1rem; bottom: 1rem;
  font-size: .82rem; color: #cbbcae;
  background: rgba(19, 16, 16, .68);
  padding: .32rem .66rem; border-radius: 2px;
  backdrop-filter: blur(6px);
}

.rec-pill {
  position: absolute; top: 1rem; left: 1rem;
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(224, 73, 47, .95);
  color: #fff;
  padding: .38rem .75rem;
  border-radius: 2px;
  font-size: .74rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
}
.rec-pill i {
  width: .45rem; height: .45rem; border-radius: 50%; background: #fff;
  animation: blink 1.5s steps(1) infinite;
}
@keyframes blink { 0%, 60% { opacity: 1; } 61%, 100% { opacity: .3; } }
.rec-pill time { font-variant-numeric: tabular-nums; letter-spacing: .06em; }

/* --------------------------------------------------------------- prompt */
.prompt-card {
  background: var(--night-2);
  border: 1px solid var(--night-edge);
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  padding: .95rem 1.15rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.prompt-card p {
  margin: 0;
  font-family: var(--display);
  
  font-size: 1.06rem;
  
  color: #e7dccd;
}
.prompt-card small {
  font-size: .68rem; letter-spacing: .14em; text-transform: uppercase;
  color: #8d7f72; display: block; margin-bottom: .28rem;
}
.prompt-card button {
  flex: none; background: none; border: 1px solid var(--night-edge);
  color: #b6a696; border-radius: 2px; padding: .45rem .7rem;
  font-family: var(--body); font-size: .78rem; cursor: pointer;
  transition: border-color .18s var(--ease), color .18s var(--ease);
}
.prompt-card button:hover { border-color: var(--gold); color: var(--gold); }

/* -------------------------------------------------------------- controls */
.controls {
  display: flex; align-items: center; justify-content: center;
  gap: .6rem; flex-wrap: wrap;
}
.ctrl {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .8rem 1.15rem;
  background: var(--night-2);
  border: 1px solid var(--night-edge);
  color: var(--night-text);
  border-radius: 3px;
  font-family: var(--body); font-size: .9rem; font-weight: 600;
  cursor: pointer;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease);
}
.ctrl:hover:not(:disabled) { background: var(--night-3); border-color: #4b403a; }
.ctrl:disabled { opacity: .45; cursor: not-allowed; }
.ctrl.is-off { background: rgba(224, 73, 47, .14); border-color: rgba(224, 73, 47, .45); color: #ffab97; }
.ctrl--rec { background: var(--live); border-color: var(--live); color: #fff; }
.ctrl--rec:hover:not(:disabled) { background: #c93c24; border-color: #c93c24; }
.ctrl--rec.is-live { background: transparent; border-color: var(--live); color: #ff9c86; }
.ctrl--end { background: transparent; border-color: #5a2a20; color: #ff9a80; }
.ctrl--end:hover { background: rgba(224, 73, 47, .12); }

.upload-note {
  text-align: center; font-size: .85rem; color: var(--gold);
}

/* ----------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: var(--gut);
  background: rgba(10, 8, 8, .78);
  backdrop-filter: blur(6px);
}
.modal__box {
  background: var(--night-2);
  border: 1px solid var(--night-edge);
  border-radius: 5px;
  padding: clamp(1.6rem, 4vw, 2.4rem);
  max-width: 460px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9);
  animation: rise .4s var(--ease) both;
}
.modal__box h2 { font-size: 1.65rem; margin-bottom: .7rem; color: var(--night-text); }
.modal__box p { color: #a89a8c; font-size: .96rem; }
.modal__actions { display: flex; gap: .6rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* ----------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem;
  transform: translate(-50%, 140%);
  background: var(--night-3);
  border: 1px solid var(--night-edge);
  color: var(--night-text);
  padding: .8rem 1.2rem; border-radius: 3px;
  font-size: .9rem; z-index: 300;
  max-width: min(90vw, 460px);
  box-shadow: 0 20px 44px -18px rgba(0, 0, 0, .9);
  transition: transform .45s var(--ease), opacity .45s var(--ease);
  opacity: 0;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast[data-tone="warn"] { border-color: #6a4a20; color: #f0cf9a; }
.toast[data-tone="live"] { border-color: #3d5a3a; color: #b9e0b0; }

/* ----------------------------------------------------------------- ended */
.ended {
  flex: 1; display: grid; place-items: center; text-align: center;
  padding: var(--gut);
}
.ended h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: .9rem; color: var(--night-text); }
.ended p { color: #a2948e; max-width: 44ch; margin-inline: auto; }

/* ===================================================== vault (paper again) */
.vault-head { padding: clamp(2rem, 5vw, 3.4rem) 0 1.6rem; border-bottom: 1px solid var(--paper-edge); }
.vault-head h1 { font-size: clamp(2.1rem, 4.6vw, 3.2rem); margin-bottom: .5rem; }
.vault-head p { color: var(--ink-soft); margin: 0; }

.vault-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.4rem; }

.sessions { display: grid; gap: 1.6rem; padding: 2rem 0 4rem; }
.rec {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: clamp(1rem, 3vw, 2rem);
  background: var(--panel);
  border: 1px solid var(--paper-edge);
  border-radius: 3px;
  padding: 1.1rem;
  box-shadow: var(--shadow-print);
}
@media (max-width: 780px) { .rec { grid-template-columns: 1fr; } }
/* Films can be landscape (1920x1080) or vertical (1080x1920, duets and
   phone-first layouts) — let the video keep its own shape, capped in height. */
.rec video {
  width: 100%; border-radius: 8px; background: var(--night);
  display: block; height: auto; max-height: 74vh; object-fit: contain;
}
.rec__meta { display: flex; flex-direction: column; }
.rec__date {
  font-size: .72rem; letter-spacing: .15em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: .5rem;
}
.rec__q {
  font-family: var(--display); 
  font-size: 1.2rem; 
  margin-bottom: .7rem;
}
.rec__who { font-size: .9rem; color: var(--ink-soft); margin-bottom: 1rem; }
.rec__links { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: auto; }
.rec__links a {
  font-size: .8rem; text-decoration: none; color: var(--ink-soft);
  border: 1px solid var(--paper-edge); border-radius: 2px;
  padding: .4rem .7rem;
  transition: border-color .18s var(--ease), color .18s var(--ease);
}
.rec__links a:hover { border-color: var(--ember); color: var(--ember); }

.badge-status {
  display: inline-block; font-size: .68rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  padding: .22rem .5rem; border-radius: 2px;
  background: var(--ember-wash); color: var(--ember-deep);
}

.empty {
  text-align: center; padding: 4rem 1rem;
  border: 1px dashed var(--paper-edge); border-radius: 3px;
  color: var(--ink-faint);
}
.empty h3 { font-size: 1.5rem; color: var(--ink); margin-bottom: .6rem; }

/* ------------------------------------------------ invite card (host only) */
.invite-card {
  position: absolute; inset: 0;
  display: grid; place-content: center; place-items: center;
  text-align: center;
  padding: 1.5rem;
  gap: .2rem;
}
.invite-card h2 { font-size: 1.5rem; color: var(--night-text); margin-bottom: .3rem; }
.invite-card p { color: #a9a9b2; font-size: .95rem; max-width: 40ch; margin-bottom: 1.1rem; }
.invite-card__row {
  display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center;
  width: min(480px, 86vw);
}
.invite-card__row .input {
  flex: 1 1 220px;
  background: rgba(255, 255, 255, .06);
  border-color: var(--night-edge);
  color: var(--night-text);
  font-size: .85rem;
}

/* ==================================================== orientation handling */
/* Once in the call, the page is locked to the viewport: the stage flexes to
   whatever space is left and the video is absolutely fitted inside it. This is
   what stops a portrait stream from blowing the page out into a scrollbar. */
body.in-call { overflow: hidden; }
body.in-call .shell { height: 100dvh; }
body.in-call .room { min-height: 0; }
body.in-call .stage { min-height: 0; }

#remoteVid {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;      /* never crop a person by default */
  z-index: 1;
}
#remoteVid.fit-cover { object-fit: cover; }  /* same orientation: fill it */

#remoteBackdrop {
  position: absolute; inset: -8%;
  width: 116%; height: 116%;
  object-fit: cover;
  filter: blur(32px) brightness(.4) saturate(1.1);
  z-index: 0;
  display: none;
}
.stage.has-backdrop #remoteBackdrop { display: block; }

.stage__status, .stage__label, .rec-pill, .self, .invite-card { z-index: 2; }
