/**
 * Verbi - Animations CSS
 * CSS Animations, Transitions, Micro-interactions
 */

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.page-exit {
    opacity: 1;
    transform: translateY(0);
}

.page-exit-active {
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 200ms ease-in, transform 200ms ease-in;
}

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

.fade-in {
    animation: fadeIn 300ms ease-out forwards;
}

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

.slide-up {
    animation: slideUp 400ms ease-out forwards;
}

/* Staggered children animation */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp 400ms ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 100ms; }
.stagger-children > *:nth-child(3) { animation-delay: 200ms; }
.stagger-children > *:nth-child(4) { animation-delay: 300ms; }
.stagger-children > *:nth-child(5) { animation-delay: 400ms; }
.stagger-children > *:nth-child(6) { animation-delay: 500ms; }

/* ============================================
   FLOATING & BOUNCING
   ============================================ */

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

.float {
    animation: float 3s ease-in-out infinite;
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(2deg); }
}

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

/* Pulse animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* Bounce */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* ============================================
   SPINNING
   ============================================ */

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

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin-slow {
    animation: spinSlow 3s linear infinite;
}

/* ============================================
   SHAKE
   ============================================ */

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

.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shakeVibrate {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-3px) rotate(-2deg); }
    50% { transform: translateX(3px) rotate(2deg); }
    75% { transform: translateX(-2px) rotate(-1deg); }
}

.shake-vibrate {
    animation: shakeVibrate 0.4s ease-in-out;
}

/* ============================================
   SCALE & GROW
   ============================================ */

@keyframes growIn {
    from { 
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.grow-in {
    animation: growIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.pop-in {
    animation: popIn 400ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ============================================
   RIPPLE EFFECTS
   ============================================ */

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

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
}

.ripple:active::after {
    animation: ripple 0.6s ease-out;
}

/* Success ripple */
@keyframes successRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.success-ripple {
    position: relative;
}

.success-ripple::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--color-success);
    animation: successRipple 0.5s ease-out forwards;
    pointer-events: none;
}

/* ============================================
   FLAME ANIMATION (Streak)
   ============================================ */

@keyframes flameFlicker {
    0%, 100% {
        transform: scale(1) rotate(-1deg);
        filter: hue-rotate(0deg);
    }
    25% {
        transform: scale(1.05) rotate(1deg);
        filter: hue-rotate(-10deg);
    }
    50% {
        transform: scale(0.95) rotate(-0.5deg);
        filter: hue-rotate(5deg);
    }
    75% {
        transform: scale(1.02) rotate(0.5deg);
        filter: hue-rotate(-5deg);
    }
}

.flame-icon {
    animation: flameFlicker 1s ease-in-out infinite;
}

.flame-icon-glow {
    filter: drop-shadow(0 0 8px var(--color-accent));
}

/* ============================================
   WAVEFORM ANIMATION (Pronunciation)
   ============================================ */

.waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 40px;
}

.waveform-bar {
    width: 4px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 2px;
    animation: waveform 0.8s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { animation-delay: 0ms; }
.waveform-bar:nth-child(2) { animation-delay: 100ms; }
.waveform-bar:nth-child(3) { animation-delay: 200ms; }
.waveform-bar:nth-child(4) { animation-delay: 300ms; }
.waveform-bar:nth-child(5) { animation-delay: 400ms; }
.waveform-bar:nth-child(6) { animation-delay: 500ms; }
.waveform-bar:nth-child(7) { animation-delay: 600ms; }
.waveform-bar:nth-child(8) { animation-delay: 700ms; }

@keyframes waveform {
    0%, 100% {
        height: 8px;
        opacity: 0.5;
    }
    50% {
        height: 40px;
        opacity: 1;
    }
}

/* Recording state */
.waveform.recording .waveform-bar {
    background: var(--color-accent);
    animation-duration: 0.4s;
}

/* ============================================
   XP GAIN FLOAT
   ============================================ */

@keyframes xpGain {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        opacity: 1;
        transform: translateY(-30px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px) scale(0.8);
    }
}

.xp-gain {
    position: absolute;
    font-family: var(--font-mono);
    font-weight: var(--font-bold);
    color: var(--color-gold);
    animation: xpGain 1s ease-out forwards;
    pointer-events: none;
    z-index: 100;
}

@keyframes xpPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.xp-pop {
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: var(--font-bold);
    color: var(--color-gold);
    animation: xpPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ============================================
   CORRECT / WRONG ANSWER ANIMATIONS
   ============================================ */

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

.correct-burst {
    position: relative;
}

.correct-burst::after {
    content: '';
    position: absolute;
    inset: -10px;
    background: radial-gradient(circle, var(--color-success) 0%, transparent 70%);
    animation: correctBurst 0.5s ease-out forwards;
    pointer-events: none;
    border-radius: inherit;
}

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

.wrong-answer {
    animation: wrongShake 0.5s ease-in-out;
    background: var(--color-error-bg) !important;
    border-color: var(--color-error) !important;
}

.correct-answer {
    background: var(--color-success-bg) !important;
    border-color: var(--color-success) !important;
}

/* ============================================
   CONFETTI
   ============================================ */

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

.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
    animation: confettiFall 3s ease-out forwards;
}

