/* Base resets - ensures layout compatibility */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

/*
  1. THE CURTAIN LAYER
  This covers your existing stylesheet background and fades out
  exactly when the CRT monitor finishes booting up.
*/
body::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #121010; /* Match this to your preferred dark screen color */
    z-index: 998; /* Sits right over your background, but under the CRT scanlines */
    pointer-events: none;
    animation: fade-out-curtain 3.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* The Full-Screen CRT Frame (Completely transparent) */
.crt-frame {
    background: transparent;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Full-Screen Ambient Screen Flicker Overlay */
.crt-frame::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    background: rgba(255, 255, 255, 0.03);
    z-index: 1000; /* Shifted higher to stay on top */
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

/* Full-Screen Scanlines Overlay */
.crt-frame::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    background:
            linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
            linear-gradient(90deg, rgba(255, 0, 0, 0.04), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.04));
    z-index: 1000; /* Shifted higher to stay on top */
    background-size: 100% 3px, 6px 100%;
    pointer-events: none;
}

/* Actual Webpage Content Layout */
.page-content {
    width: 100%;
    height: 100%;
    padding: 40px;
    box-sizing: border-box;
    overflow-y: auto;
    pointer-events: auto;

    /* Runs the warp scaling transition */
    animation: turn-on 3s linear forwards;
}

/* AV-1 Channel Overlay */
.overlay {
    color: #00FF00;
    position: fixed;
    top: 40px;
    right: 40px;
    font-size: 40px;
    font-family: monospace;
    pointer-events: none;
    z-index: 1001;
    animation: overlay-anim 4s linear forwards;
}

/* --- Keyframe Animations --- */

/* This hides your other stylesheet's background, then slowly melts away */
@keyframes fade-out-curtain {
    0% {
        opacity: 1; /* Completely hides your background */
    }
    11% {
        opacity: 1; /* Keeps it hidden during the initial horizontal white flashes */
    }
    40% {
        opacity: 0.7; /* Starts fading out */
    }
    100% {
        opacity: 0; /* Fully transparent; your background displays perfectly underneath */
        visibility: hidden;
    }
}

@keyframes flicker {
    0% { opacity: 0.2; }
    20% { opacity: 0.7; }
    40% { opacity: 0.3; }
    60% { opacity: 0.9; }
    80% { opacity: 0.1; }
    100% { opacity: 0.6; }
}

@keyframes turn-on {
    0% {
        transform: scale(1, 0.8) translate3d(0, 0, 0);
        filter: brightness(2) contrast(3);
    }
    3.5% { transform: scale(1, 0.8) translate3d(0, 100%, 0); }
    3.6% { transform: scale(1, 0.8) translate3d(0, -100%, 0); }
    9% {
        transform: scale(1.2, 0.1) translate3d(0, 100%, 0);
        filter: brightness(5);
    }
    11% {
        transform: scale(1, 1) translate3d(0, 0, 0);
        filter: contrast(0.5) brightness(0.5);
    }
    100% {
        transform: scale(1, 1) translate3d(0, 0, 0);
        filter: contrast(1) brightness(1) saturate(1);
    }
}

@keyframes overlay-anim {
    0%, 15%, 100% { visibility: hidden; }
    16%, 99% { visibility: visible; }
}
