/**
 * Web3 Animations & Visual Enhancements
 * Modern cryptocurrency exchange UI animations
 * Created: December 2025
 */

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */

/* Floating Animation for crypto icons */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* Pulse glow effect for important elements */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(93, 56, 137, 0.3),
                    0 0 10px rgba(93, 56, 137, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(93, 56, 137, 0.6),
                    0 0 30px rgba(93, 56, 137, 0.4),
                    0 0 40px rgba(93, 56, 137, 0.2);
    }
}

/* Gradient animation for backgrounds */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

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

/* Slide in from bottom */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide in from right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide in from left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

/* Number counter animation */
@keyframes numberFlip {
    0%, 100% {
        transform: rotateX(0deg);
    }
    50% {
        transform: rotateX(180deg);
    }
}

/* Price change flash */
@keyframes priceFlashGreen {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(34, 197, 94, 0.2);
    }
}

@keyframes priceFlashRed {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(239, 68, 68, 0.2);
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Float animation */
.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Pulse glow */
.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* Gradient background */
.animate-gradient {
    background: linear-gradient(-45deg, #5D3889, #8B5CF6, #6366F1, #3B82F6);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* Shimmer effect */
.animate-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Slide animations */
.animate-slide-up {
    animation: slideInUp 0.6s ease-out;
}

.animate-slide-right {
    animation: slideInRight 0.6s ease-out;
}

.animate-slide-left {
    animation: slideInLeft 0.6s ease-out;
}

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

/* Rotate */
.animate-rotate {
    animation: rotate 2s linear infinite;
}

/* ============================================
   HOVER EFFECTS
   ============================================ */

/* Glassmorphism hover effect */
.glass-hover {
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.glass-hover:hover {
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Neon glow hover */
.neon-hover {
    transition: all 0.3s ease;
}

.neon-hover:hover {
    text-shadow: 0 0 10px rgba(93, 56, 137, 0.8),
                 0 0 20px rgba(93, 56, 137, 0.6),
                 0 0 30px rgba(93, 56, 137, 0.4);
    color: #fff;
}

/* 3D lift effect */
.lift-3d {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.lift-3d:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25),
                0 10px 10px rgba(0, 0, 0, 0.22);
}

/* Glow border on hover */
.glow-border {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.glow-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #5D3889, #8B5CF6, #6366F1, #3B82F6);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.glow-border:hover::before {
    opacity: 1;
}

/* ============================================
   TRADING SPECIFIC ANIMATIONS
   ============================================ */

/* Price change animations */
.price-up {
    animation: priceFlashGreen 0.5s ease-out;
    color: #22c55e !important;
}

.price-down {
    animation: priceFlashRed 0.5s ease-out;
    color: #ef4444 !important;
}

/* Chart loading skeleton */
.chart-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Order book pulse */
.orderbook-update {
    animation: pulseGlow 0.3s ease-out;
}

/* ============================================
   BUTTON ENHANCEMENTS
   ============================================ */

/* Futuristic button */
.btn-futuristic {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #5D3889 0%, #8B5CF6 100%);
    border: none;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-futuristic::before {
    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-futuristic:hover::before {
    left: 100%;
}

.btn-futuristic:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(93, 56, 137, 0.4);
}

/* Buy/Sell buttons with glow */
.btn-buy {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    transition: all 0.3s ease;
}

.btn-buy:hover {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
    transform: scale(1.05);
}

.btn-sell {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transition: all 0.3s ease;
}

.btn-sell:hover {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    transform: scale(1.05);
}

/* ============================================
   CARD EFFECTS
   ============================================ */

/* Crypto card with gradient border */
.crypto-card {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.crypto-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 2px;
    background: linear-gradient(135deg, #5D3889, #8B5CF6, #6366F1);
    -webkit-mask: linear-gradient(#fff 0 0) content-box,
                  linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.crypto-card:hover::before {
    opacity: 1;
}

.crypto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* ============================================
   RESPONSIVE ANIMATIONS
   ============================================ */

/* Disable animations on 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;
    }
}

/* ============================================
   DARK MODE ENHANCEMENTS
   ============================================ */

body.nightmode .crypto-card,
body.darkmode .crypto-card {
    background: rgba(0, 0, 0, 0.3);
}

body.nightmode .glass-hover,
body.darkmode .glass-hover {
    background: rgba(0, 0, 0, 0.2);
}

body.nightmode .glass-hover:hover,
body.darkmode .glass-hover:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(93, 56, 137, 0.1);
    border-top-color: #5D3889;
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* Dots loading */
.dots-loading {
    display: flex;
    gap: 8px;
}

.dots-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5D3889;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.dots-loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.dots-loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   PARTICLE EFFECTS (CSS-only)
   ============================================ */

.particles-bg {
    position: relative;
    overflow: hidden;
}

.particles-bg::before,
.particles-bg::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
    animation: float 10s ease-in-out infinite;
}

.particles-bg::before {
    background: linear-gradient(135deg, #5D3889, #8B5CF6);
    top: -150px;
    right: -150px;
    animation-delay: -5s;
}

.particles-bg::after {
    background: linear-gradient(135deg, #6366F1, #3B82F6);
    bottom: -150px;
    left: -150px;
}

/* ============================================
   TEXT EFFECTS
   ============================================ */

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #5D3889, #8B5CF6, #6366F1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

/* Glitch effect for special announcements */
.glitch-text {
    position: relative;
    animation: glitch 3s infinite;
}

@keyframes glitch {
    0%, 90%, 100% {
        text-shadow: none;
    }
    92% {
        text-shadow: 2px 0 #ff00de, -2px 0 #00fff9;
        transform: translate(-2px, 2px);
    }
    94% {
        text-shadow: -2px 0 #ff00de, 2px 0 #00fff9;
        transform: translate(2px, -2px);
    }
}
