/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   FRAGMENT ZERO — IMMERSIVE VISUAL EFFECTS
   Scanlines, glitch, particles, matrix rain, neon glow
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ── 1. ANIMATED SCANLINE OVERLAY ── */
.fx-scanlines {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    overflow: hidden;
}
.fx-scanlines::before {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 200%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(0, 255, 65, 0.025) 2px,
        rgba(0, 255, 65, 0.025) 4px
    );
    animation: fx-scanline-scroll 8s linear infinite;
    will-change: transform;
}
@keyframes fx-scanline-scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

/* ── 2. GLITCH EFFECT ON HOVER (episode titles) ── */
.episode-title a {
    position: relative;
    display: inline-block;
}
.episode-title a::before,
.episode-title a::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}
.episode-title a::before {
    color: #ff0040;
    z-index: 1;
}
.episode-title a::after {
    color: #00d4ff;
    z-index: 2;
}
.episode-title a:hover::before {
    opacity: 0.8;
    animation: fx-glitch-1 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.episode-title a:hover::after {
    opacity: 0.8;
    animation: fx-glitch-2 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
@keyframes fx-glitch-1 {
    0% { clip-path: inset(40% 0 60% 0); transform: translate(-3px, 0); }
    20% { clip-path: inset(10% 0 85% 0); transform: translate(3px, 0); }
    40% { clip-path: inset(60% 0 20% 0); transform: translate(-2px, 0); }
    60% { clip-path: inset(30% 0 50% 0); transform: translate(1px, 0); }
    80% { clip-path: inset(70% 0 10% 0); transform: translate(-1px, 0); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}
@keyframes fx-glitch-2 {
    0% { clip-path: inset(65% 0 10% 0); transform: translate(3px, 0); }
    20% { clip-path: inset(20% 0 70% 0); transform: translate(-3px, 0); }
    40% { clip-path: inset(50% 0 30% 0); transform: translate(2px, 0); }
    60% { clip-path: inset(5% 0 85% 0); transform: translate(-1px, 0); }
    80% { clip-path: inset(45% 0 40% 0); transform: translate(1px, 0); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}

/* Glitch also on nav-logo */
.nav-logo:hover {
    animation: fx-logo-glitch 0.4s steps(2, end);
}
@keyframes fx-logo-glitch {
    0% { text-shadow: 0 0 8px rgba(0,255,65,0.3); }
    20% { text-shadow: -3px 0 #ff0040, 3px 0 #00d4ff, 0 0 8px rgba(0,255,65,0.3); }
    40% { text-shadow: 3px 0 #ff0040, -3px 0 #00d4ff, 0 0 8px rgba(0,255,65,0.3); }
    60% { text-shadow: -2px 0 #ff0040, 2px 0 #00d4ff, 0 0 8px rgba(0,255,65,0.3); }
    80% { text-shadow: 2px 0 #ff0040, -1px 0 #00d4ff, 0 0 8px rgba(0,255,65,0.3); }
    100% { text-shadow: 0 0 8px rgba(0,255,65,0.3); }
}

/* ── 3. PARTICLE BACKGROUND (canvas placed by JS) ── */
#fx-particles {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
}

/* ── 4. HEARTBEAT PULSING GLOW ── */
@keyframes fx-heartbeat {
    0%   { text-shadow: 0 0 10px rgba(0,255,65,0.3), 0 0 20px rgba(0,255,65,0.15); transform: scale(1); }
    7%   { text-shadow: 0 0 30px rgba(0,255,65,0.8), 0 0 60px rgba(0,255,65,0.4), 0 0 90px rgba(0,255,65,0.15); transform: scale(1.06); }
    14%  { text-shadow: 0 0 10px rgba(0,255,65,0.3), 0 0 20px rgba(0,255,65,0.15); transform: scale(1); }
    21%  { text-shadow: 0 0 25px rgba(0,255,65,0.7), 0 0 50px rgba(0,255,65,0.35), 0 0 80px rgba(0,255,65,0.12); transform: scale(1.04); }
    28%  { text-shadow: 0 0 10px rgba(0,255,65,0.3), 0 0 20px rgba(0,255,65,0.15); transform: scale(1); }
    100% { text-shadow: 0 0 10px rgba(0,255,65,0.3), 0 0 20px rgba(0,255,65,0.15); transform: scale(1); }
}
.heartbeat-number {
    animation: fx-heartbeat 1.5s ease-in-out infinite !important;
}
.heartbeat-pulse-ring {
    animation: fx-heartbeat-ring 1.5s ease-out infinite !important;
}
@keyframes fx-heartbeat-ring {
    0%   { width: 60px; height: 60px; opacity: 0; border-color: var(--phosphor-dark); }
    7%   { width: 80px; height: 80px; opacity: 0.6; border-color: var(--phosphor); }
    28%  { width: 160px; height: 160px; opacity: 0.15; }
    50%  { width: 220px; height: 220px; opacity: 0; }
    100% { width: 60px; height: 60px; opacity: 0; }
}

/* ── 5. TYPEWRITER HEADERS ── */
.fx-typewriter {
    overflow: hidden;
    border-right: 2px solid var(--phosphor);
    white-space: nowrap;
    width: 0;
    animation: none;
}
.fx-typewriter.fx-typing {
    animation: fx-type-expand 1.2s steps(40, end) forwards, fx-blink-caret 0.7s step-end 6;
}
@keyframes fx-type-expand {
    from { width: 0; }
    to { width: 100%; }
}
@keyframes fx-blink-caret {
    from, to { border-color: var(--phosphor); }
    50% { border-color: transparent; }
}
.fx-typewriter.fx-typed {
    width: 100%;
    border-right: none;
}

/* ── 6. MATRIX RAIN (canvas positioned in hero) ── */
#fx-matrix-rain {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.12;
}
.hero-terminal {
    position: relative;
    overflow: hidden;
}
.hero-terminal .terminal-bar,
.hero-terminal .terminal-body {
    position: relative;
    z-index: 1;
}

/* ── 7. NEON BORDER GLOW ON CARDS ── */
.episode-card {
    border: 1px solid rgba(0, 212, 255, 0.15) !important;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.04), inset 0 0 8px rgba(0, 212, 255, 0.02);
    transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.3s ease !important;
}
.episode-card:hover {
    border-color: rgba(0, 255, 65, 0.5) !important;
    box-shadow:
        0 0 15px rgba(0, 255, 65, 0.15),
        0 0 30px rgba(0, 255, 65, 0.08),
        0 0 60px rgba(0, 255, 65, 0.04),
        inset 0 0 15px rgba(0, 255, 65, 0.03) !important;
    transform: translateY(-2px);
}

.tool-card {
    border: 1px solid rgba(0, 212, 255, 0.12) !important;
    transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.3s ease !important;
}
.tool-card:hover {
    border-color: rgba(0, 255, 65, 0.4) !important;
    box-shadow:
        0 0 12px rgba(0, 255, 65, 0.12),
        0 0 25px rgba(0, 255, 65, 0.06),
        inset 0 0 10px rgba(0, 255, 65, 0.02) !important;
    transform: translateY(-3px) !important;
}

.short-card {
    border: 1px solid rgba(0, 212, 255, 0.1) !important;
    transition: border-color 0.3s ease, box-shadow 0.3s ease !important;
}
.short-card:hover {
    border-color: rgba(0, 255, 65, 0.35) !important;
    box-shadow: 0 0 12px rgba(0, 255, 65, 0.1), 0 0 25px rgba(0, 255, 65, 0.05) !important;
}

/* ── 8. SMOOTH SCROLL (already in style.css, reinforced) ── */
html {
    scroll-behavior: smooth;
}

/* ── 9. PARALLAX HERO ── */
.hero {
    perspective: 1px;
    overflow: visible;
}
.hero-terminal {
    will-change: transform;
}

/* ── 10. LOADING SCREEN ── */
#fx-loading-screen {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: #020202;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', 'Share Tech Mono', monospace;
    transition: opacity 0.3s ease;
}
#fx-loading-screen.fx-fade-out {
    opacity: 0;
    pointer-events: none;
}
.fx-load-line {
    color: var(--phosphor, #00ff41);
    font-size: 0.8rem;
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    line-height: 1.8;
}
.fx-load-line.fx-visible {
    opacity: 1;
    transform: translateY(0);
}
.fx-load-line.fx-dim {
    color: #444;
}
.fx-load-line.fx-accent {
    color: var(--phosphor, #00ff41);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0,255,65,0.4);
}
.fx-load-bar {
    width: 300px;
    height: 2px;
    background: #111;
    margin-top: 1rem;
    border-radius: 1px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.fx-load-bar.fx-visible {
    opacity: 1;
}
.fx-load-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--phosphor, #00ff41);
    box-shadow: 0 0 8px rgba(0,255,65,0.4);
    transition: width 0.4s ease;
}

/* ── MISC POLISH ── */
.nav {
    transition: box-shadow 0.3s ease;
}
.nav.fx-scrolled {
    box-shadow: 0 1px 20px rgba(0, 255, 65, 0.05);
}

.footer-ascii {
    transition: color 0.5s ease, text-shadow 0.5s ease;
}
.footer:hover .footer-ascii {
    color: #0a2a0a;
    text-shadow: 0 0 20px rgba(0,255,65,0.08);
}

.newsletter-input:focus {
    border-color: var(--phosphor-dark) !important;
    box-shadow: 0 0 12px rgba(0,255,65,0.08), 0 0 30px rgba(0,255,65,0.03) !important;
}

.section-header {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.section-header.fx-in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ── PERFORMANCE: Reduce motion for prefers-reduced-motion ── */
@media (prefers-reduced-motion: reduce) {
    .fx-scanlines::before { animation: none; }
    .episode-title a::before,
    .episode-title a::after { display: none; }
    .heartbeat-number { animation: glow-pulse 3s ease-in-out infinite !important; }
    .fx-typewriter { width: 100% !important; border-right: none !important; animation: none !important; }
    #fx-loading-screen { display: none !important; }
    .episode-card { transition: none !important; }
    #fx-particles, #fx-matrix-rain { display: none !important; }
}

/* ── MOBILE OPTIMIZATIONS ── */
@media (max-width: 768px) {
    .fx-scanlines::before {
        animation-duration: 12s;
    }
    #fx-particles {
        opacity: 0.5;
    }
}
