:root {
    --deep-floor: #0A1F0A;
    --moss: #1B3A1B;
    --fern-shadow: #2D5A2D;
    --bioluminescent: #3DDC84;
    --canopy-light: #81C784;
    --text-primary: #C8E6C9;
    --text-secondary: #7DA67D;
    --spore-gold: #C9B037;
    --column-width: min(680px, calc(100vw - 40px));
    color-scheme: dark;
}

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

body {
    background: radial-gradient(ellipse at 50% 0%, #1B3A1B 0%, #0A1F0A 70%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 1.05rem;
    line-height: 1.72;
    overflow-x: hidden;
}

/* Margin Layer */
.margin-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Hexagonal Lattice */
.hex-lattice {
    position: absolute;
    width: 120px;
    height: 120px;
    opacity: 0.4;
}

.hex-lattice-1 {
    top: 15%;
    left: 5%;
    background:
        radial-gradient(circle 15px at 30% 30%, rgba(61,220,132,0.15) 0%, transparent 100%),
        radial-gradient(circle 15px at 70% 30%, rgba(61,220,132,0.1) 0%, transparent 100%),
        radial-gradient(circle 15px at 50% 65%, rgba(61,220,132,0.2) 0%, transparent 100%);
    animation: hexRotate 120s linear infinite;
}

.hex-lattice-2 {
    top: 45%;
    right: 4%;
    background:
        radial-gradient(circle 12px at 25% 40%, rgba(61,220,132,0.12) 0%, transparent 100%),
        radial-gradient(circle 12px at 65% 25%, rgba(61,220,132,0.18) 0%, transparent 100%),
        radial-gradient(circle 12px at 50% 70%, rgba(61,220,132,0.1) 0%, transparent 100%);
    animation: hexRotate 100s linear infinite reverse;
}

.hex-lattice-3 {
    bottom: 20%;
    left: 8%;
    background:
        radial-gradient(circle 18px at 40% 35%, rgba(61,220,132,0.2) 0%, transparent 100%),
        radial-gradient(circle 18px at 60% 60%, rgba(61,220,132,0.14) 0%, transparent 100%);
    animation: hexRotate 140s linear infinite;
}

@keyframes hexRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Cellular Blobs */
.cellular-blob {
    position: absolute;
    background: rgba(27, 58, 27, 0.5);
    pointer-events: none;
}

.blob-1 {
    width: 140px; height: 140px;
    top: 25%; left: 3%;
    border-radius: 30% 70% 62% 38% / 47% 34% 66% 53%;
    animation: blobMorph1 10s ease-in-out infinite;
}

.blob-2 {
    width: 100px; height: 100px;
    top: 55%; right: 5%;
    border-radius: 62% 38% 45% 55% / 35% 60% 40% 65%;
    animation: blobMorph2 12s ease-in-out infinite;
}

.blob-3 {
    width: 180px; height: 180px;
    top: 70%; left: 2%;
    border-radius: 45% 55% 70% 30% / 60% 35% 65% 40%;
    animation: blobMorph1 15s ease-in-out infinite -3s;
}

.blob-4 {
    width: 90px; height: 90px;
    top: 10%; right: 8%;
    border-radius: 55% 45% 35% 65% / 40% 55% 45% 60%;
    animation: blobMorph2 8s ease-in-out infinite -2s;
}

.blob-5 {
    width: 120px; height: 120px;
    bottom: 10%; right: 3%;
    border-radius: 38% 62% 55% 45% / 65% 40% 60% 35%;
    animation: blobMorph1 11s ease-in-out infinite -5s;
}

@keyframes blobMorph1 {
    0%, 100% { border-radius: 30% 70% 62% 38% / 47% 34% 66% 53%; }
    50% { border-radius: 55% 45% 38% 62% / 60% 50% 50% 40%; }
}

@keyframes blobMorph2 {
    0%, 100% { border-radius: 62% 38% 45% 55% / 35% 60% 40% 65%; }
    50% { border-radius: 40% 60% 65% 35% / 50% 40% 60% 50%; }
}

/* Spore Particles */
.spore-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.spore {
    position: absolute;
    border-radius: 50%;
    background: var(--spore-gold);
    animation: sporePulse 4s ease-in-out infinite;
}

@keyframes sporePulse {
    0%, 100% { transform: scale(1); opacity: 0.2; }
    50% { transform: scale(1.3); opacity: 0.5; }
}

/* Viewport Reticle */
.reticle {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(60vw, 500px);
    height: min(60vw, 500px);
    pointer-events: none;
    z-index: 0;
    animation: reticleRotate 90s linear infinite;
    transition: opacity 1s ease;
}

@keyframes reticleRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Scroll Indicator */
.scroll-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
}

.scroll-track {
    width: 2px;
    height: 60px;
    background: var(--fern-shadow);
    opacity: 0.4;
    position: relative;
}

.scroll-dot {
    position: absolute;
    left: -3px;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bioluminescent);
    transition: top 0.1s linear;
}

