/* ─────────────────────────────────────────────
   voice-orb.css — Voice Orb component styles
   States: idle, listening, processing, speaking
   Sizes: full (120px), compact (40px)
   ───────────────────────────────────────────── */

/* ── Base Orb Container ── */

.voice-orb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  z-index: var(--z-base);
}

.voice-orb:focus-visible .voice-orb-core {
  outline: 2px solid var(--accent-primary-light);
  outline-offset: 4px;
}

/* ── Glow Layer ── */

.voice-orb-glow {
  position: absolute;
  inset: -30%;
  border-radius: var(--radius-full);
  filter: blur(28px);
  opacity: 0.5;
  background: var(--voice-idle);
  transition:
    background var(--transition-slow),
    opacity var(--transition-slow),
    filter var(--transition-slow);
  pointer-events: none;
  will-change: opacity, filter;
  animation: voiceGlowPulse 3s ease-in-out infinite;
}

/* ── Core ── */

.voice-orb-core {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.15) 0%,
    var(--voice-idle) 45%,
    color-mix(in srgb, var(--voice-idle) 70%, #000) 100%
  );
  box-shadow:
    0 0 20px var(--voice-idle-glow),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
  transition:
    background var(--transition-slow),
    box-shadow var(--transition-slow),
    transform var(--transition-normal);
  transform: scale(calc(1 + var(--audio-level, 0) * 0.15));
  will-change: transform;
  z-index: 2;
  overflow: hidden;
}

/* Specular highlight / glass shine */
.voice-orb-core::before {
  content: '';
  position: absolute;
  top: 8%;
  left: 15%;
  width: 55%;
  height: 40%;
  border-radius: var(--radius-full);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0.08) 60%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 3;
}

/* Icon container */
.voice-orb-core svg {
  position: relative;
  z-index: 4;
  color: rgba(255, 255, 255, 0.95);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

/* ── Ripple Rings ── */

.voice-orb-ripple {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.voice-orb-ripple span {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  border: 2px solid var(--voice-listening);
  opacity: 0;
  transform: scale(1);
  transition: border-color var(--transition-slow);
}

/* ─────────────────────────────────────────────
   Sizes
   ───────────────────────────────────────────── */

/* Full (welcome screen) */
.voice-orb--full {
  width: 120px;
  height: 120px;
}

.voice-orb--full .voice-orb-core svg {
  width: 36px;
  height: 36px;
}

/* Compact (chat input area) */
.voice-orb--compact {
  width: 40px;
  height: 40px;
}

.voice-orb--compact .voice-orb-core svg {
  width: 18px;
  height: 18px;
}

.voice-orb--compact .voice-orb-glow {
  inset: -20%;
  filter: blur(12px);
}

.voice-orb--compact .voice-orb-core::before {
  top: 6%;
  left: 18%;
  width: 50%;
  height: 35%;
}

.voice-orb--compact .voice-orb-ripple span {
  border-width: 1.5px;
}

/* ─────────────────────────────────────────────
   State: IDLE (green)
   Gentle pulse, subtle glow
   ───────────────────────────────────────────── */

.voice-orb[data-state="idle"] .voice-orb-glow {
  background: var(--voice-idle);
  opacity: 0.35;
  animation: voiceGlowPulse 3s ease-in-out infinite;
}

.voice-orb[data-state="idle"] .voice-orb-core {
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.15) 0%,
    var(--voice-idle) 45%,
    color-mix(in srgb, var(--voice-idle) 70%, #000) 100%
  );
  box-shadow:
    0 0 20px var(--voice-idle-glow),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
  animation: pulse 3s ease-in-out infinite;
}

.voice-orb[data-state="idle"] .voice-orb-ripple span {
  opacity: 0;
  animation: none;
}

/* Hover effect */
.voice-orb[data-state="idle"]:hover .voice-orb-core {
  box-shadow:
    0 0 30px var(--voice-idle-glow),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
}

.voice-orb[data-state="idle"]:hover .voice-orb-glow {
  opacity: 0.55;
}

/* ─────────────────────────────────────────────
   State: LISTENING (blue)
   Ripple rings expanding outward, brighter glow
   ───────────────────────────────────────────── */

.voice-orb[data-state="listening"] .voice-orb-glow {
  background: var(--voice-listening);
  opacity: 0.55;
  animation: voiceGlowPulse 2s ease-in-out infinite;
}

.voice-orb[data-state="listening"] .voice-orb-core {
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.18) 0%,
    var(--voice-listening) 45%,
    color-mix(in srgb, var(--voice-listening) 70%, #000) 100%
  );
  box-shadow:
    0 0 30px var(--voice-listening-glow),
    0 0 60px rgba(96, 165, 250, 0.15),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

.voice-orb[data-state="listening"] .voice-orb-ripple span {
  border-color: var(--voice-listening);
  animation: ripple 2.4s ease-out infinite;
}

.voice-orb[data-state="listening"] .voice-orb-ripple span:nth-child(1) {
  animation-delay: 0s;
}

.voice-orb[data-state="listening"] .voice-orb-ripple span:nth-child(2) {
  animation-delay: 0.8s;
}

.voice-orb[data-state="listening"] .voice-orb-ripple span:nth-child(3) {
  animation-delay: 1.6s;
}

/* ─────────────────────────────────────────────
   State: PROCESSING (yellow)
   Fast pulse, spinning motion
   ───────────────────────────────────────────── */

.voice-orb[data-state="processing"] .voice-orb-glow {
  background: var(--voice-processing);
  opacity: 0.5;
  animation: voiceGlowPulse 1.5s ease-in-out infinite;
}

.voice-orb[data-state="processing"] .voice-orb-core {
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.18) 0%,
    var(--voice-processing) 45%,
    color-mix(in srgb, var(--voice-processing) 70%, #000) 100%
  );
  box-shadow:
    0 0 24px var(--voice-processing-glow),
    0 0 48px rgba(251, 191, 36, 0.12),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
  animation: pulse 1.2s ease-in-out infinite, orbSpin 4s linear infinite;
}

