:root {
    /* Palette */
    --deep-bg: #0e1a28;
    --surface: #1a2840;
    --midtone: #3a5a78;
    --text-primary: #c8dff0;
    --text-secondary: #8fa4b8;
    --accent-warm: #8b6842;
    --accent-bright: #40e0d0;
    --light-surface: #e8eef4;
    --ornament: #5e9e8f;
    --deep-slate: #3d5166;
    --twilight: #6b8faa;

    /* Typography */
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Nunito Sans', 'Helvetica Neue', sans-serif;
    --font-mono: 'Inconsolata', 'Courier New', monospace;

    /* Timing */
    --ease-organic: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--deep-bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.65;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    cursor: default;
}

/* Leather Texture Overlay */
.leather-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(139, 104, 66, 0.015) 3px,
            rgba(139, 104, 66, 0.015) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 5px,
            rgba(139, 104, 66, 0.01) 5px,
            rgba(139, 104, 66, 0.01) 6px
        ),
        radial-gradient(ellipse at 30% 40%, rgba(139, 104, 66, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, rgba(139, 104, 66, 0.03) 0%, transparent 50%);
    mix-blend-mode: multiply;
    opacity: 0.6;
}

.leather-texture-svg {
    position: absolute;
    width: 0;
    height: 0;
}

/* ============ SPREADS ============ */
.spread {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    padding: clamp(2rem, 5vw, 6rem);
}

.spread-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ============ OPENING SPREAD ============ */
.spread-opening {
    text-align: center;
    position: relative;
}

.spread-opening .spread-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.spread-opening .svg-seedpod {
    position: absolute;
    width: clamp(300px, 50vw, 550px);
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.35;
}

.title-main {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(4rem, 10vw, 8rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    position: relative;
    z-index: 3;
}

.title-annotation {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--twilight);
    opacity: 0;
    margin-top: 1.5rem;
    transition: opacity 1.2s var(--ease-organic) 3.2s;
    position: relative;
    z-index: 3;
}

.title-annotation.visible {
    opacity: 0.8;
}

/* ============ BOTANICAL SVGs ============ */
.botanical-svg {
    width: 100%;
    height: auto;
}

.botanical-svg .draw-path,
.ornament-svg .draw-path {
    stroke: var(--ornament);
    fill: none;
    stroke-dasharray: var(--path-length, 1000);
    stroke-dashoffset: var(--path-length, 1000);
    transition: stroke-dashoffset 2.5s var(--ease-organic);
    will-change: stroke-dashoffset;
}

.botanical-svg .draw-path.drawn,
.ornament-svg .draw-path.drawn {
    stroke-dashoffset: 0;
}

.ornament-svg .draw-path {
    stroke: var(--midtone);
    opacity: 0.5;
}

/* ============ ORNAMENT BARS ============ */
.ornament-bar {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
    position: relative;
    z-index: 2;
}

.ornament-svg {
    width: clamp(200px, 40vw, 400px);
    height: auto;
    transition: transform 600ms var(--ease-organic);
}

.ornament-bar:hover .ornament-svg {
    transform: scale(1.05);
}

/* ============ SPECIMEN SPREAD (Type A) ============ */
.spread-a {
    display: grid;
    grid-template-columns: 65% 35%;
    gap: clamp(1.5rem, 3vw, 3rem);
    align-items: start;
}

.spread-a-reverse {
    grid-template-columns: 35% 65%;
}

.specimen-illustration {
    position: relative;
    overflow: visible;
}

.specimen-illustration .botanical-svg {
    max-height: 80vh;
    margin: 0 -8%;
    width: 116%;
}

.spread-a-reverse .specimen-illustration .botanical-svg {
    margin: 0 -8% 0 0;
}

.specimen-text {
    padding-top: clamp(2rem, 8vh, 8rem);
}

.specimen-label {
    display: block;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.75rem;
}

.specimen-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.specimen-body {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 40ch;
}

.specimen-annotation {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.8rem, 1vw, 0.95rem);
    color: var(--twilight);
    opacity: 0.8;
    margin-bottom: 0.4rem;
}

.mono-accent {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--accent-bright);
    font-style: normal;
}

/* ============ PUZZLE GRID (Type B) ============ */
.spread-puzzle .spread-content {
    text-align: center;
}

.puzzle-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
}

.puzzle-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 3rem;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    max-width: 700px;
    margin: 0 auto;
    aspect-ratio: 4/3;
}

.puzzle-cell {
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: crosshair;
    transition: transform 300ms var(--ease-organic),
                box-shadow 300ms var(--ease-organic);
    will-change: transform;
    overflow: hidden;
}

.puzzle-cell svg {
    width: 70%;
    height: 70%;
}

.puzzle-cell svg .draw-path {
    stroke: var(--ornament);
}

.puzzle-cell:hover {
    z-index: 10;
    box-shadow: 0 0 12px rgba(64, 224, 208, 0.15),
                0 0 24px rgba(64, 224, 208, 0.08);
}

.puzzle-cell:hover svg .draw-path {
    stroke: var(--accent-bright);
    transition: stroke 400ms var(--ease-organic);
}

/* ============ FIELD NOTES (Type C) ============ */
.spread-c {
    display: grid;
    grid-template-columns: 30% 1px 1fr;
    gap: clamp(1.5rem, 3vw, 3rem);
    align-items: start;
}

.fieldnotes-annotations {
    padding-top: clamp(2rem, 5vh, 5rem);
}

.annotation-date {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    display: block;
}

.annotation-text {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.85rem, 1vw, 1rem);
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 1.2rem;
}

