/* css/crt-hardware.css */

.screen-glass {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: black;
    animation: flicker 4s infinite linear;
}

.screen-glass::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: radial-gradient(200% 250% at center, rgba(0, 70, 70, 0.85), black 100%);
    opacity: 0;
    transition: opacity 4s ease-in;
    pointer-events: none;
    z-index: 1;
}

body.power-on .screen-glass::before {
    opacity: 1;
}

@keyframes flicker {
    0%, 19.999%, 22%, 62.999%, 64%, 64.999%, 70%, 100% { opacity: 1; }
    20%, 21.999%, 63%, 63.999%, 65%, 69.999% { opacity: 0.98; }
}

/* Background noise */
.dirt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/img/background-noise.png');
    background-size: cover;
    mix-blend-mode: overlay; /* or screen/multiply depending on the noise image */
    opacity: 0.15;
    z-index: 45;
    pointer-events: none;
}

/* Videomator exact cristal effect */
.cristal {
    pointer-events: none;	
    overflow: hidden;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.6;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 3px, 2px 100%;
    z-index: 50;
}

/* Videomator exact scanlines */
.scanline {
    width: 100%;
    height: 100px;
    z-index: 51;
    background: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(255, 255, 255, 0.2) 10%,
        rgba(0, 0, 0, 0.1) 100%
    );
    opacity: 0.1;
    position: absolute;
    bottom: 100%;
    animation: scanline 10s linear infinite;
    pointer-events: none;	
}

.scanline1 {
    width: 100%;
    height: 100px;
    z-index: 52;
    background: linear-gradient(
        0deg,
        rgba(0, 0, 0, 0) 0%,
        rgba(255, 255, 255, 0.2) 10%,
        rgba(0, 0, 0, 0.1) 100%
    );
    opacity: 0.1;
    position: absolute;
    bottom: 100%;
    animation: scanline 4s linear infinite;
    pointer-events: none;	
}

@keyframes scanline {
    0% { bottom: 100%; }
    80% { bottom: 100%; }
    100% { bottom: 0%; }
}

/* Occasional Glitch Distortion */
.glitch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 60;
    pointer-events: none;
    overflow: hidden;
}

.glitch-bar {
    position: absolute;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5), 0 0 20px rgba(255, 0, 255, 0.5);
    opacity: 0;
    z-index: 61;
}

@keyframes glitchMove {
    0% { top: -10%; opacity: 0; transform: scaleY(1) skewX(0deg); }
    2% { opacity: 0.8; transform: scaleY(10) skewX(20deg); }
    5% { opacity: 0.5; transform: scaleY(2) skewX(-20deg); }
    8% { top: 110%; opacity: 0; transform: scaleY(1) skewX(0deg); }
    100% { top: 110%; opacity: 0; }
}

.glitch-active {
    animation: glitchMove 6s infinite linear;
    /* We'll trigger this infrequently via a longer duration or JS */
    animation-delay: 5s; 
    animation-duration: 20s; 
}

#wipe-transition-layer {
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 10;
    /* Simulate barrel distortion with a stronger CSS perspective to make it feel convex */
    transform: perspective(800px) rotateX(1.5deg) scale(0.98);
    transform-style: preserve-3d;
    
    /* Occasional Glitch */
    animation: contentGlitch 25s infinite linear;
}

@keyframes contentGlitch {
    0%, 90%, 100% { transform: perspective(800px) rotateX(1.5deg) scale(0.98) translate(0); filter: none; }
    92% { transform: perspective(800px) rotateX(1.5deg) scale(0.98) translate(-10px, 2px); filter: hue-rotate(90deg) brightness(1.5); }
    94% { transform: perspective(800px) rotateX(1.5deg) scale(0.98) translate(10px, -2px); filter: hue-rotate(-90deg) brightness(1.2); }
    96% { transform: perspective(800px) rotateX(1.5deg) scale(0.98) translate(-5px, 1px); filter: contrast(2) brightness(2); }
    98% { transform: perspective(800px) rotateX(1.5deg) scale(0.98) translate(0); filter: none; }
}

/* Startup animation */
body.power-on #wipe-transition-layer {
    animation: startup 1.5s ease-out forwards;
}

@keyframes startup {
    0% { transform: scale(0.005, 0.005); filter: brightness(3); opacity: 0; }
    30% { transform: scale(1, 0.005); filter: brightness(2); opacity: 1; }
    100% { transform: perspective(800px) rotateX(1.5deg) scale(0.98); 
           filter: brightness(1); opacity: 1; }
}

@keyframes shutdown {
    0% { transform: scale(1, 1); filter: brightness(1); }
    40% { transform: scale(1, 0.005); filter: brightness(2); }
    70% { transform: scale(0.005, 0.005); filter: brightness(3); opacity: 1; }
    100% { transform: scale(0, 0); filter: brightness(0); opacity: 0; }
}
