/**
 * Animation System
 * Scroll-triggered animations and keyframes
 *
 * @package Quhe_Theme
 * @since 1.0.0
 */

/* ==========================================================================
   Keyframe Animations
   ========================================================================== */

/* Fade Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

/* Zoom Animations */
@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes zoomOut {
  from {
    opacity: 0;
    transform: scale(1.2);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Flip Animations */
@keyframes flipInX {
  from {
    opacity: 0;
    transform: perspective(400px) rotateX(90deg);
  }

  to {
    opacity: 1;
    transform: perspective(400px) rotateX(0);
  }
}

@keyframes flipInY {
  from {
    opacity: 0;
    transform: perspective(400px) rotateY(90deg);
  }

  to {
    opacity: 1;
    transform: perspective(400px) rotateY(0);
  }
}

/* Rotate Animations */
@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-200deg);
  }

  to {
    opacity: 1;
    transform: rotate(0);
  }
}

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

  to {
    transform: rotate(360deg);
  }
}

/* Bounce Animation */
@keyframes bounce {

  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-20px);
  }

  60% {
    transform: translateY(-10px);
  }
}

/* Pulse Animation */
@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }

  100% {
    transform: scale(1);
  }
}

/* ==========================================================================
   Scroll Animation Classes
   ========================================================================== */

/* Initial state - hidden before scroll */
[data-animate] {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

/* Animated state - visible after scroll */
[data-animate].animated {
  opacity: 1;
  transform: translateY(0);
}

/* Specific animation types */
[data-animate="fade"] {
  opacity: 0;
  transform: none;
}

[data-animate="fade"].animated {
  opacity: 1;
}

[data-animate="fade-up"] {
  opacity: 0;
  transform: translateY(30px);
}

[data-animate="fade-up"].animated {
  opacity: 1;
  transform: translateY(0);
}

[data-animate="fade-down"] {
  opacity: 0;
  transform: translateY(-30px);
}

[data-animate="fade-down"].animated {
  opacity: 1;
  transform: translateY(0);
}

[data-animate="fade-left"] {
  opacity: 0;
  transform: translateX(-30px);
}

[data-animate="fade-left"].animated {
  opacity: 1;
  transform: translateX(0);
}

[data-animate="fade-right"] {
  opacity: 0;
  transform: translateX(30px);
}

[data-animate="fade-right"].animated {
  opacity: 1;
  transform: translateX(0);
}

[data-animate="zoom-in"] {
  opacity: 0;
  transform: scale(0.8);
}

[data-animate="zoom-in"].animated {
  opacity: 1;
  transform: scale(1);
}

[data-animate="zoom-out"] {
  opacity: 0;
  transform: scale(1.2);
}

[data-animate="zoom-out"].animated {
  opacity: 1;
  transform: scale(1);
}

[data-animate="flip-up"] {
  opacity: 0;
  transform: perspective(400px) rotateX(90deg);
}

[data-animate="flip-up"].animated {
  opacity: 1;
  transform: perspective(400px) rotateX(0);
}

[data-animate="rotate"] {
  opacity: 0;
  transform: rotate(-200deg);
}

[data-animate="rotate"].animated {
  opacity: 1;
  transform: rotate(0);
}

/* ==========================================================================
   Animation Delays
   ========================================================================== */

[data-animate-delay="100"].animated {
  transition-delay: 0.1s;
}

[data-animate-delay="200"].animated {
  transition-delay: 0.2s;
}

[data-animate-delay="300"].animated {
  transition-delay: 0.3s;
}

[data-animate-delay="400"].animated {
  transition-delay: 0.4s;
}

[data-animate-delay="500"].animated {
  transition-delay: 0.5s;
}

[data-animate-delay="600"].animated {
  transition-delay: 0.6s;
}

/* ==========================================================================
   Animation Durations
   ========================================================================== */

[data-animate-duration="fast"] {
  transition-duration: 0.3s;
}

[data-animate-duration="normal"] {
  transition-duration: 0.6s;
}

[data-animate-duration="slow"] {
  transition-duration: 0.9s;
}

/* ==========================================================================
   Utility Animation Classes
   ========================================================================== */

.animate-fade-in {
  animation: fadeIn 0.6s ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.6s ease-out;
}

.animate-fade-in-right {
  animation: fadeInRight 0.6s ease-out;
}

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

.animate-zoom-out {
  animation: zoomOut 0.5s ease-out;
}

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

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

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

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

.hover-lift {
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
}

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

.hover-scale {
  transition: transform var(--transition-smooth);
}

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

.hover-rotate {
  transition: transform var(--transition-smooth);
}

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

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

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(1, 25, 255, 0.1);
  border-top-color: var(--color-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

/* Dots Loading */
@keyframes dotPulse {

  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.dots-loading {
  display: inline-flex;
  gap: 0.5rem;
}

.dots-loading span {
  width: 12px;
  height: 12px;
  background-color: var(--color-blue);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out;
}

.dots-loading span:nth-child(1) {
  animation-delay: 0s;
}

.dots-loading span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots-loading span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ==========================================================================
   Progress Bar Animation
   ========================================================================== */

@keyframes progressFill {
  from {
    width: 0;
  }
}

.progress-bar {
  height: 8px;
  background-color: var(--color-accent);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-blue);
  border-radius: 4px;
  animation: progressFill 1.5s ease-out;
  position: relative;
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.3),
      transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

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

  [data-animate] {
    opacity: 1;
    transform: none;
  }
}

/* ==========================================================================
   Direct Animation Delays (for immediate animations)
   ========================================================================== */

.animate-delay-100 {
  animation-delay: 0.1s;
}

.animate-delay-200 {
  animation-delay: 0.2s;
}

.animate-delay-300 {
  animation-delay: 0.3s;
}

.animate-delay-400 {
  animation-delay: 0.4s;
}

.animate-delay-500 {
  animation-delay: 0.5s;
}

.animate-delay-600 {
  animation-delay: 0.6s;
}