/* ── Open Comms — Call Page Styles ────────────────────────────────────── */

:root {
  --bg:          #0a0c10;
  --surface:     rgba(17, 20, 32, 0.85);
  --border:      rgba(30, 37, 53, 0.8);
  --accent:      #7eb8f7;
  --text:        #e8eaf0;
  --text-muted:  #6b7280;
  --green:       #4ade80;
  --red:         #f87171;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Full-viewport layout — nothing scrolls on this page */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* .call-page is the root stacking context.
   position: relative lets absolutely-positioned children layer correctly. */
.call-page {
  position: relative;
  width: 100vw;
  height: 100dvh;   /* dvh = dynamic viewport height — correct on mobile */
}

/* ── Room Layer (background video) ──────────────────────────────────────── */
.room-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

/* object-fit: cover keeps the video filling the screen without distorting,
   cropping the sides if needed (same as CSS background-size: cover). */
.room-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.room-fallback {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 60%, #0d1535 0%, #050709 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

/* Simple CSS star field using a repeating radial gradient */
.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20%  30%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 70%  15%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 55%  75%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 85%  55%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 10%  80%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 40%  50%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 90%  10%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 60%  90%, rgba(255,255,255,0.4) 0%, transparent 100%);
  animation: twinkle 6s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

.fallback-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  position: relative;
  z-index: 1;
}

/* ── Face Layer ─────────────────────────────────────────────────────────── */
.face-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;   /* Let clicks pass through to controls below */
}

/* The mirror frame — the character appears to be sitting at a makeup mirror.
   It's a rounded rectangle centred on screen, slightly off-centre vertically
   to suggest we're looking up at a mirror above a vanity table. */
.face-mirror-frame {
  position: relative;
  width: min(340px, 70vw);
  height: min(420px, 70vh);
  border-radius: 50% 50% 48% 48% / 40% 40% 60% 60%;
  overflow: hidden;
  border: 3px solid rgba(200, 220, 255, 0.15);
  box-shadow:
    0 0 60px rgba(126, 184, 247, 0.08),
    inset 0 0 40px rgba(0, 0, 0, 0.5);
  transform: translateY(-6%);
  transition:
    width 0.8s ease,
    height 0.8s ease,
    border-radius 0.8s ease,
    border-color 0.8s ease,
    box-shadow 0.8s ease,
    transform 0.8s ease;
}

/* Live avatar active — expand to fill the face layer, drop the oval frame */
.face-mirror-frame.frameless {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border-color: transparent;
  box-shadow: none;
  transform: translateY(0);
}

.character-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.face-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  background: linear-gradient(160deg, #0d1535 0%, #050810 100%);
}

/* Subtle vignette to blend the face into the room background */
.mirror-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(5, 7, 9, 0.4) 100%
  );
  pointer-events: none;
}

/* ── Ringing Overlay ─────────────────────────────────────────────────────── */
.ringing-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(5, 7, 9, 0.78);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease;
}

.ringing-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.ringing-card {
  text-align: center;
  padding: 48px 40px;
}

.ringing-photo {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  margin: 0 auto 20px;
  display: block;
  animation: ring-pulse 1.2s ease-in-out infinite;
}

@keyframes ring-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(126, 184, 247, 0.4),
                0 0 0 0 rgba(126, 184, 247, 0.2);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(126, 184, 247, 0.15),
                0 0 0 28px rgba(126, 184, 247, 0.05);
  }
}

.ringing-name {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 20px;
}

/* Three animated dots — the classic "ringing" indicator */
.ringing-dots {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.ringing-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce-dot 1.2s ease-in-out infinite;
}
.ringing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ringing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

.ringing-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

/* ── Call Chrome ─────────────────────────────────────────────────────────── */
.call-chrome {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;  /* Whole chrome is non-interactive by default… */
}

/* …except the actual buttons and bars */
.call-info-bar,
.call-bottom,
.call-controls { pointer-events: all; }

.call-chrome.hidden {
  display: none;
}

/* Info bar at top */
.call-info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(to bottom, rgba(5,7,9,0.7) 0%, transparent 100%);
}

.call-info-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.call-signal-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.call-name-label {
  font-weight: 700;
  font-size: 1rem;
}

.call-sub-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.call-timer {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;  /* Digits all same width — no layout jitter */
  color: var(--text-muted);
}

/* Bottom section — controls + status bar stacked together at the bottom */
.call-bottom {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(to top, rgba(5,7,9,0.85) 0%, transparent 100%);
  pointer-events: all;
}

/* Controls row at bottom */
.call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px 20px 12px;
}

.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 64px;
  height: 64px;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  backdrop-filter: blur(8px);
  padding: 0;
}
.ctrl-btn:hover { background: rgba(30, 37, 53, 0.95); }
.ctrl-btn:active { transform: scale(0.93); }

.ctrl-btn-end {
  width: 72px;
  height: 72px;
}

.ctrl-icon { font-size: 1.4rem; line-height: 1; }

.ctrl-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: none;
}

/* Muted / warning state — red ring around the button */
.ctrl-btn.muted   { background: rgba(248, 113, 113, 0.15); border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.ctrl-btn.warning { background: rgba(248, 113, 113, 0.15); border-color: var(--red); box-shadow: 0 0 0 3px var(--red), 0 0 12px rgba(248,113,113,0.5); animation: warn-pulse 1.2s ease-in-out infinite; }

@keyframes warn-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--red), 0 0 12px rgba(248,113,113,0.5); }
  50%       { box-shadow: 0 0 0 5px var(--red), 0 0 22px rgba(248,113,113,0.8); }
}

/* ── Tap-to-unmute overlay ───────────────────────────────────────────────── */
.unmute-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: inherit;
  animation: fadeIn 0.4s ease;
  pointer-events: all;
}

.unmute-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(126, 184, 247, 0.15);
  border: 1px solid rgba(126, 184, 247, 0.4);
  border-radius: 16px;
  padding: 24px 36px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s, transform 0.1s;
  pointer-events: all;
}

.unmute-btn:hover  { background: rgba(126, 184, 247, 0.25); }
.unmute-btn:active { transform: scale(0.96); }

.unmute-icon  { font-size: 2.4rem; }
.unmute-label { font-size: 0.95rem; letter-spacing: 0.05em; color: var(--accent); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

@keyframes mic-warn {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Mobile tweaks ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .face-mirror-frame {
    width: 72vw;
    height: 88vw;
  }
  .ctrl-btn       { width: 56px; height: 56px; }
  .ctrl-btn-end   { width: 64px; height: 64px; }
  .ctrl-icon      { font-size: 1.2rem; }
}
