/* ============================================================
   namu.farm — Forgotten Agricultural Research Station
   Palette: honeyed-neutral earth tones with neon punctuation
   Fonts: Nunito (display), Varela Round (secondary), Karla (body), Caveat (annotations)
   Layout: magazine-spread snap-scroll with hand-drawn aesthetics
   ============================================================ */

/* --- CSS CUSTOM PROPERTIES --- */
:root {
    --deep-loam: #2A2218;
    --linen-honey: #E8DCC4;
    --clay-ochre: #C4956A;
    --sage-dust: #A8A892;
    --walnut-shell: #8B7355;
    --parchment: #F0EBE3;
    --neon-coral: #FF6B4A;
    --amber-glow: #FFD166;

    --font-display: 'Nunito', sans-serif;
    --font-secondary: 'Varela Round', sans-serif;
    --font-body: 'Karla', sans-serif;
    --font-annotation: 'Caveat', cursive;

    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    overflow-x: hidden;
    scroll-behavior: auto;
}

body {
    background-color: var(--deep-loam);
    color: var(--parchment);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.8;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- PAPER GRAIN OVERLAY --- */
.paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.05;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1px,
            rgba(139, 115, 85, 0.3) 1px,
            rgba(139, 115, 85, 0.3) 2px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(139, 115, 85, 0.2) 2px,
            rgba(139, 115, 85, 0.2) 3px
        );
}

/* --- SCROLL PROGRESS INDICATOR --- */
.scroll-track {
    position: fixed;
    top: 10vh;
    right: 20px;
    width: 6px;
    height: 80vh;
    z-index: 500;
}

.scroll-track-svg {
    width: 100%;
    height: 100%;
}

.scroll-progress-marker {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neon-coral);
    box-shadow: 0 0 8px rgba(255, 107, 74, 0.5);
    transition: top 0.15s var(--ease-smooth);
}

/* --- SNAP-SCROLL CONTAINER --- */
.spreads-container {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    height: 100vh;
    scroll-behavior: smooth;
}

