/* $TAP Mini App - Animations */

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

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@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);
    }
}

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

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -30px, 0);
    }
    70% {
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

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

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(233, 69, 96, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(233, 69, 96, 0.4), 0 0 30px rgba(233, 69, 96, 0.2);
    }
    100% {
        box-shadow: 0 0 5px rgba(233, 69, 96, 0.2);
    }
}

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

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

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

@keyframes wiggle {
    0%, 7% {
        transform: rotateZ(0);
    }
    15% {
        transform: rotateZ(-15deg);
    }
    20% {
        transform: rotateZ(10deg);
    }
    25% {
        transform: rotateZ(-10deg);
    }
    30% {
        transform: rotateZ(6deg);
    }
    35% {
        transform: rotateZ(-4deg);
    }
    40%, 100% {
        transform: rotateZ(0);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateY(-5px) scale(1.1);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes progressFill {
    from {
        width: 0%;
    }
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

/* Animation Classes */
.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-fadeOut {
    animation: fadeOut 0.3s ease-out;
}

.animate-slideUp {
    animation: slideUp 0.3s ease-out;
}

.animate-slideDown {
    animation: slideDown 0.3s ease-out;
}

.animate-slideLeft {
    animation: slideLeft 0.3s ease-out;
}

.animate-slideRight {
    animation: slideRight 0.3s ease-out;
}

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

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

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

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

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

.animate-scaleIn {
    animation: scaleIn 0.3s ease-out;
}

.animate-scaleOut {
    animation: scaleOut 0.3s ease-out;
}

.animate-wiggle {
    animation: wiggle 0.6s ease-in-out;
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

/* Tap-specific animations */
.tap-button-active {
    animation: pulse 0.2s ease-out;
}

.tap-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
}

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

.tap-counter-animate {
    animation: floatUp 1s ease-out forwards;
}

.points-increase {
    animation: countUp 0.8s ease-out;
}

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

/* Screen transition animations */
.screen-enter {
    animation: slideLeft 0.3s ease-out;
}

.screen-exit {
    animation: slideRight 0.3s ease-out;
}

/* Button hover effects */
.btn-hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-hover-lift:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Loading state animations */
.loading-dots::after {
    content: '.';
    animation: loadingDots 1.5s steps(3, end) infinite;
}

@keyframes loadingDots {
    0%, 20% {
        color: rgba(255, 255, 255, 0);
        text-shadow: .25em 0 0 rgba(255, 255, 255, 0), .5em 0 0 rgba(255, 255, 255, 0);
    }
    40% {
        color: white;
        text-shadow: .25em 0 0 rgba(255, 255, 255, 0), .5em 0 0 rgba(255, 255, 255, 0);
    }
    60% {
        text-shadow: .25em 0 0 white, .5em 0 0 rgba(255, 255, 255, 0);
    }
    80%, 100% {
        text-shadow: .25em 0 0 white, .5em 0 0 white;
    }
}

/* Navigation animations */
.nav-item {
    transition: all 0.2s ease;
}

.nav-item:hover {
    transform: translateY(-2px);
}

.nav-item.active {
    transform: translateY(-1px);
}

.nav-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 3px 3px 0 0;
    transition: all 0.3s ease;
}

/* Toast animations */
.toast-slide-in {
    animation: slideUp 0.3s ease-out;
}

.toast-slide-out {
    animation: slideDown 0.3s ease-out;
}

/* Balance update animation */
.balance-update {
    animation: countUp 0.5s ease-out;
}

.balance-highlight {
    animation: glow 0.8s ease-out;
}

/* Achievement unlock animation */
.achievement-unlock {
    animation: bounce 0.6s ease-out, glow 1s ease-out;
}

/* Error state animations */
.error-shake {
    animation: shake 0.5s ease-in-out;
}

/* Success state animations */
.success-bounce {
    animation: bounce 0.8s ease-out;
}

/* Card flip animation */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
}

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

/* Stagger animation for lists */
.stagger-item {
    animation: slideUp 0.4s ease-out;
}

.stagger-item:nth-child(1) { animation-delay: 0s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.2s; }
.stagger-item:nth-child(4) { animation-delay: 0.3s; }
.stagger-item:nth-child(5) { animation-delay: 0.4s; }

/* Performance optimizations */
.animate-gpu {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

/* Disable animations for reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tap-button {
        animation: none !important;
    }
    
    .loading-spinner {
        animation: none !important;
        border-top-color: var(--accent-red);
    }
}

/* Custom easing functions */
.ease-bounce {
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ease-back {
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ease-elastic {
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}