/* =================================================================
   image2model Animation Utilities - Motion-Only Classes
   Purpose: Pure motion animations without visual styling (no color/background/border)
   Usage: Components handle their own visual appearance, utilities only control motion
   ================================================================= */

/* =================================================================
   Component Animation Classes
   For use with component animate props (Card, Button, etc.)
   ================================================================= */

.scroll-hidden {
  opacity: 0;
  transform: translateY(30px);
}

.animate-scroll-reveal {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.6s var(--ease-smooth, ease-out), transform 0.6s var(--ease-smooth, ease-out);
}

/* Component Entrance Animations */
.animate-fade-in {
  opacity: 0;
  animation: fadeIn 0.5s var(--ease-smooth, ease-out) forwards;
}

.animate-slide-up {
  opacity: 0;
  transform: translateY(30px);
  animation: slideUp 0.6s var(--ease-smooth, ease-out) forwards;
}

.animate-scale-in {
  opacity: 0;
  transform: scale(0.8);
  animation: scaleIn 0.4s var(--ease-smooth, ease-out) forwards;
}

.animate-slide-left {
  opacity: 0;
  transform: translateX(-30px);
  animation: slideLeft 0.5s var(--ease-smooth, ease-out) forwards;
}

.animate-slide-right {
  opacity: 0;
  transform: translateX(30px);
  animation: slideRight 0.5s var(--ease-smooth, ease-out) forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

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

@keyframes scaleIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

/* =================================================================
   Base Animation Classes (Motion-Only)
   ================================================================= */

/* Fade Animations */
.animate-fade-out {
    animation: fadeOut var(--duration-medium, 0.3s) var(--ease-out-cubic, ease-out) both;
}

.animate-fade-in-up {
    animation: fadeInUp var(--duration-medium, 0.3s) var(--ease-out-cubic, ease-out) both;
}

.animate-fade-in-down {
    animation: fadeInDown var(--duration-medium, 0.3s) var(--ease-out-cubic, ease-out) both;
}

.animate-fade-in-scale {
    animation: fadeInScale var(--duration-medium, 0.3s) var(--ease-smooth, ease-out) both;
}

/* Motion Namespaced Utilities */
.motion-lift {
    transition: transform var(--duration-short) var(--ease-out-cubic), 
               box-shadow var(--duration-short) var(--ease-smooth);
}

.motion-lift:hover {
    transform: translateY(-4px);
}

.motion-scale {
    transition: transform var(--duration-short) var(--ease-smooth);
}

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

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

.motion-slide-up {
    animation: slideUp var(--duration-medium) var(--ease-out-cubic) both;
}

.motion-slide-down {
    animation: slideDown var(--duration-medium) var(--ease-out-cubic) both;
}

.motion-slide-up-delay {
    animation: slideUp var(--duration-medium) var(--ease-out-cubic) both;
    animation-delay: var(--duration-short);
}

.motion-slide-right {
    animation: slideRight var(--duration-medium) var(--ease-smooth) both;
}

.motion-slide-left {
    animation: slideLeft var(--duration-medium) var(--ease-smooth) both;
}

/* Component Motion Helpers */
.motion-card-hover {
    transition: transform var(--duration-short) var(--ease-out-cubic);
}

.motion-card-hover:hover {
    transform: translateY(-6px);
}

.motion-button-glow {
    position: relative;
    overflow: hidden;
}

.motion-button-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: currentcolor;
    opacity: 0.2;
    border-radius: inherit;
    transition: opacity var(--duration-short) var(--ease-smooth);
}

.motion-button-glow:hover::before {
    opacity: 0.4;
}

/* Loading Motion States */
.motion-loading-shimmer {
    position: relative;
    overflow: hidden;
}

.motion-loading-shimmer::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / 10%), transparent);
    animation: shimmer 2s linear infinite;
}

.motion-loading-shimmer.loading {
    animation-play-state: paused;
}