/* --- SPREAD BASE --- */
.spread {
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spread-inner {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- TWO-PAGE SPREAD LAYOUT --- */
.spread-two-page {
    display: grid;
    grid-template-columns: 5fr 1fr 6fr;
    max-width: 1440px;
    margin: 0 auto;
    padding: 4rem 3rem;
    gap: 0;
    align-items: center;
}

.page {
    padding: 2rem;
}

.page-left {
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-right {
    padding-left: 2rem;
}

/* --- GUTTER --- */
.gutter {
    display: flex;
    align-items: stretch;
    justify-content: center;
    height: 80%;
    align-self: center;
}

.gutter-vine {
    width: 20px;
    height: 100%;
}

/* --- TYPOGRAPHY --- */
h1, h2 {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: var(--parchment);
}

.hero-title {
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    color: var(--parchment);
    text-shadow: 0 0 40px rgba(255, 107, 74, 0.15);
}

.spread-title {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    margin-bottom: 0.5rem;
    color: var(--linen-honey);
}

.section-label {
    font-family: var(--font-secondary);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--clay-ochre);
    display: block;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.body-text {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.8;
    color: var(--linen-honey);
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.body-text.revealed {
    opacity: 0.92;
    transform: translateY(0);
}

.body-text em {
    font-weight: 700;
    color: var(--clay-ochre);
    font-style: normal;
}

/* --- ANNOTATION / MARGINALIA (Caveat font) --- */
.annotation-note {
    font-family: var(--font-annotation);
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--sage-dust);
    margin-top: 2rem;
    opacity: 0.65;
    display: inline-block;
}

.annotation-float {
    animation: annotationDrift 6s ease-in-out infinite alternate;
}

@keyframes annotationDrift {
    0% { transform: translateY(0px) rotate(var(--rotate, 2deg)); }
    100% { transform: translateY(-3px) rotate(var(--rotate, 2deg)); }
}

/* --- SIGNATURE GRADIENT LINE --- */
.signature-gradient {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, #C4956A, #A8A892, #8B7355);
    margin: 1rem 0 2rem 0;
    border-radius: 1px;
}

/* --- SVG TEXT CLASSES --- */
.svg-annotation {
    font-family: 'Caveat', cursive;
}

.svg-label {
    font-family: 'Varela Round', sans-serif;
    letter-spacing: 0.04em;
}

/* --- SPREAD 1: HERO --- */
.spread-hero {
    background: var(--deep-loam);
}

.mountain-system {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.mountain-layer {
    transition: transform 0.8s var(--ease-smooth);
}

.hero-identity {
    position: relative;
    z-index: 10;
    text-align: center;
    transform: translateY(-10vh);
}

.hero-annotation {
    font-family: var(--font-annotation);
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--sage-dust);
    margin-top: 0.8rem;
    opacity: 0.6;
}

/* Ambient particle field */
.particle-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat var(--duration, 8s) var(--delay, 0s) ease-in-out infinite alternate;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(0) translateX(0);
    }
    30% {
        opacity: var(--max-opacity, 0.4);
    }
    70% {
        opacity: var(--max-opacity, 0.4);
    }
    100% {
        opacity: 0;
        transform: translateY(var(--drift-y, -30px)) translateX(var(--drift-x, 10px));
    }
}

/* --- NEON GLOW PULSE --- */
.neon-ridgeline {
    animation: neonPulse 10s ease-in-out infinite alternate;
}

.neon-ridgeline-c {
    animation: neonPulse 12s ease-in-out infinite alternate;
}

@keyframes neonPulse {
    0% {
        opacity: 0.3;
        filter: url(#glow-coral);
    }
    100% {
        opacity: 0.55;
        filter: url(#glow-coral);
    }
}

.glow-pulse {
    animation: glowBreathe 8s ease-in-out infinite alternate;
}

@keyframes glowBreathe {
    0% { opacity: 0.2; }
    100% { opacity: 0.6; }
}

/* --- SPREAD 2: BOTANICAL --- */
.spread-botanical {
    background: var(--deep-loam);
}

.botanical-svg {
    max-width: 380px;
    width: 100%;
    height: auto;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.botanical-svg.revealed {
    opacity: 1;
}

.root-path {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.8s ease-out;
}

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

/* --- SPREAD 3: DATA --- */
.spread-data {
    background: var(--deep-loam);
}

.field-diagram {
    max-width: 420px;
    width: 100%;
    height: auto;
}

/* Magnetic field line animation */
.mag-field-line {
    stroke-dashoffset: 0;
    animation: fieldFlow 25s linear infinite;
}

.mag-field-line.mag-reverse {
    animation: fieldFlow 30s linear infinite reverse;
}

@keyframes fieldFlow {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 500; }
}

/* --- SPREAD 4: CONTEMPLATIVE --- */
.spread-contemplative {
    background: var(--deep-loam);
}

.contemplative-mountains {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.mountain-layer-c {
    transition: transform 0.8s var(--ease-smooth);
}

.contemplative-text {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 600px;
    transform: translateY(-5vh);
}

.contemplative-quote {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    line-height: 1.4;
    color: var(--parchment);
    letter-spacing: -0.01em;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.contemplative-quote.revealed {
    opacity: 0.95;
    transform: translateY(0);
}

/* --- SPREAD 5: COLOPHON --- */
.spread-colophon {
    background: var(--deep-loam);
}

.colophon-content {
    position: relative;
    z-index: 10;
    text-align: center;
    max-width: 600px;
    padding: 2rem;
}

.colophon-title {
    font-family: var(--font-secondary);
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--clay-ochre);
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.colophon-content .signature-gradient {
    margin: 0.5rem auto 2rem auto;
}

.colophon-text {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 1vw, 1.05rem);
    line-height: 1.85;
    color: var(--linen-honey);
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.colophon-text em {
    font-style: italic;
    color: var(--clay-ochre);
}

.colophon-ornament {
    margin: 2rem 0;
    display: flex;
    justify-content: center;
}

.colophon-domain {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--parchment);
    letter-spacing: -0.01em;
    margin-top: 1rem;
    opacity: 0.7;
}

/* Fade to black overlay at bottom of colophon */
.colophon-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.6));
    pointer-events: none;
    z-index: 5;
}

/* --- INK-BLEED TEXT REVEAL (via JS class toggle) --- */
.spread .page-right .spread-title,
.spread .page-left .spread-title {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.spread .page-right .section-label,
.spread .page-left .section-label {
    opacity: 0;
    transition: opacity 0.5s ease-out 0.1s;
}

.spread.in-view .page-right .spread-title,
.spread.in-view .page-left .spread-title {
    opacity: 1;
    transform: translateY(0);
}

.spread.in-view .page-right .section-label,
.spread.in-view .page-left .section-label {
    opacity: 0.8;
}

/* Hand-drawn border draw-in animation for signature gradient */
.signature-gradient {
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.8s ease-out 0.2s;
}

.spread.in-view .signature-gradient {
    transform: scaleX(1);
}

/* --- RESPONSIVE: BELOW 768px --- */
@media (max-width: 768px) {
    .spread-two-page {
        grid-template-columns: 1fr;
        padding: 2rem 1.5rem;
        gap: 1rem;
    }

    .gutter {
        height: 40px;
        width: 80%;
        justify-self: center;
    }

    .gutter-vine {
        width: 100%;
        height: 20px;
    }

    .page {
        padding: 1rem 0;
    }

    .page-left {
        order: -1;
    }

    .page-right {
        padding-left: 0;
    }

    .botanical-svg {
        max-width: 260px;
    }

    .field-diagram {
        max-width: 300px;
    }

    .hero-identity {
        transform: translateY(-5vh);
    }

    .scroll-track {
        right: 10px;
        width: 4px;
    }

    .contemplative-text {
        padding: 0 1.5rem;
    }
}

/* --- RESPONSIVE: BELOW 480px --- */
@media (max-width: 480px) {
    .spread-two-page {
        padding: 1.5rem 1rem;
    }

    .botanical-svg {
        max-width: 200px;
    }

    .field-diagram {
        max-width: 240px;
    }

    .scroll-track {
        display: none;
    }

    .particle-field {
        display: none;
    }

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

    .contemplative-quote {
        font-size: clamp(1.3rem, 5vw, 2rem);
    }
}

/* --- REDUCED MOTION --- */
@media (prefers-reduced-motion: reduce) {
    .neon-ridgeline,
    .neon-ridgeline-c,
    .glow-pulse,
    .annotation-float,
    .mag-field-line,
    .particle {
        animation: none;
    }

    .neon-ridgeline,
    .neon-ridgeline-c {
        opacity: 0.4;
    }

    .glow-pulse {
        opacity: 0.4;
    }

    .body-text,
    .contemplative-quote,
    .spread .page-right .spread-title,
    .spread .page-left .spread-title,
    .spread .page-right .section-label,
    .spread .page-left .section-label,
    .botanical-svg,
    .signature-gradient {
        opacity: 1;
        transform: none;
        transition: opacity 0.3s ease;
    }

    .spreads-container {
        scroll-snap-type: none;
    }
}

/* --- PRINT --- */
@media print {
    .scroll-track,
    .particle-field,
    .paper-grain,
    .colophon-fade {
        display: none;
    }

    .spreads-container {
        scroll-snap-type: none;
        height: auto;
        overflow: visible;
    }

    .spread {
        height: auto;
        page-break-after: always;
    }
}
