/**
 * OPTIMIZED VISUAL EFFECTS
 * GPU-accelerated animations with performance hints
 */

/* ==========================================
   BACKGROUND REVEAL SYSTEM
========================================== */
#background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    /* Force GPU acceleration */
    transform: translateZ(0);
    will-change: auto; /* Don't force will-change globally */
}

/* Bottom Layer: Green dots (revealed on hover) */
#background-revealed-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--color-dark-bg);
    background-image: radial-gradient(var(--color-terminal-green) 1px, transparent 1px);
    background-size: 20px 20px;
    transform: translateZ(0); /* GPU layer */
}

/* Top Layer: Gray dots (with circular mask hole) */
#background-hidden-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--color-dark-bg);
    background-image: radial-gradient(#1f2937 1px, transparent 1px);
    background-size: 20px 20px;
    
    /* GPU-accelerated radial mask */
    mask-image: radial-gradient(
        circle 80px at var(--mask-x) var(--mask-y),
        transparent 0%,
        transparent 80px,
        black 100%
    );
    -webkit-mask-image: radial-gradient(
        circle 80px at var(--mask-x) var(--mask-y),
        transparent 0%,
        transparent 80px,
        black 100%
    );
    
    /* Force GPU layer and hint that mask will change */
    transform: translateZ(0);
    will-change: mask-position;
}

/* ==========================================
   CUSTOM CURSOR TRAIL
   Now using transform instead of left/top
========================================== */
.cursor-trail {
    position: fixed;
    width: 1.5rem;
    height: 1.5rem;
    background-color: var(--color-blood-red);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.6;
    z-index: 9999;
    box-shadow: 
        0 0 10px var(--color-blood-red),
        0 0 30px rgba(255, 0, 0, 0.5);
    /* Use transform for GPU acceleration */
    transform: translate(-50%, -50%);
    /* Only hint will-change on these specific properties */
    will-change: transform, opacity;
    /* Force GPU layer */
    backface-visibility: hidden;
    top: 0;
    left: 0;
}

/* ==========================================
   LOGO CANVAS
========================================== */
#logo-container {
    transition: filter 0.3s ease;
    filter: drop-shadow(0 0 50px rgb(255, 0, 0));
    cursor: none;
    /* Contain GPU work to this element */
    contain: paint;
    -webkit-filter: drop-shadow(0 0 50px rgb(255, 0, 0));
}

#logo-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: none;
    /* GPU acceleration for canvas */
    transform: translateZ(0);
}

/* ==========================================
   LOADING SCREEN
========================================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--color-dark-bg) 0%, #000000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(153, 0, 0, 0.3);
    border-top-color: var(--color-blood-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    /* GPU optimization */
    will-change: transform;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--color-blood-red);
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-size: 0.875rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==========================================
   PARALLAX LAYERS
========================================== */
.parallax-layer {
    /* Don't use will-change by default, let browser optimize */
    transition: transform 0.1s ease-out;
}

/* Only hint will-change when actively scrolling */
.is-scrolling .parallax-layer {
    will-change: transform;
}

/* ==========================================
   FPS COUNTER
========================================== */
#fps-counter {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: var(--color-terminal-green);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9998;
    display: none;
    pointer-events: none;
    border: 1px solid var(--color-blood-red);
}

#fps-counter.visible {
    display: block;
}

/* ==========================================
   CLICK RIPPLE EFFECT
========================================== */
.click-ripple {
    position: fixed;
    border: 2px solid var(--color-blood-red);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9997;
    animation: ripple-expand 0.8s ease-out forwards;
    will-change: width, height, opacity;
}

@keyframes ripple-expand {
    from {
        width: 0;
        height: 0;
        opacity: 1;
    }
    to {
        width: 100px;
        height: 100px;
        opacity: 0;
    }
}

/* ==========================================
   PERFORMANCE OPTIMIZATIONS
========================================== */

/* Contain layout shifts */
.card {
    contain: layout style paint;
}

/* Optimize text rendering */
body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   REDUCED MOTION SUPPORT
========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .parallax-layer {
        transform: none !important;
    }
    
    .cursor-trail {
        display: none !important;
    }
    
    #logo-container {
        filter: none !important;
    }
}


/* ==========================================
   BLOOD DRIP ANIMATIONS
========================================== */

/* Blood drip that falls from top of cards on hover */
.card {
    position: relative;
    overflow: visible; /* Allow drip to extend outside */
}

.card::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 0;
    background: linear-gradient(to bottom, var(--color-blood-red), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
} 


.card:hover::before {
    animation: blood-drip-fall 2s ease-in infinite;
    opacity: 1;
} 


@keyframes blood-drip-fall {
    0% {
        height: 0;
        top: -4px;
        opacity: 1;
    }
    50% {
        height: 60px;
        opacity: 0.8;
    }
    100% {
        height: 80px;
        top: 76px;
        opacity: 0;
    }
}

/* Animated blood drops on click anywhere */
.blood-drop {
    position: fixed;
    width: 6px;
    height: 0;
    background: linear-gradient(to bottom, 
        var(--color-blood-red) 0%, 
        rgba(153, 0, 0, 0.8) 50%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 9996;
    border-radius: 0 0 3px 3px;
    animation: drop-fall 1.5s ease-in forwards;
}

@keyframes drop-fall {
    0% {
        height: 0;
        opacity: 1;
    }
    70% {
        height: 100px;
        opacity: 0.7;
    }
    100% {
        height: 120px;
        opacity: 0;
        transform: translateY(50px);
    }
}

/* Blood pooling effect at bottom */
.blood-pool {
    position: fixed;
    width: 30px;
    height: 30px;
    background: radial-gradient(
        circle,
        rgba(153, 0, 0, 0.6) 0%,
        rgba(153, 0, 0, 0.3) 50%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 9995;
    border-radius: 50%;
    animation: pool-spread 1s ease-out forwards;
}

@keyframes pool-spread {
    0% {
        width: 10px;
        height: 10px;
        opacity: 1;
    }
    100% {
        width: 40px;
        height: 15px;
        opacity: 0;
    }
}