.confetti-piece:nth-child(odd) {
    background: var(--color-primary);
}

.confetti-piece:nth-child(even) {
    background: var(--color-gold);
}

.confetti-piece:nth-child(3n) {
    background: var(--color-accent);
}

.confetti-piece:nth-child(4n) {
    border-radius: 50%;
}

.confetti-piece:nth-child(5n) {
    width: 6px;
    height: 6px;
}

/* Stagger confetti */
.confetti-piece:nth-child(1) { left: 10%; animation-delay: 0ms; }
.confetti-piece:nth-child(2) { left: 20%; animation-delay: 100ms; }
.confetti-piece:nth-child(3) { left: 30%; animation-delay: 200ms; }
.confetti-piece:nth-child(4) { left: 40%; animation-delay: 50ms; }
.confetti-piece:nth-child(5) { left: 50%; animation-delay: 150ms; }
.confetti-piece:nth-child(6) { left: 60%; animation-delay: 250ms; }
.confetti-piece:nth-child(7) { left: 70%; animation-delay: 75ms; }
.confetti-piece:nth-child(8) { left: 80%; animation-delay: 175ms; }
.confetti-piece:nth-child(9) { left: 90%; animation-delay: 275ms; }
.confetti-piece:nth-child(10) { left: 15%; animation-delay: 125ms; }

/* ============================================
   PARTICLES (Background Effect)
   ============================================ */

@keyframes particleFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.3;
    }
    25% {
        transform: translate(20px, -30px) scale(1.2);
        opacity: 0.6;
    }
    50% {
        transform: translate(-10px, -60px) scale(0.8);
        opacity: 0.4;
    }
    75% {
        transform: translate(30px, -30px) scale(1.1);
        opacity: 0.5;
    }
}

.particles-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-primary);
    border-radius: 50%;
    opacity: 0.3;
    animation: particleFloat 8s ease-in-out infinite;
}

.particle:nth-child(1) { left: 10%; top: 20%; animation-delay: 0s; }
.particle:nth-child(2) { left: 25%; top: 60%; animation-delay: 1s; }
.particle:nth-child(3) { left: 40%; top: 30%; animation-delay: 2s; }
.particle:nth-child(4) { left: 55%; top: 70%; animation-delay: 3s; }
.particle:nth-child(5) { left: 70%; top: 40%; animation-delay: 4s; }
.particle:nth-child(6) { left: 85%; top: 20%; animation-delay: 5s; }
.particle:nth-child(7) { left: 15%; top: 80%; animation-delay: 6s; }
.particle:nth-child(8) { left: 60%; top: 10%; animation-delay: 7s; }

/* ============================================
   GRADIENT MESH ANIMATION
   ============================================ */

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

.gradient-mesh {
    background: linear-gradient(
        45deg,
        var(--color-bg) 0%,
        #1a1f3a 25%,
        #0d0f1a 50%,
        #1f1a3a 75%,
        var(--color-bg) 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* ============================================
   CARD FLIP
   ============================================ */

.card-flip-container {
    perspective: 1000px;
    width: 100%;
    height: 200px;
}

.card-flip {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-flip.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
}

.card-front {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.card-back {
    background: var(--color-primary-muted);
    border: 1px solid var(--color-primary);
    transform: rotateY(180deg);
}

/* ============================================
   TYPEWRITER EFFECT
   ============================================ */

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

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 2s steps(30) forwards;
}

/* ============================================
   GLASSMORPHISM CARD
   ============================================ */

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
}

.glass-card-glow {
    box-shadow: 
        0 8px 32px rgba(91, 107, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ============================================
   RANG BADGE ANIMATIONS
   ============================================ */

@keyframes badgeGlow {
    0%, 100% {
        filter: drop-shadow(0 0 4px currentColor);
    }
    50% {
        filter: drop-shadow(0 0 12px currentColor);
    }
}

.rang-badge {
    animation: badgeGlow 2s ease-in-out infinite;
}

.rang-lerner { color: #9CA3AF; }
.rang-fortgeschrittener { color: #22D3EE; }
.rang-experte { color: #5B6BFF; }
.rang-meister { color: #FACC15; }
.rang-champion { color: #FFD166; }

/* ============================================
   LOADING STATES
   ============================================ */

@keyframes loadingDots {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.4s infinite;
    animation-fill-mode: both;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-text-muted);
    display: inline-block;
    margin-left: 4px;
}

.loading-dots::after {
    content: '';
}

.loading-dots span:nth-child(1) { animation-delay: 0ms; }
.loading-dots span:nth-child(2) { animation-delay: 160ms; }
.loading-dots span:nth-child(3) { animation-delay: 320ms; }

/* Shimmer effect for loading */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.shimmer {
    background: linear-gradient(
        90deg,
        var(--color-surface) 0%,
        var(--color-surface-hover) 50%,
        var(--color-surface) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}