/* Animation System */
/* Performance-optimized animations with accessibility considerations */

/* Page Load Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Avatar Pulse Animation for Touch Devices */
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: var(--shadow-lg);
  }
  50% {
    transform: scale(1.05);
    box-shadow: var(--shadow-xl), 0 0 25px var(--color-shadow-hover);
  }
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-lg);
  }
}

/* Background Subtle Movement */
@keyframes backgroundShift {
  0%, 100% {
    background-position: center center;
  }
  50% {
    background-position: center calc(50% + 5px);
  }
}

/* Text Glow Effect */
@keyframes textGlow {
  0%, 100% {
    text-shadow: 0 2px 4px var(--color-shadow);
  }
  50% {
    text-shadow: 0 2px 8px var(--color-shadow), 0 0 15px rgba(255, 255, 255, 0.1);
  }
}

/* Page Load Animation Classes */
.animate-fade-in {
  animation: fadeIn 0.6s var(--easing-ease-out) forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s var(--easing-ease-out) forwards;
}

.animate-scale-in {
  animation: scaleIn 0.5s var(--easing-ease-out) forwards;
}

/* Staggered Animation Delays */
.animate-delay-100 {
  animation-delay: 100ms;
}

.animate-delay-200 {
  animation-delay: 200ms;
}

.animate-delay-300 {
  animation-delay: 300ms;
}

.animate-delay-400 {
  animation-delay: 400ms;
}

/* Background Animation */
.background-animated {
  animation: backgroundShift 20s ease-in-out infinite;
}

/* Avatar Touch Animation */
.avatar-pulse {
  animation: pulse 0.3s ease-out;
}

/* Text Enhancement */
.text-enhanced {
  animation: textGlow 4s ease-in-out infinite;
}

/* Loading States */
.loading {
  opacity: 0;
}

.loaded {
  opacity: 1;
  transition: opacity var(--duration-slow) var(--easing-ease-out);
}

/* Hover Enhancements */
.hover-lift {
  transition: transform var(--duration-normal) var(--easing-ease-out);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

/* Focus Ring Animation */
@keyframes focusRing {
  0% {
    box-shadow: 0 0 0 0 var(--color-accent);
  }
  100% {
    box-shadow: 0 0 0 4px transparent;
  }
}

.focus-ring:focus-visible {
  animation: focusRing 0.6s var(--easing-ease-out);
}

/* Entrance Animations for Components */
.entrance-avatar {
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  animation: 
    fadeIn 0.6s var(--easing-ease-out) 0.2s forwards,
    scaleIn 0.6s var(--easing-ease-out) 0.2s forwards;
}

.entrance-motto {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.8s var(--easing-ease-out) 0.5s forwards;
}

.entrance-footer {
  opacity: 0;
  animation: fadeIn 0.6s var(--easing-ease-out) 0.8s forwards;
}

/* Responsive Animation Adjustments */
@media (min-width: 768px) {
  .animate-fade-in-up {
    animation-duration: 0.9s;
  }
  
  .entrance-avatar {
    animation-duration: 0.7s;
  }
}

/* High Performance Mode for Older Devices */
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  .background-animated {
    animation-duration: 30s; /* Slower on mobile */
  }
}

/* Accessibility: Respect Reduced Motion Preference */
@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;
  }
  
  .background-animated {
    animation: none;
  }
  
  .text-enhanced {
    animation: none;
    text-shadow: 0 2px 4px var(--color-shadow);
  }
  
  /* Keep essential focus animations for accessibility */
  .focus-ring:focus-visible {
    animation: none;
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
  }
}

/* GPU Acceleration Hints */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform, opacity;
}

.avatar-image,
.background {
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Performance Optimization */
.optimize-animations {
  contain: layout style paint;
}

/* Dark Mode Animation Adjustments */
@media (prefers-color-scheme: dark) {
  .text-enhanced {
    animation: textGlow 6s ease-in-out infinite;
  }
}
