/* ========================================
   Animations - High Quality Motion Design
   ======================================== */

/* ===== Keyframes Library ===== */

/* Slide Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeInBlur {
    from {
        opacity: 0;
        filter: blur(10px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* Bounce & Float */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-12px);
    }
    60% {
        transform: translateY(-6px);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes floatRotate {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-5px) rotate(1deg);
    }
    50% {
        transform: translateY(-10px) rotate(0deg);
    }
    75% {
        transform: translateY(-5px) rotate(-1deg);
    }
}

/* Pulse & Glow */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(61, 90, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 15px rgba(61, 90, 69, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Spin & Rotate */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

/* Scale Effects */
@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    70% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
    }
}

/* Draw Effects */
@keyframes drawLine {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes reveal {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

/* Attention Seekers */
@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.1);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(1);
    }
}

@keyframes ring {
    0% {
        transform: rotate(0);
    }
    5% {
        transform: rotate(15deg);
    }
    10% {
        transform: rotate(-14deg);
    }
    15% {
        transform: rotate(13deg);
    }
    20% {
        transform: rotate(-12deg);
    }
    25% {
        transform: rotate(10deg);
    }
    30% {
        transform: rotate(-8deg);
    }
    35% {
        transform: rotate(5deg);
    }
    40% {
        transform: rotate(-3deg);
    }
    45% {
        transform: rotate(1deg);
    }
    50%, 100% {
        transform: rotate(0);
    }
}

/* Background Effects */
@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

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

/* Duration Classes */
.animate-fast { animation-duration: 0.2s; }
.animate-normal { animation-duration: 0.4s; }
.animate-slow { animation-duration: 0.6s; }
.animate-slower { animation-duration: 1s; }

/* Delay Classes */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }

/* Fill Mode */
.animate-fill-both { animation-fill-mode: both; }
.animate-fill-forwards { animation-fill-mode: forwards; }

/* Iteration */
.animate-infinite { animation-iteration-count: infinite; }
.animate-once { animation-iteration-count: 1; }

/* Play State */
.animate-paused { animation-play-state: paused; }
.animate-running { animation-play-state: running; }

/* ===== Scroll-Triggered Animations ===== */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered children */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.is-visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.is-visible > *:nth-child(2) { transition-delay: 0.15s; }
.stagger-children.is-visible > *:nth-child(3) { transition-delay: 0.2s; }
.stagger-children.is-visible > *:nth-child(4) { transition-delay: 0.25s; }
.stagger-children.is-visible > *:nth-child(5) { transition-delay: 0.3s; }
.stagger-children.is-visible > *:nth-child(6) { transition-delay: 0.35s; }

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

/* ===== Hover Micro-Interactions ===== */

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

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

/* Scale Effect */
.hover-scale {
    transition: transform var(--transition-base) var(--ease-out);
}

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

/* Glow Effect */
.hover-glow {
    transition: box-shadow var(--transition-base);
}

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

/* Tilt Effect (3D) */
.hover-tilt {
    transition: transform var(--transition-base) var(--ease-out);
    transform-style: preserve-3d;
}

.hover-tilt:hover {
    transform: perspective(1000px) rotateX(2deg) rotateY(-2deg);
}

/* Shine Effect */
.hover-shine {
    position: relative;
    overflow: hidden;
}

.hover-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: left 0.6s ease;
}

.hover-shine:hover::after {
    left: 100%;
}

/* ===== Loading States ===== */

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 0%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-gray-200);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* Dots Loading */
.dots-loading {
    display: flex;
    gap: var(--space-2);
}

.dots-loading span {
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: pulse 1.4s infinite both;
}

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

/* ===== Page Transition Effects ===== */
.page-enter {
    animation: fadeInScale 0.4s var(--ease-out) both;
}

.page-exit {
    animation: fadeInScale 0.3s var(--ease-in) reverse both;
}

/* ===== Modal Animations ===== */
.modal-enter {
    animation: modalSlideIn 0.3s var(--ease-out) both;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-exit {
    animation: modalSlideOut 0.2s var(--ease-in) both;
}

@keyframes modalSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

/* ===== Success/Check Animation ===== */
.success-check {
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ===== Counter Animation ===== */
.animate-counter {
    display: inline-block;
}

/* ===== Typewriter Effect ===== */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--color-primary);
    white-space: nowrap;
    animation: 
        typing 3.5s steps(40, end),
        blinkCursor 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blinkCursor {
    from, to { border-color: transparent; }
    50% { border-color: var(--color-primary); }
}

/* ===== Parallax Preparation ===== */
.parallax-container {
    overflow: hidden;
    will-change: transform;
}

.parallax-element {
    will-change: transform;
}

/* ===== Performance Optimizations ===== */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
}