.voice-orb[data-state="processing"] .voice-orb-ripple span {
  opacity: 0;
  animation: none;
}

/* ─────────────────────────────────────────────
   State: SPEAKING (purple)
   Smooth glow pulse, subtle scale
   ───────────────────────────────────────────── */

.voice-orb[data-state="speaking"] .voice-orb-glow {
  background: var(--voice-speaking);
  opacity: 0.5;
  animation: voiceGlowPulse 2.5s ease-in-out infinite;
}

.voice-orb[data-state="speaking"] .voice-orb-core {
  background: radial-gradient(
    circle at 35% 35%,
    rgba(255, 255, 255, 0.15) 0%,
    var(--voice-speaking) 45%,
    color-mix(in srgb, var(--voice-speaking) 70%, #000) 100%
  );
  box-shadow:
    0 0 24px var(--voice-speaking-glow),
    0 0 48px rgba(167, 139, 250, 0.12),
    inset 0 -4px 12px rgba(0, 0, 0, 0.2);
  animation: speakingScale 2s ease-in-out infinite;
}

.voice-orb[data-state="speaking"] .voice-orb-ripple span {
  opacity: 0;
  animation: none;
}

/* ─────────────────────────────────────────────
   Additional Keyframes
   ───────────────────────────────────────────── */

/* Processing spin — gradual rotation on the core highlight */
@keyframes orbSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Glow layer smooth pulse */
@keyframes voiceGlowPulse {
  0%, 100% {
    opacity: var(--glow-base-opacity, 0.35);
    transform: scale(1);
  }
  50% {
    opacity: calc(var(--glow-base-opacity, 0.35) + 0.2);
    transform: scale(1.08);
  }
}

/* Speaking scale — gentle breathing effect */
@keyframes speakingScale {
  0%, 100% {
    transform: scale(calc(1 + var(--audio-level, 0) * 0.15));
  }
  50% {
    transform: scale(calc(1.06 + var(--audio-level, 0) * 0.15));
  }
}

/* ─────────────────────────────────────────────
   Compact Idle Override — subtle glass button
   ───────────────────────────────────────────── */

.voice-orb--compact[data-state="idle"] .voice-orb-glow {
  opacity: 0;
  animation: none;
}

.voice-orb--compact[data-state="idle"] .voice-orb-core {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--blur-sm));
  -webkit-backdrop-filter: blur(var(--blur-sm));
  border: 1px solid var(--glass-border);
  box-shadow: none;
  animation: none;
}

.voice-orb--compact[data-state="idle"] .voice-orb-core svg {
  color: var(--text-secondary);
}

.voice-orb--compact[data-state="idle"]:hover .voice-orb-core {
  background: var(--glass-bg-hover);
  border-color: var(--glass-border-light);
  box-shadow: none;
}

.voice-orb--compact[data-state="idle"]:hover .voice-orb-core svg {
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────
   Reduced Motion
   ───────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .voice-orb-glow,
  .voice-orb-core,
  .voice-orb-ripple span {
    animation: none !important;
  }

  .voice-orb[data-state="listening"] .voice-orb-ripple span {
    opacity: 0.3;
    transform: scale(1.5);
  }

  .voice-orb[data-state="processing"] .voice-orb-core {
    animation: none !important;
  }
}
