/* Video call screen. Always dark, like a phone's call screen. */

body.in-video-call { overflow: hidden; }

.video-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #0E0F16;
}

.vc {
  --vc-bg: #0E0F16;
  --vc-panel: #1A1C2B;
  --vc-text: #F2F3F8;
  --vc-muted: #B7BACB;
  --vc-accent: #5B5FC7;
  --vc-danger: #C62828;
  height: 100%;
  display: grid;
  /* Regular phone: their face on top, captions underneath. */
  grid-template-rows: minmax(0, 58fr) minmax(0, 42fr);
  color: var(--vc-text);
  background: var(--vc-bg);
  font: 500 16px/1.4 Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Foldable opened up, tablet, or any wide window: video on one side, captions on the other. */
@media (min-width: 600px) and (min-aspect-ratio: 5/6) {
  .vc {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* Browsers that report a physical fold put each pane on its own screen segment. */
@media (horizontal-viewport-segments: 2) {
  .vc {
    grid-template-rows: none;
    grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0));
  }
}
@media (vertical-viewport-segments: 2) {
  .vc {
    grid-template-columns: none;
    grid-template-rows: env(viewport-segment-height 0 0) env(viewport-segment-height 0 1);
    row-gap: calc(env(viewport-segment-top 0 1) - env(viewport-segment-bottom 0 0));
  }
}

.vc-video {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #000;
  padding-top: env(safe-area-inset-top);
}

/* Everyone else's video, in a grid; the script sets the columns and rows. */
.vc-remote {
  width: 100%;
  height: 100%;
  display: grid;
}
.vc-remote.many { gap: 2px; }
.vc-tile { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #23253A; border-radius: 20px; }
.vc-remote { padding: 8px; box-sizing: border-box; gap: 8px; }
.vc-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vc-tile .name {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
}
/* With one other person, their name would sit under the call controls. */
.vc-remote:not(.many) .vc-tile .name { bottom: auto; top: calc(12px + env(safe-area-inset-top)); }

.vc-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--vc-muted);
}
.vc-status[hidden], .vc-banner[hidden] { display: none; }

.vc-local {
  position: absolute;
  right: 18px;
  top: calc(18px + env(safe-area-inset-top));
  width: 26%;
  max-width: 160px;
  aspect-ratio: 3 / 4;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  overflow: hidden;
  background: #222;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.vc-local video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.vc-local.rear video { transform: none; }

.vc-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
}
.vc-controls button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  background: #2A2D44;
  border: 0;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.vc-controls button.danger { background: var(--vc-danger); font-weight: 600; }

.vc-banner {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: calc(26% + 24px);
  top: calc(12px + env(safe-area-inset-top));
  background: rgba(17, 20, 24, 0.92);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.9rem;
}
.vc-banner p { margin: 0 0 8px; color: var(--vc-muted); }
.vc-banner .row { display: flex; flex-wrap: wrap; gap: 8px; }
.vc-banner button, .vc-banner a {
  font: inherit;
  font-size: 0.85rem;
  color: #fff;
  background: var(--vc-accent);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}
.vc-banner .close { background: rgba(255, 255, 255, 0.16); }

.vc-captions {
  min-height: 0;
  overflow-y: auto;
  background: var(--vc-panel);
  border-radius: 24px 24px 0 0;
  padding: 14px 16px max(16px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.vc-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.vc-lines li { overflow-wrap: anywhere; }
.vc-lines .who { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--vc-muted); }
.vc-lines .main { display: block; }
.vc-lines .sub { display: block; font-size: 0.85rem; color: var(--vc-muted); white-space: pre-line; }
/* What they said, translated for you, is what matters most: make it big. */
.vc-lines li.theirs .main { font-size: 1.35rem; font-weight: 600; line-height: 1.3; }
.vc-lines li.mine { opacity: 0.8; }
.vc-hint, .vc-event { color: var(--vc-muted); font-size: 0.9rem; }
.vc-event { text-align: center; }

/* Captions: Translated / Original / Off */
.vc-capmode {
  position: sticky;
  top: -14px;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin: 0 0 12px;
  border-radius: 16px;
  background: #0E0F16;
}
.vc-capmode button {
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #D5D7E3;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.vc-capmode button[aria-checked="true"] { background: #FFFFFF; color: #272B8A; }
.vc-off-note { display: none; margin: 8px 0; color: var(--vc-muted); text-align: center; font-weight: 600; }
.vc-captions.off .vc-off-note { display: block; }
.vc-captions.off .vc-lines, .vc-captions.off .vc-interim { display: none; }
.vc-lines .who { color: #A9B4FF; font-weight: 800; }

.vc-interim { margin: 10px 0 0; color: var(--vc-muted); font-style: italic; min-height: 0; }
.vc-interim:empty { display: none; }

/* ---------- In person: one phone between two people ---------- */

.ip {
  --ip-text: #1C1D2E;
  --ip-muted: #4A4D63;
  --ip-accent: #5B5FC7;
  --ip-danger: #C62828;
  height: 100%;
  display: grid;
  /* Regular phone: their half on top, the buttons, your half underneath. */
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  color: var(--ip-text);
  background: #5B5FC7;
  font: 500 16px/1.4 Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Turned round so someone across the table can read their half. */
.ip.flipped .ip-them { transform: rotate(180deg); }

.ip-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  border-radius: 28px;
  background: #FFFFFF;
}
.ip-them { margin: calc(12px + env(safe-area-inset-top)) 12px 0; background: #ECEDFB; }
.ip-me { margin: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.ip-head strong { color: #3A3FB0; font-weight: 800; }

.ip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
}
.ip-status { color: var(--ip-muted); font-size: 13px; font-weight: 700; }
.ip.paused .ip-status { color: var(--ip-danger); }

.ip-lines {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ip-lines li { overflow-wrap: anywhere; }
.ip-lines .heard { font-size: 24px; font-weight: 700; line-height: 1.3; }
.ip-lines .said { color: var(--ip-muted); font-size: 14px; font-weight: 600; }
.ip-lines .said .who { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.ip-hint { color: var(--ip-muted); }
.ip-error { color: var(--ip-danger); }
.ip-interim { min-height: 1.4em; margin: 6px 0 0; color: var(--ip-muted); font-style: italic; }

.ip-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}
.ip-bar button {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 24px;
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.2);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.ip-bar button:first-child { background: #FFFFFF; color: #1C1D2E; }
.ip-bar button.on { background: #FFFFFF; color: #3A3FB0; }
.ip-bar button.danger { background: var(--ip-danger); color: #FFFFFF; }

/* Foldable opened up, tablet, or any wide window: one side each, nothing turned round. */
@media (min-width: 600px) and (min-aspect-ratio: 5/6) {
  .ip {
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .ip-bar { grid-column: 1 / -1; grid-row: 2; }
  .ip.flipped .ip-them { transform: none; }
  .ip-them { margin: 12px 6px 0 12px; }
  .ip-me { margin: 12px 12px 0 6px; }
  .ip-bar button:nth-child(3) { display: none; } /* Flip */
}
/* Lights up while the microphone hears sound. */
.ip-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #9A9DB2;
  transition: background 0.1s;
}
.ip.hearing .ip-status::before { background: #1F8A4C; }
.ip.paused .ip-status::before { background: var(--ip-danger); }