/* Reveal Animations */
.motion-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: 
        opacity var(--duration-medium) var(--ease-out-cubic),
        transform var(--duration-medium) var(--ease-out-cubic);
}

.motion-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger Animations */
.motion-stagger-item {
    opacity: 0;
    transform: translateY(20px);
    transition: 
        opacity var(--duration-medium) var(--ease-out-cubic),
        transform var(--duration-medium) var(--ease-out-cubic);
}

.motion-stagger-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.motion-stagger-item:nth-child(1) { transition-delay: 0.1s; }

.motion-stagger-item:nth-child(2) { transition-delay: 0.2s; }

.motion-stagger-item:nth-child(3) { transition-delay: 0.3s; }

.motion-stagger-item:nth-child(4) { transition-delay: 0.4s; }

.motion-stagger-item:nth-child(5) { transition-delay: 0.5s; }

/* Motion Slide Animations */
.motion-slide-in-left {
    animation: slideInLeft var(--duration-medium) var(--ease-out-cubic) both;
}

.motion-slide-in-right {
    animation: slideInRight var(--duration-medium) var(--ease-out-cubic) both;
}

.motion-slide-in-up {
    animation: slideInUp var(--duration-medium) var(--ease-out-cubic) both;
}

.motion-slide-in-down {
    animation: slideInDown var(--duration-medium) var(--ease-out-cubic) both;
}

/* Motion Scale Animations */
.motion-scale-in {
    animation: scaleIn var(--duration-short) var(--ease-spring) both;
}

.motion-scale-out {
    animation: scaleOut var(--duration-short) var(--ease-smooth) both;
}

.motion-scale-pulse {
    animation: scalePulse var(--duration-xl) var(--ease-in-out-cubic) infinite;
}

/* Rotation Animations */
.animate-rotate {
    animation: rotate var(--duration-xl) linear infinite;
}

.animate-rotate-in {
    animation: rotateIn var(--duration-medium) var(--ease-spring) both;
}

.animate-swing {
    animation: swing var(--duration-long) var(--ease-bounce) both;
}

/* Special Effects */
.animate-float {
    animation: float 3s var(--ease-in-out-cubic) infinite;
}

.animate-bounce {
    animation: bounce var(--duration-xl) var(--ease-bounce) infinite;
}

.animate-shake {
    animation: shake var(--duration-long) var(--ease-smooth) both;
}

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

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

/* =================================================================
   Hover State Utilities - Motion Only
   ================================================================= */

/* Lift Effect */
.hover-lift {
    transition: transform var(--duration-short) var(--ease-out-cubic),
                box-shadow var(--duration-short) var(--ease-out-cubic);
}

.hover-lift:hover {
    transform: translateY(-4px);
}

/* Scale Effect */
.hover-scale {
    transition: transform var(--duration-short) var(--ease-spring);
    transform-origin: center center;
}

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

.hover-scale-sm {
    transition: transform var(--duration-short) var(--ease-spring);
    transform-origin: center center;
}

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

.hover-scale-lg {
    transition: transform var(--duration-short) var(--ease-spring);
    transform-origin: center center;
}

.hover-scale-lg:hover {
    transform: scale(1.1);
}

/* Glow Effect */
.hover-glow {
    transition: box-shadow var(--duration-short) var(--ease-smooth);
}

.hover-glow:hover {
    box-shadow: var(--shadow-md);
}

/* Rotate Effect */
.hover-rotate {
    transition: transform var(--duration-short) var(--ease-smooth);
}

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

.hover-rotate-3d:hover {
    transform: perspective(400px) rotateY(10deg);
}

/* Underline Effects */
.hover-underline {
    position: relative;
    overflow: hidden;
}

.hover-underline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateX(-100%);
    transition: transform var(--duration-medium) var(--ease-out-cubic);
}

.hover-underline:hover::after {
    transform: translateX(0);
}

/* =================================================================
   Loading Animation Utilities - Motion Only
   ================================================================= */

