/* ==========================================================================
   Animation Utilities and Keyframes
   ========================================================================== */

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

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

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

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

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

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

@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);
  }
}

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -30px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0, -4px, 0);
  }
}

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

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

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

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Animation Classes */
.animate-ready {
  opacity: 0;
  transform: translateY(30px);
  transition: all var(--duration-500) var(--ease-out);
}

.animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* Fade Animations */
.fade-in {
  animation: fadeIn var(--duration-500) var(--ease-out) forwards;
}

.fade-out {
  animation: fadeOut var(--duration-300) var(--ease-in) forwards;
}

/* Slide Animations */
.slide-up {
  animation: slideUp var(--duration-500) var(--ease-out) forwards;
}

.slide-up-in {
  animation: slideUp var(--duration-500) var(--ease-out) forwards;
}

.slide-down {
  animation: slideDown var(--duration-300) var(--ease-in) forwards;
}

.slide-left {
  animation: slideLeft var(--duration-500) var(--ease-out) forwards;
}

.slide-right {
  animation: slideRight var(--duration-500) var(--ease-out) forwards;
}

/* Scale Animations */
.scale-in {
  animation: scaleIn var(--duration-300) var(--ease-out) forwards;
}

.scale-out {
  animation: scaleOut var(--duration-200) var(--ease-in) forwards;
}

/* Interactive Animations */
.bounce {
  animation: bounce var(--duration-1000) infinite;
}

.pulse {
  animation: pulse var(--duration-1000) infinite;
}

.shake {
  animation: shake var(--duration-500) var(--ease-in-out);
}

.spin {
  animation: spin var(--duration-1000) linear infinite;
}

.ping {
  animation: ping var(--duration-1000) cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Hover Animations */
.hover-lift {
  transition: transform var(--duration-200) var(--ease-out);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

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

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

.hover-rotate {
  transition: transform var(--duration-300) var(--ease-out);
}

.hover-rotate:hover {
  transform: rotate(5deg);
}

/* Loading Animations */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Stagger Animation Delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }
.stagger-6 { animation-delay: 0.6s; }

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .animate-ready {
    opacity: 1;
    transform: none;
  }
}

/* Performance Optimizations */
.will-animate {
  will-change: transform, opacity;
}

.gpu-accelerated {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}