/**
 * animations.css - 애니메이션 스타일시트
 * 왕초보 영어배우기 (wang.soritune.com)
 *
 * Antigravity Effects Selection:
 * 1. 렌즈 플레어 (Lens Flare) - 카메라 렌즈 빛 효과
 * 2. 공중 부양 (Levitation) - 부유하는 요소들
 * 3. 컬러 시프트 (Color Shift) - 색상 변화 효과
 */

/* ==========================================================================
   Base Animation Keyframes
   ========================================================================== */

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

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In Right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Bounce */
@keyframes bounce {
    0%, 20%, 53%, 100% {
        animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
        transform: translateY(0);
    }
    40%, 43% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translateY(-20px);
    }
    70% {
        animation-timing-function: cubic-bezier(0.755, 0.05, 0.855, 0.06);
        transform: translateY(-10px);
    }
    90% {
        transform: translateY(-4px);
    }
}

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

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

/* Float (Levitation Effect) */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* Float with Rotation */
@keyframes floatRotate {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-8px) rotate(2deg);
    }
    50% {
        transform: translateY(-15px) rotate(0deg);
    }
    75% {
        transform: translateY(-8px) rotate(-2deg);
    }
}

/* Gentle Float */
@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0) translateX(0);
    }
    25% {
        transform: translateY(-5px) translateX(3px);
    }
    50% {
        transform: translateY(-10px) translateX(0);
    }
    75% {
        transform: translateY(-5px) translateX(-3px);
    }
}

/* ==========================================================================
   Antigravity Effect 1: Lens Flare
   ========================================================================== */
@keyframes lensFlare {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1) rotate(0deg);
    }
    25% {
        opacity: 0.6;
        transform: scale(1.1) rotate(90deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.2) rotate(180deg);
    }
    75% {
        opacity: 0.6;
        transform: scale(1.1) rotate(270deg);
    }
}

@keyframes lensFlareGlow {
    0%, 100% {
        box-shadow:
            0 0 20px rgba(229, 25, 55, 0.3),
            0 0 40px rgba(102, 126, 234, 0.2),
            0 0 60px rgba(240, 147, 251, 0.1);
    }
    50% {
        box-shadow:
            0 0 30px rgba(229, 25, 55, 0.5),
            0 0 60px rgba(102, 126, 234, 0.3),
            0 0 90px rgba(240, 147, 251, 0.2);
    }
}

@keyframes lensFlareRays {
    0% {
        transform: rotate(0deg);
        opacity: 0.5;
    }
    100% {
        transform: rotate(360deg);
        opacity: 0.5;
    }
}

.lens-flare {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(229, 25, 55, 0.4) 20%,
        rgba(102, 126, 234, 0.2) 40%,
        rgba(240, 147, 251, 0.1) 60%,
        transparent 80%
    );
    animation: lensFlare 8s ease-in-out infinite, lensFlareGlow 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

.lens-flare::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    transform: translate(-50%, -50%);
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(229, 25, 55, 0.1) 10deg,
        transparent 20deg,
        rgba(102, 126, 234, 0.1) 30deg,
        transparent 40deg,
        rgba(240, 147, 251, 0.1) 50deg,
        transparent 60deg
    );
    animation: lensFlareRays 20s linear infinite;
}

.lens-flare-small {
    width: 80px;
    height: 80px;
}

.lens-flare-large {
    width: 400px;
    height: 400px;
}

/* ==========================================================================
   Antigravity Effect 2: Levitation
   ========================================================================== */
@keyframes levitate {
    0%, 100% {
        transform: translateY(0) scale(1);
        filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
    }
    50% {
        transform: translateY(-20px) scale(1.02);
        filter: drop-shadow(0 30px 40px rgba(0, 0, 0, 0.15));
    }
}

@keyframes levitateGlow {
    0%, 100% {
        box-shadow:
            0 5px 15px rgba(229, 25, 55, 0.2),
            0 10px 30px rgba(102, 126, 234, 0.15);
    }
    50% {
        box-shadow:
            0 15px 30px rgba(229, 25, 55, 0.3),
            0 25px 50px rgba(102, 126, 234, 0.2);
    }
}

@keyframes levitateParticle {
    0%, 100% {
        transform: translateY(0) scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: translateY(-30px) scale(1);
        opacity: 1;
    }
}

.levitate {
    animation: levitate 4s ease-in-out infinite;
}

.levitate-slow {
    animation: levitate 6s ease-in-out infinite;
}

.levitate-fast {
    animation: levitate 2.5s ease-in-out infinite;
}

.levitate-glow {
    animation: levitate 4s ease-in-out infinite, levitateGlow 4s ease-in-out infinite;
}

.levitate-delay-1 { animation-delay: 0.5s; }
.levitate-delay-2 { animation-delay: 1s; }
.levitate-delay-3 { animation-delay: 1.5s; }
.levitate-delay-4 { animation-delay: 2s; }

/* Levitation Particles */
.levitation-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.levitation-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gradient-primary);
    animation: levitateParticle 3s ease-in-out infinite;
}

/* ==========================================================================
   Antigravity Effect 3: Color Shift
   ========================================================================== */
@keyframes colorShift {
    0%, 100% {
        filter: hue-rotate(0deg);
    }
    25% {
        filter: hue-rotate(30deg);
    }
    50% {
        filter: hue-rotate(60deg);
    }
    75% {
        filter: hue-rotate(30deg);
    }
}

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

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

