/* ========================================
   Effects - CRT, VHS, Glitch, Scanlines
   ======================================== */

/* --- Global Scanline Overlay (optional, on body) --- */
.scanline-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.08) 0px,
        rgba(0, 0, 0, 0.08) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 0.4;
}

/* --- VHS Tracking Lines --- */
.vhs-tracking {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s;
}

.vhs-tracking.active {
    opacity: 1;
}

.vhs-tracking::before {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 30px;
    background: rgba(255, 255, 255, 0.08);
    animation: vhsTrack 2s linear infinite;
}

.vhs-tracking::after {
    content: '';
    position: absolute;
    top: -50%;
    left: 0;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.15);
    animation: vhsTrack 3s linear infinite;
    animation-delay: 0.5s;
}

@keyframes vhsTrack {
    0% { top: -10%; }
    100% { top: 110%; }
}

/* --- Channel Static Transition --- */
.channel-static {
    height: 60px;
    margin: var(--space-lg) 0;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s;
}

.channel-static.active {
    opacity: 1;
}

.channel-static::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
    background-size: 150px;
    animation: staticMove 0.08s steps(4) infinite;
}

/* --- Film Grain (subtle) --- */
.film-grain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--z-overlay);
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 256px;
    animation: grainShift 0.5s steps(3) infinite;
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-5px, -5px); }
    66% { transform: translate(5px, 5px); }
    100% { transform: translate(0, 0); }
}

/* --- Phosphor Glow (for text) --- */
.glow-green {
    text-shadow:
        0 0 7px rgba(51, 255, 102, 0.6),
        0 0 15px rgba(51, 255, 102, 0.4),
        0 0 30px rgba(51, 255, 102, 0.2);
}

.glow-amber {
    text-shadow:
        0 0 7px rgba(255, 179, 71, 0.6),
        0 0 15px rgba(255, 179, 71, 0.4),
        0 0 30px rgba(255, 179, 71, 0.2);
}

/* --- Flicker --- */
.flicker {
    animation: textFlicker 1s linear infinite;
}

@keyframes textFlicker {
    0%, 97%, 100% { opacity: 1; }
    97.5% { opacity: 0.8; }
    98% { opacity: 1; }
    98.5% { opacity: 0.6; }
    99% { opacity: 1; }
}

/* --- CRT Power Off Effect --- */
.crt-off {
    animation: crtPowerOff 0.6s ease-in forwards;
}

@keyframes crtPowerOff {
    0% {
        filter: brightness(1);
        transform: scale(1);
    }
    50% {
        filter: brightness(3);
        transform: scaleY(0.005) scaleX(1.2);
    }
    80% {
        filter: brightness(5);
        transform: scaleY(0.005) scaleX(0.01);
    }
    100% {
        filter: brightness(0);
        transform: scaleY(0) scaleX(0);
    }
}

/* --- Typewriter cursor --- */
.typewriter-cursor::after {
    content: '|';
    font-weight: 400;
    color: var(--verde-fosforo);
    animation: cursorBlink 0.7s steps(1) infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Fade In Up (for scroll reveals) --- */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Stagger delay classes --- */
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }
.reveal-delay-6 { transition-delay: 0.6s; }

/* --- Horizontal Line Separator --- */
.line-separator {
    width: 60px;
    height: 2px;
    background: var(--verde-fosforo);
    margin: var(--space-md) 0;
    box-shadow: 0 0 10px rgba(51, 255, 102, 0.3);
}
