/* ============================================
   algoha.com - Candy Glitch Split-Screen Design
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Palette - Candy Bright */
    --licorice-void: #1C1024;
    --deep-void: #2A1838;
    --bubblegum-haze: #FF6B9D;
    --electric-lemon: #FFD166;
    --pixel-magenta: #FF2D7B;
    --cyber-mint: #00F5D4;
    --glitch-violet: #B24BF3;
    --powdered-sugar: #F2E9FF;
    --frosted-grape: #C4A8D9;
    --neon-coral: #FF4D6A;
    --pure-black: #000000;

    /* Split ratio (updated by JS) */
    --split: 55fr;
    --split-right: 45fr;

    /* Divider position */
    --divider-x: 55%;
}

/* --- @property for animated gradient --- */
@property --gradient-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@property --gradient-color-a {
    syntax: '<color>';
    initial-value: #FF6B9D;
    inherits: false;
}

@property --gradient-color-b {
    syntax: '<color>';
    initial-value: #FFD166;
    inherits: false;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: var(--licorice-void);
    color: var(--powdered-sugar);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.05rem;
    line-height: 1.7;
    letter-spacing: 0.01em;
    font-weight: 400;
    overflow-x: hidden;
}

/* --- Scan Lines Overlay (CRT effect) --- */
/* Horizontal lines 1px tall, spaced 3px apart, #000 at 8% opacity */
.scan-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 3px
    );
}

/* --- Split Container --- */
.split-container {
    display: grid;
    grid-template-columns: var(--split) var(--split-right);
    min-height: 400vh;
    position: relative;
    will-change: grid-template-columns;
    contain: layout;
}

/* --- Signal Panel (Left) --- */
.signal-panel {
    position: relative;
    z-index: 2;
    padding: 0 clamp(2rem, 4vw, 5rem);
    /* Checkerboard micro-pattern: 6x6px alternating #1C1024 and #2A1838 */
    background-color: var(--licorice-void);
    background-image:
        linear-gradient(45deg, var(--deep-void) 25%, transparent 25%),
        linear-gradient(-45deg, var(--deep-void) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--deep-void) 75%),
        linear-gradient(-45deg, transparent 75%, var(--deep-void) 75%);
    background-size: 6px 6px;
    background-position: 0 0, 0 3px, 3px -3px, -3px 0px;
}

/* --- Noise Panel (Right) --- */
.noise-panel {
    position: relative;
    z-index: 1;
    overflow: hidden;
    background: linear-gradient(
        135deg,
        var(--gradient-color-a),
        var(--gradient-color-b)
    );
    animation: noiseGradientCycle 20s ease-in-out infinite;
}

/* Cycling gradient: Bubblegum Haze -> Electric Lemon -> Cyber Mint -> back */
@keyframes noiseGradientCycle {
    0% {
        --gradient-color-a: #FF6B9D;
        --gradient-color-b: #FFD166;
    }
    33% {
        --gradient-color-a: #FFD166;
        --gradient-color-b: #00F5D4;
    }
    66% {
        --gradient-color-a: #00F5D4;
        --gradient-color-b: #FF6B9D;
    }
    100% {
        --gradient-color-a: #FF6B9D;
        --gradient-color-b: #FFD166;
    }
}

/* Dot matrix texture: 2px circles, 16px apart, Frosted Grape at 20% opacity */
.dot-matrix-texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: radial-gradient(circle, var(--frosted-grape) 1px, transparent 1px);
    background-size: 16px 16px;
    opacity: 0.2;
    z-index: 1;
}

/* Noise shapes container */
.noise-shapes {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    z-index: 2;
    perspective: 800px;
}

.noise-shape {
    position: absolute;
    transition: none;
    will-change: transform;
}

.noise-shape svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Corrupted shapes: dashed stroke in Neon Coral */
.noise-shape.corrupted svg polygon,
.noise-shape.corrupted svg circle,
.noise-shape.corrupted svg path {
    stroke-dasharray: 8 4;
    stroke: var(--neon-coral);
}

