/**
 * PyBLOCK Pool - Advanced Visual Effects
 * Enhanced CRT, Glitch, and Animation System
 */

/* ============================================================================
   ENHANCED CRT EFFECTS
   ============================================================================ */

/* Screen Curvature Effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 70%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 9998;
}

/* Flickering CRT Effect - DISABLED (too distracting) */
/*
@keyframes crtFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.97; }
}

.container {
    animation: crtFlicker 0.15s infinite;
}
*/

/* Enhanced Scanlines with RGB Split */
@keyframes rgbSplit {
    0%, 100% {
        text-shadow:
            0.05em 0 0 rgba(255, 0, 0, 0.75),
            -0.05em 0 0 rgba(0, 255, 0, 0.75),
            0 0 0 rgba(0, 0, 255, 0.75);
    }
    50% {
        text-shadow:
            0.025em 0 0 rgba(255, 0, 0, 0.75),
            -0.025em 0 0 rgba(0, 255, 0, 0.75),
            0 0 0 rgba(0, 0, 255, 0.75);
    }
}

/* ============================================================================
   INTENSE GLITCH EFFECTS
   ============================================================================ */

/* Glitch Intensity Levels */
.glitch-intense {
    position: relative;
    animation: glitchIntense 5s infinite;
}

.glitch-intense::before,
.glitch-intense::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.glitch-intense::before {
    animation: glitchTop 3s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
    color: var(--color-accent);
}

.glitch-intense::after {
    animation: glitchBottom 2.5s infinite;
    clip-path: polygon(0 67%, 100% 67%, 100% 100%, 0 100%);
    color: var(--color-magenta);
}

@keyframes glitchIntense {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-5px, 5px); }
    40% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    80% { transform: translate(5px, -5px); }
}

@keyframes glitchTop {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

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

/* Glitch Scan Effect - DISABLED (too distracting) */
/*
@keyframes glitchScan {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 100%;
    }
}

.glitch-scan {
    position: relative;
    overflow: hidden;
}

.glitch-scan::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 255, 65, 0.1) 50%,
        transparent 100%
    );
    background-size: 100% 50px;
    animation: glitchScan 8s linear infinite;
    pointer-events: none;
    z-index: 1;
}
*/

/* ============================================================================
   TERMINAL TYPING ANIMATIONS
   ============================================================================ */

.terminal-typing {
    overflow: hidden;
    border-right: 3px solid var(--color-primary);
    white-space: nowrap;
    animation:
        typing 3.5s steps(40, end),
        cursorBlink 0.75s step-end infinite;
}

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

@keyframes cursorBlink {
    from, to { border-color: transparent; }
    50% { border-color: var(--color-primary); }
}

/* Terminal Text Effect with Delay */
.terminal-text {
    display: inline-block;
    opacity: 0;
    animation: terminalReveal 0.1s forwards;
}

@keyframes terminalReveal {
    to { opacity: 1; }
}

/* Matrix Rain Effect for Backgrounds */
@keyframes matrixRain {
    0% {
        transform: translateY(-100%);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

.matrix-rain {
    position: absolute;
    top: 0;
    font-size: 20px;
    color: var(--color-primary);
    opacity: 0.3;
    animation: matrixRain 10s linear infinite;
    pointer-events: none;
}

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

/* Page Fade In */
.page-transition {
    animation: pageTransitionIn 0.6s ease-out;
}

@keyframes pageTransitionIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card Entrance Animations */
.card-entrance {
    opacity: 0;
    animation: cardEntrance 0.8s ease-out forwards;
}

@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
        filter: blur(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Staggered Card Animations */
.card-entrance:nth-child(1) { animation-delay: 0.1s; }
.card-entrance:nth-child(2) { animation-delay: 0.2s; }
.card-entrance:nth-child(3) { animation-delay: 0.3s; }
.card-entrance:nth-child(4) { animation-delay: 0.4s; }
.card-entrance:nth-child(5) { animation-delay: 0.5s; }
.card-entrance:nth-child(6) { animation-delay: 0.6s; }

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

/* Loading Spinner - Cyberpunk Style */
.loading-spinner {
    display: inline-block;
    width: 80px;
    height: 80px;
    border: 8px solid rgba(0, 255, 65, 0.1);
    border-top: 8px solid var(--color-primary);
    border-radius: 50%;
    animation: spinnerRotate 1s linear infinite;
    box-shadow:
        0 0 30px var(--color-primary),
        inset 0 0 30px var(--color-primary);
}

@keyframes spinnerRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Dots */
.loading-dots {
    display: inline-flex;
    gap: 10px;
}

.loading-dots span {
    width: 15px;
    height: 15px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
    box-shadow: 0 0 20px var(--color-primary);
}

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

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

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--color-primary);
    overflow: hidden;
    position: relative;
    box-shadow:
        0 0 20px var(--color-primary),
        inset 0 0 20px rgba(0, 255, 65, 0.2);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--color-primary) 0%,
        var(--color-accent) 50%,
        var(--color-primary) 100%
    );
    background-size: 200% 100%;
    animation: progressGlow 2s linear infinite;
    box-shadow: 0 0 30px var(--color-primary);
}

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

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        rgba(0, 255, 65, 0.05) 25%,
        rgba(0, 255, 65, 0.15) 50%,
        rgba(0, 255, 65, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: skeletonShimmer 2s infinite;
    border-radius: 4px;
}