/* Content Column */
.content-column {
    position: relative;
    z-index: 2;
    max-width: var(--column-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* Chapters */
.chapter {
    min-height: 100vh;
    padding: 20vh 0;
}

.canopy {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Titles */
.site-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(3.5rem, 8vw, 6rem);
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}

.subtitle {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.intro-text {
    max-width: 42ch;
    margin: 0 auto;
    text-align: center;
    color: var(--text-secondary);
}

.section-heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
    text-shadow: 0 0 40px rgba(61, 220, 132, 0.15);
    margin-bottom: 24px;
    transition: font-weight 0.3s ease;
}

.section-heading:hover {
    font-weight: 700;
}

.body-text {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Data Annotations */
.data-annotation {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.7;
    display: block;
    text-align: right;
    margin-bottom: 12px;
}

/* Card Flip */
.card-flip-zone {
    margin: 10vh 0;
    perspective: 1200px;
}

.card-container {
    position: relative;
    width: 100%;
    transform-style: preserve-3d;
    transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card-container.flipped {
    transform: rotateY(180deg);
}

.card-face {
    backface-visibility: hidden;
    border-radius: 4px;
}

.card-front {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--moss);
    overflow: hidden;
}

.card-back {
    transform: rotateY(180deg);
    background: var(--deep-floor);
    border: 1px solid var(--fern-shadow);
    padding: 40px 32px;
}

/* Front patterns */
.front-pattern {
    position: absolute;
    inset: 0;
    opacity: 0.5;
}

.pattern-hex {
    background:
        radial-gradient(circle 20px at 20% 30%, rgba(61,220,132,0.25) 0%, transparent 100%),
        radial-gradient(circle 20px at 50% 50%, rgba(61,220,132,0.2) 0%, transparent 100%),
        radial-gradient(circle 20px at 80% 40%, rgba(61,220,132,0.3) 0%, transparent 100%),
        radial-gradient(circle 15px at 35% 70%, rgba(61,220,132,0.15) 0%, transparent 100%),
        radial-gradient(circle 15px at 65% 20%, rgba(61,220,132,0.18) 0%, transparent 100%);
}

.pattern-branch {
    background:
        linear-gradient(30deg, transparent 48%, rgba(45,90,45,0.3) 48%, rgba(45,90,45,0.3) 52%, transparent 52%),
        linear-gradient(-30deg, transparent 48%, rgba(45,90,45,0.3) 48%, rgba(45,90,45,0.3) 52%, transparent 52%),
        linear-gradient(60deg, transparent 46%, rgba(45,90,45,0.2) 46%, rgba(45,90,45,0.2) 54%, transparent 54%);
}

.pattern-cells {
    background:
        radial-gradient(circle 30px at 25% 35%, rgba(27,58,27,0.6) 0%, transparent 100%),
        radial-gradient(circle 40px at 60% 55%, rgba(27,58,27,0.5) 0%, transparent 100%),
        radial-gradient(circle 25px at 75% 25%, rgba(27,58,27,0.4) 0%, transparent 100%),
        radial-gradient(circle 35px at 40% 75%, rgba(27,58,27,0.55) 0%, transparent 100%);
}

.pattern-network {
    background:
        radial-gradient(circle 5px at 20% 20%, rgba(61,220,132,0.3) 0%, transparent 100%),
        radial-gradient(circle 5px at 50% 40%, rgba(61,220,132,0.25) 0%, transparent 100%),
        radial-gradient(circle 5px at 80% 30%, rgba(61,220,132,0.2) 0%, transparent 100%),
        radial-gradient(circle 5px at 35% 70%, rgba(61,220,132,0.3) 0%, transparent 100%),
        radial-gradient(circle 5px at 65% 65%, rgba(61,220,132,0.22) 0%, transparent 100%),
        linear-gradient(25deg, transparent 49%, rgba(45,90,45,0.15) 49%, rgba(45,90,45,0.15) 51%, transparent 51%),
        linear-gradient(-40deg, transparent 49%, rgba(45,90,45,0.1) 49%, rgba(45,90,45,0.1) 51%, transparent 51%);
}

.pattern-dissolve {
    background:
        radial-gradient(circle 50px at 30% 40%, rgba(27,58,27,0.3) 0%, transparent 100%),
        radial-gradient(circle 40px at 70% 60%, rgba(27,58,27,0.2) 0%, transparent 100%),
        radial-gradient(circle 60px at 50% 50%, rgba(10,31,10,0.4) 0%, transparent 100%);
}

/* Colophon */
.colophon {
    padding: 10vh 0;
    text-align: center;
}

.colophon-text {
    font-family: 'Space Mono', monospace;
    font-weight: 400;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Reveal */
[data-reveal] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

.subtitle[data-reveal].revealed {
    opacity: 0.7;
}

/* Responsive */
@media (max-width: 768px) {
    .margin-layer {
        display: none;
    }

    .reticle {
        display: none;
    }

    .content-column {
        padding: 0 20px;
    }

    .card-face {
        padding: 32px 20px;
    }

    .chapter {
        padding: 15vh 0;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .hex-lattice {
        animation: none;
    }

    .cellular-blob {
        animation: none;
    }

    .spore {
        animation: none;
        opacity: 0.3;
    }

    .reticle {
        animation: none;
    }

    .card-container {
        transition: transform 0.3s ease;
    }

    [data-reveal] {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
