/* CRT Monitor Effect CSS */
.crt-effect {
    position: relative;
    /* Remove overflow: hidden to allow scrolling */
}

/* Screen curvature - subtle vignette */
.crt-effect::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 65%,
        rgba(0, 0, 0, 0.15) 85%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
    z-index: 9998;
}

/* Scan lines */
.crt-scanlines::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.1) 50%,
        rgba(0, 0, 0, 0) 100%
    );
    background-size: 100% 3px;
    animation: scanlines 10s linear infinite;
    pointer-events: none;
    z-index: 9997;
}

/* Phosphor glow */
.crt-effect * {
    text-shadow: 
        0 0 2px currentColor,
        0 0 4px currentColor,
        0 0 6px currentColor,
        0 0 8px rgba(0, 255, 0, 0.5);
}

/* Flicker effect */
.crt-flicker {
    animation: flicker 0.15s infinite;
}

/* RGB shift effect */
.crt-effect .crt-content {
    animation: rgbShift 2s infinite alternate;
}

/* Animations */
@keyframes scanlines {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(3px);
    }
}

@keyframes flicker {
    0% {
        opacity: 0.97;
    }
    5% {
        opacity: 0.94;
    }
    10% {
        opacity: 0.98;
    }
    15% {
        opacity: 0.96;
    }
    20% {
        opacity: 0.98;
    }
    25% {
        opacity: 0.92;
    }
    30% {
        opacity: 0.98;
    }
    35% {
        opacity: 0.96;
    }
    40% {
        opacity: 0.93;
    }
    45% {
        opacity: 0.99;
    }
    50% {
        opacity: 0.96;
    }
    60% {
        opacity: 0.97;
    }
    70% {
        opacity: 0.93;
    }
    80% {
        opacity: 0.99;
    }
    90% {
        opacity: 0.97;
    }
    100% {
        opacity: 0.98;
    }
}

@keyframes rgbShift {
    0%, 100% {
        text-shadow: 
            -1px 0 0 rgba(255, 0, 0, 0.3),
            1px 0 0 rgba(0, 255, 255, 0.3),
            0 0 2px currentColor;
    }
    25% {
        text-shadow: 
            -1.5px 0 0 rgba(255, 0, 0, 0.3),
            1.5px 0 0 rgba(0, 255, 255, 0.3),
            0 0 2px currentColor;
    }
    50% {
        text-shadow: 
            -1px 0 0 rgba(255, 0, 0, 0.3),
            1px 0 0 rgba(0, 255, 255, 0.3),
            0 0 3px currentColor;
    }
    75% {
        text-shadow: 
            -0.5px 0 0 rgba(255, 0, 0, 0.3),
            0.5px 0 0 rgba(0, 255, 255, 0.3),
            0 0 2px currentColor;
    }
}

/* Screen power on effect */
@keyframes turnOn {
    0% {
        transform: scale(1, 0.8) skewX(1deg);
        filter: brightness(30);
        opacity: 0;
    }
    5% {
        transform: scale(1, 0.8) skewX(0deg);
        filter: brightness(30);
        opacity: 0.2;
    }
    10% {
        transform: scale(1, 0.8) skewX(0deg);
        filter: brightness(30);
        opacity: 0.5;
    }
    15% {
        transform: scale(1.05, 1) skewX(0deg);
        filter: brightness(30);
        opacity: 0.6;
    }
    30% {
        transform: scale(1, 1) skewX(0.5deg);
        filter: brightness(10);
        opacity: 0.8;
    }
    50% {
        transform: scale(0.99, 0.98) skewX(0deg);
        filter: brightness(3);
        opacity: 0.9;
    }
    100% {
        transform: scale(1, 1) skewX(0deg);
        filter: brightness(1);
        opacity: 1;
    }
}

.crt-turn-on {
    animation: turnOn 0.4s ease-out;
}

/* Random noise/static effect */
.crt-static::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-radial-gradient(
            circle at 30% 70%,
            transparent 0,
            transparent 0.5px,
            rgba(0, 255, 0, 0.03) 0.5px,
            rgba(0, 255, 0, 0.03) 1px
        );
    animation: noise 0.2s steps(10) infinite;
    opacity: 0.4;
    pointer-events: none;
    z-index: 9996;
}

@keyframes noise {
    0%, 100% {
        background-position: 0 0;
    }
    10% {
        background-position: -5% -10%;
    }
    20% {
        background-position: -15% 5%;
    }
    30% {
        background-position: 7% -25%;
    }
    40% {
        background-position: 20% 25%;
    }
    50% {
        background-position: -25% 20%;
    }
    60% {
        background-position: 15% 5%;
    }
    70% {
        background-position: 0 15%;
    }
    80% {
        background-position: 25% 35%;
    }
    90% {
        background-position: -10% 10%;
    }
}

/* Disable effect for certain elements */
.no-crt {
    text-shadow: none !important;
    animation: none !important;
}

/* Enhanced glow for terminal and important text */
.crt-effect .terminal-window,
.crt-effect .article-title,
.crt-effect .glitch-text {
    text-shadow: 
        0 0 5px currentColor,
        0 0 10px currentColor,
        0 0 15px rgba(0, 255, 0, 0.5);
}

/* Button to toggle CRT effect */
.crt-toggle {
    background: rgba(0, 0, 0, 0.8) !important;
    border: 1px solid #0f0 !important;
    color: #0f0 !important;
    padding: 5px 10px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    transition: all 0.3s ease;
    text-shadow: 0 0 5px #0f0;
    margin-left: 15px;
}

.crt-toggle:hover {
    background: rgba(0, 255, 0, 0.1) !important;
    color: #0f0 !important;
    box-shadow: 0 0 15px #0f0;
    transform: scale(1.05);
}

.crt-toggle:active {
    background: rgba(0, 255, 0, 0.2) !important;
    color: #0f0 !important;
    transform: scale(0.95);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .crt-toggle {
        display: none; /* Hide CRT toggle on mobile since effects are disabled anyway */
    }
    
    /* Reduce effects on mobile for performance */
    .crt-effect * {
        text-shadow: 
            0 0 1px currentColor,
            0 0 2px rgba(0, 255, 0, 0.3);
    }
    
    .crt-static::before {
        display: none;
    }
}