/* ============================================
   layer2.wiki — Goblincore Translucent-Frost
   ============================================ */

:root {
    /* Palette — Translucent Frost */
    --bg-humus: #0F1A12;
    --bg-bark: #1C2B21;
    --surface-lichen: #2A3F30;
    --accent-spore: #7ECBA1;
    --accent-gold: #C4A35A;
    --text-birch: #E8EDE9;
    --text-stone: #9EADA3;
    --deco-bloom: #5B8A72;
    --deco-rust: #A67B5B;
    --bg-soil: #1A1208;

    /* Typography */
    --font-heading: 'Archivo', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-humus);
    color: var(--text-birch);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ============================================
   Noise Texture Overlay
   ============================================ */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* ============================================
   Layer Base
   ============================================ */
.layer {
    position: relative;
    overflow: hidden;
}

/* ============================================
   CANOPY — Layer 0 (Hero)
   ============================================ */
.layer-canopy {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--bg-humus);
    position: relative;
}

/* Organic blobs — three distinct shapes */
.canopy-blob {
    position: absolute;
    opacity: 0.25;
    will-change: transform, border-radius;
    transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.blob-1 {
    width: 420px;
    height: 420px;
    background: radial-gradient(ellipse at 40% 40%, rgba(42, 63, 48, 0.7), rgba(91, 138, 114, 0.3));
    top: 8%;
    left: -2%;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: blobPulse1 10s ease-in-out infinite;
}

.blob-2 {
    width: 360px;
    height: 360px;
    background: radial-gradient(ellipse at 60% 50%, rgba(91, 138, 114, 0.5), rgba(42, 63, 48, 0.2));
    bottom: 8%;
    right: -1%;
    border-radius: 70% 30% 40% 60% / 50% 60% 40% 50%;
    animation: blobPulse2 12s ease-in-out infinite;
}

.blob-3 {
    width: 280px;
    height: 280px;
    background: radial-gradient(ellipse at 50% 60%, rgba(91, 138, 114, 0.4), rgba(15, 26, 18, 0.3));
    top: 35%;
    left: 55%;
    border-radius: 60% 40% 50% 50% / 40% 50% 50% 60%;
    animation: blobPulse3 8s ease-in-out infinite;
}

/* Blob scroll-driven separation */
.canopy-blob.scrolled {
    opacity: 0.12;
}
.blob-1.scrolled {
    transform: translate(-120px, -60px) scale(1.1);
}
.blob-2.scrolled {
    transform: translate(120px, 60px) scale(1.1);
}
.blob-3.scrolled {
    transform: translate(80px, -80px) scale(0.9);
}

@keyframes blobPulse1 {
    0%, 100% {
        border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
        transform: scale(1);
    }
    50% {
        border-radius: 50% 50% 30% 70% / 60% 40% 60% 40%;
        transform: scale(1.03);
    }
}

@keyframes blobPulse2 {
    0%, 100% {
        border-radius: 70% 30% 40% 60% / 50% 60% 40% 50%;
        transform: scale(1);
    }
    33% {
        border-radius: 40% 60% 60% 40% / 40% 50% 50% 60%;
        transform: scale(1.04);
    }
    66% {
        border-radius: 55% 45% 35% 65% / 55% 45% 55% 45%;
        transform: scale(0.98);
    }
}

@keyframes blobPulse3 {
    0%, 100% {
        border-radius: 60% 40% 50% 50% / 40% 50% 50% 60%;
        transform: scale(1);
    }
    50% {
        border-radius: 45% 55% 60% 40% / 55% 45% 45% 55%;
        transform: scale(1.05);
    }
}

/* Fern decorations */
.fern-decoration {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    opacity: 0;
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.fern-decoration.visible {
    opacity: 0.6;
}

.fern-left {
    left: 2%;
    transform: translateY(-50%) translateX(-80px);
}

.fern-left.visible {
    transform: translateY(-50%) translateX(0);
}

.fern-right {
    right: 2%;
    transform: translateY(-50%) translateX(80px);
}

.fern-right.visible {
    transform: translateY(-50%) translateX(0);
}

/* Spore particles */
.spore-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.spore {
    position: absolute;
    border-radius: 50%;
    background-color: var(--deco-bloom);
    animation: sporeDrift 12s ease-in-out infinite;
}

@keyframes sporeDrift {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-6px) translateX(3px); }
    50% { transform: translateY(-10px) translateX(-2px); }
    75% { transform: translateY(-4px) translateX(5px); }
}

/* Hero content */
.hero-content {
    position: relative;
    z-index: 3;
    max-width: 780px;
}

.hero-meta {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.8s ease-out 0.3s, transform 0.8s ease-out 0.3s;
}

.hero-meta.visible {
    opacity: 1;
    transform: translateY(0);
}

.meta-label {
    display: block;
    font-family: var(--font-mono);
    font-size: clamp(0.7rem, 0.85vw, 0.8rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-stone);
    margin-bottom: 1.5rem;
}

