/*
 * animations.css - Advanced Animation Library with Antigravity Effects
 * 위치: /assets/css/animations.css
 * Includes: Light Bloom, Spark Shower, Momentum effects
 */

/* ========== COSMIC THEME ANIMATIONS ========== */

/* Cosmic Gradient Animation */
@keyframes cosmicGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.cosmic-bg {
    background: linear-gradient(-45deg,
        var(--color-primary),
        var(--cosmic-purple),
        var(--color-primary-light),
        var(--cosmic-blue)
    );
    background-size: 400% 400%;
    animation: cosmicGradient 15s ease infinite;
}

/* ========== LIGHT BLOOM EFFECT ========== */
/* Creates an overexposed glow effect */

@keyframes lightBloom {
    0%, 100% {
        filter: brightness(1) blur(0px);
        opacity: 1;
    }
    50% {
        filter: brightness(1.3) blur(2px);
        opacity: 0.9;
    }
}

@keyframes bloomPulse {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(255, 215, 0, 0.3),
            0 0 40px rgba(255, 215, 0, 0.2),
            0 0 60px rgba(255, 215, 0, 0.1);
    }
    50% {
        box-shadow:
            0 0 30px rgba(255, 215, 0, 0.5),
            0 0 60px rgba(255, 215, 0, 0.3),
            0 0 90px rgba(255, 215, 0, 0.2);
    }
}

@keyframes textBloom {
    0%, 100% {
        text-shadow:
            0 0 10px rgba(255, 215, 0, 0.5),
            0 0 20px rgba(255, 215, 0, 0.3),
            0 0 30px rgba(255, 215, 0, 0.2);
    }
    50% {
        text-shadow:
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.5),
            0 0 60px rgba(255, 215, 0, 0.3);
    }
}

.light-bloom {
    animation: lightBloom 3s ease-in-out infinite;
}

.bloom-glow {
    animation: bloomPulse 2s ease-in-out infinite;
}

.text-bloom {
    animation: textBloom 2.5s ease-in-out infinite;
}

/* Light Bloom Button Effect */
.btn-bloom {
    position: relative;
    overflow: hidden;
}

.btn-bloom::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.3) 0%,
        transparent 70%
    );
    opacity: 0;
    transform: scale(0);
    transition: all 0.5s ease;
}

.btn-bloom:hover::before {
    opacity: 1;
    transform: scale(1);
    animation: bloomExpand 0.8s ease-out;
}

@keyframes bloomExpand {
    0% {
        transform: scale(0);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ========== SPARK SHOWER EFFECT ========== */
/* Sparkling particles that cascade down */

.spark-shower-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 5;
}

.spark {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-accent);
    border-radius: 50%;
    opacity: 0;
    animation: sparkFall linear infinite;
    box-shadow:
        0 0 6px 2px rgba(255, 215, 0, 0.6),
        0 0 12px 4px rgba(255, 215, 0, 0.3);
}

@keyframes sparkFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Spark variations */
.spark:nth-child(1) { left: 10%; animation-duration: 8s; animation-delay: 0s; width: 3px; height: 3px; }
.spark:nth-child(2) { left: 20%; animation-duration: 10s; animation-delay: 1s; width: 5px; height: 5px; }
.spark:nth-child(3) { left: 30%; animation-duration: 7s; animation-delay: 2s; width: 4px; height: 4px; }
.spark:nth-child(4) { left: 40%; animation-duration: 9s; animation-delay: 0.5s; width: 3px; height: 3px; }
.spark:nth-child(5) { left: 50%; animation-duration: 11s; animation-delay: 1.5s; width: 6px; height: 6px; }
.spark:nth-child(6) { left: 60%; animation-duration: 8s; animation-delay: 2.5s; width: 4px; height: 4px; }
.spark:nth-child(7) { left: 70%; animation-duration: 10s; animation-delay: 0.8s; width: 5px; height: 5px; }
.spark:nth-child(8) { left: 80%; animation-duration: 7s; animation-delay: 1.8s; width: 3px; height: 3px; }
.spark:nth-child(9) { left: 90%; animation-duration: 9s; animation-delay: 0.3s; width: 4px; height: 4px; }
.spark:nth-child(10) { left: 15%; animation-duration: 12s; animation-delay: 2s; width: 5px; height: 5px; }
.spark:nth-child(11) { left: 25%; animation-duration: 8s; animation-delay: 3s; width: 3px; height: 3px; }
.spark:nth-child(12) { left: 35%; animation-duration: 10s; animation-delay: 1.2s; width: 4px; height: 4px; }
.spark:nth-child(13) { left: 45%; animation-duration: 9s; animation-delay: 2.2s; width: 6px; height: 6px; }
.spark:nth-child(14) { left: 55%; animation-duration: 11s; animation-delay: 0.7s; width: 3px; height: 3px; }
.spark:nth-child(15) { left: 65%; animation-duration: 7s; animation-delay: 1.7s; width: 5px; height: 5px; }
.spark:nth-child(16) { left: 75%; animation-duration: 8s; animation-delay: 2.7s; width: 4px; height: 4px; }
.spark:nth-child(17) { left: 85%; animation-duration: 10s; animation-delay: 0.4s; width: 3px; height: 3px; }
.spark:nth-child(18) { left: 95%; animation-duration: 9s; animation-delay: 1.4s; width: 5px; height: 5px; }
.spark:nth-child(19) { left: 5%; animation-duration: 12s; animation-delay: 2.4s; width: 4px; height: 4px; }
.spark:nth-child(20) { left: 48%; animation-duration: 8s; animation-delay: 0.9s; width: 6px; height: 6px; }

