/* VoiceMate Orb — standalone styles (no external dependencies) */

@property --orb-scale {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

/* Voice orb: dark glass depth + rainbow warmth (blue → purple → pink → coral). */
.orb {
  position: relative;
  border-radius: 50%;
  isolation: isolate;
  overflow: hidden;
  /* Mobile Safari fails to clip 3D-transformed pseudo-elements with just
     border-radius + overflow: hidden, leaking the inner conic-gradient swirl
     into a visible rectangle around the orb. Geometric clip + webkit mask
     forces a proper circular clip even when the orb's perspective transform
     is active. */
  clip-path: circle(50%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 99%, transparent 100%);
  mask-image: radial-gradient(circle at 50% 50%, #000 99%, transparent 100%);
  cursor: pointer;
  transform:
    perspective(900px)
    rotateX(var(--orb-tilt-x, 0deg))
    rotateY(var(--orb-tilt-y, 0deg))
    scale(var(--orb-scale, 1));
  transform-style: preserve-3d;
  background:
    radial-gradient(58% 52% at 72% 16%, rgba(218, 238, 255, 0.82) 0%, rgba(128, 157, 255, 0.48) 22%, transparent 58%),
    radial-gradient(128% 128% at 30% 24%,
      rgba(255, 255, 255, 0.42) 0%, rgba(211, 230, 255, 0.38) 4%, rgba(79, 139, 255, 0.52) 20%,
      rgba(91, 84, 242, 0.48) 38%, rgba(168, 61, 240, 0.44) 55%, rgba(255, 79, 151, 0.4) 71%,
      rgba(255, 106, 44, 0.32) 87%, rgba(192, 38, 63, 0.28) 100%),
    radial-gradient(68% 78% at 20% 46%, rgba(2, 8, 85, 0.9) 0%, rgba(18, 13, 112, 0.78) 30%, rgba(36, 18, 130, 0.24) 62%, transparent 76%),
    radial-gradient(46% 38% at 74% 70%, rgba(255, 44, 193, 0.66) 0%, rgba(159, 47, 232, 0.44) 38%, transparent 72%),
    radial-gradient(95% 95% at 60% 44%, #c8ddff 0%, #6b92ff 18%, #5b54f2 36%, #8d37e6 56%, #ff4f97 74%, #241068 100%);
  box-shadow:
    inset 0 3px 4px rgba(255, 255, 255, 0.86),
    inset 0 2px 3px rgba(255, 255, 255, 0.72),
    inset 10px 16px 36px rgba(230, 244, 255, 0.4),
    inset 0 22px 50px rgba(255, 255, 255, 0.32),
    inset -18px -10px 50px rgba(90, 40, 160, 0.3),
    inset -34px 0 58px rgba(1, 4, 55, 0.72),
    inset 0 -34px 60px rgba(70, 5, 50, 0.48),
    inset 0 -42px 70px rgba(91, 0, 117, 0.58),
    inset 0 0 0 1px rgba(218, 228, 255, 0.32),
    0 18px 44px rgba(120, 70, 220, 0.24),
    0 24px 56px rgba(40, 30, 140, 0.26),
    0 0 90px rgba(128, 112, 255, 0.24);
  animation: orbHue 14s ease-in-out infinite;
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: filter, transform;
}

.orb:focus-visible {
  outline: 4px solid rgba(0, 122, 255, 0.34);
  outline-offset: 8px;
}

.orb::before {
  content: "";
  position: absolute;
  inset: -32%;
  background:
    conic-gradient(from 0deg at 50% 50%,
      rgba(80, 130, 255, 0.22) 0deg,
      rgba(95, 84, 242, 0.78) 56deg,
      rgba(168, 61, 240, 0.72) 112deg,
      rgba(255, 79, 151, 0.78) 168deg,
      rgba(255, 106, 44, 0.68) 224deg,
      rgba(13, 7, 96, 0.82) 280deg,
      rgba(1, 5, 64, 0.88) 320deg,
      rgba(80, 130, 255, 0.22) 360deg),
    radial-gradient(54% 58% at 18% 44%, rgba(0, 0, 56, 0.78), transparent 68%),
    radial-gradient(48% 28% at 70% 18%, rgba(207, 242, 255, 0.68), transparent 72%);
  filter: blur(18px) saturate(1.42);
  mix-blend-mode: screen;
  opacity: 0.76;
  animation: orbSwirl 11s linear infinite;
  transform: translate3d(var(--orb-fluid-x, 0px), var(--orb-fluid-y, 0px), -18px) rotate(var(--orb-fluid-rot, 0deg));
  transition: transform 220ms ease-out;
}

.orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(16% 13% at 33% 21%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0) 70%),
    radial-gradient(46% 36% at 31% 25%, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0) 62%),
    radial-gradient(13% 10% at 68% 70%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 72%),
    radial-gradient(25% 20% at 39% 14%, rgba(246, 252, 255, 0.78), rgba(246, 252, 255, 0.06) 52%, transparent 75%),
    radial-gradient(46% 30% at 59% 8%, rgba(187, 225, 255, 0.38), transparent 66%),
    radial-gradient(26% 20% at 83% 39%, rgba(233, 247, 255, 0.24), transparent 70%),
    radial-gradient(36% 16% at 69% 78%, rgba(255, 67, 211, 0.4), transparent 74%),
    radial-gradient(118% 112% at 50% 49%, transparent 61%, rgba(214, 224, 255, 0.4) 78%, rgba(255, 255, 255, 0.12) 84%, transparent 91%),
    radial-gradient(120% 80% at 50% 122%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.18) 100%),
    linear-gradient(116deg, rgba(255, 255, 255, 0.28), transparent 22%, transparent 67%, rgba(255, 255, 255, 0.1));
  transform: translate3d(var(--orb-glint-x, 0px), var(--orb-glint-y, 0px), 28px) rotate(var(--orb-glint-rot, 0deg));
  transition: transform 220ms ease-out;
}

