/* 
 * LaunchPage AI - Global Animations
 * 
 * Scroll-triggered animations, typing animations, and accessibility rules
 */

/* ============================================
   SCROLL-TRIGGERED ANIMATIONS
   ============================================ */

/* Typing Animation - Character by character reveal */
@keyframes blink {
    50% {
        opacity: 0;
    }
}

.typing-animation {
    position: relative;
    display: inline-block;
}

/* Typing cursor */
.typing-animation::after {
    content: '|';
    color: #00ffa2;
    animation: blink 0.7s step-end infinite;
    margin-left: 2px;
}

.typing-animation.typing-complete::after {
    display: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .typing-animation::after {
        font-size: 0.875rem; /* Match mobile text size */
    }
}

/* Base state for all scroll animations */
.scroll-fade-in,
.scroll-fade-up,
.scroll-fade-down,
.scroll-fade-left,
.scroll-fade-right,
.scroll-scale-in,
.scroll-slide-left,
.scroll-slide-right,
.scroll-bounce-in {
    opacity: 0;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    /* Optimize: Only animate transform and opacity */
}

/* Fade In */
.scroll-fade-in {
    opacity: 0;
}
.scroll-fade-in.animate-in {
    opacity: 1;
}

/* Fade Up */
.scroll-fade-up {
    opacity: 0;
    transform: translateY(40px);
    will-change: transform, opacity; /* Performance hint */
}
.scroll-fade-up.animate-in {
    opacity: 1;
    transform: translateY(0);
    will-change: auto; /* Remove hint after animation */
}

/* Fade Down */
.scroll-fade-down {
    opacity: 0;
    transform: translateY(-40px);
}
.scroll-fade-down.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Fade Left */
.scroll-fade-left {
    opacity: 0;
    transform: translateX(-40px);
}
.scroll-fade-left.animate-in {
    opacity: 1;
    transform: translateX(0);
}

/* Fade Right */
.scroll-fade-right {
    opacity: 0;
    transform: translateX(40px);
}
.scroll-fade-right.animate-in {
    opacity: 1;
    transform: translateX(0);
}

/* Scale In */
.scroll-scale-in {
    opacity: 0;
    transform: scale(0.9);
}
.scroll-scale-in.animate-in {
    opacity: 1;
    transform: scale(1);
}

/* Slide Left */
.scroll-slide-left {
    opacity: 0;
    transform: translateX(-80px);
}
.scroll-slide-left.animate-in {
    opacity: 1;
    transform: translateX(0);
}

/* Slide Right */
.scroll-slide-right {
    opacity: 0;
    transform: translateX(80px);
}
.scroll-slide-right.animate-in {
    opacity: 1;
    transform: translateX(0);
}

/* Bounce In */
.scroll-bounce-in {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.scroll-bounce-in.animate-in {
    opacity: 1;
    transform: scale(1);
}

/* Staggered children animations */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease-out;
}

.stagger-children.animate-in > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.animate-in > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.animate-in > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.animate-in > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.animate-in > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.animate-in > *:nth-child(6) { transition-delay: 0.6s; }

.stagger-children.animate-in > * {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================ */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .scroll-fade-in,
    .scroll-fade-up,
    .scroll-fade-down,
    .scroll-fade-left,
    .scroll-fade-right,
    .scroll-scale-in,
    .scroll-slide-left,
    .scroll-slide-right,
    .scroll-bounce-in,
    .stagger-children > *,
    .animate-underline-slide {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

@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;
    }
}
