/* ===========================================
   footprint.market - Botanical Field Journal
   =========================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Color Palette - from DESIGN.md */
    --herbarium-cream: #F5F0E8;
    --lichen-mist: #E8E3D6;
    --forest-ink: #2C3E2D;
    --deep-moss: #3D5440;
    --living-fern: #4A7C59;
    --sage-annotation: #6B8F71;
    --spore-gold: #C4A44A;
    --humus-dark: #1A2618;
    --root-brown: #7A6B5A;
    --morning-dew: #D4DFD0;

    /* Organic border-radius sets */
    --br-stone-1: 73% 27% 64% 36% / 42% 58% 33% 67%;
    --br-stone-2: 36% 64% 27% 73% / 58% 42% 67% 33%;
    --br-stone-3: 64% 36% 73% 27% / 33% 67% 42% 58%;
    --br-stone-4: 43% 57% 68% 32% / 55% 45% 38% 62%;
    --br-stone-5: 57% 43% 32% 68% / 45% 55% 62% 38%;
    --br-stone-6: 68% 32% 43% 57% / 38% 62% 55% 45%;
    --br-stone-7: 32% 68% 57% 43% / 62% 38% 45% 55%;
    --br-stone-8: 52% 48% 61% 39% / 47% 53% 40% 60%;

    /* Animation timing */
    --ease-organic: cubic-bezier(0.25, 0.1, 0.25, 1.0);
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Source Serif 4', 'Georgia', serif;
    background-color: var(--herbarium-cream);
    color: var(--deep-moss);
    overflow-x: hidden;
    line-height: 1.72;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Paper Grain Texture Overlay --- */
#paper-grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.04;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-size: 200px 200px;
}

/* --- Spore Canvas --- */
#spore-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* --- Vine Pathway --- */
#vine-pathway {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

#vine-path {
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
    opacity: 0.6;
}

/* --- Leaf Navigation --- */
#leaf-nav {
    position: fixed;
    bottom: 30px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 900;
    opacity: 0.5;
    transition: opacity 0.6s var(--ease-organic);
}

#leaf-nav:hover {
    opacity: 1;
}

.leaf-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    transition: transform 0.4s var(--ease-organic), filter 0.4s var(--ease-organic);
}

.leaf-btn:hover {
    transform: scale(1.15);
}

.leaf-btn.active .leaf-icon {
    filter: drop-shadow(0 0 6px rgba(74, 124, 89, 0.6));
}

.leaf-btn.active .leaf-icon path,
.leaf-btn.active .leaf-icon circle {
    stroke: var(--living-fern);
}

.leaf-icon {
    width: 32px;
    height: 38px;
    display: block;
    transition: filter 0.4s var(--ease-organic);
}

.ginkgo-icon {
    width: 34px;
    height: 34px;
}

.oak-icon {
    width: 32px;
    height: 36px;
}

/* --- Typography --- */
.section-heading {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(2.2rem, 6vw + 0.5rem, 5.5rem);
    letter-spacing: 0.02em;
    color: var(--forest-ink);
    text-shadow: 0 1px 2px rgba(44, 62, 45, 0.15);
    margin-bottom: 1.2rem;
    line-height: 1.15;
}

.small-heading {
    font-size: clamp(1.6rem, 3vw + 0.5rem, 2.8rem);
}

.body-text {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw + 0.5rem, 1.2rem);
    color: var(--deep-moss);
    line-height: 1.72;
    margin-bottom: 1rem;
}

.body-text:last-of-type {
    margin-bottom: 0.5rem;
}

.caveat-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1vw + 0.3rem, 1.1rem);
    color: var(--sage-annotation);
}

/* --- Sections / Acts --- */
.act {
    position: relative;
    width: 100%;
}

/* ACT I: Canopy */
.act-canopy {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--herbarium-cream);
    padding: 2rem;
}

.canopy-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 700px;
}

.title-top {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(3rem, 8vw + 1rem, 7rem);
    letter-spacing: 0.02em;
    color: var(--forest-ink);
    text-shadow: 0 1px 2px rgba(44, 62, 45, 0.15);
    text-align: center;
    margin-bottom: -1rem;
    position: relative;
    z-index: 10;
}