/* Corrupted shapes get diagonal hash fill overlay via CSS */
.noise-shape.corrupted {
    position: absolute;
}

.noise-shape.corrupted::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Diagonal hash lines: 45-degree, 1px at 12px spacing, #FF2D7B at 15% opacity */
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 11px,
        rgba(255, 45, 123, 0.15) 11px,
        rgba(255, 45, 123, 0.15) 12px
    );
    pointer-events: none;
    border-radius: 2px;
}

/* Blurred background shapes: depth effect */
.noise-shape.blurred {
    filter: blur(3px) saturate(0.7);
}

/* Glitch freeze overlay */
.glitch-freeze-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    background-color: var(--neon-coral);
    transition: opacity 0.05s;
}

.glitch-freeze-overlay.active {
    opacity: 0.4;
}

/* Glitch freeze scan-line artifacts */
.glitch-artifact {
    position: absolute;
    left: 0;
    width: 100%;
    height: 8px;
    background-color: var(--neon-coral);
    opacity: 0.6;
    z-index: 11;
    pointer-events: none;
}

/* --- Zig-Zag Divider --- */
.zigzag-divider {
    position: fixed;
    top: 0;
    left: var(--divider-x);
    width: 40px;
    height: 100vh;
    z-index: 5;
    transform: translateX(-50%);
    pointer-events: none;
    will-change: left;
}

.zigzag-divider svg {
    width: 100%;
    height: 100%;
}

/* Chromatic aberration on divider via pseudo-elements */
.zigzag-divider::before,
.zigzag-divider::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* --- Hero Section --- */
.hero-signal {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
}

.hero-title-wrapper {
    text-align: center;
}

/* Glitch Title: Rubik with chromatic aberration layering */
.glitch-title {
    position: relative;
    font-family: 'Rubik', sans-serif;
    font-weight: 900;
    font-size: clamp(3rem, 8vw + 1rem, 9rem);
    letter-spacing: -0.04em;
    line-height: 0.95;
    display: inline-block;
}

.glitch-layer {
    display: block;
}

.glitch-layer--base {
    color: var(--powdered-sugar);
    position: relative;
    z-index: 2;
}

.glitch-layer--shift {
    position: absolute;
    top: 2px;
    left: 3px;
    color: var(--pixel-magenta);
    mix-blend-mode: difference;
    z-index: 1;
}

.hero-subtitle {
    margin-top: 1.5rem;
    color: var(--frosted-grape);
}

.hero-tagline {
    margin-top: 1rem;
    opacity: 0.7;
}

.hero-tag-accent {
    color: var(--cyber-mint);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
}

/* --- Silkscreen Text (pixel font for labels/metadata) --- */
.silkscreen-text {
    font-family: 'Silkscreen', cursive;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--frosted-grape);
}

/* --- Section Headings (Glitch style) --- */
.glitch-heading {
    position: relative;
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw + 0.5rem, 5rem);
    letter-spacing: -0.04em;
    line-height: 0.95;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.glitch-heading .glitch-layer--base {
    color: var(--powdered-sugar);
}

.glitch-heading .glitch-layer--shift {
    color: var(--pixel-magenta);
    top: 2px;
    left: 2px;
}

/* --- Bungee Shade Text (pull quotes, feature text) --- */
.bungee-text {
    font-family: 'Bungee Shade', cursive;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: var(--glitch-violet);
    line-height: 1.2;
}

/* --- Body Text: Space Grotesk --- */
.body-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.05rem;
    line-height: 1.7;
    letter-spacing: 0.01em;
    font-weight: 400;
    color: var(--powdered-sugar);
    max-width: 55ch;
}

.body-text--secondary {
    margin-top: 1.2rem;
    color: var(--frosted-grape);
    font-size: 0.95rem;
}

.body-text strong,
.body-text b {
    font-weight: 500;
}

/* --- Narrative Blocks --- */
.narrative-block {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 8vh 0;
    position: relative;
    overflow: hidden;
}

.narrative-inner {
    position: relative;
    z-index: 2;
}

.section-label {
    display: block;
    margin-bottom: 1rem;
    color: var(--cyber-mint);
}