/* ========== MOMENTUM EFFECT ========== */
/* Moving force transfer animation */

@keyframes momentum {
    0% {
        transform: translateX(-20px) scale(0.95);
        opacity: 0;
    }
    20% {
        transform: translateX(10px) scale(1.02);
        opacity: 1;
    }
    40% {
        transform: translateX(-5px) scale(0.99);
    }
    60% {
        transform: translateX(3px) scale(1.01);
    }
    80% {
        transform: translateX(-1px) scale(1);
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes momentumBounce {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-15px);
    }
    50% {
        transform: translateY(0);
    }
    75% {
        transform: translateY(-8px);
    }
}

@keyframes momentumWave {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    25% {
        transform: translateX(10px) rotate(2deg);
    }
    75% {
        transform: translateX(-10px) rotate(-2deg);
    }
}

.animate-momentum {
    animation: momentum 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}

.momentum-bounce {
    animation: momentumBounce 2s ease-in-out infinite;
}

.momentum-wave {
    animation: momentumWave 3s ease-in-out infinite;
}

/* Momentum on hover */
.momentum-hover {
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.momentum-hover:hover {
    transform: translateY(-8px) scale(1.02);
}

/* Sequential momentum for list items */
.momentum-stagger > * {
    opacity: 0;
    animation: momentum 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}

.momentum-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.momentum-stagger > *:nth-child(2) { animation-delay: 0.2s; }
.momentum-stagger > *:nth-child(3) { animation-delay: 0.3s; }
.momentum-stagger > *:nth-child(4) { animation-delay: 0.4s; }
.momentum-stagger > *:nth-child(5) { animation-delay: 0.5s; }
.momentum-stagger > *:nth-child(6) { animation-delay: 0.6s; }
.momentum-stagger > *:nth-child(7) { animation-delay: 0.7s; }
.momentum-stagger > *:nth-child(8) { animation-delay: 0.8s; }

/* ========== FLOATING SHAPES ========== */
.floating-shapes {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.shape {
    position: absolute;
    opacity: 0.1;
}

.shape-circle {
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent), var(--cosmic-purple));
}

.shape-square {
    background: linear-gradient(45deg, var(--color-primary), var(--cosmic-blue));
    transform: rotate(45deg);
}

@keyframes floatShape {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(50px, -50px) rotate(90deg);
    }
    50% {
        transform: translate(100px, 0) rotate(180deg);
    }
    75% {
        transform: translate(50px, 50px) rotate(270deg);
    }
}

.shape-1 { width: 100px; height: 100px; top: 10%; left: 5%; animation: floatShape 20s linear infinite; }
.shape-2 { width: 60px; height: 60px; top: 30%; right: 10%; animation: floatShape 15s linear infinite reverse; }
.shape-3 { width: 80px; height: 80px; bottom: 20%; left: 15%; animation: floatShape 25s linear infinite; }
.shape-4 { width: 40px; height: 40px; top: 60%; right: 20%; animation: floatShape 18s linear infinite reverse; }
.shape-5 { width: 120px; height: 120px; bottom: 10%; right: 5%; animation: floatShape 22s linear infinite; }

/* ========== PARTICLE EFFECTS ========== */
.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100vh) scale(1);
        opacity: 0;
    }
}

/* ========== RIPPLE EFFECT ========== */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255, 215, 0, 0.3) 10%, transparent 10.01%);
    background-repeat: no-repeat;
    background-position: 50%;
    transform: scale(10, 10);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
    transform: scale(0, 0);
    opacity: 0.3;
    transition: 0s;
}