.annotation-class {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--twilight);
    margin-bottom: 0.3rem;
}

.annotation-label {
    color: var(--text-secondary);
}

.fieldnotes-dashed-rule {
    width: 1px;
    min-height: 100%;
    background-image: repeating-linear-gradient(
        to bottom,
        var(--midtone) 0px,
        var(--midtone) 6px,
        transparent 6px,
        transparent 12px
    );
    animation: dash-scroll 4s linear infinite;
    background-size: 1px 12px;
}

@keyframes dash-scroll {
    0% { background-position: 0 0; }
    100% { background-position: 0 24px; }
}

.fieldnotes-illustration {
    display: flex;
    align-items: center;
    justify-content: center;
}

.fieldnotes-illustration .botanical-svg {
    max-height: 80vh;
}

/* ============ ASSEMBLY SPREAD ============ */
.spread-assembly .spread-content {
    text-align: center;
}

.assembly-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: 0.8rem;
}

.assembly-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 3rem;
}

.assembly-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.assembly-piece {
    width: clamp(100px, 15vw, 150px);
    height: clamp(100px, 15vw, 150px);
    transition: transform 1.2s var(--ease-organic),
                opacity 1s var(--ease-organic);
    will-change: transform;
    opacity: 0.5;
}

.assembly-piece svg {
    width: 100%;
    height: 100%;
}

.assembly-piece svg .draw-path {
    stroke: var(--ornament);
}

/* Scattered initial positions */
.assembly-piece.piece-0 { transform: translate(-80px, 40px) rotate(-12deg); }
.assembly-piece.piece-1 { transform: translate(60px, -50px) rotate(8deg); }
.assembly-piece.piece-2 { transform: translate(-40px, -70px) rotate(-5deg); }
.assembly-piece.piece-3 { transform: translate(90px, 30px) rotate(15deg); }
.assembly-piece.piece-4 { transform: translate(-60px, 60px) rotate(-10deg); }
.assembly-piece.piece-5 { transform: translate(50px, -40px) rotate(6deg); }

/* Assembled positions */
.assembly-piece.assembled {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
}

.assembly-piece.assembled svg .draw-path {
    stroke: var(--accent-bright);
    filter: drop-shadow(0 0 8px rgba(64, 224, 208, 0.3));
    transition: stroke 800ms var(--ease-organic),
                filter 800ms var(--ease-organic);
}

/* Stagger transition delays for assembly */
.assembly-piece.piece-0 { transition-delay: 0ms; }
.assembly-piece.piece-1 { transition-delay: 120ms; }
.assembly-piece.piece-2 { transition-delay: 240ms; }
.assembly-piece.piece-3 { transition-delay: 360ms; }
.assembly-piece.piece-4 { transition-delay: 480ms; }
.assembly-piece.piece-5 { transition-delay: 600ms; }

/* ============ CLOSING SPREAD ============ */
.spread-closing {
    text-align: center;
}

.spread-closing .spread-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.svg-closing-ornament {
    width: clamp(150px, 25vw, 250px);
    margin-bottom: 2rem;
}

.closing-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: -0.02em;
    line-height: 1.05;
    color: var(--ornament);
    margin-bottom: 1rem;
}

.closing-annotation {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--twilight);
    opacity: 0.8;
}

/* Intensified leather texture for closing */
.spread-closing .leather-overlay {
    opacity: 1;
}

/* ============ PUZZLE NAVIGATION ============ */
.puzzle-nav {
    position: fixed;
    right: clamp(1rem, 2vw, 2rem);
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.nav-piece {
    width: 16px;
    height: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 400ms var(--ease-organic);
}

.nav-piece span {
    display: block;
    background: var(--midtone);
    border-radius: 1px;
    transition: background-color 400ms var(--ease-organic),
                transform 300ms var(--ease-organic);
}

.nav-piece:hover {
    opacity: 0.8;
}

.nav-piece.active {
    opacity: 1;
}

.nav-piece.active span {
    background: var(--accent-bright);
    box-shadow: 0 0 4px rgba(64, 224, 208, 0.4);
}

/* Active state: pieces snap together */
.nav-piece.active span:nth-child(1) { transform: translate(0.5px, 0.5px); }
.nav-piece.active span:nth-child(2) { transform: translate(-0.5px, 0.5px); }
.nav-piece.active span:nth-child(3) { transform: translate(0.5px, -0.5px); }
.nav-piece.active span:nth-child(4) { transform: translate(-0.5px, -0.5px); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .spread-a {
        grid-template-columns: 1fr;
    }

    .spread-a-reverse {
        grid-template-columns: 1fr;
    }

    .spread-a-reverse .specimen-text {
        order: -1;
    }

    .specimen-illustration .botanical-svg {
        margin: 0;
        width: 100%;
        max-height: 50vh;
    }

    .spread-a-reverse .specimen-illustration .botanical-svg {
        margin: 0;
    }

    .spread-c {
        grid-template-columns: 1fr;
    }

    .fieldnotes-dashed-rule {
        width: 100%;
        min-height: 1px;
        height: 1px;
        background-image: repeating-linear-gradient(
            to right,
            var(--midtone) 0px,
            var(--midtone) 6px,
            transparent 6px,
            transparent 12px
        );
        animation: none;
    }

    .puzzle-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }

    .puzzle-nav {
        display: none;
    }

    .specimen-body {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .puzzle-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(6, 1fr);
    }

    .assembly-grid {
        gap: 1rem;
    }

    .assembly-piece {
        width: 80px;
        height: 80px;
    }
}
