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

:root {
  --bg: #09090b;
  --text: #e4e4e7;
  --text2: #a1a1aa;
  --text3: #71717a;
  --text4: #52525b;
  --text5: #3f3f46;
  --emerald: #10b981;
  --red: #f87171;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  --font-display: 'Red Hat Display', system-ui, sans-serif;
  --font-body: 'Red Hat Text', system-ui, sans-serif;
  --orb-size: 180px;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 100dvh;
}

/* ── Logo ── */
.logo {
  position: absolute;
  top: max(env(safe-area-inset-top, 16px), 16px);
  left: 20px;
  padding-top: 8px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}
.logo:hover img { opacity: 0.9; }

/* ── Connection indicator ── */
.connection {
  position: absolute;
  top: max(env(safe-area-inset-top, 16px), 16px);
  right: 20px;
  padding-top: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 6px;
}
.conn-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text5);
  transition: background 0.4s ease;
}
.conn-dot.connected { background: var(--emerald); }
.conn-dot.error { background: var(--red); }
.conn-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text5);
  transition: color 0.4s ease;
}
.conn-dot.connected + .conn-label { color: var(--text4); }

/* ── Ambient glow ── */
.ambient {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(16,185,129,0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  transition: all 1.5s ease;
}
body[data-state="active"] .ambient {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(16,185,129,0.06) 0%, transparent 70%);
}

/* ── Center stage ── */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  position: relative;
}

/* ── Orb ── */
.orb-wrapper {
  position: relative;
  width: var(--orb-size);
  height: var(--orb-size);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.orb-wrapper:active {
  transform: scale(0.97);
  transition: transform 0.1s ease;
}

/* Glow */
.orb-glow {
  position: absolute;
  inset: -25px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  transition: box-shadow 0.12s ease;
}
/* Idle: static subtle glow — no animation */
body[data-state="idle"] .orb-glow {
  box-shadow:
    0 0 8px 0 rgba(16,185,129,0.08),
    0 0 20px 0 rgba(16,185,129,0.04);
}

/* Active: breathing glow that reacts */
body[data-state="active"] .orb-glow {
  animation: activeGlow 2.4s ease-in-out infinite;
}
@keyframes activeGlow {
  0%, 100% {
    box-shadow:
      0 0 16px 2px rgba(16,185,129,0.35),
      0 0 40px 4px rgba(16,185,129,0.18),
      0 0 70px 6px rgba(16,185,129,0.06);
  }
  50% {
    box-shadow:
      0 0 28px 5px rgba(16,185,129,0.55),
      0 0 60px 10px rgba(16,185,129,0.28),
      0 0 100px 14px rgba(16,185,129,0.10);
  }
}

/* Video orb + fallback gradient */
.orb-video-wrap {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: radial-gradient(circle at 40% 40%, #1a3a2e 0%, #0d1f18 50%, #09090b 100%);
}
.orb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Subtle ring */
.orb-ring {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(16,185,129,0.08);
  z-index: 2;
  pointer-events: none;
  transition: border-color 0.4s ease;
}
body[data-state="active"] .orb-ring { border-color: rgba(16,185,129,0.2); }
body[data-state="connecting"] .orb-ring { border-color: rgba(16,185,129,0.15); }
.orb-wrapper:hover .orb-ring { border-color: rgba(16,185,129,0.25); }

/* Connecting spinner — orbits the orb while dialing */
.dial-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1.5px solid rgba(16,185,129,0.06);
  border-top-color: rgba(16,185,129,0.5);
  border-right-color: rgba(16,185,129,0.2);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
body[data-state="connecting"] .dial-ring {
  opacity: 1;
  animation: dialSpin 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes dialSpin { to { transform: rotate(360deg); } }

/* Connecting pulse on the orb glow */
body[data-state="connecting"] .orb-glow {
  animation: connectingPulse 1.6s ease-in-out infinite;
}
@keyframes connectingPulse {
  0%, 100% {
    box-shadow:
      0 0 12px 0 rgba(16,185,129,0.15),
      0 0 30px 0 rgba(16,185,129,0.08),
      0 0 50px 0 rgba(16,185,129,0.03);
  }
  50% {
    box-shadow:
      0 0 20px 3px rgba(16,185,129,0.35),
      0 0 50px 6px rgba(16,185,129,0.18),
      0 0 80px 8px rgba(16,185,129,0.06);
  }
}

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(16,185,129,0.3);
  pointer-events: none;
  z-index: 4;
  animation: rippleOut 0.7s ease-out forwards;
}
@keyframes rippleOut {
  0% { width: var(--orb-size); height: var(--orb-size); top: 0; left: 0; opacity: 0.8; }
  100% { width: calc(var(--orb-size) + 60px); height: calc(var(--orb-size) + 60px); top: -30px; left: -30px; opacity: 0; }
}

/* ── Below orb ── */
.below-orb {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 50px;
}

/* Waveform canvas */
.wave-canvas {
  width: 200px;
  height: 36px;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
body[data-state="active"] .wave-canvas {
  opacity: 1;
}

/* Call timer */
.timer {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.timer.visible { opacity: 1; transform: translateY(0); }

/* ── Subtitle (connecting / status) ── */
.subtitle {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.4s ease;
  height: 16px;
  margin-bottom: 4px;
}
body[data-state="connecting"] .subtitle { opacity: 1; }

/* ── Hint ── */
.hint {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom, 24px), 28px);
  left: 0;
  right: 0;
  text-align: center;
  padding-bottom: 8px;
}
.hint-text {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text5);
  letter-spacing: 0.04em;
  transition: opacity 0.5s ease;
}
body[data-state="active"] .hint-text { opacity: 0; }
body[data-state="connecting"] .hint-text { opacity: 0; }

/* ── Responsive ── */
@media (max-height: 680px) {
  :root { --orb-size: 150px; }
  .below-orb { margin-top: 18px; }
}
@media (min-width: 768px) {
  :root { --orb-size: 200px; }
}
@media (min-width: 1200px) {
  :root { --orb-size: 220px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
