/* ============================================
   haskell.quest — The Proof
   Scholarly terminal honeycomb
   ============================================ */

:root {
    --void-black: #0F0F0A;
    --deep-parchment: #1C1C14;
    --warm-parchment: #E8DCC8;
    --aged-paper: #C4B998;
    --dark-gold: #B8860B;
    --terminal-sage: #7B9971;
    --haskell-green: #4A6741;
    --muted-umber: #3A3A2E;
    --bright-gold: #D4A847;
    --deep-crimson: #8B3A3A;
    --code-bg: #0C0C08;
    --inline-code-bg: #1A1A12;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.72;
    color: var(--aged-paper);
    background: var(--void-black);
    overflow-x: hidden;
}

/* --- Hex Background Pattern --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.15;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100'%3E%3Cpath d='M28 66L0 50V16l28-16 28 16v34L28 66zm0-32l28-16v34L28 66 0 50V16l28 16z' fill='none' stroke='%233A3A2E' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: 56px 100px;
}

/* --- Evaluation Spine --- */
#spine {
    position: fixed;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    pointer-events: none;
}

.spine-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: var(--dark-gold);
    opacity: 0.6;
}

.spine-node {
    width: 16px;
    height: 16px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: transparent;
    border: 1px solid var(--dark-gold);
    position: relative;
    z-index: 1;
    cursor: pointer;
    pointer-events: auto;
    animation: spine-pulse 3s ease-in-out infinite;
    text-decoration: none;
}

.spine-node.active {
    background: var(--dark-gold);
    opacity: 1;
}

@keyframes spine-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* --- Type Signature Bar --- */
#type-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 36px;
    background: var(--code-bg);
    border-top: 1px solid var(--muted-umber);
    display: flex;
    align-items: center;
    padding: 0 24px;
    z-index: 100;
}

#type-sig {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--terminal-sage);
    font-feature-settings: "liga" 1, "calt" 1;
}

/* --- Proof Sections --- */
.proof-section {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 100px 8% 80px;
}

/* Section Label */
.section-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
}

.section-glyph {
    width: 20px;
    height: 20px;
}

.section-label h2 {
    font-family: 'Bitter', serif;
    font-weight: 700;
    font-size: clamp(1.6rem, 3.5vw, 3rem);
    color: var(--warm-parchment);
    letter-spacing: 0.01em;
}

/* ===========================
   AXIOM
   =========================== */
#axiom {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.axiom-layout {
    display: flex;
    align-items: center;
    gap: 60px;
    max-width: 900px;
    width: 100%;
}

.axiom-text {
    flex: 1;
}

.wordmark {
    font-family: 'Bitter', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--warm-parchment);
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 1s ease;
}

.wordmark.visible {
    opacity: 1;
}

.axiom-subtitle {
    font-family: 'Source Sans 3', sans-serif;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--aged-paper);
    margin-top: 12px;
    opacity: 0;
    transition: opacity 1s ease;
}

.axiom-subtitle.visible {
    opacity: 1;
}

.axiom-lambda {
    flex-shrink: 0;
}

#hero-lambda {
    width: clamp(120px, 20vw, 200px);
    height: auto;
}

#lambda-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2.4s cubic-bezier(0.25, 0.1, 0.25, 1), stroke 1s ease;
}

#lambda-path.drawn {
    stroke-dashoffset: 0;
}

/* ===========================
   HEX GRID
   =========================== */
.hex-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.hex-grid-dense {
    grid-template-columns: repeat(3, 1fr);
}

.hex-cell {
    background: var(--deep-parchment);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    padding: 3rem 2rem;
    text-align: center;
    border: 1px solid var(--muted-umber);
    box-shadow: 0 0 12px rgba(184, 134, 11, 0.08);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hex-cell.visible {
    opacity: 1;
    transform: scale(1);
}

.hex-cell h3 {
    font-family: 'Bitter', serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--warm-parchment);
    margin-bottom: 10px;
}

.hex-cell p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--aged-paper);
    margin-bottom: 12px;
    max-width: 260px;
}

.hex-cell code {
    display: block;
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--terminal-sage);
    background: var(--code-bg);
    border-left: 3px solid var(--dark-gold);
    padding: 8px 12px;
    text-align: left;
    line-height: 1.55;
    font-feature-settings: "liga" 1, "calt" 1;
    width: 100%;
    max-width: 260px;
}

.hex-cell-large {
    grid-column: span 1;
    min-height: 320px;
}

/* Type arrows */
.type-arrows {
    width: 80%;
    max-width: 600px;
    height: 40px;
    margin: 20px auto;
    display: block;
    opacity: 0.5;
}

.arrow-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.5s ease;
}

.arrow-path.drawn {
    stroke-dashoffset: 0;
}

/* --- Lemma Signature --- */
.lemma-sig-block {
    text-align: center;
    margin-bottom: 40px;
}

.big-signature {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.5rem);
    color: var(--terminal-sage);
    font-feature-settings: "liga" 1, "calt" 1;
}

/* ===========================
   Q.E.D.
   =========================== */
.qed-final {
    display: flex;
    justify-content: center;
    margin-bottom: 60px;
}

.hex-cell-final {
    min-height: 360px;
    max-width: 400px;
    padding: 3.5rem 2rem;
}

.final-code {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--terminal-sage);
    line-height: 1.6;
    text-align: left;
    font-feature-settings: "liga" 1, "calt" 1;
}

.turnstile {
    text-align: center;
    margin: 40px 0;
    opacity: 0;
    transition: opacity 1s ease;
}

.turnstile.visible {
    opacity: 1;
}

.turnstile svg {
    width: 40px;
    height: 40px;
}

.closing-statement {
    font-family: 'Bitter', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    color: var(--dark-gold);
    text-align: center;
    margin-bottom: 60px;
}

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

.final-lambda svg {
    width: clamp(80px, 15vw, 160px);
    height: auto;
    animation: slow-rotate 60s linear infinite;
}

@keyframes slow-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    .hex-cell {
        opacity: 1;
        transform: none;
    }

    .wordmark,
    .axiom-subtitle {
        opacity: 1;
    }

    .turnstile {
        opacity: 1;
    }

    #lambda-path {
        stroke-dashoffset: 0;
    }

    .arrow-path {
        stroke-dashoffset: 0;
    }

    .final-lambda svg {
        animation: none;
    }

    .spine-node {
        animation: none;
        opacity: 0.6;
    }
}

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

    .hex-cell {
        clip-path: none;
        border-radius: 8px;
        min-height: auto;
        padding: 2rem 1.5rem;
    }

    .axiom-layout {
        flex-direction: column;
        text-align: center;
    }

    #spine {
        display: none;
    }

    .proof-section {
        padding: 80px 5% 60px;
    }

    #type-bar {
        display: none;
    }
}
