/* ========================================
   haskell.monster - Burgundy & Cream
   Mid-century editorial / aquatic laboratory
   ======================================== */

/* ---- CSS Custom Properties ---- */
:root {
    --deep-burgundy: #8b2942;
    --dark-burgundy-brown: #3d2027;
    --terracotta: #c97d60;
    --warm-cream: #f7ede2;
    --ivory-white: #faf6f0;
    --blush-pink: #e8c4b8;
    --muted-gold: #d4a843;
    --deep-slate: #2c1f24;
    --scroll-y: 0;
    --section-progress: 0;
}

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

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

body {
    background-color: var(--warm-cream);
    color: var(--dark-burgundy-brown);
    font-family: 'Libre Baskerville', Georgia, serif;
    line-height: 1.72;
    overflow-x: hidden;
}

/* ---- Spine Navigation ---- */
.spine {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background-color: var(--deep-burgundy);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.6s ease;
}

.spine-symbol {
    font-family: 'Abril Fatface', serif;
    font-size: 1.5rem;
    color: var(--warm-cream);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 0.05em;
    transition: transform 0.3s ease;
}

.spine-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background-color: var(--terracotta);
    opacity: 0.4;
    transition: height 0.1s linear;
}

/* ---- Spine Overlay ---- */
.spine-overlay {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--deep-slate);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.spine-overlay.is-open {
    left: 48px;
}

.spine-overlay-content {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
    padding: 2rem;
}

.spine-link {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--blush-pink);
    text-decoration: none;
    transition: color 0.3s ease;
}

.spine-link:hover {
    color: var(--warm-cream);
}

/* ---- Spread Layout ---- */
.spread {
    position: relative;
    min-height: 100vh;
    padding-left: 48px;
    overflow: hidden;
}

.spread-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 3rem;
    gap: 3rem;
}

/* ---- Verso (Left - Content) ---- */
.verso {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 2rem;
    opacity: 0;
    transform: translateX(-60px);
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.9s ease;
}

.verso.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* ---- Recto (Right - Visual) ---- */
.recto {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateX(60px);
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.9s ease;
    transition-delay: 0.2s;
}

.recto.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* ---- Typography ---- */
.display-title {
    font-family: 'Abril Fatface', serif;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--deep-burgundy);
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.display-title-accent {
    color: var(--terracotta);
}

.section-heading {
    font-family: 'Abril Fatface', serif;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--deep-burgundy);
    line-height: 1.15;
    margin-bottom: 1.5rem;
}

.body-prose {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    font-weight: 400;
    line-height: 1.72;
    color: var(--dark-burgundy-brown);
    max-width: 38em;
    margin-bottom: 1.2rem;
}

.body-prose em {
    font-style: italic;
    color: var(--deep-burgundy);
}

.caption-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--terracotta);
    margin-top: 1rem;
}

.oversized-type {
    font-family: 'Abril Fatface', serif;
    font-size: clamp(4rem, 12vw, 10rem);
    font-weight: 400;
    color: var(--deep-burgundy);
    line-height: 1;
    letter-spacing: -0.02em;
}

/* ---- Code Blocks ---- */
.code-block {
    background-color: var(--warm-cream);
    border-left: 3px solid var(--terracotta);
    padding: 1.2rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.code-block:hover {
    border-left-color: var(--deep-burgundy);
    background-color: var(--ivory-white);
}

.code-block code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.92em;
    font-weight: 400;
    display: block;
    line-height: 1.7;
    color: var(--dark-burgundy-brown);
}

.code-keyword {
    color: var(--deep-burgundy);
    font-weight: 600;
}

.code-operator {
    color: var(--terracotta);
}

.inline-code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.92em;
    background-color: var(--ivory-white);
    padding: 0.1em 0.4em;
    border-radius: 3px;
    color: var(--deep-burgundy);
}

/* ---- Lambda Watermark ---- */
.lambda-watermark {
    position: absolute;
    font-family: 'Abril Fatface', serif;
    font-size: 20vw;
    color: var(--deep-burgundy);
    opacity: 0.04;
    z-index: 0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

/* ---- Bubble System ---- */
.bubble-cluster {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
}

.bubble {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(232, 196, 184, 0.6), rgba(139, 41, 66, 0.15));
    border: 1px solid rgba(139, 41, 66, 0.2);
    box-shadow: inset 0 -4px 12px rgba(139, 41, 66, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    animation: wobble var(--duration) ease-in-out var(--delay) infinite;
    transform: translate(-50%, -50%);
}

.bubble::before {
    content: '';
    position: absolute;
    top: 18%;
    left: 22%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    filter: blur(2px);
}

@keyframes wobble {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    25% { transform: translate(calc(-50% + 2px), calc(-50% - 3px)) scale(1.02); }
    50% { transform: translate(calc(-50% - 1px), calc(-50% + 2px)) scale(0.98); }
    75% { transform: translate(calc(-50% + 3px), calc(-50% + 1px)) scale(1.01); }
}

/* ---- Fold Lines ---- */
.fold-line {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
    padding-left: 48px;
}

.fold-line::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 48px;
    right: 0;
    height: 1px;
    background-color: rgba(139, 41, 66, 0.3);
    transform: scaleX(0);
    transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: center;
}

