/* ========================================
   xanadu.quest — Cybernetic Pleasure Garden
   ======================================== */

:root {
    /* Palette */
    --spore-white: #EDF1F4;
    --substrate-gray: #D4DDE2;
    --deep-fern: #2C3E44;
    --lichen-gray: #4A5B63;
    --sensor-blue: #7A9BA8;
    --nav-dot-base: #4A6670;
    --chlorophyll-pulse: #6B9B7A;
    --root-depth: #1A2830;
    --bioluminescent: #A8D8B9;
    --panel-border: #C8D0D8;
    --shadow-color: #B8C4CC;
    --muted-gray-1: #B8C4CC;
    --muted-gray-2: #8A9AA6;
    --panel-bg: rgba(232, 238, 242, 0.85);

    /* Animation speeds */
    --blob-speed: 60s;
    --panel-blur: 12px;
    --vine-grow-duration: 1200ms;

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--spore-white);
    font-family: var(--font-body);
    color: var(--lichen-gray);
    overflow-x: hidden;
    min-height: 100vh;
}

/* ========================================
   Plane 1: Deep Garden (Blob Ecosystem)
   ======================================== */
#deep-garden {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    mix-blend-mode: multiply;
    opacity: 0;
    animation: blobMorph1 var(--blob-speed) ease-in-out infinite,
               blobFadeIn 3s ease-out forwards;
}

.blob-1 {
    width: 500px; height: 500px;
    background: var(--muted-gray-1);
    top: -5%; left: -5%;
    border-radius: 30% 70% 60% 40% / 50% 60% 40% 50%;
    animation: blobMorph1 55s ease-in-out infinite, blobFadeIn 3s 0.2s ease-out forwards;
}

.blob-2 {
    width: 400px; height: 400px;
    background: var(--muted-gray-2);
    top: 20%; right: 10%;
    border-radius: 60% 40% 30% 70% / 40% 50% 60% 50%;
    animation: blobMorph2 70s ease-in-out infinite, blobFadeIn 3s 0.6s ease-out forwards;
}

.blob-3 {
    width: 350px; height: 350px;
    background: var(--substrate-gray);
    top: 55%; left: 15%;
    border-radius: 40% 60% 70% 30% / 60% 40% 50% 50%;
    animation: blobMorph3 80s ease-in-out infinite, blobFadeIn 3s 1s ease-out forwards;
}

.blob-4 {
    width: 600px; height: 600px;
    background: var(--muted-gray-1);
    top: 40%; left: 40%;
    border-radius: 50% 50% 40% 60% / 40% 60% 50% 50%;
    animation: blobMorph4 90s ease-in-out infinite, blobFadeIn 3s 1.4s ease-out forwards;
}

.blob-5 {
    width: 280px; height: 280px;
    background: var(--muted-gray-2);
    top: 10%; left: 50%;
    border-radius: 70% 30% 50% 50% / 50% 70% 30% 50%;
    animation: blobMorph5 65s ease-in-out infinite, blobFadeIn 3s 1.8s ease-out forwards;
}

.blob-6 {
    width: 450px; height: 450px;
    background: var(--substrate-gray);
    top: 70%; right: 5%;
    border-radius: 35% 65% 55% 45% / 55% 45% 65% 35%;
    animation: blobMorph6 75s ease-in-out infinite, blobFadeIn 3s 2.2s ease-out forwards;
}

.blob-7 {
    width: 220px; height: 220px;
    background: var(--muted-gray-1);
    top: 80%; left: 5%;
    border-radius: 45% 55% 65% 35% / 35% 65% 45% 55%;
    animation: blobMorph1 50s ease-in-out infinite, blobFadeIn 3s 2.6s ease-out forwards;
}

.blob-chlorophyll {
    width: 380px; height: 380px;
    background: var(--chlorophyll-pulse);
    opacity: 0;
    top: 35%; left: 25%;
    border-radius: 55% 45% 60% 40% / 45% 55% 40% 60%;
    mix-blend-mode: normal;
    transition: transform 2s ease-out;
    animation: blobMorph3 60s ease-in-out infinite,
               chlorophyllFadeIn 3s 1.2s ease-out forwards,
               chlorophyllBreath 6s ease-in-out infinite 4.2s;
}

