/**
 * Chrome Theme Pro 2.0 - Animation Library
 * Modern micro-interactions and animation utilities
 */

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

/* 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 fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

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

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

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

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

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

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

@keyframes bounceIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

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

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

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(var(--sf-accent-rgb), 0.4);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(var(--sf-accent-rgb), 0);
  }
}

@keyframes ringPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

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

@keyframes floatRotate {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(3deg);
  }
}

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

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

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

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

/* Stagger reveal */
@keyframes staggerReveal {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Page transitions */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

/* Gradient flow */
@keyframes gradientFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Glow pulse */
@keyframes glowPulse {
  0%, 100% {
    filter: drop-shadow(0 0 2px rgba(var(--sf-accent-rgb), 0.5));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(var(--sf-accent-rgb), 0.8));
  }
}

/* Typewriter cursor */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}


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

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

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

.animate-fade-in-up {
  animation: fadeInUp var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-down {
  animation: fadeInDown var(--duration-normal) var(--ease-out) forwards;
}

.animate-fade-in-scale {
  animation: fadeInScale var(--duration-normal) var(--ease-bounce) forwards;
}

/* Slide utilities */
.animate-slide-in-right {
  animation: slideInRight var(--duration-normal) var(--ease-out) forwards;
}

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

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

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

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

.animate-pop-in {
  animation: popIn var(--duration-slow) var(--ease-out) forwards;
}

.animate-bounce-in {
  animation: bounceIn var(--duration-slow) var(--ease-out) forwards;
}

/* Continuous animations */
.animate-bounce {
  animation: bounce 1s var(--ease-in-out) infinite;
}

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

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

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

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

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

.animate-ping {
  animation: ping 1s var(--ease-out) infinite;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s var(--ease-in-out) infinite;
}

.animate-gradient {
  background-size: 200% 200%;
  animation: gradientFlow 3s var(--ease-in-out) infinite;
}

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

/* Shake utilities */
.animate-shake {
  animation: shake var(--duration-slow) var(--ease-out);
}

.animate-gentle-shake {
  animation: gentleShake var(--duration-normal) var(--ease-out) infinite;
}

/* Page transition */
.page-enter {
  animation: pageEnter var(--duration-slow) var(--ease-out) forwards;
}

.page-exit {
  animation: pageExit var(--duration-fast) var(--ease-in) forwards;
}


/* ========================================
   INTERACTIVE EFFECTS
   ======================================== */

/* Press effect (haptic-feel) */
.press-effect {
  transition: transform var(--duration-fast) var(--ease-out);
  will-change: transform;
}

.press-effect:active {
  transform: scale(0.97);
}

/* Hover lift effect */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}

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

/* Hover scale effect */
.hover-scale {
  transition: transform var(--duration-normal) var(--ease-out);
}

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

/* Hover glow effect */
.hover-glow {
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(var(--sf-accent-rgb), 0.3);
}

/* Ripple container */
.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect .ripple {
  position: absolute;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: ripple var(--duration-slow) var(--ease-out);
  pointer-events: none;
}


/* ========================================
   STAGGER ANIMATION SYSTEM
   ======================================== */

.stagger-children > * {
  opacity: 0;
  animation: staggerReveal var(--duration-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; }
.stagger-children > *:nth-child(n+11) { animation-delay: 500ms; }

/* Fast stagger */
.stagger-fast > * {
  animation-delay: calc(var(--stagger-index, 0) * 30ms);
}

/* Slow stagger */
.stagger-slow > * {
  animation-delay: calc(var(--stagger-index, 0) * 100ms);
}


/* ========================================
   ANIMATION MODIFIERS
   ======================================== */

/* Duration modifiers */
.animation-instant { animation-duration: var(--duration-instant) !important; }
.animation-fast { animation-duration: var(--duration-fast) !important; }
.animation-normal { animation-duration: var(--duration-normal) !important; }
.animation-slow { animation-duration: var(--duration-slow) !important; }
.animation-slower { animation-duration: var(--duration-slower) !important; }

/* Delay modifiers */
.animation-delay-100 { animation-delay: 100ms; }
.animation-delay-200 { animation-delay: 200ms; }
.animation-delay-300 { animation-delay: 300ms; }
.animation-delay-500 { animation-delay: 500ms; }
.animation-delay-700 { animation-delay: 700ms; }
.animation-delay-1000 { animation-delay: 1000ms; }

/* Iteration modifiers */
.animation-once { animation-iteration-count: 1; }
.animation-twice { animation-iteration-count: 2; }
.animation-infinite { animation-iteration-count: infinite; }

/* Direction modifiers */
.animation-reverse { animation-direction: reverse; }
.animation-alternate { animation-direction: alternate; }

/* Fill mode */
.animation-fill-forwards { animation-fill-mode: forwards; }
.animation-fill-backwards { animation-fill-mode: backwards; }
.animation-fill-both { animation-fill-mode: both; }

/* Pause control */
.animation-paused { animation-play-state: paused; }
.animation-running { animation-play-state: running; }

/* Pausable class for visibility API */
.animation-pausable {
  /* Can be paused when tab is hidden */
}


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

@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-bounce,
  .animate-pulse,
  .animate-float,
  .animate-spin,
  .animate-ping,
  .animate-shimmer,
  .animate-gradient,
  .animate-glow,
  .animate-gentle-shake {
    animation: none !important;
  }

  .hover-lift:hover {
    transform: none;
  }

  .hover-scale:hover {
    transform: none;
  }

  /* Keep essential feedback */
  .press-effect:active {
    opacity: 0.8;
    transform: none;
  }
}