.timestamp-label {
    display: block;
    margin-top: 1.5rem;
    color: var(--bubblegum-haze);
    opacity: 0.7;
}

/* Zig-zag pixel border on narrative blocks (4px steps) */
.narrative-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: repeating-linear-gradient(
        90deg,
        var(--pixel-magenta) 0px,
        var(--pixel-magenta) 4px,
        transparent 4px,
        transparent 8px
    );
    opacity: 0.5;
    z-index: 1;
}

/* Bottom border for narrative blocks */
.narrative-block::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(
        90deg,
        var(--glitch-violet) 0px,
        var(--glitch-violet) 4px,
        transparent 4px,
        transparent 8px
    );
    opacity: 0.3;
    z-index: 1;
}

/* Pull Quote with zig-zag border and diagonal hash background */
.pull-quote-wrapper {
    margin: 2rem 0;
    padding: 2rem 2.5rem;
    position: relative;
    border-left: 4px solid var(--glitch-violet);
    /* Pixel-stepped dashed borders */
    border-top: 2px dashed var(--glitch-violet);
    border-bottom: 2px dashed var(--glitch-violet);
}

.pull-quote-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Diagonal hash lines: 45deg, 1px at 12px spacing, #FF2D7B at 15% opacity */
    background:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 11px,
            rgba(255, 45, 123, 0.15) 11px,
            rgba(255, 45, 123, 0.15) 12px
        );
    pointer-events: none;
}

.pull-quote {
    quotes: none;
}

/* --- Pixel Dissolve Mask --- */
.pixel-dissolve-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(auto-fill, 8px);
    grid-template-rows: repeat(auto-fill, 8px);
    overflow: hidden;
}

.pixel-dissolve-mask.revealed {
    display: none;
}

.pixel-cell {
    width: 8px;
    height: 8px;
    transition: opacity 0.1s ease;
}

.pixel-cell.cleared {
    opacity: 0;
}

/* --- Finale Section --- */
.finale-signal {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    position: relative;
}

.finale-content {
    text-align: center;
    max-width: 60ch;
}

.finale-title {
    margin-bottom: 2rem;
}

.finale-text {
    margin-bottom: 2rem;
    max-width: 45ch;
    margin-left: auto;
    margin-right: auto;
}

.finale-shapes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 2.5rem 0;
    flex-wrap: wrap;
}

.finale-shape {
    animation: finaleShapeFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(178, 75, 243, 0.4));
}

.finale-shape:nth-child(1) { animation-delay: 0s; }
.finale-shape:nth-child(2) { animation-delay: -0.75s; }
.finale-shape:nth-child(3) { animation-delay: -1.5s; }
.finale-shape:nth-child(4) { animation-delay: -2.25s; }

@keyframes finaleShapeFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(3deg); }
    50% { transform: translateY(-4px) rotate(-2deg); }
    75% { transform: translateY(-10px) rotate(1deg); }
}

.finale-label {
    display: block;
    margin-top: 1.5rem;
    color: var(--neon-coral);
    opacity: 0.8;
}

/* --- Floating Nav Sprite --- */
.nav-sprite {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-sprite:hover {
    transform: scale(1.2);
}

.nav-sprite-icon {
    display: block;
    filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.6));
    animation: spriteFloat 3s ease-in-out infinite;
}

@keyframes spriteFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Glitch-expand animation on hover */
.nav-sprite:hover .nav-sprite-icon {
    animation: spriteGlitch 0.3s steps(3) forwards, spriteFloat 3s ease-in-out infinite;
}

@keyframes spriteGlitch {
    0% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.6)); }
    33% { transform: translateY(-2px) scale(1.1) skewX(5deg); filter: drop-shadow(-2px 0 0 rgba(255, 45, 123, 0.5)) drop-shadow(2px 0 0 rgba(0, 245, 212, 0.5)); }
    66% { transform: translateY(1px) scale(1.15) skewX(-3deg); filter: drop-shadow(2px 0 0 rgba(255, 45, 123, 0.5)) drop-shadow(-2px 0 0 rgba(0, 245, 212, 0.5)); }
    100% { transform: translateY(-6px) scale(1.2); filter: drop-shadow(0 0 12px rgba(255, 209, 102, 0.8)); }
}

