/* ============================================
   FIDEM Animations
   Pulse wave, fade transitions, particles
   ============================================ */

/* --- Pulse wave (waiting screen) --- */
.pulse-container {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: pulse-wave 3s ease-out infinite;
}

.pulse-ring:nth-child(2) {
  animation-delay: 0.7s;
}

.pulse-ring:nth-child(3) {
  animation-delay: 1.3s;
}

.pulse-ring:nth-child(4) {
  animation-delay: 2.1s;
}

.pulse-core {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 2px solid var(--accent);
  animation: pulse-core-beat 2s cubic-bezier(0.22, 0.61, 0.36, 1.0) infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-core svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
}

@keyframes pulse-wave {
  0% {
    transform: scale(0.4);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

@keyframes pulse-core-beat {
  0%, 100% {
    transform: scale(1) translate(0, 0);
    box-shadow: 0 0 0 0 var(--accent-glow);
  }
  25% {
    transform: scale(1.02) translate(0.5px, -0.5px);
  }
  50% {
    transform: scale(1.05) translate(0, 0);
    box-shadow: 0 0 20px 4px var(--accent-glow);
  }
  75% {
    transform: scale(1.02) translate(-0.5px, 0.5px);
  }
}

/* --- Golden time (subtle opacity pulse) --- */
.golden-pulse {
  animation: golden-glow 3s ease-in-out infinite;
}

@keyframes golden-glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* --- Empty state ambient --- */
.empty-state-ambient {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
  transition: opacity 500ms ease-out;
}

.empty-state-ambient[data-state="hidden"] {
  opacity: 0;
  pointer-events: none;
}

.empty-state-wave {
  position: absolute;
  width: 260px;
  height: 160px;
  top: -80px;
  left: -130px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  opacity: 0;
  will-change: transform, opacity;
}

.empty-state-wave:nth-child(1) {
  opacity: 0.12;
  animation: ambient-wave-1 3.7s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite alternate;
}

.empty-state-wave:nth-child(2) {
  width: 220px;
  height: 130px;
  top: -65px;
  left: -110px;
  opacity: 0.08;
  animation: ambient-wave-2 4.3s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite alternate;
}

@keyframes ambient-wave-1 {
  0% { transform: scaleX(0.95) scaleY(0.97); }
  100% { transform: scaleX(1.05) scaleY(1.03); }
}

@keyframes ambient-wave-2 {
  0% { transform: scaleX(1.04) scaleY(1.02); }
  100% { transform: scaleX(0.96) scaleY(0.98); }
}

.empty-state-blob {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-glow);
  opacity: 0.18;
  will-change: transform, opacity;
}

.empty-state-blob:nth-child(3) {
  width: 60px;
  height: 60px;
  top: -80px;
  left: -90px;
  animation: blob-float-1 17s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
}

.empty-state-blob:nth-child(4) {
  width: 50px;
  height: 50px;
  top: -70px;
  left: 40px;
  opacity: 0.14;
  animation: blob-float-2 23s cubic-bezier(0.25, 0.1, 0.25, 1) infinite;
}

@keyframes blob-float-1 {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(12px, -8px) scale(1.03); }
  50%  { transform: translate(-5px, 6px) scale(0.97); }
  75%  { transform: translate(8px, 3px) scale(1.02); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes blob-float-2 {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(-10px, 5px) scale(0.98); }
  50%  { transform: translate(7px, -6px) scale(1.04); }
  75%  { transform: translate(-4px, -3px) scale(0.99); }
  100% { transform: translate(0, 0) scale(1); }
}

.empty-state-text {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #D4B87A;
  opacity: 0.85;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 300ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .empty-state-wave,
  .empty-state-blob {
    animation: none !important;
  }
  .empty-state-wave:nth-child(1) { opacity: 0.10; }
  .empty-state-wave:nth-child(2) { opacity: 0.06; }
  .empty-state-blob { opacity: 0.14; }
}

/* --- Floating avatars --- */
.floating-avatars {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}
.floating-avatar {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(196, 164, 110, 0.35);
  will-change: transform, opacity;
  transition: opacity 600ms ease-out, transform 600ms ease-out;
  transform: translate3d(0, 0, 0) scale(0);
  color: var(--accent);
  backdrop-filter: blur(1px);
}
.floating-avatar svg {
  opacity: 0.7;
}
[data-theme="light"] .floating-avatar {
  border-color: rgba(196, 164, 110, 0.5);
}
@media (prefers-reduced-motion: reduce) {
  .floating-avatar {
    transition: none;
  }
}

/* --- CTA idle glow --- */
.btn-glow {
  animation: cta-glow 2.5s ease-in-out infinite;
}
@keyframes cta-glow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 12px 4px var(--accent-glow); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-glow { animation: none; }
}

/* --- Fade transitions (opacity only) --- */
.fade-enter {
  opacity: 0;
}

.fade-enter-active {
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.fade-exit {
  opacity: 1;
}

.fade-exit-active {
  opacity: 0;
  transition: opacity var(--transition-normal);
}

/* --- Hint text crossfade (opacity only) --- */
.hint-text {
  position: relative;
  min-height: 24px;
  overflow: hidden;
}

.hint-text span {
  display: block;
  animation: hint-fade 6s ease-in-out;
}

@keyframes hint-fade {
  0% { opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Celebration (subtle fade-in) --- */
.celebrate {
  animation: celebrate-fade 300ms ease-out;
}

@keyframes celebrate-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* --- Spin (loading) --- */
.spin {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Connection established effect (subtle) --- */
.connected-flash {
  animation: flash-accent 400ms ease-out;
}

@keyframes flash-accent {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* --- Heart pop (subtle opacity) --- */
.heart-pop {
  animation: heart-pop 250ms ease-out;
}

@keyframes heart-pop {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

/* --- Dot loading --- */
.dots-loading {
  display: inline-flex;
  gap: 4px;
}

.dots-loading span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

.dots-loading span:nth-child(2) {
  animation-delay: 0.15s;
}

.btn-primary .dots-loading span {
  background: var(--bg);
}

.dots-loading span:nth-child(3) {
  animation-delay: 0.3s;
}

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

/* --- Call hangup press ring --- */
.btn-call-action.pressing {
  position: relative;
}

.btn-call-action.pressing::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(
    var(--danger) calc(var(--press-progress, 0) * 360deg),
    transparent 0
  );
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px));
  pointer-events: none;
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .pulse-ring,
  .pulse-core,
  .golden-pulse,
  .dots-loading span {
    animation: none !important;
  }

  .pulse-ring {
    opacity: 0.2 !important;
    transform: scale(1) !important;
  }
}

/* --- Lively pulse (high traffic) --- */
.pulse-container.lively .pulse-ring {
  animation-duration: 2.2s;
}

.pulse-container.lively .pulse-core {
  animation-duration: 1.6s;
}
