/* VoxPoly — split layout: participants (left) + captions (right). */

:root {
  --bg: #101418;
  --panel: #181f26;
  --panel-2: #1f2830;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4cc38a;
  --accent-dim: #2b5d47;
  --danger: #e5534b;
  --border: #232e37;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

/* our own display rules must not resurrect elements that HTML hides */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.captions-body {
  height: 100vh;
  height: 100dvh; /* iOS Safari: excludes the collapsing URL bar */
  overflow: hidden;
}

.shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 100%;
}

/* ===== left: participants ===== */

.video-pane {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  padding: 3rem 12px 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 20% -10%, #1a2230 0%, transparent 60%),
    radial-gradient(900px 500px at 90% 110%, #14201c 0%, transparent 55%),
    var(--bg);
}

.pane-title {
  position: absolute;
  top: 14px;
  left: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.spacer { flex: 1; }

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;   /* grid children may shrink, never overflow */
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #171d24 0%, #10151b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: box-shadow 0.25s, border-color 0.25s;
}

/* breathing glow while this side is speaking (push-to-talk or free talk) */
.tile.speaking {
  border-color: rgba(76, 195, 138, 0.9);
  animation: glow 1.6s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(76, 195, 138, 0.45), 0 0 16px rgba(76, 195, 138, 0.22);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(76, 195, 138, 0.85), 0 0 36px rgba(76, 195, 138, 0.5);
  }
}

/* speaking glow while this side is speaking (push-to-talk or free talk) */

/* self-view / remote video */
.tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.tile.has-video .tile-video { display: block; }
.tile.has-video .avatar { display: none; }

#local-video {
  transform: scaleX(-1); /* mirror, like a mirror — standard self-view */
}

/* keep the label readable over the video */
.tile.has-video::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 34%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.tile-label { z-index: 1; }

.avatar {
  width: clamp(64px, 22%, 110px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.avatar.you  { background: var(--accent-dim); color: var(--accent); }
.avatar.peer { background: #232c34; color: var(--muted); }

.tile-label {
  position: absolute;
  left: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tile-label .name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  flex: none;
  font-size: 0.7rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
}

.tile-label { z-index: 1; }

/* ===== right: captions ===== */

.caption-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--bg);
}

.cap-screen {
  flex: 1;
  min-height: 0;   /* allow the feed to scroll instead of stretching the pane */
  overflow-y: auto;
  padding: 0.8rem 1rem 0;
  display: flex;
  flex-direction: column;
}

.cap-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem 0.4rem;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  border: 1px solid #2c3742;
  border-radius: 8px;
  overflow: hidden;
}

.seg-btn {
  border: none;
  border-radius: 0;
  background: var(--panel-2);
  color: var(--muted);
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

button {
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid #2c3742;
  border-radius: 8px;
  cursor: pointer;
}

button:hover { border-color: #3d4a56; }

button.recording {
  background: #6e2b2b;
  border-color: var(--danger);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 83, 75, 0.45); }
  50%      { box-shadow: 0 0 0 10px rgba(229, 83, 75, 0); }
}

button.ghost {
  background: transparent;
  font-weight: 400;
  color: var(--muted);
}

button.ghost:hover { color: var(--text); }

.status {
  margin: 0.8rem 1rem 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.status.busy { color: var(--accent); }

.error {
  margin: 0.7rem 1rem 0;
  padding: 0.6rem 0.8rem;
  background: #3a1f1e;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: #ffb3ae;
  font-size: 0.85rem;
}

kbd {
  padding: 0.1em 0.4em;
  border: 1px solid #3d4a56;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--panel);
  font-size: 0.85em;
}

.cap-screen {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 1rem 0;
  display: flex;
  flex-direction: column;
}

.cap-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.cap-item {
  position: relative;
  padding: 0.5rem 0.8rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cap-source {
  color: var(--muted);
  font-size: 0.78rem;
}

/* who said the line */
.cap-speaker {
  display: inline-block;
  margin-right: 7px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: 1px;
}

.cap-speaker.peer {
  background: #2a343e;
  color: var(--muted);
}

/* pending-translation spinner */
.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #3d4a56;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: -1px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.cap-translation {
  font-size: 1.05rem;
  margin-top: 0.15rem;
}

.cap-translation.pending { color: var(--muted); font-style: italic; }

.cap-latency {
  position: absolute;
  right: 0.55rem;
  bottom: 0.3rem;
  color: #4a5560;
  font-size: 0.68rem;
}

.cap-current {
  position: sticky;
  bottom: 0;
  padding: 0.7rem 0 0.8rem;
}

/* "the other side is talking on push-to-talk" line, same fashion as the
   translating… placeholder */
.cap-peer-live {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.15rem;
  color: var(--accent);
  font-size: 0.92rem;
  font-style: italic;
}

.cap-line.live {
  display: inline-block;
  background: #1a2a24;
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-size: 1.15rem;
  font-style: italic;
  max-width: 100%;
}

/* ===== responsive: stack panes on narrow/tablet screens ===== */

@media (max-width: 900px) {
  body.captions-body { overflow: auto; }
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 48vh) minmax(360px, 1fr);
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .caption-pane {
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
