/* ============================================
   UNIVERSAL ANIMATION LIBRARY
   ============================================ */

/* Base animation setup */
:root {
    --animation-duration: 0.8s;
    --animation-delay: 0.1s;
    --animation-timing: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   SECTION ANIMATIONS
   ============================================ */

/* Fade In Animations */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-down {
    opacity: 0;
    transform: translateY(-30px);
    animation: fadeInDown var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-left {
    opacity: 0;
    transform: translateX(30px);
    animation: fadeInLeft var(--animation-duration) var(--animation-timing) forwards;
}

.animate-fade-in-right {
    opacity: 0;
    transform: translateX(-30px);
    animation: fadeInRight var(--animation-duration) var(--animation-timing) forwards;
}

/* Zoom Animations */
.animate-zoom-in {
    opacity: 0;
    transform: scale(0.8);
    animation: zoomIn var(--animation-duration) var(--animation-timing) forwards;
}

.animate-zoom-in-up {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
    animation: zoomInUp var(--animation-duration) var(--animation-timing) forwards;
}

/* Slide Animations */
.animate-slide-in-left {
    transform: translateX(-100%);
    animation: slideInLeft var(--animation-duration) var(--animation-timing) forwards;
}

.animate-slide-in-right {
    transform: translateX(100%);
    animation: slideInRight var(--animation-duration) var(--animation-timing) forwards;
}

.animate-slide-in-top {
    transform: translateY(-100%);
    animation: slideInTop var(--animation-duration) var(--animation-timing) forwards;
}

.animate-slide-in-bottom {
    transform: translateY(100%);
    animation: slideInBottom var(--animation-duration) var(--animation-timing) forwards;
}

/* Rotate Animations */
.animate-rotate-in {
    opacity: 0;
    transform: rotate(-180deg);
    animation: rotateIn var(--animation-duration) var(--animation-timing) forwards;
}

.animate-flip-in-x {
    opacity: 0;
    transform: rotateX(90deg);
    animation: flipInX var(--animation-duration) var(--animation-timing) forwards;
}

.animate-flip-in-y {
    opacity: 0;
    transform: rotateY(90deg);
    animation: flipInY var(--animation-duration) var(--animation-timing) forwards;
}

/* ============================================
   TEXT ANIMATIONS
   ============================================ */

/* Typewriter Effect */
.animate-typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid;
    animation: 
        typewriter 3s steps(40) forwards,
        blink 0.75s step-end infinite;
}

/* Letter by Letter Animation (container) */
.animate-letters {
    
}

/* Letter by Letter Animation (spans) */
.animate-letters span {
    display: inline; /* no inline-block layout shift */
    opacity: 0;
    animation: letterFadeIn 0.5s var(--animation-timing) forwards;
}

/* Word by Word Animation */
.animate-words span {
    display: inline; /* keep natural text flow */
    opacity: 0;
    transform: translateY(20px);
    animation: wordFadeInUp 0.6s var(--animation-timing) forwards;
}

/* Gate letter/word animations so they run only after scroll trigger */
.scroll-trigger.animate-letters span,
.scroll-trigger.animate-words span {
    animation-play-state: paused;
}

.scroll-trigger.triggered.animate-letters span,
.scroll-trigger.triggered.animate-words span {
    animation-play-state: running;
}

/* Glow Text Animation */
.animate-text-glow {
    animation: textGlow 2s ease-in-out infinite;
}

/* Gradient Text Animation */
.animate-text-gradient {
    background: linear-gradient(180deg, #ebcf8e 0%, #b97244 100%);
    background-size: 800% 800%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 8s ease infinite;
}

/* Bounce Text Animation */
.animate-text-bounce {
    display: inline-block;
    animation: bounce 2s ease infinite;
}

/* Text Shadow Pulse */
.animate-text-shadow-pulse {
    animation: shadowPulse 2s ease-in-out infinite;
}

/* Text Scale Pulse */
.animate-text-pulse {
    animation: textPulse 1.5s ease-in-out infinite;
}

/* Text Blur In */
.animate-text-blur-in {
    animation: blurIn 1s var(--animation-timing) forwards;
}

/* ============================================
   SCROLL-TRIGGERED ANIMATIONS (with .scroll-trigger)
   ============================================ */

.scroll-trigger {
    opacity: 0;
    transition: opacity var(--animation-duration) var(--animation-timing);
}

.scroll-trigger.triggered {
    opacity: 1;
}

/* Stagger animations for child elements */
.stagger-animation > * {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-animation.triggered > * {
    animation: fadeInUp var(--animation-duration) var(--animation-timing) forwards;
}

/* Apply stagger delay to children */
.stagger-animation.triggered > *:nth-child(1) { animation-delay: calc(var(--animation-delay) * 1); }
.stagger-animation.triggered > *:nth-child(2) { animation-delay: calc(var(--animation-delay) * 2); }
.stagger-animation.triggered > *:nth-child(3) { animation-delay: calc(var(--animation-delay) * 3); }
.stagger-animation.triggered > *:nth-child(4) { animation-delay: calc(var(--animation-delay) * 4); }
.stagger-animation.triggered > *:nth-child(5) { animation-delay: calc(var(--animation-delay) * 5); }
.stagger-animation.triggered > *:nth-child(6) { animation-delay: calc(var(--animation-delay) * 6); }
.stagger-animation.triggered > *:nth-child(7) { animation-delay: calc(var(--animation-delay) * 7); }
.stagger-animation.triggered > *:nth-child(8) { animation-delay: calc(var(--animation-delay) * 8); }

/* ============================================
   KEYFRAMES DEFINITIONS
   ============================================ */

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes zoomIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomInUp {
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes slideInLeft {
    to {
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    to {
        transform: translateX(0);
    }
}

@keyframes slideInTop {
    to {
        transform: translateY(0);
    }
}

@keyframes slideInBottom {
    to {
        transform: translateY(0);
    }
}

@keyframes rotateIn {
    to {
        opacity: 1;
        transform: rotate(0);
    }
}

@keyframes flipInX {
    to {
        opacity: 1;
        transform: rotateX(0);
    }
}

@keyframes flipInY {
    to {
        opacity: 1;
        transform: rotateY(0);
    }
}

@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: currentColor;
    }
}

@keyframes letterFadeIn {
    to {
        opacity: 1;
    }
}

@keyframes wordFadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes textGlow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.8),
                     0 0 10px rgba(255, 255, 255, 0.6),
                     0 0 15px rgba(255, 255, 255, 0.4);
    }
    50% {
        text-shadow: 0 0 10px rgba(255, 255, 255, 1),
                     0 0 20px rgba(255, 255, 255, 0.8),
                     0 0 30px rgba(255, 255, 255, 0.6);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

@keyframes shadowPulse {
    0%, 100% {
        text-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
    }
    50% {
        text-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
    }
}

@keyframes textPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes blurIn {
    from {
        filter: blur(10px);
        opacity: 0;
    }
    to {
        filter: blur(0);
        opacity: 1;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Animation Delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }

/* Animation Durations */
.duration-fast { animation-duration: 0.3s; }
.duration-normal { animation-duration: 0.8s; }
.duration-slow { animation-duration: 1.5s; }
.duration-slower { animation-duration: 2s; }

/* Animation Repeat */
.animate-once { animation-iteration-count: 1; }
.animate-twice { animation-iteration-count: 2; }
.animate-infinite { animation-iteration-count: infinite; }

/* Hover Animations */
.hover-grow:hover {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.hover-shrink:hover {
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
    transition: transform 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

/* Parallax Effect Class */
.parallax-element {
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}