.hero-title {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(2.4rem, 6vw, 4.8rem);
    color: var(--text-birch);
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease-out 0.6s, transform 1s ease-out 0.6s;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-sub {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.5vw, 1.3rem);
    color: var(--text-stone);
    line-height: 1.75;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1s ease-out 1s, transform 1s ease-out 1s;
}

.hero-sub.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   UNDERSTORY — Layer 1
   ============================================ */
.layer-understory {
    padding: 100px 2rem 140px;
    position: relative;
    background: linear-gradient(
        to bottom,
        var(--bg-humus) 0%,
        rgba(28, 43, 33, 0.4) 30%,
        rgba(28, 43, 33, 0.5) 70%,
        rgba(26, 18, 8, 0.3) 100%
    );
}

/* Understory background blobs */
.understory-blob {
    position: absolute;
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
}

.ub-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(ellipse, rgba(42, 63, 48, 0.5), transparent);
    top: 5%;
    right: -10%;
    border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
    animation: blobPulse1 14s ease-in-out infinite;
}

.ub-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(ellipse, rgba(91, 138, 114, 0.4), transparent);
    top: 40%;
    left: -8%;
    border-radius: 55% 45% 50% 50% / 45% 55% 45% 55%;
    animation: blobPulse2 16s ease-in-out infinite;
}

.ub-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(ellipse, rgba(42, 63, 48, 0.35), transparent);
    bottom: 10%;
    right: 5%;
    border-radius: 50% 50% 40% 60% / 60% 40% 50% 50%;
    animation: blobPulse3 11s ease-in-out infinite;
}

/* Root tendril */
.root-tendril-main {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(196, 163, 90, 0.18),
        transparent 15%,
        rgba(196, 163, 90, 0.08) 30%,
        transparent 50%,
        rgba(196, 163, 90, 0.1) 70%,
        transparent 85%,
        rgba(196, 163, 90, 0.12)
    );
    transform: translateX(-50%);
    z-index: 0;
}

/* Specimen cards — frosted glass */
.specimen-card {
    max-width: 680px;
    margin: 0 auto 40px;
    background-color: rgba(28, 43, 33, 0.6);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(158, 173, 163, 0.2);
    border-radius: 12px;
    padding: 0;
    position: relative;
    z-index: 2;
}

.card-inner {
    padding: 2.5rem;
}

/* Alternating card offsets */
.slide-from-left.specimen-card:nth-of-type(odd) {
    margin-left: 5%;
}

.slide-from-right.specimen-card:nth-of-type(even) {
    margin-left: 12%;
}

/* Card classification label */
.card-label {
    font-size: clamp(0.65rem, 0.8vw, 0.75rem);
    color: var(--accent-spore);
    margin-bottom: 0.8rem;
}

/* Card botanical motif */
.card-motif {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    opacity: 0.6;
}

/* Card rule separator */
.card-rule {
    border: none;
    height: 1px;
    background: linear-gradient(to right, rgba(126, 203, 161, 0.3), transparent);
    margin-bottom: 1.5rem;
}

/* Slide-reveal animation for specimen cards */
.slide-reveal {
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-from-left {
    transform: translateX(-120px);
}

.slide-from-right {
    transform: translateX(120px);
}

.slide-reveal.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Soil layer uses slower reveal */
.soil-reveal {
    transition-duration: 800ms;
}

.section-heading {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: clamp(1.3rem, 2.8vw, 2rem);
    color: var(--text-birch);
    letter-spacing: 0.04em;
    margin-bottom: 1.5rem;
    line-height: 1.3;
}

.body-text {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.15rem);
    line-height: 1.75;
    color: var(--text-stone);
    margin-bottom: 1.5rem;
    max-width: 65ch;
}

.body-text:last-child {
    margin-bottom: 0;
}

/* Mycelium connectors between cards */
.mycelium-connector {
    max-width: 400px;
    margin: 0 auto;
    height: 120px;
    position: relative;
    z-index: 1;
}

.mycelium-svg {
    width: 100%;
    height: 100%;
}

.mycelium-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1500ms ease-out;
}

.mycelium-connector.visible .mycelium-path {
    stroke-dashoffset: 0;
}

/* Spore clusters */
.spore-cluster {
    position: relative;
    height: 80px;
    max-width: 680px;
    margin: 0 auto;
    z-index: 1;
}

/* ============================================
   SOIL HORIZON — Layer 2
   ============================================ */
.layer-soil {
    padding: 140px 2rem 160px;
    position: relative;
    background: linear-gradient(
        to bottom,
        rgba(28, 43, 33, 0.3) 0%,
        var(--bg-soil) 40%,
        var(--bg-soil) 100%
    );
}

.soil-transition-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 250px;
    background: linear-gradient(
        to bottom,
        rgba(28, 43, 33, 0.5),
        transparent
    );
    z-index: 0;
}

/* Fern margin illustrations */
.fern-margin {
    position: absolute;
    top: 10%;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.2s ease-out, transform 1.2s ease-out;
}

