/* ============================================
   haskell.monster — Descending into the Type System
   Glitch-infected academic manuscript
   ============================================ */

:root {
    --deep-abyss: #0B0A10;
    --manuscript-cream: #F5F0E6;
    --electric-violet: #7B2FBE;
    --spectral-cyan: #00D4AA;
    --bone-white: #E8E4DC;
    --bruised-violet: #1A0A2E;
    --graphite-whisper: #3D3A4A;
    --ember-warning: #D4533B;
}

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

html {
    scroll-behavior: smooth;
    scroll-snap-type: y proximity;
}

body {
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.85;
    color: var(--bone-white);
    background: var(--deep-abyss);
    overflow-x: hidden;
}

/* --- Scanline Overlay --- */
#scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 3px,
        rgba(232, 228, 220, 0.015) 3px,
        rgba(232, 228, 220, 0.015) 4px
    );
}

/* --- Ghost Type Signatures --- */
#ghost-signatures {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.ghost-sig {
    position: absolute;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--graphite-whisper);
    opacity: 0.12;
    white-space: nowrap;
    transform: translateY(0);
    transition: transform 0.1s linear;
}

/* --- Zones --- */
.zone {
    position: relative;
    z-index: 2;
    scroll-snap-align: start;
}

/* --- Chromatic Aberration Headings --- */
.glitch-heading {
    position: relative;
    display: inline-block;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.04em;
}

.glitch-v, .glitch-c, .glitch-b {
    display: block;
}

.glitch-v {
    color: var(--electric-violet);
    position: absolute;
    top: 0;
    left: 0;
    mix-blend-mode: screen;
    animation: glitch-shift-v 10s ease-in-out infinite;
}

.glitch-c {
    color: var(--spectral-cyan);
    position: absolute;
    top: 0;
    left: 0;
    mix-blend-mode: screen;
    animation: glitch-shift-c 10s ease-in-out infinite;
}

.glitch-b {
    color: var(--bone-white);
    position: relative;
}

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

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

/* ===========================
   ZONE 1: THE LAMBDA GATE
   =========================== */
#lambda-gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--deep-abyss);
}

.lambda-hero {
    text-align: center;
}

.lambda-glyph {
    position: relative;
    display: inline-block;
    height: 200px;
    width: 200px;
    margin-bottom: 40px;
}

.lambda-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 180px;
    line-height: 200px;
    text-align: center;
    mix-blend-mode: screen;
}

.lambda-violet {
    color: var(--electric-violet);
    animation: lambda-glitch-v 8s ease-in-out infinite;
}

.lambda-cyan {
    color: var(--spectral-cyan);
    animation: lambda-glitch-c 8s ease-in-out infinite;
}

.lambda-bone {
    color: var(--bone-white);
}

@keyframes lambda-glitch-v {
    0%, 100% { transform: translate(-3px, -2px); }
    30% { transform: translate(-4px, 0px); }
    60% { transform: translate(-2px, -3px); }
    80% { transform: translate(-4px, 1px); }
}

@keyframes lambda-glitch-c {
    0%, 100% { transform: translate(3px, 2px); }
    30% { transform: translate(4px, 0px); }
    60% { transform: translate(2px, 3px); }
    80% { transform: translate(3px, -1px); }
}

.hero-title {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    letter-spacing: 0.15em;
    color: var(--bone-white);
    margin-bottom: 24px;
    opacity: 0;
    transition: opacity 600ms ease;
}

.hero-title.visible {
    opacity: 1;
}

.hero-sig {
    opacity: 0;
    transition: opacity 800ms ease;
}

.hero-sig.visible {
    opacity: 1;
}

.hero-sig code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--spectral-cyan);
}

/* ===========================
   ZONE 2: THE TYPE LATTICE
   =========================== */
#type-lattice {
    padding: 120px 5%;
}

.lattice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    max-width: 1100px;
    margin: 0 auto;
}

.lattice-panel {
    padding: 40px 36px;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transition: opacity 500ms ease, transform 500ms ease;
}

.lattice-panel.visible {
    opacity: 1;
    transform: rotate(0deg) !important;
}

.panel-dark {
    background: var(--deep-abyss);
    border: 1px solid var(--graphite-whisper);
    color: var(--bone-white);
}

.panel-light {
    background: var(--manuscript-cream);
    color: var(--deep-abyss);
}

.panel-tilt-r {
    transform: rotate(0.5deg);
}

.panel-tilt-l {
    transform: rotate(-0.4deg);
}

.panel-offset {
    margin-top: 40px;
}

