/* ============================================
   Empire Design System — Animations
   ============================================ */

/* ---- Keyframes ---- */
@keyframes eds-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes eds-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes eds-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes eds-slide-down {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes eds-slide-left {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes eds-slide-right {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes eds-scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes eds-bounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

@keyframes eds-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

@keyframes eds-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes eds-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes eds-checkmark {
  0% { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}

@keyframes eds-confetti-fall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes eds-progress-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

/* ---- Utility classes ---- */
.eds-animate-in     { animation: eds-fade-in var(--duration-normal) var(--ease-out) both; }
.eds-animate-up     { animation: eds-slide-up var(--duration-slow) var(--ease-spring) both; }
.eds-animate-down   { animation: eds-slide-down var(--duration-slow) var(--ease-spring) both; }
.eds-animate-left   { animation: eds-slide-left var(--duration-slow) var(--ease-spring) both; }
.eds-animate-right  { animation: eds-slide-right var(--duration-slow) var(--ease-spring) both; }
.eds-animate-scale  { animation: eds-scale-in var(--duration-normal) var(--ease-spring) both; }
.eds-animate-bounce { animation: eds-bounce var(--duration-slow) var(--ease-spring); }
.eds-animate-shake  { animation: eds-shake 0.4s ease; }
.eds-animate-pulse  { animation: eds-pulse 1.5s ease infinite; }
.eds-animate-spin   { animation: eds-spin 0.8s linear infinite; }

/* Stagger children */
.eds-stagger > *:nth-child(1) { animation-delay: 0ms; }
.eds-stagger > *:nth-child(2) { animation-delay: 50ms; }
.eds-stagger > *:nth-child(3) { animation-delay: 100ms; }
.eds-stagger > *:nth-child(4) { animation-delay: 150ms; }
.eds-stagger > *:nth-child(5) { animation-delay: 200ms; }
.eds-stagger > *:nth-child(6) { animation-delay: 250ms; }
.eds-stagger > *:nth-child(7) { animation-delay: 300ms; }
.eds-stagger > *:nth-child(8) { animation-delay: 350ms; }

/* ---- Success Checkmark (SVG) ---- */
.eds-checkmark-svg {
  width: 64px;
  height: 64px;
}
.eds-checkmark-circle {
  fill: none;
  stroke: var(--green);
  stroke-width: 2;
  stroke-dasharray: 166;
  stroke-dashoffset: 166;
  animation: eds-checkmark 0.6s var(--ease-out) forwards;
}
.eds-checkmark-check {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  animation: eds-checkmark 0.3s var(--ease-out) 0.3s forwards;
}

/* ---- Loading Spinner ---- */
.eds-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: eds-spin 0.6s linear infinite;
}
.eds-spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ---- Skeleton Loading ---- */
.eds-skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 0%, var(--bg-active) 50%, var(--bg-hover) 100%);
  background-size: 400px 100%;
  animation: eds-progress-shimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
}
.eds-skeleton-text { height: 14px; margin-bottom: 8px; }
.eds-skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.eds-skeleton-card { height: 80px; border-radius: var(--radius-lg); }

/* ---- Page Transitions ---- */
.eds-page-enter {
  animation: eds-slide-left var(--duration-slow) var(--ease-spring) both;
}
.eds-page-exit {
  animation: eds-fade-out var(--duration-fast) var(--ease-in) both;
}

/* ---- Celebration ---- */
.eds-celebration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-toast);
}
.eds-confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  top: -10px;
  animation: eds-confetti-fall 2s ease forwards;
}

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