.fold-line.is-visible::before {
    transform: scaleX(1);
}

.fold-line::after {
    content: attr(data-label);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--terracotta);
    background-color: var(--warm-cream);
    padding: 0 1rem;
    position: relative;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease 0.3s;
}

.fold-line.is-visible::after {
    opacity: 1;
}

.fold-type-sig {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--terracotta);
    opacity: 0.4;
    position: relative;
    z-index: 1;
    background-color: var(--warm-cream);
    padding: 0 0.5rem;
    margin-top: 0.3rem;
}

/* ---- Diamond Ornament ---- */
.fold-line .fold-type-sig::before {
    content: '◇';
    margin-right: 0.5rem;
    font-size: 0.6rem;
}

.fold-line .fold-type-sig::after {
    content: '◇';
    margin-left: 0.5rem;
    font-size: 0.6rem;
}

/* ---- Decorative Starburst ---- */
.decorative-starburst {
    position: absolute;
    left: var(--x);
    top: var(--y);
    width: 24px;
    height: 24px;
    opacity: 0.6;
}

.decorative-starburst::before {
    content: '✳';
    font-size: 24px;
    color: var(--terracotta);
    position: absolute;
    top: 0;
    left: 0;
}

/* ---- Monster Badge ---- */
.monster-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--muted-gold);
    font-family: 'Abril Fatface', serif;
    font-size: 2rem;
    color: var(--muted-gold);
    margin-top: 2rem;
}

/* ---- Category Diagram ---- */
.category-diagram {
    position: absolute;
    bottom: 10%;
    right: 5%;
    width: 160px;
    height: 160px;
    opacity: 0.5;
}

/* ---- Footer ---- */
.footer {
    background-color: var(--deep-slate);
    padding: 3rem;
    padding-left: calc(48px + 3rem);
    text-align: center;
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.footer-lambda {
    font-family: 'Abril Fatface', serif;
    font-size: 1.5rem;
    color: var(--deep-burgundy);
}

.footer-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--blush-pink);
}

.footer-type-sig {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--terracotta);
    opacity: 0.6;
}

/* ---- Breathing Spreads ---- */
.spread--breathing .spread-inner {
    align-items: center;
}

.spread--breathing .verso {
    text-align: center;
    align-items: center;
    padding-right: 0;
}

/* ---- Dense Spreads ---- */
.spread--dense .spread-inner {
    align-items: start;
    padding-top: 6rem;
}

/* ---- Diagonal Rule ---- */
.spread--dense .verso::after {
    content: '';
    display: block;
    width: 60px;
    height: 1px;
    background-color: var(--terracotta);
    opacity: 0.4;
    transform: rotate(7deg);
    margin-top: 1.5rem;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
    .spine {
        width: 36px;
    }

    .spread {
        padding-left: 36px;
    }

    .spread-inner {
        grid-template-columns: 1fr;
        padding: 3rem 1.5rem;
        gap: 2rem;
    }

    .verso {
        padding-right: 0;
        transform: translateY(30px);
    }

    .verso.is-visible {
        transform: translateY(0);
    }

    .recto {
        transform: translateY(30px);
    }

    .recto.is-visible {
        transform: translateY(0);
    }

    .fold-line {
        padding-left: 36px;
    }

    .fold-line::before {
        left: 36px;
    }

    .footer {
        padding-left: calc(36px + 1.5rem);
    }

    .spine-overlay {
        width: 250px;
    }

    .spine-overlay.is-open {
        left: 36px;
    }

    .bubble-cluster {
        min-height: 300px;
    }

    .oversized-type {
        font-size: clamp(3rem, 15vw, 6rem);
    }

    .spread--breathing .verso {
        text-align: left;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .spread-inner {
        padding: 2rem 1rem;
    }

    .display-title {
        font-size: clamp(2rem, 8vw, 3rem);
    }

    .section-heading {
        font-size: clamp(1.5rem, 5vw, 2rem);
    }
}