.lambda-watermark {
    position: absolute;
    top: -20px;
    right: -10px;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 180px;
    color: var(--electric-violet);
    opacity: 0.06;
    transform: rotate(15deg);
    pointer-events: none;
    line-height: 1;
}

.lattice-panel h2 {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.6rem, 3.5vw, 3rem);
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}

.panel-dark h2 {
    color: var(--bone-white);
}

.panel-light h2 {
    color: var(--deep-abyss);
}

.lattice-panel p {
    margin-bottom: 20px;
}

.panel-code {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--spectral-cyan);
    background: var(--deep-abyss);
    border-left: 3px solid var(--electric-violet);
    padding: 16px 20px;
    margin-top: 16px;
    line-height: 1.6;
}

.panel-code-light {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--deep-abyss);
    background: rgba(11, 10, 16, 0.05);
    border-left: 3px solid var(--electric-violet);
    padding: 16px 20px;
    margin-top: 16px;
    line-height: 1.6;
}

/* ===========================
   ZONE 3: THE RECURSION CORRIDOR
   =========================== */
#recursion-corridor {
    padding: 120px 5%;
    display: flex;
    justify-content: center;
}

.corridor-inner {
    max-width: 80vw;
    width: 100%;
    transition: max-width 600ms ease;
}

.corridor-block {
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.corridor-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.corridor-heading {
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    margin-bottom: 12px;
}

.corridor-code {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--spectral-cyan);
    background: var(--deep-abyss);
    border-left: 3px solid var(--electric-violet);
    padding: 12px 16px;
    margin-bottom: 16px;
    line-height: 1.6;
}

.corridor-block p {
    color: var(--bone-white);
    max-width: 600px;
}

.glitch-rule {
    border: none;
    height: 1px;
    background: var(--graphite-whisper);
    margin-top: 40px;
    position: relative;
    overflow: hidden;
}

.glitch-rule::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 30%;
    height: 100%;
    background: var(--spectral-cyan);
    animation: rule-glitch 4s infinite linear;
}

@keyframes rule-glitch {
    0% { left: -30%; }
    100% { left: 130%; }
}

/* ===========================
   ZONE 4: THE MONSTER CHAMBER
   =========================== */
#monster-chamber {
    min-height: 100vh;
    padding: 120px 5%;
    background: linear-gradient(180deg, var(--deep-abyss) 0%, var(--bruised-violet) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chamber-title {
    text-align: center;
    margin-bottom: 60px;
}

.chamber-heading {
    font-size: clamp(2rem, 4vw, 3.5rem);
    margin-bottom: 12px;
}

.chamber-subtitle {
    font-family: 'Source Serif 4', serif;
    font-size: 1rem;
    color: var(--graphite-whisper);
}

.constellation-container {
    width: 100%;
    max-width: 800px;
    position: relative;
}

#constellation {
    width: 100%;
    height: auto;
}

.constellation-edges line {
    stroke: var(--graphite-whisper);
    stroke-width: 1;
    transition: stroke 200ms ease;
}

.constellation-edges line.highlight {
    stroke: var(--electric-violet);
}

.constellation-nodes circle {
    fill: var(--graphite-whisper);
    cursor: pointer;
    transition: fill 200ms ease, r 200ms ease;
}

.constellation-nodes circle:hover {
    fill: var(--electric-violet);
    r: 6;
}

.node-tooltip {
    position: absolute;
    background: var(--deep-abyss);
    border: 1px solid var(--electric-violet);
    color: var(--spectral-cyan);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    padding: 8px 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    white-space: nowrap;
    z-index: 100;
}

.node-tooltip.visible {
    opacity: 1;
}

.chamber-cta {
    margin-top: 60px;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-style: italic;
    font-size: 1.3rem;
    color: var(--bone-white);
    opacity: 0.6;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .lambda-violet,
    .lambda-cyan {
        animation: none;
        transform: translate(-2px, -1px);
    }

    .lambda-cyan {
        transform: translate(2px, 1px);
    }

    .glitch-v,
    .glitch-c {
        animation: none;
    }

    .glitch-rule::after {
        animation: none;
    }

    #scanlines {
        display: none;
    }

    .ghost-sig {
        display: none;
    }

    .hero-title,
    .hero-sig {
        opacity: 1;
    }

    .lattice-panel {
        opacity: 1;
    }

    .corridor-block {
        opacity: 1;
        transform: none;
    }
}

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

    .panel-offset {
        margin-top: 0;
    }

    .lambda-glyph {
        height: 120px;
        width: 120px;
    }

    .lambda-layer {
        font-size: 110px;
        line-height: 120px;
    }

    .corridor-inner {
        max-width: 95vw !important;
    }

    .pipeline-container {
        flex-direction: column;
    }
}