.tree-illustration {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

#hero-tree {
    width: 100%;
    height: auto;
}

/* Tree draw animation */
.tree-trunk,
.tree-branch,
.tree-roots path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.tree-trunk.animate {
    animation: drawLine 2s var(--ease-organic) forwards;
}

.tree-branch.branch-major.animate {
    animation: drawLine 1.5s var(--ease-organic) forwards;
    animation-delay: 1s;
}

.tree-branch.branch-minor.animate {
    animation: drawLine 1.2s var(--ease-organic) forwards;
    animation-delay: 2s;
}

.tree-roots.animate path {
    animation: drawLine 1.5s var(--ease-organic) forwards;
    animation-delay: 1.5s;
}

.tree-leaves circle {
    opacity: 0;
    transform-origin: center;
}

.tree-leaves.animate circle {
    animation: fadeLeaf 1.2s var(--ease-organic) forwards;
}

.tree-leaves.animate circle:nth-child(1) { animation-delay: 2.2s; }
.tree-leaves.animate circle:nth-child(2) { animation-delay: 2.3s; }
.tree-leaves.animate circle:nth-child(3) { animation-delay: 2.4s; }
.tree-leaves.animate circle:nth-child(4) { animation-delay: 2.5s; }
.tree-leaves.animate circle:nth-child(5) { animation-delay: 2.6s; }
.tree-leaves.animate circle:nth-child(6) { animation-delay: 2.3s; }
.tree-leaves.animate circle:nth-child(7) { animation-delay: 2.4s; }
.tree-leaves.animate circle:nth-child(8) { animation-delay: 2.5s; }
.tree-leaves.animate circle:nth-child(9) { animation-delay: 2.6s; }
.tree-leaves.animate circle:nth-child(10) { animation-delay: 2.7s; }
.tree-leaves.animate circle:nth-child(11) { animation-delay: 2.5s; }
.tree-leaves.animate circle:nth-child(12) { animation-delay: 2.6s; }
.tree-leaves.animate circle:nth-child(13) { animation-delay: 2.7s; }
.tree-leaves.animate circle:nth-child(14) { animation-delay: 2.4s; }
.tree-leaves.animate circle:nth-child(15) { animation-delay: 2.5s; }
.tree-leaves.animate circle:nth-child(16) { animation-delay: 2.6s; }
.tree-leaves.animate circle:nth-child(17) { animation-delay: 2.7s; }
.tree-leaves.animate circle:nth-child(18) { animation-delay: 2.8s; }

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes fadeLeaf {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.title-bottom {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(3rem, 8vw + 1rem, 7rem);
    letter-spacing: 0.02em;
    color: var(--forest-ink);
    text-shadow: 0 1px 2px rgba(44, 62, 45, 0.15);
    text-align: center;
    margin-top: -1.5rem;
    position: relative;
    z-index: 10;
}

.subtitle {
    font-size: clamp(1.1rem, 2vw + 0.3rem, 1.6rem);
    margin-top: 1.2rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1.2s var(--ease-organic), transform 1.2s var(--ease-organic);
}

.subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ACT II: Understory */
.act-understory {
    position: relative;
    padding: 6rem 3rem 4rem;
    min-height: 150vh;
    background: linear-gradient(
        to bottom,
        var(--herbarium-cream) 0%,
        var(--herbarium-cream) 10%,
        var(--lichen-mist) 40%,
        var(--lichen-mist) 100%
    );
}

.understory-content {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
}

/* ACT III: Forest Floor */
.act-floor {
    position: relative;
    padding: 4rem 3rem;
    min-height: 150vh;
    background: linear-gradient(
        to bottom,
        var(--lichen-mist) 0%,
        var(--morning-dew) 20%,
        var(--morning-dew) 80%,
        var(--morning-dew) 100%
    );
}

#mycelium-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.floor-content {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
    z-index: 2;
}

/* ACT IV: Clearing */
.act-clearing {
    position: relative;
    padding: 8rem 3rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        to bottom,
        var(--morning-dew) 0%,
        var(--herbarium-cream) 25%,
        var(--herbarium-cream) 75%,
        var(--herbarium-cream) 100%
    );
}