@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   DATA VISUALIZATION ENHANCEMENTS
   ============================================================================ */

/* Pulsing Number Updates */
.number-update {
    animation: numberPulse 0.5s ease-out;
}

@keyframes numberPulse {
    0% {
        transform: scale(1);
        color: var(--color-primary);
    }
    50% {
        transform: scale(1.3);
        color: var(--color-accent);
        text-shadow: 0 0 40px var(--color-accent);
    }
    100% {
        transform: scale(1);
        color: var(--color-primary);
    }
}

/* Chart Entrance */
.chart-entrance {
    opacity: 0;
    animation: chartReveal 1.2s ease-out forwards;
}

@keyframes chartReveal {
    0% {
        opacity: 0;
        transform: scale(0.9);
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

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

/* Holographic Effect */
.holographic {
    position: relative;
    transition: all 0.3s ease;
}

.holographic::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(0, 255, 255, 0.1) 50%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.holographic:hover::before {
    opacity: 1;
    animation: holographicSweep 1.5s ease-in-out infinite;
}

@keyframes holographicSweep {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Electromagnetic Pulse Effect */
.emp-pulse {
    position: relative;
}

.emp-pulse::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 255, 65, 0.4);
    transform: translate(-50%, -50%);
    opacity: 0;
}

.emp-pulse:active::after {
    animation: empPulseEffect 0.6s ease-out;
}

@keyframes empPulseEffect {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* ============================================================================
   NOTIFICATION ANIMATIONS
   ============================================================================ */

/* Toast Notification */
.toast {
    position: fixed;
    top: 100px;
    right: 20px;
    background: var(--bg-black);
    border: 3px solid var(--color-primary);
    padding: 20px 30px;
    box-shadow: 0 0 50px var(--color-primary);
    z-index: 10000;
    animation: toastSlideIn 0.5s ease-out;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-exit {
    animation: toastSlideOut 0.5s ease-in forwards;
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .glitch-intense::before,
    .glitch-intense::after {
        display: none; /* Disable heavy effects on mobile */
    }

    .loading-spinner {
        width: 50px;
        height: 50px;
        border-width: 5px;
    }

    .toast {
        right: 10px;
        left: 10px;
        width: calc(100% - 20px);
    }
}

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

.fade-in { animation: fadeIn 0.6s ease-out; }
.fade-in-slow { animation: fadeIn 1.2s ease-out; }
.slide-up { animation: slideUp 0.6s ease-out; }
.slide-down { animation: slideDown 0.6s ease-out; }
.bounce-in { animation: bounceIn 0.8s ease-out; }
.glow-pulse { animation: glowPulse 2s ease-in-out infinite; }

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

@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 bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px var(--color-primary);
    }
    50% {
        box-shadow: 0 0 60px var(--color-primary), 0 0 100px var(--color-accent);
    }
}
