/**
 * Kiki Academy Animation Library
 * Keyframe animations and scroll-triggered effects
 */

/* ═══════════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

/* Fade In */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp var(--duration-slow) var(--ease-out);
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-down {
    animation: fadeInDown var(--duration-slow) var(--ease-out);
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in-left {
    animation: fadeInLeft var(--duration-slow) var(--ease-out);
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-fade-in-right {
    animation: fadeInRight var(--duration-slow) var(--ease-out);
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn var(--duration-normal) var(--ease-bounce);
}

/* ═══════════════════════════════════════════════════════════════
   CONTINUOUS ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

/* Pulse */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(-5%);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.animate-bounce {
    animation: bounce 1s infinite;
}

/* Spin */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Ping */
@keyframes ping {
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* Float */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Shimmer */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-shimmer {
    background: linear-gradient(
        90deg,
        var(--kiki-silk) 0%,
        var(--kiki-white) 50%,
        var(--kiki-silk) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Glow */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px var(--kiki-rose-light);
    }
    50% {
        box-shadow: 0 0 40px var(--kiki-rose);
    }
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   ATTENTION SEEKERS
   ═══════════════════════════════════════════════════════════════ */

/* Shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

/* Wiggle */
@keyframes wiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

.animate-wiggle {
    animation: wiggle 0.3s ease-in-out infinite;
}

/* Heart beat */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

/* Sparkle */
@keyframes sparkle {
    0%, 100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
    25% {
        opacity: 0.8;
        transform: scale(0.9) rotate(90deg);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.8) rotate(180deg);
    }
    75% {
        opacity: 0.8;
        transform: scale(0.9) rotate(270deg);
    }
}

.animate-sparkle {
    animation: sparkle 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLL-TRIGGERED ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

/* Elements with this class will be animated when in viewport */
[data-animate] {
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-out),
                transform var(--duration-slow) var(--ease-out);
}

[data-animate="fade-up"] {
    transform: translateY(32px);
}

[data-animate="fade-down"] {
    transform: translateY(-32px);
}

[data-animate="fade-left"] {
    transform: translateX(-32px);
}

[data-animate="fade-right"] {
    transform: translateX(32px);
}

[data-animate="scale"] {
    transform: scale(0.9);
}

[data-animate="zoom"] {
    transform: scale(0.5);
}

/* Animated state */
[data-animate].animated {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
}

/* Staggered delays */
[data-animate-delay="100"] { transition-delay: 100ms; }
[data-animate-delay="200"] { transition-delay: 200ms; }
[data-animate-delay="300"] { transition-delay: 300ms; }
[data-animate-delay="400"] { transition-delay: 400ms; }
[data-animate-delay="500"] { transition-delay: 500ms; }
[data-animate-delay="600"] { transition-delay: 600ms; }
[data-animate-delay="700"] { transition-delay: 700ms; }
[data-animate-delay="800"] { transition-delay: 800ms; }

/* ═══════════════════════════════════════════════════════════════
   LOADING STATES
   ═══════════════════════════════════════════════════════════════ */

/* Skeleton loader */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--kiki-silk);
    border-radius: var(--radius-md);
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
    );
    animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--kiki-silk);
    border-top-color: var(--kiki-rose);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

.spinner--sm { width: 16px; height: 16px; border-width: 2px; }
.spinner--lg { width: 40px; height: 40px; border-width: 4px; }

/* Loading dots */
.loading-dots {
    display: inline-flex;
    gap: var(--space-1);
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--kiki-rose);
    border-radius: var(--radius-full);
    animation: loadingDot 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════
   PAGE TRANSITIONS
   ═══════════════════════════════════════════════════════════════ */

/* Page enter */
.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity var(--duration-slow) var(--ease-out),
                transform var(--duration-slow) var(--ease-out);
}

/* Page exit */
.page-exit {
    opacity: 1;
}

.page-exit-active {
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-in);
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════ */

@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;
    }
    
    [data-animate] {
        opacity: 1;
        transform: none;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SPECIAL EFFECTS
   ═══════════════════════════════════════════════════════════════ */

/* Gradient text animation */
.animate-gradient-text {
    background: linear-gradient(
        90deg,
        var(--kiki-rose) 0%,
        var(--kiki-gold) 25%,
        var(--kiki-rose) 50%,
        var(--kiki-gold) 75%,
        var(--kiki-rose) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientText 3s linear infinite;
}

@keyframes gradientText {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

/* Border animation */
.animate-border {
    position: relative;
}

.animate-border::before {
    content: "";
    position: absolute;
    inset: -2px;
    background: linear-gradient(
        90deg,
        var(--kiki-rose),
        var(--kiki-gold),
        var(--kiki-rose)
    );
    background-size: 200% 100%;
    border-radius: inherit;
    z-index: -1;
    animation: animateBorder 3s linear infinite;
}

@keyframes animateBorder {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

/* Ripple effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease-out, height 0.6s ease-out;
}

.ripple:active::after {
    width: 300%;
    height: 300%;
}

/* Counter animation */
.counter {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}
