/* ============================================
   gabs.day - Corrupted VHS Mixtape
   ============================================ */

:root {
    --deep-black: #0a0a12;
    --static-white: #f0ece4;
    --channel-red: #e8334a;
    --channel-cyan: #33e8d4;
    --doodle-ink: #3d2c1e;
    --pencil-gray: #8a8279;
    --signal-green: #39ff6e;
    --paper-cream: #f7f2e8;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--deep-black);
    color: var(--static-white);
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.72;
    overflow-x: hidden;
    position: relative;
}

/* --- Scanline Overlay --- */
.scanlines {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.06) 2px,
        rgba(0, 0, 0, 0.06) 3px
    );
    transition: opacity 0.3s;
}

/* --- Doodle Margins --- */
.doodle-margin {
    position: fixed;
    top: 0;
    height: 100vh;
    width: 80px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
    padding: 60px 10px;
    pointer-events: none;
}

.doodle-left {
    left: 0;
}

.doodle-right {
    right: 0;
}

.doodle {
    width: 50px;
    height: 50px;
    opacity: 0.6;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
}

.doodle-arrows {
    height: 70px;
}

.doodle path,
.doodle line,
.doodle circle {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 1.5s ease-out;
}

.doodle.drawn path,
.doodle.drawn line,
.doodle.drawn circle {
    stroke-dashoffset: 0;
}

/* --- CRT Hero --- */
.crt-hero {
    position: relative;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--deep-black);
    overflow: hidden;
    border-radius: 12px;
    z-index: 1;
}

.crt-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 50%,
        rgba(10, 10, 18, 0.6) 80%,
        rgba(10, 10, 18, 0.95) 100%
    );
    z-index: 3;
    pointer-events: none;
}

.static-noise {
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%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.08'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    z-index: 2;
    pointer-events: none;
    animation: staticShift 0.1s steps(4) infinite;
}

@keyframes staticShift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-20px, 10px); }
    50% { transform: translate(15px, -15px); }
    75% { transform: translate(-10px, -20px); }
    100% { transform: translate(20px, 5px); }
}

.hero-content {
    position: relative;
    z-index: 5;
    text-align: center;
    padding: 0 24px;
}

.hero-title {
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: clamp(48px, 10vw, 96px);
    letter-spacing: 0.04em;
    color: var(--static-white);
    position: relative;
}

/* --- RGB Channel Split Glitch --- */
.glitch-text {
    position: relative;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.glitch-text::before {
    color: var(--channel-red);
    left: -3px;
    top: 1px;
    mix-blend-mode: screen;
    clip-path: inset(0 0 0 0);
    animation: glitchRed 8s ease-in-out infinite;
}

.glitch-text::after {
    color: var(--channel-cyan);
    left: 3px;
    top: -1px;
    mix-blend-mode: screen;
    clip-path: inset(0 0 0 0);
    animation: glitchCyan 8s ease-in-out infinite;
}

@keyframes glitchRed {
    0%, 92%, 100% { left: -3px; top: 1px; clip-path: inset(0 0 0 0); }
    93% { left: -8px; top: 0; clip-path: inset(20% 0 60% 0); }
    94% { left: -5px; top: 2px; clip-path: inset(50% 0 10% 0); }
    95% { left: -3px; top: 1px; clip-path: inset(0 0 0 0); }
}

@keyframes glitchCyan {
    0%, 90%, 100% { left: 3px; top: -1px; clip-path: inset(0 0 0 0); }
    91% { left: 6px; top: -2px; clip-path: inset(40% 0 20% 0); }
    92% { left: 4px; top: 0; clip-path: inset(10% 0 70% 0); }
    93% { left: 3px; top: -1px; clip-path: inset(0 0 0 0); }
}

.hero-tagline {
    font-family: 'Caveat', cursive;
    font-size: clamp(20px, 3vw, 32px);
    color: var(--pencil-gray);
    margin-top: 20px;
    opacity: 0;
    animation: fadeTagline 1.5s ease-out 0.8s forwards;
}

@keyframes fadeTagline {
    to { opacity: 1; }
}

/* --- Glitch Bands --- */
.glitch-band {
    width: 100%;
    height: 60px;
    position: relative;
    z-index: 5;
    overflow: hidden;
    background: repeating-linear-gradient(
        to right,
        var(--channel-cyan) 0px,
        var(--channel-cyan) 4px,
        var(--channel-red) 4px,
        var(--channel-red) 8px,
        var(--signal-green) 8px,
        var(--signal-green) 12px,
        var(--deep-black) 12px,
        var(--deep-black) 16px,
        var(--channel-red) 16px,
        var(--channel-red) 18px,
        var(--channel-cyan) 18px,
        var(--channel-cyan) 24px,
        var(--deep-black) 24px,
        var(--deep-black) 30px
    );
    animation: bandShift 3s ease-in-out infinite;
    opacity: 0.7;
}

.glitch-band-wide {
    height: 100px;
}

@keyframes bandShift {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-15px); }
    75% { transform: translateX(10px); }
}

/* --- Broadcast Segments --- */
.broadcast-segment {
    position: relative;
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    z-index: 10;
}

/* --- Content Islands --- */
.content-island {
    position: relative;
    max-width: 720px;
    background: var(--paper-cream);
    color: var(--doodle-ink);
    padding: clamp(28px, 4vw, 48px);
    border-radius: 4px;
    /* Graph-paper background */
    background-image:
        linear-gradient(var(--pencil-gray) 1px, transparent 1px),
        linear-gradient(90deg, var(--pencil-gray) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--paper-cream);
    background-blend-mode: overlay;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

.content-island::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--paper-cream);
    z-index: -1;
    border-radius: 4px;
}

