/* === CSS Custom Properties === */
:root {
    --void: #0a0a0f;
    --chlorophyll: #a3e635;
    --violet: #7c3aed;
    --slate: #94a3b8;
    --condensation: #cbd5e1;
    --amber: #d97706;
    --soil: #1c1917;
    --mycelium: #57534e;
    --drift-x: 0px;
}

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
}

body {
    background: var(--void);
    color: var(--condensation);
    font-family: 'Lora', Georgia, serif;
    overflow-x: hidden;
    cursor: default;
}

/* === Scanning Line === */
.scan-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: var(--chlorophyll);
    opacity: 0.03;
    z-index: 100;
    pointer-events: none;
    animation: scanDown 12s linear infinite;
}

@keyframes scanDown {
    0% { transform: translateY(0); }
    100% { transform: translateY(100vh); }
}

/* === Progress Indicator === */
.progress-indicator {
    position: fixed;
    right: 16px;
    top: 0;
    width: 1px;
    height: 100vh;
    z-index: 90;
    pointer-events: none;
}

.progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--chlorophyll);
    opacity: 0.15;
    transition: height 0.3s ease-out;
}

.progress-pulse {
    position: absolute;
    top: 0;
    left: -2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--chlorophyll);
    opacity: 0;
    transition: opacity 0.3s ease-out, top 0.3s ease-out;
}

.progress-pulse.active {
    opacity: 0.6;
    animation: pulseFlash 0.3s ease-out;
}

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

/* === Floating Spores === */
.spores {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.spore {
    position: absolute;
    bottom: -10px;
    left: var(--x);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: var(--chlorophyll);
    opacity: var(--opacity);
    animation: sporeDrift var(--dur) linear var(--delay) infinite;
    transform: translateX(var(--drift-x));
}

@keyframes sporeDrift {
    0% {
        transform: translateY(0) translateX(var(--drift-x));
        opacity: 0;
    }
    10% {
        opacity: var(--opacity);
    }
    90% {
        opacity: var(--opacity);
    }
    100% {
        transform: translateY(-110vh) translateX(calc(var(--drift-x) * 3));
        opacity: 0;
    }
}

/* === Specimen Sections === */
.specimen-section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
    padding: 4vh 3vw;
    scroll-snap-align: start;
    overflow: hidden;
}

/* === Grid Fragments === */
.grid-fragment {
    position: absolute;
    pointer-events: none;
    z-index: 1;
}

.grid-frag-1 {
    top: 10%;
    left: 5%;
    width: 30%;
    height: 40%;
    border-left: 1px dashed var(--mycelium);
    border-top: 1px dashed var(--mycelium);
    opacity: 0.3;
}

.grid-frag-2 {
    bottom: 15%;
    right: 8%;
    width: 25%;
    height: 35%;
    border-right: 1px dashed var(--mycelium);
    border-bottom: 1px dashed var(--mycelium);
    opacity: 0.25;
}

.grid-frag-3 {
    top: 20%;
    left: 15%;
    width: 70%;
    height: 60%;
    border: 1px dashed var(--mycelium);
    opacity: 0.15;
}

.grid-frag-4 {
    top: 5%;
    left: 2%;
    width: 40%;
    height: 90%;
    border-left: 1px dashed var(--mycelium);
    opacity: 0.2;
}

/* === Section Dividers === */
.section-divider {
    position: absolute;
    bottom: 0;
    left: 20%;
    width: 60%;
    height: 1px;
    background: var(--chlorophyll);
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.specimen-section.in-view .section-divider {
    opacity: 0.08;
}

/* === Section 1 - Entry Portal === */
.specimen-upper-left {
    grid-column: 1 / 6;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    z-index: 10;
}

.specimen-upper-left .specimen-svg {
    width: 100%;
    max-width: 420px;
    height: auto;
}

.title-container.title-lower-right {
    grid-column: 8 / 13;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    padding-bottom: 8vh;
    z-index: 10;
}

.site-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    font-weight: 700;
    color: var(--chlorophyll);
    letter-spacing: 0.02em;
    line-height: 1.1;
    text-shadow:
        0 0 20px rgba(163, 230, 53, 0.3),
        0 0 40px rgba(163, 230, 53, 0.15);
}