/* Blob morph keyframes */
@keyframes blobMorph1 {
    0%, 100% { border-radius: 30% 70% 60% 40% / 50% 60% 40% 50%; }
    25% { border-radius: 55% 45% 40% 60% / 60% 35% 65% 40%; }
    50% { border-radius: 40% 60% 70% 30% / 35% 55% 45% 65%; }
    75% { border-radius: 65% 35% 45% 55% / 50% 40% 60% 50%; }
}

@keyframes blobMorph2 {
    0%, 100% { border-radius: 60% 40% 30% 70% / 40% 50% 60% 50%; }
    33% { border-radius: 40% 60% 55% 45% / 55% 40% 45% 60%; }
    66% { border-radius: 50% 50% 45% 55% / 60% 45% 55% 40%; }
}

@keyframes blobMorph3 {
    0%, 100% { border-radius: 40% 60% 70% 30% / 60% 40% 50% 50%; }
    25% { border-radius: 60% 40% 50% 50% / 40% 60% 45% 55%; }
    50% { border-radius: 50% 50% 35% 65% / 55% 50% 60% 40%; }
    75% { border-radius: 35% 65% 60% 40% / 45% 55% 35% 65%; }
}

@keyframes blobMorph4 {
    0%, 100% { border-radius: 50% 50% 40% 60% / 40% 60% 50% 50%; }
    33% { border-radius: 35% 65% 55% 45% / 55% 45% 40% 60%; }
    66% { border-radius: 60% 40% 45% 55% / 50% 55% 60% 40%; }
}

@keyframes blobMorph5 {
    0%, 100% { border-radius: 70% 30% 50% 50% / 50% 70% 30% 50%; }
    50% { border-radius: 40% 60% 60% 40% / 60% 40% 60% 40%; }
}

@keyframes blobMorph6 {
    0%, 100% { border-radius: 35% 65% 55% 45% / 55% 45% 65% 35%; }
    33% { border-radius: 55% 45% 40% 60% / 40% 60% 45% 55%; }
    66% { border-radius: 45% 55% 65% 35% / 60% 35% 55% 45%; }
}

@keyframes blobFadeIn {
    from { opacity: 0; }
    to { opacity: 0.7; }
}

@keyframes chlorophyllFadeIn {
    from { opacity: 0; }
    to { opacity: 0.3; }
}

@keyframes chlorophyllBreath {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 0.35; }
}

/* ========================================
   Pollen Particle Field
   ======================================== */
#pollen-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
}

.pollen {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--sensor-blue);
    opacity: 0.15;
    animation: pollenFloat linear infinite;
}

.p1  { left: 5%;  bottom: -5%; animation-duration: 18s; animation-delay: 0s; width: 2px; height: 2px; }
.p2  { left: 12%; bottom: -5%; animation-duration: 24s; animation-delay: 2s; }
.p3  { left: 22%; bottom: -5%; animation-duration: 15s; animation-delay: 5s; width: 4px; height: 4px; }
.p4  { left: 30%; bottom: -5%; animation-duration: 28s; animation-delay: 1s; }
.p5  { left: 38%; bottom: -5%; animation-duration: 20s; animation-delay: 8s; width: 2px; height: 2px; }
.p6  { left: 45%; bottom: -5%; animation-duration: 22s; animation-delay: 3s; }
.p7  { left: 55%; bottom: -5%; animation-duration: 16s; animation-delay: 6s; width: 4px; height: 4px; }
.p8  { left: 62%; bottom: -5%; animation-duration: 26s; animation-delay: 0.5s; }
.p9  { left: 70%; bottom: -5%; animation-duration: 19s; animation-delay: 4s; width: 2px; height: 2px; }
.p10 { left: 78%; bottom: -5%; animation-duration: 30s; animation-delay: 7s; }
.p11 { left: 85%; bottom: -5%; animation-duration: 14s; animation-delay: 2.5s; }
.p12 { left: 90%; bottom: -5%; animation-duration: 25s; animation-delay: 9s; width: 4px; height: 4px; }
.p13 { left: 17%; bottom: -5%; animation-duration: 21s; animation-delay: 11s; }
.p14 { left: 50%; bottom: -5%; animation-duration: 17s; animation-delay: 13s; width: 2px; height: 2px; }
.p15 { left: 75%; bottom: -5%; animation-duration: 23s; animation-delay: 10s; }