.clearing-content {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* ACT V: Root System */
.act-roots {
    position: relative;
    padding: 6rem 3rem 8rem;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(
        to bottom,
        var(--herbarium-cream) 0%,
        #2C3E2D 30%,
        var(--humus-dark) 60%,
        var(--humus-dark) 100%
    );
}

.roots-content {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#root-illustration {
    width: 100%;
    max-width: 700px;
    margin-bottom: 4rem;
    opacity: 0.4;
}

.closing-message {
    text-align: center;
    max-width: 650px;
}

.closing-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(2.4rem, 5vw + 1rem, 5rem);
    letter-spacing: 0.02em;
    color: var(--herbarium-cream);
    text-shadow: 0 2px 4px rgba(26, 38, 24, 0.3);
    margin-bottom: 2rem;
    line-height: 1.2;
}

.closing-body {
    font-family: 'Source Serif 4', 'Georgia', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw + 0.5rem, 1.2rem);
    color: var(--morning-dew);
    line-height: 1.72;
    margin-bottom: 2rem;
}

.closing-label {
    font-family: 'Caveat', cursive;
    font-size: clamp(1rem, 1.2vw + 0.4rem, 1.3rem);
    color: var(--sage-annotation);
    display: block;
    margin-top: 2rem;
    opacity: 0.8;
}

/* --- Content Blocks / Specimen Sheets --- */
.content-block {
    position: relative;
    background-color: rgba(245, 240, 232, 0.85);
    border: 1px solid rgba(122, 107, 90, 0.2);
    padding: 2.5rem 2.8rem 2rem;
    margin-bottom: 2rem;
    box-shadow:
        2px 4px 16px rgba(26, 38, 24, 0.06),
        0 1px 3px rgba(26, 38, 24, 0.04),
        inset 0 0 60px rgba(245, 240, 232, 0.3);
    border-radius: var(--br, 73% 27% 64% 36% / 42% 58% 33% 67%);
    margin-left: var(--block-x, 0);
    width: var(--block-w, 100%);
    max-width: 600px;
}

.content-block.specimen-sheet {
    transform: rotate(var(--rotation, 0deg));
}

/* Stagger rotations for understory blocks */
.understory-content .content-block:nth-child(1) { --rotation: 0.8deg; }
.understory-content .content-block:nth-child(2) { --rotation: -0.5deg; }
.understory-content .content-block:nth-child(3) { --rotation: 1.2deg; }

.floor-block {
    margin-bottom: -30px;
    max-width: 480px;
}

.floor-content .floor-block:nth-child(1) { --rotation: 1deg; }
.floor-content .floor-block:nth-child(2) { --rotation: -0.7deg; }
.floor-content .floor-block:nth-child(3) { --rotation: 0.5deg; }
.floor-content .floor-block:nth-child(4) { --rotation: -1.1deg; }
.floor-content .floor-block:nth-child(5) { --rotation: 0.8deg; }
.floor-content .floor-block:nth-child(6) { --rotation: -0.6deg; }

/* Specimen Pins */
.specimen-pin {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--root-brown);
    background: rgba(245, 240, 232, 0.5);
    box-shadow: 0 1px 2px rgba(26, 38, 24, 0.1);
}

.pin-tl { top: 12px; left: 14px; }
.pin-tr { top: 12px; right: 14px; }
.pin-bl { bottom: 12px; left: 14px; }
.pin-br { bottom: 12px; right: 14px; }

/* Specimen Labels */
.specimen-label {
    display: block;
    margin-top: 1.2rem;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(122, 107, 90, 0.2);
    font-style: italic;
    transform: rotate(var(--label-rotation, 0deg));
    transform-origin: left center;
}

/* --- Ginkgo Divider --- */
.ginkgo-divider {
    text-align: center;
    padding: 2rem 0;
    opacity: 0.3;
}

.ginkgo-svg {
    width: 80px;
    height: auto;
}

/* --- Oak Cluster --- */
.oak-cluster {
    text-align: center;
    padding: 2rem 0;
    opacity: 0.25;
    position: relative;
    z-index: 2;
}

.oak-svg {
    width: 120px;
    height: auto;
}

