/* #/live/:id — live session (WebRTC + subtitles/dub). Full-bleed dark stage
   using the shared tokens; controls echo .btn styling. Layout is role-driven:
   the main stage carries teacher + customer; interpreter/admin + self sit in
   small draggable, grid-snapping portraits. */

.live-call {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 5;
  overflow: hidden;
  touch-action: none; /* portraits use pointer drag */
}

/* Main stage: 1 remote = full-bleed, 2 = equal rows. */
.lc-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.lc-stage video {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: cover;
  background: var(--surface);
}
.lc-stage[data-count="0"]::before {
  content: '';
  flex: 1;
  background:
    radial-gradient(60% 50% at 50% 38%, var(--brand-soft), transparent 70%),
    var(--bg);
}

/* Off-screen sink that keeps a peer's audio playing when their video isn't
   shown (interpreter with camera off, second main on an observer's screen). */
.lc-audiohide {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

/* Floating portraits layer (self + interpreter/admin). */
.lc-portraits {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.lc-pip {
  position: absolute;
  width: 116px;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--border-alt);
  background: var(--surface);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.lc-pip video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.lc-pip.lc-dragging { cursor: grabbing; box-shadow: 0 10px 26px rgba(0, 0, 0, .6); }
/* Observer tiles that can be promoted to the main stage by a tap. */
.lc-pip.lc-tappable { cursor: pointer; }
.lc-pip.lc-tappable::after {
  content: '⤢';
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 13px;
  color: var(--text);
  opacity: .8;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  pointer-events: none;
}
.lc-pip.lc-cam-off video { visibility: hidden; }
.lc-pip.lc-cam-off::after {
  content: '📷';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  opacity: .4;
}
.lc-pip-tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 11px;
  color: var(--text);
  background: rgba(8, 8, 12, .7);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  pointer-events: none;
}
.lc-pip-tag:empty { display: none; }
.lc-pip-self .lc-pip-tag { display: none; }

/* Status + timer. */
.lc-top {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 6;
}
.lc-status {
  color: var(--text-secondary);
  font-size: 13px;
  background: rgba(19, 19, 26, .72);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  backdrop-filter: blur(6px);
}
.lc-status:empty { display: none; }
.lc-timer { color: var(--text-secondary); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Subtitle stack: chat-style bubbles that rise and fade as they pass the
   upper half of the screen (the mask), and drop out of the live stack a
   little later (lc-gone). The transcript overlay keeps the full history. */
.lc-subs {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  top: 18%;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 46%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 46%);
}
.lc-subs.lc-subs-off { display: none; }
.lc-sub-stack { display: flex; flex-direction: column; gap: 6px; }
.lc-bubble {
  max-width: 82%;
  width: fit-content;
  padding: 7px 12px;
  border-radius: var(--radius-card);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  backdrop-filter: blur(6px);
  transition: opacity .6s ease, transform .6s ease;
}
.lc-bubble.lc-gone { opacity: 0; transform: translateY(-8px); }
.lc-remote {
  align-self: flex-start;
  background: rgba(19, 19, 26, .78);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.lc-mine {
  align-self: flex-end;
  background: var(--brand-soft);
  border: 1px solid rgba(229, 50, 62, .35);
  border-bottom-right-radius: 4px;
}
.lc-interim { opacity: .6; font-style: italic; }
.lc-pending { opacity: .55; }
.lc-who {
  font-size: 11px;
  font-weight: 600;
  opacity: .75;
  margin-right: 4px;
}
/* Per-role accent on the speaker label. */
.lc-role-teacher .lc-who { color: #6FB1FF; }
.lc-role-customer .lc-who { color: var(--brand); }
.lc-role-interpreter .lc-who { color: #46C39A; }
.lc-role-admin .lc-who { color: var(--star); }

/* Transcript overlay: translucent, scrollable full history. */
.lc-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 12, .82);
  backdrop-filter: blur(10px);
}
/* The class sets display:flex, which would defeat the [hidden] attribute — so
   restore it explicitly (this is what makes the panel actually close). */
.lc-overlay[hidden] { display: none; }
.lc-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.lc-overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lc-ov-row {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-body);
}

/* Control bar. */
.lc-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  z-index: 7;
  padding: 0 12px;
}
.lc-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border-alt);
  background: rgba(34, 34, 42, .85);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform .08s, background .12s;
}
.lc-btn:active { transform: scale(.92); }
.lc-btn svg { width: 26px; height: 26px; display: block; margin: auto; }
.lc-txt-btn { font-size: 14px; font-weight: 700; letter-spacing: .3px; }
.lc-btn-sm { width: 40px; height: 40px; font-size: 16px; }
/* Engaged / alert state: mic muted, camera off, dubbing on, transcript open. */
.lc-btn.lc-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.lc-btn.lc-on:active { background: var(--brand-press); }
.lc-hangup { background: var(--danger); border-color: var(--danger); }
.lc-hangup:active { background: var(--brand-press); }
.lc-lang {
  height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-alt);
  background: rgba(34, 34, 42, .85);
  color: var(--text-body);
  font-size: 13px;
  padding: 0 10px;
  backdrop-filter: blur(6px);
}
