/* ============================================================
   desca.works -- Goblincore Apothecary / Bioluminescent Specimen Collection
   Aesthetic: Goblincore + Dopamine-Neon + Editorial-Flow
   ============================================================ */

/* --- Custom Properties (exact DESIGN.md palette) --- */
:root {
    /* Background */
    --bg-deep: #0B0E0A;           /* Mycelium Black */
    --bg-mid: #1A2318;            /* Spore Dark */

    /* Neon Accents */
    --neon-green: #39FF14;        /* Bioluminescent Green */
    --neon-magenta: #FF00E5;      /* Toxic Magenta */
    --neon-yellow: #DFFF00;       /* Slime Yellow */

    /* Card & Surface */
    --card-surface: rgba(255,255,255,0.06);  /* Frosted Lichen */
    --card-border: rgba(255,255,255,0.15);
    --card-shadow: rgba(57,255,20,0.15);

    /* Text */
    --text-primary: #E8F5E0;     /* Pale Spore */
    --text-secondary: #7A9B6D;   /* Faded Moss */

    /* Accent */
    --accent-warm: #FF8F00;      /* Fungi Amber */
    --dormant-green: #2A4A1E;

    /* Easing (from DESIGN.md) */
    --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-exit: cubic-bezier(0.7, 0, 0.84, 0);

    /* Spacing */
    --spacing: clamp(2rem, 5vw, 6rem);
}

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

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

body {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    background-color: var(--bg-deep);
    overflow-x: hidden;
}

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

/* --- Spore Navigation (left-edge vertical dots) --- */
#spore-nav {
    position: fixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 900;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.spore-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--dormant-green);
    cursor: pointer;
    transition: background 0.6s var(--ease-enter), box-shadow 0.6s var(--ease-enter);
    animation: spore-pulse 3s ease-in-out infinite;
}

.spore-dot.active {
    background: var(--neon-green);
    box-shadow: 0 0 12px var(--neon-green), 0 0 24px rgba(57,255,20,0.3);
}

@keyframes spore-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* --- Spore Particle System (CSS-only, ~30 spores) --- */
#spore-field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 800;
    overflow: hidden;
}

.spore {
    position: absolute;
    bottom: -20px;
    left: var(--x-start);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
    opacity: 0;
    animation: spore-drift var(--duration) var(--delay) infinite;
    will-change: transform, opacity;
}

@keyframes spore-drift {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    8% {
        opacity: 0.8;
    }
    25% {
        transform: translateY(-25vh) translateX(calc(var(--x-end) - var(--x-start)));
        opacity: 0.7;
    }
    50% {
        transform: translateY(-50vh) translateX(calc((var(--x-end) - var(--x-start)) * 0.6));
        opacity: 0.5;
    }
    75% {
        transform: translateY(-80vh) translateX(calc(var(--x-end) - var(--x-start)));
        opacity: 0.2;
    }
    100% {
        transform: translateY(-110vh) translateX(calc((var(--x-end) - var(--x-start)) * 0.4));
        opacity: 0;
    }
}

/* --- Chamber Base (full-viewport specimen plates) --- */
.chamber {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    perspective: 1000px;
}

.chamber-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 1400px;
    padding: var(--spacing);
}

