/* ============================================
   VixViu Motion Containers - Animation Effects
   ============================================ */

/* ===== SCROLL-BASED ANIMATIONS (8 presets) ===== */

/* 1. Motion Fade In - Scroll Triggered */
.motion-fade-in {
  --motion-type: entrance;
  --motion-trigger: scroll;
  --motion-duration: 0.8s;
  --motion-easing: ease-out;
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 0;
  transform: translateY(30px);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 2. Motion Fade Out - Scroll Triggered */
.motion-fade-out {
  --motion-type: exit;
  --motion-trigger: scroll;
  --motion-duration: 0.6s;
  --motion-easing: ease-in;
  --motion-delay: 0s;
  --motion-direction: out;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: translateY(0);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 3. Motion Scale In - Scroll Triggered */
.motion-scale-in {
  --motion-type: entrance;
  --motion-trigger: scroll;
  --motion-duration: 0.7s;
  --motion-easing: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 0;
  transform: scale(0.8) translateY(20px);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 4. Motion Scale Out - Scroll Triggered */
.motion-scale-out {
  --motion-type: exit;
  --motion-trigger: scroll;
  --motion-duration: 0.5s;
  --motion-easing: ease-in;
  --motion-delay: 0s;
  --motion-direction: out;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: scale(1);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 5. Motion Bounce In - Scroll Triggered */
.motion-bounce-in {
  --motion-type: entrance;
  --motion-trigger: scroll;
  --motion-duration: 1s;
  --motion-easing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 0;
  transform: scale(0.3) translateY(50px);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 6. Motion Bounce Out - Scroll Triggered */
.motion-bounce-out {
  --motion-type: exit;
  --motion-trigger: scroll;
  --motion-duration: 0.8s;
  --motion-easing: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --motion-delay: 0s;
  --motion-direction: out;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: scale(1);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 7. Motion Rotate In - Scroll Triggered */
.motion-rotate-in {
  --motion-type: entrance;
  --motion-trigger: scroll;
  --motion-duration: 0.9s;
  --motion-easing: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 0;
  transform: rotate(-180deg) scale(0.5);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 8. Motion Rotate Out - Scroll Triggered */
.motion-rotate-out {
  --motion-type: exit;
  --motion-trigger: scroll;
  --motion-duration: 0.7s;
  --motion-easing: ease-in;
  --motion-delay: 0s;
  --motion-direction: out;
  --motion-mobile-behavior: disable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: rotate(0deg) scale(1);
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* ===== CLICK-BASED ANIMATIONS (4 presets) ===== */

/* 9. Motion Pulse - Click Triggered */
.motion-pulse {
  --motion-type: interaction;
  --motion-trigger: click;
  --motion-duration: 0.6s;
  --motion-easing: ease-in-out;
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: enable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: scale(1);
  cursor: pointer;
  
  /* Animation properties */
  will-change: transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  transition: transform 0.3s ease;
}

.motion-pulse:hover {
  transform: scale(1.05);
}

.motion-pulse:active {
  transform: scale(0.95);
}

/* 10. Motion Shake - Click Triggered */
.motion-shake {
  --motion-type: interaction;
  --motion-trigger: click;
  --motion-duration: 0.8s;
  --motion-easing: ease-in-out;
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: enable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: translateX(0);
  cursor: pointer;
  
  /* Animation properties */
  will-change: transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* 11. Motion Spin - Click Triggered */
.motion-spin {
  --motion-type: interaction;
  --motion-trigger: click;
  --motion-duration: 1s;
  --motion-easing: ease-in-out;
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: enable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: rotate(0deg) translate3d(0, 0, 0);
  cursor: pointer;
  
  /* Animation properties */
  will-change: transform;
  backface-visibility: hidden;
}

/* 12. Motion Flash - Click Triggered */
.motion-flash {
  --motion-type: interaction;
  --motion-trigger: click;
  --motion-duration: 0.4s;
  --motion-easing: ease-in-out;
  --motion-delay: 0s;
  --motion-direction: in;
  --motion-mobile-behavior: enable;
  --motion-respect-reduced-motion: true;
  
  /* Initial state */
  opacity: 1;
  transform: scale(1);
  cursor: pointer;
  
  /* Animation properties */
  will-change: opacity, transform;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

/* ===== ANIMATION KEYFRAMES ===== */

/* Shake Animation */
@keyframes motion-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Spin Animation */
@keyframes motion-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Flash Animation */
@keyframes motion-flash {
  0%, 100% { 
    opacity: 1; 
    transform: scale(1); 
  }
  50% { 
    opacity: 0.7; 
    transform: scale(1.1); 
  }
}

/* Pulse Animation */
@keyframes motion-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ===== REDUCED MOTION SUPPORT ===== */

@media (prefers-reduced-motion: reduce) {
  .motion-fade-in,
  .motion-fade-out,
  .motion-scale-in,
  .motion-scale-out,
  .motion-bounce-in,
  .motion-bounce-out,
  .motion-rotate-in,
  .motion-rotate-out,
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* Disable all animations for users who prefer reduced motion */
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  
  /* Ensure elements are visible when animations are disabled */
  .motion-fade-in,
  .motion-scale-in,
  .motion-bounce-in,
  .motion-rotate-in {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ===== MOBILE RESPONSIVE ===== */

@media (max-width: 768px) {
  /* Disable animations on mobile for performance */
  .motion-fade-in[data-mobile-behavior="disable"],
  .motion-fade-out[data-mobile-behavior="disable"],
  .motion-scale-in[data-mobile-behavior="disable"],
  .motion-scale-out[data-mobile-behavior="disable"],
  .motion-bounce-in[data-mobile-behavior="disable"],
  .motion-bounce-out[data-mobile-behavior="disable"],
  .motion-rotate-in[data-mobile-behavior="disable"],
  .motion-rotate-out[data-mobile-behavior="disable"] {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  
  /* Enable click animations on mobile */
  .motion-pulse[data-mobile-behavior="enable"],
  .motion-shake[data-mobile-behavior="enable"],
  .motion-spin[data-mobile-behavior="enable"],
  .motion-flash[data-mobile-behavior="enable"] {
    /* Keep click animations enabled on mobile */
    animation: none;
    transition: transform 0.3s ease;
  }
  
  /* Optimize touch interactions */
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* Improve touch response */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

/* Hardware acceleration for all motion elements */
.motion-fade-in,
.motion-fade-out,
.motion-scale-in,
.motion-scale-out,
.motion-bounce-in,
.motion-bounce-out,
.motion-rotate-in,
.motion-rotate-out,
.motion-pulse,
.motion-shake,
.motion-spin,
.motion-flash {
  /* Force GPU acceleration */
  will-change: transform, opacity;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
  
  /* Smooth rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== ACCESSIBILITY ENHANCEMENTS ===== */

/* Focus indicators for interactive animations */
.motion-pulse:focus-visible,
.motion-shake:focus-visible,
.motion-spin:focus-visible,
.motion-flash:focus-visible {
  outline: 2px solid #007cba;
  outline-offset: 2px;
}

/* High contrast support */
@media (prefers-contrast: high) {
  .motion-fade-in,
  .motion-fade-out,
  .motion-scale-in,
  .motion-scale-out,
  .motion-bounce-in,
  .motion-bounce-out,
  .motion-rotate-in,
  .motion-rotate-out,
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* Ensure visibility in high contrast mode */
    border: 1px solid currentColor;
  }
}

/* ===== PRINT STYLES ===== */

@media print {
  .motion-fade-in,
  .motion-fade-out,
  .motion-scale-in,
  .motion-scale-out,
  .motion-bounce-in,
  .motion-bounce-out,
  .motion-rotate-in,
  .motion-rotate-out,
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* Disable animations for print */
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ===== BROWSER-SPECIFIC OPTIMIZATIONS ===== */

/* Safari/WebKit optimizations */
@supports (-webkit-backdrop-filter: blur(1px)) {
  .motion-fade-in,
  .motion-fade-out,
  .motion-scale-in,
  .motion-scale-out,
  .motion-bounce-in,
  .motion-bounce-out,
  .motion-rotate-in,
  .motion-rotate-out,
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* WebKit-specific optimizations */
    -webkit-transform: translateZ(0);
  }
}

/* Firefox optimizations */
@-moz-document url-prefix() {
  .motion-fade-in,
  .motion-fade-out,
  .motion-scale-in,
  .motion-scale-out,
  .motion-bounce-in,
  .motion-bounce-out,
  .motion-rotate-in,
  .motion-rotate-out,
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* Firefox-specific optimizations */
    transform: translateZ(0);
  }
}

/* Edge optimizations */
@supports (-ms-ime-align: auto) {
  .motion-fade-in,
  .motion-fade-out,
  .motion-scale-in,
  .motion-scale-out,
  .motion-bounce-in,
  .motion-bounce-out,
  .motion-rotate-in,
  .motion-rotate-out,
  .motion-pulse,
  .motion-shake,
  .motion-spin,
  .motion-flash {
    /* Edge-specific optimizations */
    transform: translateZ(0);
  }
}

/* ===== DEBUG MODE STYLES ===== */

/* Debug indicators for animation classes */
.motion-fade-in[data-debug="true"]::before,
.motion-fade-out[data-debug="true"]::before,
.motion-scale-in[data-debug="true"]::before,
.motion-scale-out[data-debug="true"]::before,
.motion-bounce-in[data-debug="true"]::before,
.motion-bounce-out[data-debug="true"]::before,
.motion-rotate-in[data-debug="true"]::before,
.motion-rotate-out[data-debug="true"]::before,
.motion-pulse[data-debug="true"]::before,
.motion-shake[data-debug="true"]::before,
.motion-spin[data-debug="true"]::before,
.motion-flash[data-debug="true"]::before {
  content: attr(class);
  position: absolute;
  top: 5px;
  left: 5px;
  background-color: #007cba;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  z-index: 1000;
  pointer-events: none;
}

/* ===== ANIMATION STATE INDICATORS ===== */

/* Loading state */
.motion-fade-in[data-state="loading"],
.motion-fade-out[data-state="loading"],
.motion-scale-in[data-state="loading"],
.motion-scale-out[data-state="loading"],
.motion-bounce-in[data-state="loading"],
.motion-bounce-out[data-state="loading"],
.motion-rotate-in[data-state="loading"],
.motion-rotate-out[data-state="loading"],
.motion-pulse[data-state="loading"],
.motion-shake[data-state="loading"],
.motion-spin[data-state="loading"],
.motion-flash[data-state="loading"] {
  position: relative;
}

.motion-fade-in[data-state="loading"]::after,
.motion-fade-out[data-state="loading"]::after,
.motion-scale-in[data-state="loading"]::after,
.motion-scale-out[data-state="loading"]::after,
.motion-bounce-in[data-state="loading"]::after,
.motion-bounce-out[data-state="loading"]::after,
.motion-rotate-in[data-state="loading"]::after,
.motion-rotate-out[data-state="loading"]::after,
.motion-pulse[data-state="loading"]::after,
.motion-shake[data-state="loading"]::after,
.motion-spin[data-state="loading"]::after,
.motion-flash[data-state="loading"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Error state */
.motion-fade-in[data-state="error"],
.motion-fade-out[data-state="error"],
.motion-scale-in[data-state="error"],
.motion-scale-out[data-state="error"],
.motion-bounce-in[data-state="error"],
.motion-bounce-out[data-state="error"],
.motion-rotate-in[data-state="error"],
.motion-rotate-out[data-state="error"],
.motion-pulse[data-state="error"],
.motion-shake[data-state="error"],
.motion-spin[data-state="error"],
.motion-flash[data-state="error"] {
  border: 2px solid #f44336;
  background-color: rgba(244, 67, 54, 0.1);
}

/* Success state */
.motion-fade-in[data-state="success"],
.motion-fade-out[data-state="success"],
.motion-scale-in[data-state="success"],
.motion-scale-out[data-state="success"],
.motion-bounce-in[data-state="success"],
.motion-bounce-out[data-state="success"],
.motion-rotate-in[data-state="success"],
.motion-rotate-out[data-state="success"],
.motion-pulse[data-state="success"],
.motion-shake[data-state="success"],
.motion-spin[data-state="success"],
.motion-flash[data-state="success"] {
  border: 2px solid #4CAF50;
  background-color: rgba(76, 175, 80, 0.1);
} 