/*
 * ANIMATION SYSTEM
 * Keyframe animations, transitions, and animation utilities
 */

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

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

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

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

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

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  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);
  }
}

/* Bounce animation */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Pulse animation */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* Rotate animation */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Float animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-15px);
  }
}

/* Shimmer effect */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Gradient rotate animation */
@keyframes gradientRotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Progress bar fill */
@keyframes progressFill {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

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

/* Glow pulse */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(200, 161, 90, 0.25);
  }
  50% {
    box-shadow: 0 0 40px rgba(39, 90, 78, 0.35), 0 0 60px rgba(200, 161, 90, 0.25);
  }
}

/* Existing flash message slide in */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

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

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

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

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

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

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

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

/* Continuous animations */
.animate-bounce {
  animation: bounce 2s ease-in-out infinite;
}

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

.animate-rotate {
  animation: rotate 3s linear infinite;
}

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

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

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

/* Transition speeds */
.transition-fast {
  transition: all var(--transition-fast);
}

.transition-base {
  transition: all var(--transition-base);
}

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

/* Specific transitions */
.transition-transform {
  transition: transform var(--transition-base);
}

.transition-opacity {
  transition: opacity var(--transition-base);
}

.transition-colors {
  transition: color var(--transition-base), background-color var(--transition-base), border-color var(--transition-base);
}

/* ========================================
   TRANSFORM UTILITIES
   ======================================== */

/* 3D perspective */
.perspective {
  perspective: 1000px;
}

.preserve-3d {
  transform-style: preserve-3d;
}

/* Transforms will be applied via JavaScript for dynamic effects */
.transform-gpu {
  will-change: transform;
  transform: translateZ(0);
}

.backface-hidden {
  backface-visibility: hidden;
}

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

/* Lift effect */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

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

/* Glow effect on hover */
.hover-glow {
  transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
  box-shadow: 0 0 30px rgba(200, 161, 90, 0.3), 0 0 60px rgba(39, 90, 78, 0.2);
}

/* Scale on hover */
.hover-scale {
  transition: transform var(--transition-base);
}

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

/* Rotate on hover */
.hover-rotate {
  transition: transform var(--transition-base);
}

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

/* ========================================
   LOADING & STATES
   ======================================== */

/* Loading spinner */
.spinner {
  border: 3px solid var(--color-slate-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: rotate 1s linear infinite;
}

/* Shimmer loading effect */
.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-slate-100) 0%,
    var(--color-slate-200) 50%,
    var(--color-slate-100) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* Skeleton loader */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-slate-100) 25%,
    var(--color-slate-200) 50%,
    var(--color-slate-100) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* ========================================
   STAGGER DELAYS (for JS-controlled stagger)
   ======================================== */

.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; }

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Mark elements that will be animated */
.will-animate {
  will-change: transform, opacity;
}

/* GPU acceleration */
.gpu-accelerate {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ========================================
   SCROLL-TRIGGERED STATES (applied by JS)
   ======================================== */

/* Initial state for scroll-triggered elements */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

/* Scale on scroll */
.scroll-scale {
  opacity: 0;
  transform: scale(0.95);
}

.scroll-scale.revealed {
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

/* ========================================
   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;
  }

  /* Disable continuous animations */
  .animate-bounce,
  .animate-pulse,
  .animate-rotate,
  .animate-float,
  .animate-glow {
    animation: none;
  }

  /* Disable loading animations */
  .loading-shimmer,
  .skeleton,
  .spinner {
    animation: none;
  }

  /* Keep elements visible */
  .scroll-reveal,
  .scroll-scale {
    opacity: 1;
    transform: none;
  }
}

/* ========================================
   RESPONSIVE ANIMATIONS
   ======================================== */

/* Reduce animation intensity on mobile */
@media (max-width: 768px) {
  .hover-lift:hover {
    transform: translateY(-4px);
  }

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

  /* Disable hover animations on touch devices */
  @media (hover: none) {
    .hover-lift:hover,
    .hover-scale:hover,
    .hover-rotate:hover,
    .hover-glow:hover {
      transform: none;
      box-shadow: none;
    }
  }
}