@keyframes pollenFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    5% {
        opacity: 0.15;
    }
    25% {
        transform: translateY(-30vh) translateX(8px);
    }
    50% {
        transform: translateY(-60vh) translateX(-5px);
    }
    75% {
        transform: translateY(-90vh) translateX(10px);
    }
    95% {
        opacity: 0.15;
    }
    100% {
        transform: translateY(-120vh) translateX(-3px);
        opacity: 0;
    }
}

/* ========================================
   Botanical Circuit Lines (SVG Vines)
   ======================================== */
#vine-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 8;
    pointer-events: none;
}

.vine {
    fill: none;
    stroke: var(--muted-gray-1);
    stroke-width: 1;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset var(--vine-grow-duration) ease-in-out;
}

.vine.grown {
    stroke-dashoffset: 0;
}

.vine-node {
    fill: var(--muted-gray-1);
    opacity: 0;
    transition: opacity 0.8s ease-in-out 0.6s;
}

.vine-node.visible {
    opacity: 1;
}

/* ========================================
   Plane 2: Observation Panels
   ======================================== */
#panels-container {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    padding: 8vh 4vw;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    max-width: 1600px;
    margin: 0 auto;
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    border: 1px solid var(--panel-border);
    padding: clamp(2rem, 4vw, 3.5rem);
    position: relative;
    opacity: 0;
    transition: backdrop-filter 300ms ease, box-shadow 300ms ease, transform 300ms ease;
}

.panel.visible {
    opacity: 1;
}

.panel:hover {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateZ(0) scale(1.002);
}

/* Asymmetric placement with overlaps */
.panel-genesis {
    grid-column: 1;
    margin-right: -8%;
    margin-top: 10vh;
    margin-bottom: 4vh;
    box-shadow: -15px 8px 30px rgba(184, 196, 204, 0.25);
    transform: translateX(-60px);
}
.panel-genesis.visible { transform: translateX(0); }

.panel-taxonomy {
    grid-column: 2;
    margin-left: -5%;
    margin-top: 18vh;
    margin-bottom: 4vh;
    box-shadow: 12px -10px 35px rgba(184, 196, 204, 0.25);
    transform: translateX(60px);
}
.panel-taxonomy.visible { transform: translateX(0); }

.panel-root-network {
    grid-column: 1 / -1;
    max-width: 70%;
    margin: 4vh auto;
    box-shadow: 0px 15px 40px rgba(184, 196, 204, 0.25);
    transform: translateY(60px);
}
.panel-root-network.visible { transform: translateY(0); }

.panel-phenology {
    grid-column: 1;
    margin-right: -10%;
    margin-top: 4vh;
    margin-bottom: 4vh;
    box-shadow: -10px -12px 28px rgba(184, 196, 204, 0.25);
    transform: translateX(-60px);
}
.panel-phenology.visible { transform: translateX(0); }

.panel-spore {
    grid-column: 2;
    margin-left: -8%;
    margin-top: 12vh;
    margin-bottom: 4vh;
    box-shadow: 18px 6px 32px rgba(184, 196, 204, 0.25);
    transform: translateX(60px);
}
.panel-spore.visible { transform: translateX(0); }

/* Panel transition */
.panel {
    transition: backdrop-filter 300ms ease, box-shadow 300ms ease, transform 800ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 600ms ease;
}

/* ---- Panel Typography ---- */
.panel-meta {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sensor-blue);
    margin-bottom: 1.5rem;
}

.panel-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--deep-fern);
    margin-bottom: 1.5rem;
}

.panel-body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.72;
    color: var(--lichen-gray);
    max-width: 58ch;
    margin-bottom: 1.2rem;
}

/* ---- Dark Panel (Root Network) ---- */
.dark-panel {
    background: rgba(26, 40, 48, 0.95);
    backdrop-filter: blur(var(--panel-blur));
    -webkit-backdrop-filter: blur(var(--panel-blur));
    transition: background-color 600ms ease, backdrop-filter 300ms ease, box-shadow 300ms ease, transform 800ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 600ms ease;
}