/* --- Typography: Headlines (Anybody, variable-fluid) --- */
.title-surface {
    font-family: 'Anybody', sans-serif;
    font-size: clamp(2.8rem, 7vw, 5.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    text-align: center;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.title-char {
    display: inline-block;
    font-variation-settings: 'wdth' 75;
    color: var(--text-secondary);
    animation: char-expand 1.5s var(--ease-enter) forwards;
    animation-delay: var(--char-delay);
}

@keyframes char-expand {
    0% {
        font-variation-settings: 'wdth' 75;
        color: var(--text-secondary);
    }
    100% {
        font-variation-settings: 'wdth' 125;
        color: var(--neon-green);
    }
}

.card-title {
    font-family: 'Anybody', sans-serif;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 700;
    font-variation-settings: 'wdth' 100;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

/* Chamber 3: narrow width axis (75%) for variety */
.narrow-title {
    font-variation-settings: 'wdth' 75;
}

/* Chamber 4: extreme settings -- weight 900, width 125%, Fungi Amber */
.core-title {
    font-weight: 900;
    font-variation-settings: 'wdth' 125;
    color: var(--accent-warm);
    font-size: clamp(2.2rem, 5vw, 4rem);
}

/* --- Typography: Body (Outfit) --- */
.card-body {
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.65;
    letter-spacing: 0.01em;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* --- Typography: Labels (Fira Code, monospace) --- */
.specimen-label {
    font-family: 'Fira Code', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--neon-green);
    display: block;
    margin-bottom: 0.5rem;
}

/* --- Blink Label (Chamber 1: 3s interval blink) --- */
.blink-label {
    text-align: center;
    animation: label-blink 3s step-end infinite;
}

@keyframes label-blink {
    0%, 80% { opacity: 1; }
    40%, 60% { opacity: 0; }
}

/* --- Pulse Label (Chamber 5: pulsing final text) --- */
.pulse-label {
    text-align: center;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    animation: label-pulse 3s ease-in-out infinite;
}

@keyframes label-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; text-shadow: 0 0 20px var(--neon-green), 0 0 40px rgba(57,255,20,0.3); }
}

/* --- Glassmorphic Specimen Cards --- */
.specimen-card {
    background: var(--card-surface);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: clamp(1.5rem, 3vw, 2.5rem);
    box-shadow: 0 8px 32px var(--card-shadow);
    position: relative;
    animation: border-shift 6s ease-in-out infinite;
}

/* Card border shifts between neon green and toxic magenta */
@keyframes border-shift {
    0%, 100% { border-color: rgba(57,255,20,0.3); }
    50% { border-color: rgba(255,0,229,0.3); }
}

/* --- Blur-Focus Transition (primary interaction pattern) --- */
.blur-target {
    filter: blur(12px);
    opacity: 0.3;
    transition: filter 0.8s var(--ease-enter), opacity 0.8s var(--ease-enter);
}

.blur-target.in-focus {
    filter: blur(0px);
    opacity: 1;
}

/* --- Gradient Glow Background (behind glassmorphic cards) --- */
.gradient-glow-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #39FF14, #FF00E5, #DFFF00, #39FF14);
    background-size: 400% 400%;
    animation: gradient-cycle 12s ease infinite;
    opacity: 0.08;
    z-index: 1;
}

.glow-intense {
    opacity: 0.15;
}

@keyframes gradient-cycle {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 50%; }
}

/* ============================================================
   CHAMBER 1: Surface
   ============================================================ */
.chamber-surface {
    background: var(--bg-deep);
    flex-direction: column;
}

.surface-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wave-low {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    z-index: 5;
}

/* ============================================================
   CHAMBER 2: First Specimens
   ============================================================ */
.chamber-specimens {
    background: var(--bg-deep);
}

.specimens-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--spacing);
    position: relative;
}

/* Large card: 60vw, 40vh, left-of-center, -2deg rotation */
.card-large {
    width: min(60vw, 700px);
    min-height: 280px;
    transform: rotate(-2deg) translateZ(40px);
}

/* Small card: 35vw, 30vh, right-of-center, +3deg rotation, asymmetric radii */
.card-small {
    width: min(35vw, 420px);
    min-height: 220px;
    transform: rotate(3deg) translateZ(20px);
    margin-top: 4rem;
    border-radius: 20px 4px 20px 4px;
}

/* Mid-frequency connector wave between the two cards */
.wave-connector {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 200px;
    transform: translateY(-50%);
    z-index: 5;
    pointer-events: none;
}

/* ============================================================
   CHAMBER 3: Deep Network
   ============================================================ */
.chamber-network {
    background: var(--bg-mid);
}

.network-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: var(--spacing);
    position: relative;
}

/* Triangular card layout with asymmetric border-radii */
.card-triangle-a {
    grid-column: 1;
    grid-row: 1;
    transform: rotate(-1deg) translateZ(30px);
    border-radius: 4px 20px 20px 4px;
    max-width: 420px;
}

.card-triangle-b {
    grid-column: 2;
    grid-row: 1;
    transform: rotate(2deg) translateZ(50px);
    justify-self: end;
    border-radius: 20px 4px 4px 20px;
    max-width: 380px;
}

.card-triangle-c {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    transform: rotate(-0.5deg) translateZ(10px);
    border-radius: 20px 20px 4px 4px;
    max-width: 450px;
}

/* Mycelial thread wave-forms */
.wave-thread-1 {
    position: absolute;
    top: 15%;
    left: 5%;
    width: 90%;
    height: 200px;
    z-index: 5;
    pointer-events: none;
}

.wave-thread-2 {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 200px;
    z-index: 5;
    pointer-events: none;
}

.wave-thread-3 {
    position: absolute;
    top: 75%;
    left: 8%;
    width: 84%;
    height: 200px;
    z-index: 5;
    pointer-events: none;
}

/* ============================================================
   CHAMBER 4: Bioluminescent Core
   ============================================================ */
.chamber-core {
    background: var(--bg-deep);
}

