
/**
 * Animation styles optimized for performance and simplicity
 * 
 * @author Luca Racchetti <razzo1987@gmail.com>
 * @version 1.0.0
 * @since 2025-11-03
 */

/* Global variables for animation speed control */
:root {
  --animate-duration: 0.8s;
  --animate-delay: 0.3s;
}

/* FOUC (Flash of Unstyled Content) prevention and animated elements visibility control */
/* Applied ONLY to elements with data-animation attribute */
[data-animation] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease; /* Fallback for browsers without Animate.css */
}

[data-animation].animate__animated {
  opacity: 1;
  transform: translateY(0);
}

/* Progressive delays for sequential elements in timeline */
.timeline-item:nth-child(1) [data-animation] { --animate-delay: 0.1s; }
.timeline-item:nth-child(2) [data-animation] { --animate-delay: 0.2s; }
.timeline-item:nth-child(3) [data-animation] { --animate-delay: 0.3s; }
.timeline-item:nth-child(4) [data-animation] { --animate-delay: 0.4s; }
.timeline-item:nth-child(5) [data-animation] { --animate-delay: 0.5s; }
.timeline-item:nth-child(n+6) [data-animation] { --animate-delay: 0.6s; }

/* Simplified animation for section titles */
h2.title {
  position: relative;
}

h2.title::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--bs-primary, #007bff);
  animation: expandLine 1s ease-out forwards;
}

@keyframes expandLine {
  from { width: 0; }
  to { width: 50px; }
}

/* Optimizations for mobile devices and accessibility preferences */
@media (prefers-reduced-motion: reduce) {
  [data-animation] {
    opacity: 1 !important;
    transform: none !important;
  }
  
  [data-animation].animate__animated {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  
  h2.title::after {
    animation: none !important;
    width: 50px !important;
  }
}

/* Performance improvements for high-density screens */
@media (min-resolution: 2dppx) {
  [data-animation].animate__animated {
    transform: translateZ(0); /* Enable hardware acceleration */
    will-change: transform, opacity;
  }
}

/* Cleanup after animations to free resources */
[data-animation].animate__animated.animate__fadeInUp,
[data-animation].animate__animated.animate__fadeInLeft,
[data-animation].animate__animated.animate__fadeInRight,
[data-animation].animate__animated.animate__zoomIn {
  will-change: auto;
}
