/* ============================================================
   EMMA C2C — Animations
   Speaking pulse, milestone check, gauge fill, page transitions
   ============================================================ */

/* ── Avatar Speaking Pulse ── */
@keyframes speakingPulse {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50%  { box-shadow: 0 0 0 12px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ── Gold Celebration Pulse (Competency Verified) ── */
@keyframes goldPulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--theme-secondary-rgb), 0.5); }
  50%  { box-shadow: 0 0 0 16px rgba(var(--theme-secondary-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--theme-secondary-rgb), 0); }
}

/* ── Milestone Check Animation ── */
@keyframes milestoneCheck {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.06); }
  50%  { transform: scale(0.97); }
  70%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.milestone-card.just-checked {
  animation: milestoneCheck 0.5s var(--ease-spring);
}

/* ── Confetti Burst (when a gauge verifies) ── */
@keyframes confettiBurst {
  0%   { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translateY(-80px) scale(0) rotate(360deg); }
}

.confetti-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: confettiBurst 0.8s var(--ease-out-expo) forwards;
  pointer-events: none;
}

/* ── Phase Entrance ── */
@keyframes phaseSlideIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.phase-column {
  animation: phaseSlideIn 0.6s var(--ease-out-expo) both;
}

.phase-column:nth-child(1) { animation-delay: 0ms; }
.phase-column:nth-child(2) { animation-delay: 100ms; }
.phase-column:nth-child(3) { animation-delay: 200ms; }
.phase-column:nth-child(4) { animation-delay: 300ms; }

/* ── Milestone Card Entrance ── */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.milestone-card {
  animation: cardSlideIn 0.4s var(--ease-out-expo) both;
}

/* Stagger within phase columns */
.milestone-card:nth-child(1)  { animation-delay: 50ms; }
.milestone-card:nth-child(2)  { animation-delay: 100ms; }
.milestone-card:nth-child(3)  { animation-delay: 150ms; }
.milestone-card:nth-child(4)  { animation-delay: 200ms; }
.milestone-card:nth-child(5)  { animation-delay: 250ms; }
.milestone-card:nth-child(6)  { animation-delay: 300ms; }
.milestone-card:nth-child(7)  { animation-delay: 350ms; }
.milestone-card:nth-child(8)  { animation-delay: 400ms; }

/* ── Gauge Ring Entrance ── */
@keyframes gaugeSlideIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.gauge-card {
  animation: gaugeSlideIn 0.5s var(--ease-out-expo) both;
}

.gauge-card:nth-child(1) { animation-delay: 100ms; }
.gauge-card:nth-child(2) { animation-delay: 200ms; }
.gauge-card:nth-child(3) { animation-delay: 300ms; }
.gauge-card:nth-child(4) { animation-delay: 400ms; }

/* ── Verified Badge Pop ── */
@keyframes badgePop {
  0%   { transform: scale(0); opacity: 0; }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: linear-gradient(135deg, var(--theme-secondary), #FFD700);
  color: #1A1A2E;
  font-size: var(--font-scale-xs);
  font-weight: var(--font-weight-black);
  border-radius: var(--radius-full);
  animation: badgePop 0.5s var(--ease-out-expo);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Gauge Verified Glow Animation ── */
.gauge-card.verified {
  animation: goldPulse 1.5s var(--ease-spring) 1;
}

/* ── Loading Skeleton ── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.04) 25%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* ── Utility Link Hover Glow ── */
.utility-link-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: radial-gradient(
    circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(var(--theme-primary-rgb), 0.06) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity var(--duration-normal);
  pointer-events: none;
}

.utility-link-card:hover::before {
  opacity: 1;
}

.utility-link-card {
  position: relative;
  overflow: hidden;
}

/* ── Progress Bar Glow ── */
.header-progress-bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--theme-secondary);
  box-shadow: 0 0 12px rgba(var(--theme-secondary-rgb), 0.6);
  opacity: 0;
  transition: opacity var(--duration-normal);
}

.header-progress-bar-fill[style*="width"]:not([style*="width: 0"]):not([style*="width:0"])::after {
  opacity: 1;
}

.header-progress-bar-fill {
  position: relative;
}

/* ── Page Transition ── */
@keyframes pageIn {
  from {
    opacity: 0;
    filter: blur(4px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

.app-body {
  animation: pageIn 0.6s var(--ease-out-expo);
}

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