.nav-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1rem;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
    transform-origin: bottom right;
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-sprite:hover .nav-menu,
.nav-sprite.active .nav-menu {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.nav-menu-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(28, 16, 36, 0.85);
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s;
    text-decoration: none;
    border: 1px solid rgba(242, 233, 255, 0.15);
}

.nav-menu-item:hover {
    transform: scale(1.3);
    background: rgba(28, 16, 36, 0.95);
    border-color: var(--cyber-mint);
}

.nav-menu-item svg {
    width: 24px;
    height: 24px;
}

/* --- RGB Channel Split Effect --- */
.rgb-split {
    box-shadow:
        -3px 0 0 rgba(255, 0, 0, 0.3),
        3px 0 0 rgba(0, 0, 255, 0.3);
    animation: rgbSplit 0.2s ease-out;
}

@keyframes rgbSplit {
    0% {
        box-shadow:
            -3px 0 0 rgba(255, 0, 0, 0.4),
            3px 0 0 rgba(0, 0, 255, 0.4);
    }
    100% {
        box-shadow:
            0 0 0 rgba(255, 0, 0, 0),
            0 0 0 rgba(0, 0, 255, 0);
    }
}

/* --- Noise Panel animation states --- */
.noise-panel.frozen .noise-shape {
    animation-play-state: paused !important;
}

/* --- Shape rotation / float / pulse animations --- */
@keyframes shapeRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes shapeFloat {
    0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); }
    50% { transform: translateY(-15px) rotate(calc(var(--rot, 0deg) + 10deg)); }
}

@keyframes shapePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* --- Divider dissolve for finale (stepped pixel-dissolve) --- */
.zigzag-divider.dissolving {
    transition: opacity 0.8s steps(12);
    opacity: 0;
}

/* --- Glitch title hover animation --- */
.glitch-title:hover .glitch-layer--shift {
    animation: glitchShiftDance 0.5s steps(4) infinite;
}

@keyframes glitchShiftDance {
    0% { transform: translate(3px, 2px); }
    25% { transform: translate(-2px, -1px); }
    50% { transform: translate(1px, 3px); }
    75% { transform: translate(-3px, 1px); }
    100% { transform: translate(2px, -2px); }
}

/* --- Section heading hover effects --- */
.glitch-heading:hover .glitch-layer--shift {
    animation: headingGlitch 0.4s steps(3) infinite;
}

@keyframes headingGlitch {
    0% { transform: translate(2px, 2px); color: var(--neon-coral); }
    33% { transform: translate(-1px, -1px); color: var(--cyber-mint); }
    66% { transform: translate(3px, 0px); color: var(--pixel-magenta); }
    100% { transform: translate(-2px, 1px); color: var(--electric-lemon); }
}

/* --- Responsive adjustments --- */
@media (max-width: 768px) {
    .split-container {
        grid-template-columns: 1fr;
    }

    .noise-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        z-index: 0;
        opacity: 0.3;
    }

    .signal-panel {
        z-index: 2;
        background: rgba(28, 16, 36, 0.88);
        background-image: none;
    }

    .zigzag-divider {
        display: none;
    }

    .glitch-title {
        font-size: clamp(2.5rem, 12vw, 5rem);
    }

    .glitch-heading {
        font-size: clamp(1.5rem, 8vw, 3rem);
    }

    .bungee-text {
        font-size: clamp(1.4rem, 6vw, 2.5rem);
    }

    .nav-sprite {
        bottom: 1rem;
        right: 1rem;
    }

    .finale-shapes {
        gap: 1rem;
    }

    .finale-shape {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .signal-panel {
        padding: 0 1.25rem;
    }

    .narrative-block {
        min-height: 40vh;
        padding: 6vh 0;
    }

    .body-text {
        font-size: 0.95rem;
    }

    .pull-quote-wrapper {
        padding: 1.25rem;
    }

    .hero-tagline {
        display: none;
    }
}