/* Graph paper lines at low opacity */
.content-island {
    background-image:
        linear-gradient(rgba(138, 130, 121, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(138, 130, 121, 0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--paper-cream);
}

.content-island.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--rotation, 0deg));
}

.island-left {
    --rotation: 2deg;
    margin-right: auto;
    margin-left: 10%;
    clip-path: polygon(0% 2%, 98% 0%, 100% 97%, 3% 100%);
}

.island-right {
    --rotation: -1.5deg;
    margin-left: auto;
    margin-right: 8%;
    clip-path: polygon(2% 0%, 100% 3%, 97% 100%, 0% 98%);
}

.island-final {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
    clip-path: none;
}

/* --- Island Content Styles --- */
.meta-stamp {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--signal-green);
    opacity: 0.6;
    display: block;
    margin-bottom: 16px;
}

.island-heading {
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 48px);
    letter-spacing: 0.04em;
    color: var(--doodle-ink);
    margin-bottom: 16px;
}

.island-heading.glitch-text::before {
    color: var(--channel-red);
    left: -2px;
    top: 1px;
    opacity: 0.6;
}

.island-heading.glitch-text::after {
    color: var(--channel-cyan);
    left: 2px;
    top: -1px;
    opacity: 0.6;
}

.island-body {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 17px;
    line-height: 1.72;
    color: var(--doodle-ink);
    margin-bottom: 16px;
    max-width: 42em;
}

.island-annotation {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    color: var(--pencil-gray);
    margin-top: 12px;
}

/* --- Glitchy Island --- */
.island-glitchy {
    animation: islandGlitch 10s ease-in-out infinite;
}

@keyframes islandGlitch {
    0%, 93%, 100% { transform: rotate(-1.5deg) translate(0, 0); }
    94% { transform: rotate(-1.5deg) translate(6px, 0); }
    95% { transform: rotate(-1.5deg) translate(-3px, 0); }
    96% { transform: rotate(-1.5deg) translate(0, 0); }
}

/* --- Broadcast Log --- */
.segment-log {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 120px 24px;
}

.log-entry {
    position: relative;
    max-width: 560px;
    padding: 20px 28px;
    margin-bottom: 48px;
    background: rgba(247, 242, 232, 0.06);
    border-left: 2px solid var(--signal-green);
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.log-entry.visible {
    opacity: 1;
    transform: translateX(0) rotate(var(--rotation, 0deg));
}

.log-time {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--signal-green);
    opacity: 0.8;
    display: block;
    margin-bottom: 8px;
}

.log-text {
    font-family: 'Nunito Sans', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--static-white);
    opacity: 0.85;
}

/* --- Static Intermission --- */
.static-intermission {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 5;
}

.gradient-wash {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to right,
        var(--channel-cyan) 0px,
        var(--channel-cyan) 6px,
        transparent 6px,
        transparent 10px,
        var(--channel-red) 10px,
        var(--channel-red) 14px,
        transparent 14px,
        transparent 20px
    );
    opacity: 0.15;
    animation: washCycle 20s linear infinite;
}

@keyframes washCycle {
    0% { background-position: 0 0; }
    100% { background-position: 600px 0; }
}

.intermission-text {
    position: relative;
    z-index: 10;
    font-family: 'Caveat', cursive;
    font-size: clamp(24px, 4vw, 40px);
    font-weight: 700;
    color: var(--static-white);
    text-align: center;
    padding: 0 24px;
    text-shadow:
        -2px 0 var(--channel-red),
        2px 0 var(--channel-cyan);
}

/* --- Final Section --- */
.island-final .island-heading {
    font-size: clamp(32px, 5vw, 56px);
}

.compass-rose {
    display: block;
    width: 80px;
    height: 80px;
    margin: 32px auto 16px;
    opacity: 0.7;
}

.final-domain {
    display: block;
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pencil-gray);
    opacity: 0.5;
    margin-top: 24px;
}

/* --- Glitch Burst (JS-toggled) --- */
body.glitch-burst {
    transform: translateX(3px);
}

body.glitch-burst .scanlines {
    opacity: 0.15 !important;
}

body.glitch-burst .glitch-text::before {
    left: -6px !important;
}

body.glitch-burst .glitch-text::after {
    left: 6px !important;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .doodle-margin {
        display: none;
    }

    .island-left,
    .island-right {
        margin-left: 5%;
        margin-right: 5%;
        clip-path: none;
    }

    .content-island {
        max-width: 100%;
    }

    .segment-log {
        padding: 80px 16px;
    }

    .log-entry {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .broadcast-segment {
        padding: 60px 16px;
    }

    .glitch-band {
        height: 40px;
    }

    .glitch-band-wide {
        height: 60px;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .static-noise,
    .hero-bubble-el {
        animation: none;
    }

    .glitch-text::before,
    .glitch-text::after {
        animation: none;
    }

    .island-glitchy {
        animation: none;
    }

    .glitch-band {
        animation: none;
    }

    .gradient-wash {
        animation: none;
    }

    .content-island,
    .log-entry {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .doodle path,
    .doodle line,
    .doodle circle {
        stroke-dasharray: none;
        stroke-dashoffset: 0;
        transition: none;
    }
}