/* ========== TYPEWRITER EFFECT ========== */
.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--color-accent);
    white-space: nowrap;
    animation:
        typing 3.5s steps(40, end),
        blink-caret 0.75s step-end infinite;
}

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

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--color-accent); }
}

/* ========== GLITCH EFFECT ========== */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 #ff00c1;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 #00fff9;
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-anim2 5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(31px, 9999px, 94px, 0); }
    5% { clip: rect(70px, 9999px, 71px, 0); }
    10% { clip: rect(29px, 9999px, 24px, 0); }
    15% { clip: rect(60px, 9999px, 97px, 0); }
    20% { clip: rect(18px, 9999px, 10px, 0); }
    25% { clip: rect(85px, 9999px, 55px, 0); }
    30% { clip: rect(96px, 9999px, 41px, 0); }
    35% { clip: rect(38px, 9999px, 77px, 0); }
    40% { clip: rect(79px, 9999px, 16px, 0); }
    45% { clip: rect(48px, 9999px, 67px, 0); }
    50% { clip: rect(23px, 9999px, 7px, 0); }
    55% { clip: rect(91px, 9999px, 35px, 0); }
    60% { clip: rect(14px, 9999px, 88px, 0); }
    65% { clip: rect(52px, 9999px, 49px, 0); }
    70% { clip: rect(66px, 9999px, 28px, 0); }
    75% { clip: rect(3px, 9999px, 83px, 0); }
    80% { clip: rect(45px, 9999px, 62px, 0); }
    85% { clip: rect(72px, 9999px, 19px, 0); }
    90% { clip: rect(8px, 9999px, 100px, 0); }
    95% { clip: rect(57px, 9999px, 39px, 0); }
    100% { clip: rect(33px, 9999px, 76px, 0); }
}

@keyframes glitch-anim2 {
    0% { clip: rect(65px, 9999px, 100px, 0); }
    5% { clip: rect(28px, 9999px, 15px, 0); }
    10% { clip: rect(82px, 9999px, 48px, 0); }
    15% { clip: rect(11px, 9999px, 73px, 0); }
    20% { clip: rect(94px, 9999px, 36px, 0); }
    25% { clip: rect(47px, 9999px, 89px, 0); }
    30% { clip: rect(6px, 9999px, 54px, 0); }
    35% { clip: rect(75px, 9999px, 21px, 0); }
    40% { clip: rect(39px, 9999px, 96px, 0); }
    45% { clip: rect(17px, 9999px, 63px, 0); }
    50% { clip: rect(88px, 9999px, 8px, 0); }
    55% { clip: rect(51px, 9999px, 79px, 0); }
    60% { clip: rect(24px, 9999px, 42px, 0); }
    65% { clip: rect(69px, 9999px, 13px, 0); }
    70% { clip: rect(2px, 9999px, 91px, 0); }
    75% { clip: rect(56px, 9999px, 32px, 0); }
    80% { clip: rect(83px, 9999px, 67px, 0); }
    85% { clip: rect(19px, 9999px, 44px, 0); }
    90% { clip: rect(70px, 9999px, 5px, 0); }
    95% { clip: rect(37px, 9999px, 98px, 0); }
    100% { clip: rect(60px, 9999px, 26px, 0); }
}

/* ========== SHIMMER LOADING ========== */
.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.5) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

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

/* ========== TILT EFFECT ========== */
.tilt-effect {
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

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

/* ========== MORPH ANIMATION ========== */
@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

.morph {
    animation: morph 8s ease-in-out infinite;
}

/* ========== SCALE REVEAL ========== */
@keyframes scaleReveal {
    0% {
        transform: scaleX(0);
        transform-origin: left;
    }
    50% {
        transform: scaleX(1);
        transform-origin: left;
    }
    50.1% {
        transform-origin: right;
    }
    100% {
        transform: scaleX(0);
        transform-origin: right;
    }
}

.scale-reveal {
    position: relative;
    overflow: hidden;
}

.scale-reveal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-primary);
    animation: scaleReveal 1.5s ease-in-out forwards;
}

/* ========== GRADIENT BORDER ANIMATION ========== */
.gradient-border {
    position: relative;
    background: var(--color-white);
    border-radius: var(--radius-lg);
}

.gradient-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg,
        var(--color-primary),
        var(--color-accent),
        var(--cosmic-purple),
        var(--cosmic-blue),
        var(--color-primary)
    );
    background-size: 400% 400%;
    border-radius: calc(var(--radius-lg) + 2px);
    z-index: -1;
    animation: gradientBorder 3s ease infinite;
}

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

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .spark-shower-container,
    .floating-shapes,
    .particle-container {
        display: none !important;
    }
}