.light-meta {
    color: var(--sensor-blue);
}

.light-title {
    color: var(--substrate-gray);
}

.light-body {
    color: var(--substrate-gray);
}

.accent-text {
    color: var(--chlorophyll-pulse);
}

/* ---- Taxonomy List ---- */
.taxonomy-list {
    margin-top: 1.5rem;
}

.taxon {
    padding: 1rem 0;
    border-bottom: 1px solid var(--panel-border);
}

.taxon:last-child {
    border-bottom: none;
}

.taxon-label {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1rem;
    letter-spacing: 0.03em;
    color: var(--deep-fern);
    display: block;
    margin-bottom: 0.3rem;
}

.taxon-data {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--sensor-blue);
}

/* ---- Phenology Phases ---- */
.phenology-phases {
    margin-top: 1.5rem;
}

.phase {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.8rem;
}

.phase-name {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sensor-blue);
    min-width: 120px;
}

.phase-bar {
    flex: 1;
    height: 4px;
    background: var(--substrate-gray);
    position: relative;
}

.phase-fill {
    height: 100%;
    background: var(--muted-gray-2);
    transition: width 1.5s ease-out;
}

.phase-fill.active {
    background: var(--chlorophyll-pulse);
}

/* ========================================
   Navigation Dots
   ======================================== */
#nav-dots {
    position: fixed;
    right: 2vw;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.nav-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--nav-dot-base);
    cursor: pointer;
    position: relative;
    transition: width 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
                height 300ms cubic-bezier(0.34, 1.56, 0.64, 1),
                background 300ms ease;
}

.nav-dot:hover {
    width: 28px;
    height: 28px;
    margin-top: -8px;
    margin-bottom: -8px;
    background: var(--chlorophyll-pulse);
}

.nav-dot:hover .dot-label {
    opacity: 0.8;
    transform: translateX(-100%) translateX(-12px);
}

.nav-dot.active {
    background: var(--chlorophyll-pulse);
}

.dot-label {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateX(-100%) translateX(-12px) translateY(-50%);
    white-space: nowrap;
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--deep-fern);
    opacity: 0;
    transition: opacity 300ms ease;
    pointer-events: none;
    transform: translateY(-50%) translateX(-12px);
}

.nav-dot:hover .dot-label {
    opacity: 0.8;
}

/* ========================================
   Status Readout (large screens only)
   ======================================== */
#status-readout {
    position: fixed;
    bottom: 2vh;
    right: 4vw;
    z-index: 100;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sensor-blue);
    opacity: 0.6;
    display: none;
}

@media (min-width: 1600px) {
    #status-readout {
        display: block;
    }
}

.readout-line {
    margin-bottom: 0.3rem;
}

/* ========================================
   Responsive: Mobile / Tablet
   ======================================== */
@media (max-width: 900px) {
    #panels-container {
        display: flex;
        flex-direction: column;
        padding: 0;
        gap: 0;
        scroll-snap-type: y mandatory;
        overflow-y: auto;
        height: 100vh;
    }

    .panel {
        scroll-snap-align: start;
        min-height: 100vh;
        margin: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border: none;
        border-bottom: 1px solid var(--panel-border);
    }

    .panel-genesis,
    .panel-taxonomy,
    .panel-root-network,
    .panel-phenology,
    .panel-spore {
        margin: 0;
        grid-column: auto;
        max-width: 100%;
    }

    .panel-genesis { box-shadow: none; }
    .panel-taxonomy { box-shadow: none; }
    .panel-root-network { box-shadow: none; }
    .panel-phenology { box-shadow: none; }
    .panel-spore { box-shadow: none; }

    #nav-dots {
        right: 1vw;
        gap: 14px;
    }

    #vine-lines {
        display: none;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .blob {
        animation: none;
        opacity: 0.7;
    }

    .blob-chlorophyll {
        animation: none;
        opacity: 0.3;
    }

    .pollen {
        animation: none;
        opacity: 0;
    }

    .vine {
        stroke-dashoffset: 0;
        transition: none;
    }

    .vine-node {
        opacity: 1;
        transition: none;
    }

    .panel {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