/* --- Featured Specimen (Act IV) --- */
.featured-specimen {
    position: relative;
    background-color: rgba(245, 240, 232, 0.92);
    border: 1px solid rgba(122, 107, 90, 0.25);
    border-radius: var(--br-stone-1);
    padding: 3rem;
    box-shadow:
        4px 8px 32px rgba(26, 38, 24, 0.08),
        0 2px 6px rgba(26, 38, 24, 0.05),
        inset 0 0 80px rgba(245, 240, 232, 0.4);
    transform: rotate(0.5deg);
}

.featured-illustration {
    position: relative;
    max-width: 500px;
    margin: 0 auto 2rem;
}

.featured-plant-svg {
    width: 100%;
    height: auto;
}

/* Annotations */
.annotation {
    position: absolute;
    font-size: clamp(0.75rem, 0.9vw + 0.3rem, 0.95rem);
    color: var(--root-brown);
    line-height: 1.4;
    max-width: 160px;
}

.annotation-left-1 {
    bottom: 28%;
    left: -5%;
    transform: rotate(-1.5deg);
}

.annotation-right-1 {
    bottom: 38%;
    right: -5%;
    transform: rotate(1deg);
}

.annotation-top {
    top: 28%;
    right: 10%;
    transform: rotate(-0.5deg);
}

.annotation-bottom {
    bottom: 8%;
    left: 10%;
    transform: rotate(1.5deg);
}

.featured-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(2rem, 4vw + 0.5rem, 4rem);
    letter-spacing: 0.02em;
    color: var(--forest-ink);
    text-shadow: 0 1px 2px rgba(44, 62, 45, 0.15);
    margin-bottom: 1.2rem;
    text-align: center;
}

.featured-text {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Fade Reveal Animation --- */
.fade-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 800ms var(--ease-organic), transform 800ms var(--ease-organic);
}

.fade-reveal.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--rotation, 0deg));
}

/* --- Leaf Pulse Animation (vine leaves) --- */
@keyframes leafPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.vine-leaf {
    animation: leafPulse 4s ease-in-out infinite;
}

/* --- Mycelium Pulse --- */
@keyframes myceliumPulse {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.14; }
}

#mycelium-pattern g {
    animation: myceliumPulse 8s ease-in-out infinite;
}

/* --- Root illustration subtle animation --- */
@keyframes rootBreathe {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 0.5; }
}

#root-illustration {
    animation: rootBreathe 10s ease-in-out infinite;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .content-block {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100%;
        border-radius: 24px;
        padding: 1.8rem 1.5rem 1.4rem;
    }

    .content-block.specimen-sheet {
        transform: none !important;
    }

    .fade-reveal.visible {
        transform: translateY(0) !important;
    }

    .floor-block {
        margin-bottom: 1.5rem;
        max-width: 100%;
    }

    .act-understory,
    .act-floor,
    .act-clearing {
        padding-left: 1.2rem;
        padding-right: 1.2rem;
    }

    .featured-specimen {
        padding: 1.8rem 1.2rem;
        border-radius: 24px;
        transform: none;
    }

    .annotation {
        position: relative;
        display: block;
        margin: 0.5rem 0;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        transform: none !important;
        max-width: 100%;
    }

    .featured-illustration {
        max-width: 100%;
    }

    #leaf-nav {
        bottom: 16px;
        left: 12px;
        gap: 8px;
    }

    .leaf-icon {
        width: 26px;
        height: 30px;
    }

    .ginkgo-icon {
        width: 28px;
        height: 28px;
    }

    .oak-icon {
        width: 26px;
        height: 30px;
    }

    .title-top,
    .title-bottom {
        font-size: clamp(2.4rem, 10vw, 4.5rem);
    }

    .closing-title {
        font-size: clamp(2rem, 6vw, 3.5rem);
    }

    .act-roots {
        padding: 4rem 1.5rem 6rem;
    }

    #root-illustration {
        max-width: 100%;
        margin-bottom: 2rem;
    }

    .specimen-label {
        transform: none;
    }
}

@media (max-width: 480px) {
    .act-canopy {
        padding: 1rem;
    }

    .tree-illustration {
        max-width: 300px;
    }

    .featured-specimen {
        padding: 1.2rem 1rem;
    }

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