// ========================================
// ANIMATIONS - Smooth & Modern Transitions
// ========================================

@import './design-tokens';

// Fade Animations
// ========================================

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

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

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

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

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

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

// Scale Animations
// ========================================

@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 scaleUp {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.05);
  }
}

@keyframes scaleDown {
  from {
    transform: scale(1.05);
  }
  to {
    transform: scale(1);
  }
}

// Slide Animations
// ========================================

@keyframes slideInUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutUp {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-100%);
  }
}

@keyframes slideOutDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

// Rotation Animations
// ========================================

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

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

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 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(-2px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(2px);
  }
}

@keyframes wiggle {
  0%, 7% {
    transform: rotateZ(0);
  }
  15% {
    transform: rotateZ(-15deg);
  }
  20% {
    transform: rotateZ(10deg);
  }
  25% {
    transform: rotateZ(-10deg);
  }
  30% {
    transform: rotateZ(6deg);
  }
  35% {
    transform: rotateZ(-4deg);
  }
  40%, 100% {
    transform: rotateZ(0);
  }
}

// Loading Animations
// ========================================

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

@keyframes shimmer2 {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes dots {
  0%, 20% {
    color: transparent;
    text-shadow: 0.25em 0 0 transparent, 0.5em 0 0 transparent;
  }
  40% {
    color: currentColor;
    text-shadow: 0.25em 0 0 transparent, 0.5em 0 0 transparent;
  }
  60% {
    text-shadow: 0.25em 0 0 currentColor, 0.5em 0 0 transparent;
  }
  80%, 100% {
    text-shadow: 0.25em 0 0 currentColor, 0.5em 0 0 currentColor;
  }
}

@keyframes wave {
  0%, 60%, 100% {
    transform: initial;
  }
  30% {
    transform: translateY(-15px);
  }
}

// Hover Animations
// ========================================

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

@keyframes glow {
  0% {
    box-shadow: 0 0 5px rgba($primary-500, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba($primary-500, 0.8), 0 0 30px rgba($primary-500, 0.6);
  }
  100% {
    box-shadow: 0 0 5px rgba($primary-500, 0.5);
  }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

// Animation Classes
// ========================================

// Fade Classes
.animate-fade-in {
  animation: fadeIn $duration-300 $ease-out;
}

.animate-fade-out {
  animation: fadeOut $duration-300 $ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp $duration-500 $ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown $duration-500 $ease-out;
}

.animate-fade-in-left {
  animation: fadeInLeft $duration-500 $ease-out;
}

.animate-fade-in-right {
  animation: fadeInRight $duration-500 $ease-out;
}

// Scale Classes
.animate-scale-in {
  animation: scaleIn $duration-300 $ease-out;
}

.animate-scale-out {
  animation: scaleOut $duration-300 $ease-out;
}

.animate-scale-up {
  animation: scaleUp $duration-200 $ease-out;
}

.animate-scale-down {
  animation: scaleDown $duration-200 $ease-out;
}

// Slide Classes
.animate-slide-in-up {
  animation: slideInUp $duration-500 $ease-out;
}

.animate-slide-in-down {
  animation: slideInDown $duration-500 $ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft $duration-500 $ease-out;
}

.animate-slide-in-right {
  animation: slideInRight $duration-500 $ease-out;
}

.animate-slide-out-up {
  animation: slideOutUp $duration-300 $ease-out;
}

.animate-slide-out-down {
  animation: slideOutDown $duration-300 $ease-out;
}

.animate-slide-out-left {
  animation: slideOutLeft $duration-300 $ease-out;
}

.animate-slide-out-right {
  animation: slideOutRight $duration-300 $ease-out;
}

// Rotation Classes
.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-spin-reverse {
  animation: spinReverse 1s linear infinite;
}

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

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-wiggle {
  animation: wiggle 1s ease-in-out;
}

// Loading Classes
.animate-shimmer {
  animation: shimmer 1.5s infinite;
}

.animate-shimmer2 {
  animation: shimmer2 1.5s infinite;
}

.animate-dots {
  animation: dots 1.4s infinite;
}

.animate-wave {
  animation: wave 1.4s infinite;
}

// Hover Classes
.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-glow {
  animation: glow 2s ease-in-out infinite;
}

.animate-ripple {
  animation: ripple 0.6s linear;
}

// Transition Classes
// ========================================

.transition-all {
  transition: all $duration-300 $ease-out;
}

.transition-colors {
  transition: color $duration-200 $ease-out, background-color $duration-200 $ease-out, border-color $duration-200 $ease-out;
}

.transition-opacity {
  transition: opacity $duration-200 $ease-out;
}

.transition-transform {
  transition: transform $duration-200 $ease-out;
}

.transition-shadow {
  transition: box-shadow $duration-200 $ease-out;
}

// Hover Effects
// ========================================

.hover-lift {
  transition: transform $duration-200 $ease-out, box-shadow $duration-200 $ease-out;

  &:hover {
    transform: translateY(-2px);
    box-shadow: $shadow-lg;
  }
}

.hover-glow {
  transition: box-shadow $duration-200 $ease-out;

  &:hover {
    box-shadow: 0 0 20px rgba($primary-500, 0.3);
  }
}

.hover-scale {
  transition: transform $duration-200 $ease-out;

  &:hover {
    transform: scale(1.05);
  }
}

.hover-rotate {
  transition: transform $duration-200 $ease-out;

  &:hover {
    transform: rotate(5deg);
  }
}

.hover-bounce {
  transition: transform $duration-200 $ease-bounce;

  &:hover {
    transform: translateY(-4px);
  }
}

// Staggered Animations
// ========================================

.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; }
.stagger-7 { animation-delay: 0.7s; }
.stagger-8 { animation-delay: 0.8s; }

// Animation States
// ========================================

.animation-paused {
  animation-play-state: paused;
}

.animation-running {
  animation-play-state: running;
}

// 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-spin,
  .animate-pulse,
  .animate-bounce,
  .animate-float,
  .animate-glow {
    animation: none;
  }
}