.title-annotation {
    font-family: 'Kalam', cursive;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--slate);
    margin-top: 0.5rem;
    letter-spacing: 0.01em;
}

/* === Section 2 - Classification === */
.specimen-left-wide {
    grid-column: 1 / 8;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.specimen-left-wide .specimen-svg {
    width: 100%;
    max-width: 520px;
    height: auto;
}

.text-right-narrow {
    grid-column: 9 / 12;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
}

/* === Section 3 - Cross-Section === */
.specimen-center {
    grid-column: 3 / 11;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.specimen-svg-large {
    width: 100%;
    max-width: 480px;
    height: auto;
}

.section-title-overlay {
    position: absolute;
    bottom: 10vh;
    left: 3vw;
    z-index: 15;
}

.cross-section-labels {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cs-label {
    position: absolute;
    font-family: 'Kalam', cursive;
    font-size: clamp(0.7rem, 1.2vw, 0.95rem);
    color: var(--slate);
    opacity: 0;
    transition: opacity 0.8s ease-out;
    white-space: nowrap;
}

.specimen-section.in-view .cs-label {
    opacity: 1;
}

.cs-label-tl { top: 10%; left: 5%; }
.cs-label-tr { top: 12%; right: 5%; }
.cs-label-ml { top: 45%; left: 0; }
.cs-label-mr { top: 48%; right: 0; }
.cs-label-bl { bottom: 20%; left: 8%; }
.cs-label-br { bottom: 18%; right: 8%; }

/* Staggered label reveal */
.specimen-section.in-view .cs-label-tl { transition-delay: 0.2s; }
.specimen-section.in-view .cs-label-tr { transition-delay: 0.4s; }
.specimen-section.in-view .cs-label-ml { transition-delay: 0.6s; }
.specimen-section.in-view .cs-label-mr { transition-delay: 0.8s; }
.specimen-section.in-view .cs-label-bl { transition-delay: 1.0s; }
.specimen-section.in-view .cs-label-br { transition-delay: 1.2s; }

/* === Section 4 - Propagation === */
.specimen-left-cascade {
    grid-column: 1 / 5;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    position: relative;
    z-index: 10;
}

.specimen-small {
    width: 100%;
    max-width: 180px;
    height: auto;
    transition: filter 0.6s ease-out;
}

.cascade-specimen {
    transition: filter 0.6s ease-out;
}

.text-right-propagation {
    grid-column: 6 / 12;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
}

/* === Section 5 - Archive === */
.section-final {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.final-glow {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: finalFade 8s ease-in-out infinite alternate;
}

@keyframes finalFade {
    0% { opacity: 0.6; }
    100% { opacity: 0.15; }
}

.specimen-final-svg {
    width: 200px;
    height: 200px;
}

.final-text {
    margin-top: 4rem;
    text-align: center;
}

.closing-notation {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 700;
    color: var(--chlorophyll);
    opacity: 0.5;
    letter-spacing: 0.02em;
    line-height: 1.8;
    text-shadow: 0 0 15px rgba(163, 230, 53, 0.2);
}

.closing-date {
    font-family: 'Kalam', cursive;
    font-size: clamp(0.8rem, 1.4vw, 1rem);
    color: var(--slate);
    opacity: 0.6;
}

/* === Typography === */
.specimen-title {
    font-family: 'Caveat', cursive;
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 700;
    color: var(--chlorophyll);
    letter-spacing: 0.02em;
    text-shadow:
        0 0 15px rgba(163, 230, 53, 0.25),
        0 0 30px rgba(163, 230, 53, 0.1);
}

.specimen-subtitle {
    font-family: 'Kalam', cursive;
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 400;
    color: var(--slate);
    letter-spacing: 0.01em;
}

.field-notes {
    font-family: 'Lora', Georgia, serif;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    font-weight: 400;
    line-height: 1.8;
    color: var(--condensation);
    max-width: 42ch;
}

/* === Annotations === */
.annotation {
    margin-top: 1rem;
}

.annotation-text {
    font-family: 'Kalam', cursive;
    font-size: clamp(0.7rem, 1.1vw, 0.9rem);
    color: var(--slate);
    opacity: 0;
    transition: opacity 0.8s ease-out;
    letter-spacing: 0.01em;
}

.specimen-section.in-view .annotation-text {
    opacity: 0.7;
}

/* Annotation reveal stagger */
.specimen-section.in-view .annotation-1 .annotation-text { transition-delay: 0.4s; }
.specimen-section.in-view .annotation-2 .annotation-text { transition-delay: 0.6s; }
.specimen-section.in-view .annotation-3 .annotation-text { transition-delay: 0.5s; }
.specimen-section.in-view .annotation-4a .annotation-text { transition-delay: 0.3s; }
.specimen-section.in-view .annotation-4b .annotation-text { transition-delay: 0.5s; }
.specimen-section.in-view .annotation-4c .annotation-text { transition-delay: 0.7s; }
.specimen-section.in-view .annotation-4d .annotation-text { transition-delay: 0.9s; }

/* Annotation positioning for section 3 */
#section3 > .annotation {
    position: absolute;
    bottom: 6vh;
    right: 5vw;
    z-index: 15;
}

/* === SVG Glow Interaction === */
.specimen-glow {
    transition: filter 0.6s ease-out;
}

.specimen-svg {
    filter: drop-shadow(0 0 8px rgba(163, 230, 53, 0.15));
    transition: filter 0.6s ease-out;
}

.specimen-svg.glow-active {
    filter: drop-shadow(0 0 16px rgba(163, 230, 53, 0.35));
}

/* === Cascade Hover Interaction === */
.specimen-small.dim {
    opacity: 0.3;
    transition: opacity 0.4s ease-out;
}

.specimen-small.bright {
    opacity: 1;
    filter: drop-shadow(0 0 20px rgba(163, 230, 53, 0.4));
    transition: opacity 0.4s ease-out, filter 0.4s ease-out;
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    .scan-line { animation: none; display: none; }
    .spore { animation: none; display: none; }
    .final-glow { animation: none; opacity: 0.4; }
    .specimen-glow { transition: none; }
    .specimen-svg { transition: none; }
    .cs-label { transition: none; opacity: 1; }
    .annotation-text { transition: none; opacity: 0.7; }
    .section-divider { transition: none; }
}

/* === Responsive === */
@media (max-width: 768px) {
    .specimen-section {
        grid-template-columns: 1fr;
        padding: 6vh 5vw;
        gap: 2rem;
    }

    .specimen-upper-left,
    .specimen-left-wide,
    .specimen-center,
    .specimen-left-cascade,
    .title-container.title-lower-right,
    .text-right-narrow,
    .text-right-propagation {
        grid-column: 1 / -1;
        grid-row: auto;
        align-items: center;
        justify-content: center;
    }

    .title-container.title-lower-right {
        align-items: center;
        text-align: center;
        padding-bottom: 2vh;
    }

    .specimen-left-cascade {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .specimen-small {
        max-width: 120px;
    }

    .text-right-narrow,
    .text-right-propagation {
        text-align: center;
    }

    .field-notes {
        max-width: 100%;
    }

    .section-title-overlay {
        position: relative;
        bottom: auto;
        left: auto;
        text-align: center;
        grid-column: 1 / -1;
    }

    .cross-section-labels {
        display: none;
    }

    #section3 > .annotation {
        position: relative;
        bottom: auto;
        right: auto;
        text-align: center;
    }
}