/* Spinner */
.loading-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid transparent;
    border-radius: 50%;
    animation: rotate var(--duration-xl) linear infinite;
}

/* Low-poly spinner */
.loading-low-poly {
    display: inline-block;
    width: 40px;
    height: 40px;
    position: relative;
}

.loading-low-poly::before,
.loading-low-poly::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    animation: lowPolySpinner 1.5s var(--ease-in-out-cubic) infinite;
}

.loading-low-poly::after {
    animation-delay: -0.75s;
    opacity: 0.6;
}

/* Progress Bar */
.loading-progress {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loading-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgb(255 255 255 / 10%) 20%,
        rgb(255 255 255 / 20%) 50%,
        rgb(255 255 255 / 10%) 80%,
        transparent 100%
    );
    animation: progressSweep 2s linear infinite;
}

/* Skeleton Loading */
.loading-skeleton {
    position: relative;
    overflow: hidden;
}

.loading-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgb(255 255 255 / 10%) 20%,
        rgb(255 255 255 / 20%) 50%,
        rgb(255 255 255 / 10%) 80%,
        transparent 100%
    );
    animation: shimmer 2s linear infinite;
}

/* Pulsing Dots */
.loading-dots {
    display: inline-flex;
    gap: 0.25em;
}

.loading-dots span {
    display: inline-block;
    width: 0.5em;
    height: 0.5em;
    border-radius: 50%;
    animation: pulsingDots 1.4s linear infinite both;
}

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

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

/* =================================================================
   Transition Utilities - Motion Only
   ================================================================= */

/* Page Transitions */
.transition-fade {
    opacity: 0;
    transition: opacity var(--duration-medium) var(--ease-smooth);
}

.transition-fade.active {
    opacity: 1;
}

.transition-slide-up {
    transform: translateY(20px);
    opacity: 0;
    transition: transform var(--duration-medium) var(--ease-out-cubic),
                opacity var(--duration-medium) var(--ease-smooth);
}

.transition-slide-up.active {
    transform: translateY(0);
    opacity: 1;
}

/* Content Reveals */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--duration-long) var(--ease-smooth),
                transform var(--duration-long) var(--ease-out-cubic);
}

.reveal-on-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* =================================================================
   Micro-interaction Utilities - Motion Only
   ================================================================= */

/* Button Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    animation: ripple var(--duration-medium) var(--ease-out-cubic);
    pointer-events: none;
}

/* Form Feedback */
.form-shake {
    animation: shake var(--duration-medium) var(--ease-smooth);
}

.form-success {
    position: relative;
}

.form-success::after {
    content: '✓';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    animation: scaleIn var(--duration-short) var(--ease-spring) forwards;
}

/* =================================================================
   Special Effect Utilities - Motion Only
   ================================================================= */

/* Gradient Animation */
.gradient-animate {
    background-size: 200% 200%;
    animation: gradientShift 4s var(--ease-in-out-cubic) infinite;
}

.gradient-rotate {
    animation: gradientRotate 5s linear infinite;
}

/* Text Effects */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    animation: fadeInUp var(--duration-medium) var(--ease-out-cubic) both;
    animation-delay: calc(var(--delay-stagger) * var(--i));
}

/* Shape Morphing */
.morph-triangle {
    animation: morphTriangle 3s var(--ease-in-out-cubic) infinite;
}

.morph-square {
    animation: morphSquare 4s var(--ease-in-out-cubic) infinite;
}

/* =================================================================
   Animation Delay Utilities
   ================================================================= */

.delay-100 { animation-delay: 100ms; }

.delay-200 { animation-delay: 200ms; }

.delay-300 { animation-delay: 300ms; }

.delay-400 { animation-delay: 400ms; }

.delay-500 { animation-delay: 500ms; }

.delay-600 { animation-delay: 600ms; }

.delay-700 { animation-delay: 700ms; }

.delay-800 { animation-delay: 800ms; }

/* =================================================================
   Animation Duration Modifiers
   ================================================================= */