.fern-margin.visible {
    opacity: 1;
}

.fern-margin-left {
    left: calc(50% - 480px);
    transform: translateX(-60px);
}

.fern-margin-left.visible {
    transform: translateX(0);
}

.fern-margin-right {
    right: calc(50% - 480px);
    transform: translateX(60px);
}

.fern-margin-right.visible {
    transform: translateX(0);
}

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

/* Pull quote */
.pull-quote {
    margin: 3rem 0;
    padding-left: 1.5rem;
    border-left: 2px solid var(--accent-gold);
}

.pull-quote p {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    line-height: 1.6;
    color: var(--text-birch);
    font-style: italic;
}

/* Soil divider */
.soil-divider {
    max-width: 600px;
    margin: 3rem auto;
    height: 40px;
}

.soil-divider-svg {
    width: 100%;
    height: 100%;
}

/* ============================================
   BEDROCK — Substrate Layer
   ============================================ */
.layer-bedrock {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    position: relative;
    background-color: var(--bg-humus);
}

/* Mycelium network background illustration */
.bedrock-mycelium {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 800px;
    height: 400px;
    z-index: 0;
    pointer-events: none;
}

.bedrock-mycelium-svg {
    width: 100%;
    height: 100%;
}

.mycelium-network-fade {
    opacity: 0.6;
    transition: opacity 3s ease-out;
}

.layer-bedrock.at-bottom .mycelium-network-fade {
    opacity: 0;
}

/* Central pulsing blob */
.bedrock-blob {
    position: absolute;
    width: 50vw;
    max-width: 550px;
    height: 50vw;
    max-height: 550px;
    background: radial-gradient(
        ellipse at 45% 45%,
        rgba(42, 63, 48, 0.5),
        rgba(28, 43, 33, 0.3) 50%,
        rgba(15, 26, 18, 0.15) 80%,
        transparent
    );
    border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
    animation: bedrockPulse 15s ease-in-out infinite;
    opacity: 0.35;
    z-index: 0;
}

@keyframes bedrockPulse {
    0% {
        border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
        transform: scale(1);
    }
    20% {
        border-radius: 50% 50% 45% 55% / 45% 55% 50% 50%;
        transform: scale(1.02);
    }
    40% {
        border-radius: 55% 45% 50% 50% / 55% 45% 45% 55%;
        transform: scale(1.04);
    }
    60% {
        border-radius: 45% 55% 55% 45% / 50% 50% 55% 45%;
        transform: scale(1.01);
    }
    80% {
        border-radius: 50% 50% 40% 60% / 40% 60% 50% 50%;
        transform: scale(1.03);
    }
    100% {
        border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
        transform: scale(1);
    }
}

/* Bedrock content with blur-to-focus reveal */
.bedrock-content {
    position: relative;
    z-index: 2;
    max-width: 600px;
}

.blur-reveal {
    filter: blur(8px);
    opacity: 0;
    transition: filter 1.5s ease-out, opacity 1.5s ease-out;
}

.blur-reveal.visible {
    filter: blur(0px);
    opacity: 1;
}

.closing-statement {
    font-family: var(--font-heading);
    font-weight: 300;
    font-size: clamp(1.3rem, 3vw, 2.2rem);
    color: var(--text-birch);
    line-height: 1.7;
    margin-bottom: 2rem;
}

.closing-attribution {
    color: var(--text-stone);
    opacity: 0.5;
    margin-top: 2rem;
    font-size: clamp(0.6rem, 0.7vw, 0.7rem);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
    .fern-margin-left { left: 2%; }
    .fern-margin-right { right: 2%; }
}

@media (max-width: 768px) {
    .layer-canopy {
        padding: 3rem 1.5rem;
    }

    .layer-understory {
        padding: 60px 1.5rem 80px;
    }

    .layer-soil {
        padding: 80px 1.5rem 100px;
    }

    .specimen-card {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .slide-from-left.specimen-card,
    .slide-from-right.specimen-card {
        margin-left: auto !important;
    }

    .slide-from-left {
        transform: translateX(-60px);
    }

    .slide-from-right {
        transform: translateX(60px);
    }

    .fern-decoration {
        display: none;
    }

    .fern-margin {
        display: none;
    }

    .root-tendril-main {
        display: none;
    }

    .canopy-blob {
        opacity: 0.15;
    }

    .blob-1 { width: 250px; height: 250px; }
    .blob-2 { width: 200px; height: 200px; }
    .blob-3 { width: 180px; height: 180px; }

    .mycelium-connector {
        height: 80px;
    }

    .bedrock-mycelium {
        width: 95%;
    }
}

@media (max-width: 480px) {
    .body-text {
        font-size: 0.95rem;
    }

    .section-heading {
        font-size: 1.2rem;
    }

    .card-inner {
        padding: 1.5rem;
    }

    .card-motif {
        display: none;
    }

    .hero-content {
        max-width: 95%;
    }

    .spore-field-canopy {
        display: none;
    }
}