.core-layout {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Large centered card: 80vw, 60vh */
.card-core {
    width: min(80vw, 960px);
    min-height: 400px;
    animation: border-shift-fast 2s ease-in-out infinite;
}

/* Fastest border animation cycle (2s) in this section */
@keyframes border-shift-fast {
    0%, 100% {
        border-color: rgba(57,255,20,0.5);
        box-shadow: 0 8px 40px rgba(57,255,20,0.25), 0 0 60px rgba(57,255,20,0.1);
    }
    50% {
        border-color: rgba(255,0,229,0.5);
        box-shadow: 0 8px 40px rgba(255,0,229,0.2), 0 0 60px rgba(255,0,229,0.08);
    }
}

.core-data {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.core-data .specimen-label {
    margin-bottom: 0;
}

.wave-core-low {
    bottom: 5%;
    opacity: 0.6;
}

.wave-core-mid {
    position: absolute;
    top: 15%;
    left: 0;
    width: 100%;
    height: 200px;
    z-index: 5;
    opacity: 0.5;
}

.wave-core-high {
    position: absolute;
    top: 40%;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 5;
    opacity: 0.7;
}

.wave-high {
    position: absolute;
}

/* ============================================================
   CHAMBER 5: Spore Release
   ============================================================ */
.chamber-release {
    background: var(--bg-deep);
}

.release-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.final-label {
    font-size: clamp(1rem, 1.5vw, 1.3rem);
}

/* Ghost echo cards: faint remnants drifting upward */
.ghost-card {
    position: absolute;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 20px;
    pointer-events: none;
    animation: ghost-drift 15s ease-in-out infinite;
}

.ghost-1 {
    width: 300px;
    height: 200px;
    top: 20%;
    left: 15%;
    animation-delay: 0s;
}

.ghost-2 {
    width: 250px;
    height: 180px;
    top: 35%;
    right: 20%;
    animation-delay: 3s;
}

.ghost-3 {
    width: 200px;
    height: 150px;
    bottom: 25%;
    left: 40%;
    animation-delay: 6s;
}

@keyframes ghost-drift {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.05;
    }
    50% {
        transform: translateY(-40px) rotate(1deg);
        opacity: 0.02;
    }
}

.wave-release {
    bottom: 10%;
    opacity: 0.3;
}

/* ============================================================
   Mushroom Silhouettes (decorative, 5-10% opacity)
   ============================================================ */
.mushroom-silhouette {
    position: absolute;
    z-index: 2;
    opacity: 0.06;
    pointer-events: none;
}

.mushroom-bracket {
    width: 200px;
    height: 200px;
    top: 10%;
    right: 5%;
    transform: rotate(3deg);
}

.mushroom-amanita {
    width: 180px;
    height: 220px;
    bottom: 10%;
    left: 3%;
    transform: rotate(-5deg);
    opacity: 0.08;
}

.mushroom-morel {
    width: 150px;
    height: 200px;
    top: 15%;
    right: 8%;
    transform: rotate(2deg);
    opacity: 0.07;
}

.mushroom-bracket-2 {
    width: 160px;
    height: 180px;
    bottom: 5%;
    right: 4%;
    transform: rotate(-3deg);
    opacity: 0.05;
}

/* ============================================================
   Wave Styling (SVG wave-forms)
   ============================================================ */
.wave-mid {
    position: absolute;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    #spore-nav {
        left: 12px;
        gap: 14px;
    }

    .spore-dot {
        width: 8px;
        height: 8px;
    }

    .specimens-layout {
        flex-direction: column;
        align-items: center;
    }

    .card-large {
        width: min(85vw, 500px);
        transform: rotate(-1deg);
    }

    .card-small {
        width: min(80vw, 450px);
        transform: rotate(1deg);
        margin-top: 2rem;
    }

    .network-layout {
        grid-template-columns: 1fr;
    }

    .card-triangle-a,
    .card-triangle-b,
    .card-triangle-c {
        max-width: 100%;
        justify-self: center;
    }

    .card-triangle-b {
        justify-self: center;
    }

    .card-core {
        width: min(92vw, 700px);
        min-height: 300px;
    }

    .core-data {
        flex-direction: column;
        gap: 0.75rem;
    }

    .ghost-1 { width: 200px; height: 140px; }
    .ghost-2 { width: 170px; height: 120px; }
    .ghost-3 { width: 140px; height: 100px; }

    .mushroom-silhouette {
        display: none;
    }
}

@media (max-width: 480px) {
    .title-surface {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .card-title {
        font-size: clamp(1.4rem, 5vw, 2rem);
    }

    .core-title {
        font-size: clamp(1.6rem, 6vw, 2.5rem);
    }
}