@keyframes rainbowShift {
    0% { color: #E51937; }
    14% { color: #ff6b6b; }
    28% { color: #feca57; }
    42% { color: #1dd1a1; }
    57% { color: #54a0ff; }
    71% { color: #667eea; }
    85% { color: #f093fb; }
    100% { color: #E51937; }
}

.color-shift {
    animation: colorShift 10s ease-in-out infinite;
}

.color-shift-fast {
    animation: colorShift 5s ease-in-out infinite;
}

.color-shift-slow {
    animation: colorShift 20s ease-in-out infinite;
}

.gradient-shift {
    background: linear-gradient(
        270deg,
        var(--primary),
        var(--cosmic-purple),
        var(--cosmic-pink),
        var(--cosmic-blue),
        var(--primary)
    );
    background-size: 400% 400%;
    animation: gradientFlow 8s ease infinite;
}

.rainbow-text {
    animation: rainbowShift 5s linear infinite;
}

/* Color Shift Background */
.color-shift-bg {
    background: linear-gradient(
        -45deg,
        #E51937,
        #667eea,
        #f093fb,
        #4facfe
    );
    background-size: 400% 400%;
    animation: colorShiftBackground 15s ease infinite;
}

/* ==========================================================================
   Hero Section Animations
   ========================================================================== */
.hero-animate-title {
    animation: fadeInUp 1s ease forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

.hero-animate-subtitle {
    animation: fadeInUp 1s ease forwards;
    animation-delay: 0.4s;
    opacity: 0;
}

.hero-animate-cta {
    animation: fadeInUp 1s ease forwards;
    animation-delay: 0.6s;
    opacity: 0;
}

.hero-animate-visual {
    animation: fadeIn 1.2s ease forwards, levitate 4s ease-in-out infinite;
    animation-delay: 0.8s, 1.2s;
    opacity: 0;
}

/* ==========================================================================
   Card Hover Animations
   ========================================================================== */
.card-hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-hover-lift:hover {
    transform: translateY(-8px);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 0 30px rgba(229, 25, 55, 0.1);
}

.card-hover-glow {
    transition: box-shadow 0.3s ease;
}

.card-hover-glow:hover {
    box-shadow:
        0 0 20px rgba(229, 25, 55, 0.3),
        0 0 40px rgba(102, 126, 234, 0.2);
}

.card-hover-scale {
    transition: transform 0.3s ease;
}

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

/* ==========================================================================
   Button Animations
   ========================================================================== */
.btn-animate {
    position: relative;
    overflow: hidden;
}

.btn-animate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-animate:hover::before {
    width: 300%;
    height: 300%;
}

.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-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.5s ease;
}

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

/* ==========================================================================
   Text Animations
   ========================================================================== */
@keyframes typewriter {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 50% {
        border-color: transparent;
    }
    51%, 100% {
        border-color: var(--primary);
    }
}

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--primary);
    animation: typewriter 3s steps(30) forwards, blink 1s infinite;
}

.text-glow {
    text-shadow:
        0 0 10px rgba(229, 25, 55, 0.5),
        0 0 20px rgba(229, 25, 55, 0.3),
        0 0 30px rgba(229, 25, 55, 0.2);
}

/* ==========================================================================
   Learning Card Animations
   ========================================================================== */
@keyframes cardFlip {
    0% {
        transform: perspective(1000px) rotateY(0);
    }
    100% {
        transform: perspective(1000px) rotateY(180deg);
    }
}

@keyframes cardPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

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

.learning-card-animate {
    transition: all 0.3s ease;
}

.learning-card-animate:hover {
    animation: cardPop 0.4s ease;
}

.learning-card-animate.correct {
    animation: cardPop 0.5s ease;
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: white;
}

.learning-card-animate.incorrect {
    animation: shake 0.5s ease;
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    color: white;
}

.letter-animate {
    display: inline-block;
    animation: letterBounce 0.5s ease;
}

/* ==========================================================================
   Sentence Builder Animations
   ========================================================================== */
@keyframes wordSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes wordPulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 4px 25px rgba(229, 25, 55, 0.3);
    }
}

@keyframes sentenceComplete {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.word-animate-in {
    animation: wordSlideIn 0.4s ease forwards;
}

.word-animate-pulse {
    animation: wordPulse 2s ease-in-out infinite;
}

.sentence-complete {
    animation: sentenceComplete 0.6s ease, levitateGlow 2s ease-in-out infinite;
}

/* ==========================================================================
   Progress Animations
   ========================================================================== */
@keyframes progressFill {
    from {
        width: 0%;
    }
}

@keyframes progressGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(229, 25, 55, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(229, 25, 55, 0.6);
    }
}

.progress-animate {
    animation: progressFill 1s ease forwards;
}

.progress-glow {
    animation: progressGlow 2s ease-in-out infinite;
}

/* ==========================================================================
   Stagger Animations
   ========================================================================== */
.stagger-animate > * {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

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

/* ==========================================================================
   Scroll Reveal Animations
   ========================================================================== */
.reveal-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-up.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   Interactive Feedback Animations
   ========================================================================== */
@keyframes successPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes celebrateConfetti {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-200px) rotate(720deg);
        opacity: 0;
    }
}

.success-feedback {
    animation: successPulse 0.6s ease;
}

.error-feedback {
    animation: errorShake 0.5s ease;
}

.confetti-piece {
    animation: celebrateConfetti 1s ease forwards;
}

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

    .levitate,
    .color-shift,
    .lens-flare,
    .gradient-shift {
        animation: none;
    }

    .reveal,
    .reveal-up,
    .reveal-left,
    .reveal-right,
    .reveal-scale {
        opacity: 1;
        transform: none;
    }
}
