/* ========================================
   HIGHSCORES DESIGN SYSTEM - Animations
   ======================================== */

/* ================================
   KEYFRAMES
   ================================ */

/* Fade */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Slide */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* Scale */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes scaleOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

/* Bounce */
@keyframes bounce {
  0%, 100% {
    transform: translateY(-5%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Pulse */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Glow */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--color-primary-500);
  }
  50% {
    box-shadow: 0 0 20px var(--color-primary-500), 0 0 30px var(--color-primary-400);
  }
}

/* Ripple */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Score pop */
@keyframes scorePop {
  0% {
    opacity: 0;
    transform: scale(0.5) translateY(0);
  }
  50% {
    opacity: 1;
    transform: scale(1.2) translateY(-10px);
  }
  100% {
    opacity: 0;
    transform: scale(1) translateY(-30px);
  }
}

/* XP gain */
@keyframes xpGain {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translateY(-10px) scale(1);
  }
  80% {
    opacity: 1;
    transform: translateY(-20px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px) scale(0.8);
  }
}

/* Achievement unlock */
@keyframes achievementUnlock {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  50% {
    transform: scale(1.2) rotate(10deg);
  }
  75% {
    transform: scale(0.9) rotate(-5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

/* Confetti */
@keyframes confettiFall {
  0% {
    transform: translateY(-100%) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Number count up */
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Skeleton loading */
@keyframes skeletonShimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

/* Card hover lift */
@keyframes cardLift {
  from {
    transform: translateY(0);
    box-shadow: var(--card-shadow);
  }
  to {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.1);
  }
}

/* Badge pulse for urgent items */
@keyframes badgePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

/* Button press feedback */
@keyframes buttonPress {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

/* Gradient shimmer for skeleton */
@keyframes gradientShimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Page content fade in */
@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================================
   ANIMATION CLASSES
   ================================ */

/* Fade */
.animate-fade-in {
  animation: fadeIn var(--transition-normal) var(--ease-out) forwards;
}

.animate-fade-out {
  animation: fadeOut var(--transition-normal) var(--ease-in) forwards;
}

/* Slide */
.animate-slide-in-up {
  animation: slideInUp var(--transition-normal) var(--ease-out) forwards;
}

.animate-slide-in-down {
  animation: slideInDown var(--transition-normal) var(--ease-out) forwards;
}

.animate-slide-in-left {
  animation: slideInLeft var(--transition-normal) var(--ease-out) forwards;
}

.animate-slide-in-right {
  animation: slideInRight var(--transition-normal) var(--ease-out) forwards;
}

.animate-slide-out-up {
  animation: slideOutUp var(--transition-normal) var(--ease-in) forwards;
}

.animate-slide-out-down {
  animation: slideOutDown var(--transition-normal) var(--ease-in) forwards;
}

/* Scale */
.animate-scale-in {
  animation: scaleIn var(--transition-normal) var(--ease-out) forwards;
}

.animate-scale-out {
  animation: scaleOut var(--transition-normal) var(--ease-in) forwards;
}

/* Bounce */
.animate-bounce {
  animation: bounce 1s infinite;
}

.animate-bounce-in {
  animation: bounceIn 0.6s var(--ease-bounce) forwards;
}

/* Shake */
.animate-shake {
  animation: shake 0.5s var(--ease-in-out);
}

/* Pulse */
.animate-pulse {
  animation: pulse 2s var(--ease-in-out) infinite;
}

.animate-pulse-scale {
  animation: pulseScale 2s var(--ease-in-out) infinite;
}

/* Glow */
.animate-glow {
  animation: glow 2s var(--ease-in-out) infinite;
}

/* Game-specific */
.animate-score-pop {
  animation: scorePop 0.8s var(--ease-out) forwards;
}

.animate-xp-gain {
  animation: xpGain 1.2s var(--ease-out) forwards;
}

.animate-achievement {
  animation: achievementUnlock 0.8s var(--ease-bounce) forwards;
}

/* Card & component micro-interactions */
.animate-card-lift:hover {
  animation: cardLift var(--transition-fast) var(--ease-out) forwards;
}

.animate-badge-pulse {
  animation: badgePulse 2s var(--ease-in-out) infinite;
}

.animate-button-press:active {
  animation: buttonPress 0.15s var(--ease-out);
}

.animate-page-in {
  animation: pageFadeIn 0.3s var(--ease-out) forwards;
}

.animate-gradient-shimmer {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.04) 25%, rgba(99, 102, 241, 0.08) 50%, rgba(99, 102, 241, 0.04) 75%);
  background-size: 200% 100%;
  animation: gradientShimmer 1.5s ease-in-out infinite;
}

/* ================================
   TRANSITION UTILITIES
   ================================ */

.transition-none { transition: none; }

.transition-all {
  transition: all var(--transition-normal) var(--ease-in-out);
}

.transition-fast {
  transition: all var(--transition-fast) var(--ease-in-out);
}

.transition-slow {
  transition: all var(--transition-slow) var(--ease-in-out);
}

.transition-colors {
  transition: color var(--transition-fast) var(--ease-in-out),
              background-color var(--transition-fast) var(--ease-in-out),
              border-color var(--transition-fast) var(--ease-in-out);
}

.transition-opacity {
  transition: opacity var(--transition-normal) var(--ease-in-out);
}

.transition-transform {
  transition: transform var(--transition-normal) var(--ease-in-out);
}

/* ================================
   HOVER EFFECTS
   ================================ */

.hover-lift {
  transition: transform var(--transition-fast) var(--ease-out),
              box-shadow var(--transition-fast) var(--ease-out);
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.hover-scale {
  transition: transform var(--transition-fast) var(--ease-out);
}

.hover-scale:hover {
  transform: scale(1.02);
}

.hover-brightness {
  transition: filter var(--transition-fast) var(--ease-out);
}

.hover-brightness:hover {
  filter: brightness(1.05);
}

/* ================================
   PAGE TRANSITIONS
   ================================ */

.page-enter {
  opacity: 0;
  transform: translateX(20px);
}

.page-enter-active {
  opacity: 1;
  transform: translateX(0);
  transition: opacity var(--transition-normal) var(--ease-out),
              transform var(--transition-normal) var(--ease-out);
}

.page-exit {
  opacity: 1;
  transform: translateX(0);
}

.page-exit-active {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity var(--transition-normal) var(--ease-in),
              transform var(--transition-normal) var(--ease-in);
}

/* ================================
   STAGGERED ANIMATIONS
   ================================ */

.stagger-children > * {
  opacity: 0;
  animation: slideInUp var(--transition-normal) var(--ease-out) forwards;
}

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

/* ================================
   REDUCED MOTION
   ================================ */

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