/**
 * Token Purchase Celebration Animations
 * =====================================
 * Minimal Swiss-style celebration for token purchases.
 * Uses sage green (#81B29A) to match existing value-change patterns.
 */

/* Celebration pulse animation for token counter */
@keyframes tokenCelebrate {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(129, 178, 154, 0.7);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 20px 8px rgba(129, 178, 154, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(129, 178, 154, 0);
    }
}

/* Glow ring animation */
@keyframes tokenGlow {
    0% {
        box-shadow: 0 0 5px rgba(129, 178, 154, 0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(129, 178, 154, 0.6),
                    0 0 50px rgba(129, 178, 154, 0.3);
    }
    100% {
        box-shadow: 0 0 5px rgba(129, 178, 154, 0.3);
    }
}

/* Apply celebration to token counter */
.token-counter.celebrating {
    animation: tokenCelebrate 0.6s ease-out;
    animation-iteration-count: 3;
    z-index: 1000;
}

/* Success background state during celebration */
.token-counter.celebrating-active {
    background: linear-gradient(135deg, #81B29A 0%, #6a9b82 100%) !important;
    color: white !important;
    border-color: #81B29A !important;
}

/* Token count number animation */
.token-count-animating {
    font-variant-numeric: tabular-nums;
    transition: none;
}

/* Purchase success toast */
.token-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #81B29A 0%, #6a9b82 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15),
                0 0 40px rgba(129, 178, 154, 0.3);
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 320px;
    font-family: inherit;
}

.token-toast.visible {
    opacity: 1;
    transform: translateX(0);
}

.token-toast-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.token-toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-size: 14px;
}

.token-toast-text {
    flex: 1;
}

.token-toast-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.token-toast-subtitle {
    font-size: 13px;
    opacity: 0.9;
}

.token-toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.token-toast-close:hover {
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .token-toast {
        top: 80px;
        bottom: auto;
        right: 16px;
        left: 16px;
        max-width: none;
    }

    /* Ensure mobile token displays also celebrate */
    #mobileMenuTokenCount.celebrating,
    #menuTokenCount.celebrating {
        animation: tokenCelebrate 0.6s ease-out;
        animation-iteration-count: 3;
    }
}

/* Confetti-like sparkle accents (subtle) */
@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

.token-sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #81B29A;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 0.8s ease-out forwards;
}

/* Test mode indicator */
.token-test-mode-badge {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #f59e0b;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