.duration-fast { animation-duration: var(--duration-short) !important; }

.duration-normal { animation-duration: var(--duration-medium) !important; }

.duration-slow { animation-duration: var(--duration-long) !important; }

.duration-xl { animation-duration: var(--duration-xl) !important; }

/* =================================================================
   Animation Control Classes
   ================================================================= */

.animation-play-once {
    animation-iteration-count: 1 !important;
}

.animation-play-twice {
    animation-iteration-count: 2 !important;
}

.animation-play-infinite {
    animation-iteration-count: infinite !important;
}

.animation-reverse {
    animation-direction: reverse !important;
}

.animation-alternate {
    animation-direction: alternate !important;
}

/* =================================================================
   Responsive Animation Utilities
   ================================================================= */

/* Disable complex animations on small devices */
@media (width <= 768px) {
    .mobile-no-animation {
        animation: none !important;
        transition: none !important;
    }
    
    .mobile-simple-fade {
        animation: fadeIn var(--duration-short) var(--ease-smooth) both !important;
    }
}

/* =================================================================
   Animation Keyframes - Motion Only
   ================================================================= */

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

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

@keyframes swing {
    0%, 100% {
        transform: rotate(0deg);
    }

    20% {
        transform: rotate(15deg);
    }

    40% {
        transform: rotate(-10deg);
    }

    60% {
        transform: rotate(5deg);
    }

    80% {
        transform: rotate(-5deg);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateY(0);
        animation-timing-function: ease-out;
    }

    40%, 43% {
        transform: translateY(-30px);
    }

    70% {
        transform: translateY(-15px);
    }

    90% {
        transform: translateY(-4px);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }

    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgb(0 0 0 / 20%);
    }

    50% {
        box-shadow: 0 0 30px rgb(0 0 0 / 40%);
    }
}

@keyframes shadowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgb(0 0 0 / 10%);
    }

    50% {
        box-shadow: 0 0 40px rgb(0 0 0 / 30%);
    }
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

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

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

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

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

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

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

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

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

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

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

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

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

@keyframes scalePulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes lowPolySpinner {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.9);
    }
}

@keyframes progressSweep {
    from {
        transform: translateX(-100%);
    }

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

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

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

@keyframes pulsingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

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

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@keyframes gradientRotate {
    from {
        background-position: 0% 50%;
    }

    to {
        background-position: 100% 50%;
    }
}

@keyframes morphTriangle {
    0%, 100% {
        clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    }

    33% {
        clip-path: polygon(50% 10%, 10% 90%, 90% 90%);
    }

    66% {
        clip-path: polygon(50% 0%, 90% 10%, 90% 100%, 10% 100%, 10% 90%);
    }
}

@keyframes morphSquare {
    0%, 100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(45deg);
    }

    75% {
        transform: rotate(-45deg);
    }
}

/* =================================================================
   CRITICAL: Accessibility - Reduced Motion Support
   Ensures elements are ALWAYS visible when users prefer reduced motion
   or when animations might not complete properly
   ================================================================= */
@media (prefers-reduced-motion: reduce) {
  /* Make all animated elements immediately visible */
  .animate-fade-in,
  .animate-slide-up,
  .animate-scale-in,
  .animate-slide-left,
  .animate-slide-right,
  .animate-fade-in-up,
  .animate-fade-in-down,
  .animate-fade-in-left,
  .animate-fade-in-right,
  .animate-zoom-in,
  .animate-bounce-in,
  .scroll-hidden,
  [class*="animate-"] {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}

/* =================================================================
   CRITICAL: Animation Fallback Safety Net
   For browsers that don't support animations or when CSS variables fail
   ================================================================= */
@supports not (animation: fadeIn 0.5s forwards) {
  .animate-fade-in,
  .animate-slide-up,
  .animate-scale-in,
  .animate-slide-left,
  .animate-slide-right,
  .scroll-hidden {
    opacity: 1 !important;
    transform: none !important;
  }
}