.orb.orb-tapped {
  animation: none;
}

.orb-eyes.squinting i {
  transform: scale(1.12, 0.38);
}

.orb-eyes {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9%;
  will-change: transform;
}

.orb-eyes i {
  width: 8%;
  aspect-ratio: 1 / 2.3;
  border-radius: 999px;
  background: linear-gradient(160deg, #ffffff, #eaf0ff);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.9),
    inset 0 -2px 3px rgba(60, 20, 90, 0.12),
    0 2px 12px rgba(40, 0, 40, 0.24);
  transform-origin: center;
  transition: transform 110ms ease;
}

.orb-eyes.alert i {
  transform: scaleY(1.18);
}

.orb-eyes.blinking i {
  transform: scaleY(0.08);
}

.orb.listening {
  animation: orbHue 14s ease-in-out infinite, breathe 1.7s ease-in-out infinite;
}

.orb.speaking {
  animation: orbHue 14s ease-in-out infinite, orbSpeak 0.8s ease-in-out infinite;
}

.orb.confused {
  filter: saturate(0.92) contrast(1.02);
}

.orb.confused .orb-eyes i {
  transform: scaleY(0.88) rotate(-4deg);
}

.orb.error,
.orb.offline {
  filter: saturate(0.72) brightness(0.92);
  opacity: 0.92;
}

.orb.reading .orb-eyes {
  transform: translateY(4%);
}

.orb.reacting {
  animation: none !important;
  --orb-scale: calc(1 + var(--level, 0) * 0.06);
  transition: transform 120ms ease-out;
}

/* Size presets */
.orb--hero {
  width: min(260px, 62vw);
  height: min(260px, 62vw);
}

.orb--focus {
  width: min(280px, 52vw);
  height: min(280px, 52vw);
}

.orb--sm {
  width: 120px;
  height: 120px;
}

.orb--md {
  width: 200px;
  height: 200px;
}

.orb--lg {
  width: 320px;
  height: 320px;
}

@keyframes breathe {
  0%,
  100% {
    --orb-scale: 1;
  }

  50% {
    --orb-scale: 1.035;
  }
}

@keyframes orbSwirl {
  from {
    transform: translate3d(var(--orb-fluid-x, 0px), var(--orb-fluid-y, 0px), -18px) rotate(var(--orb-fluid-rot, 0deg));
  }
  to {
    transform: translate3d(var(--orb-fluid-x, 0px), var(--orb-fluid-y, 0px), -18px) rotate(calc(360deg + var(--orb-fluid-rot, 0deg)));
  }
}

@keyframes orbHue {
  0%,
  100% {
    filter: saturate(1.12) contrast(1.04) hue-rotate(0deg);
  }
  50% {
    filter: saturate(1.28) contrast(1.08) hue-rotate(12deg);
  }
}

@keyframes orbSpeak {
  0%,
  100% {
    --orb-scale: 1;
    filter: saturate(1);
  }

  50% {
    --orb-scale: 1.05;
    filter: saturate(1.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb::before,
  .orb::after,
  .orb {
    animation: none !important;
  }
}
