/* ============================================
   gabs.cafe - Goblincore Pastoral Design
   A vertical descent through a living forest
   ============================================ */

/* ---- CSS Custom Properties ---- */
:root {
    --deep-loam: #1b2a1b;
    --amethyst-fungus: #6b3fa0;
    --lichen-gold: #b8860b;
    --chanterelle-amber: #d4883a;
    --birch-parchment: #f2e8d5;
    --burrow-earth: #2d1f3d;
    --bark-dark: #2e2e28;
    --dried-sage: #7a8068;
    --dried-oak: #6b5b3e;
    --beetle-emerald: #1a6b4a;
    --warm-light: #d4c9b8;
    --secondary-light: #e8dcc8;
    --dark-accent: #3d2f4d;
    --true-dark: #0d0d0d;
    --card-bg: rgba(242, 232, 213, 0.92);
}

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

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

body {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    color: var(--bark-dark);
    background: var(--birch-parchment);
    overflow-x: hidden;
    line-height: 1.72;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
}

/* ---- Grain Texture Overlay ---- */
#grain-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 viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 256px 256px;
}

.layer-deep #grain-overlay,
.layer-deep ~ #grain-overlay {
    opacity: 0.08;
}

/* ---- Floating Spore Particles ---- */
#spore-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

.spore {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: spore-float linear infinite;
}

@keyframes spore-float {
    0% {
        transform: translateY(100vh) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: var(--spore-opacity, 0.4);
    }
    90% {
        opacity: var(--spore-opacity, 0.4);
    }
    100% {
        transform: translateY(-20vh) translateX(var(--drift-x, 30px));
        opacity: 0;
    }
}

.spore.firefly {
    animation: spore-float linear infinite, firefly-flash 1.5s ease-in-out infinite;
}

@keyframes firefly-flash {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* ---- Navigation ---- */
#mushroom-nav {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 500;
}

.nav-caps {
    position: relative;
    width: 44px;
    height: 44px;
    cursor: pointer;
}

.cap {
    position: absolute;
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.cap-1 {
    width: 20px;
    height: 20px;
    background: var(--chanterelle-amber);
    top: 0;
    left: 10px;
    opacity: 0.85;
}

.cap-2 {
    width: 16px;
    height: 16px;
    background: var(--amethyst-fungus);
    top: 12px;
    left: 0;
    opacity: 0.75;
}

.cap-3 {
    width: 14px;
    height: 14px;
    background: var(--beetle-emerald);
    top: 14px;
    left: 22px;
    opacity: 0.8;
}

.nav-menu {
    list-style: none;
    position: absolute;
    top: 50px;
    right: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    transform: translateY(-10px) rotate(-3deg);
    background: rgba(45, 31, 61, 0.95);
    padding: 1.2rem 1.6rem;
    border-radius: 12px 30px 8px 24px;
    min-width: 180px;
    backdrop-filter: blur(8px);
}

#mushroom-nav:hover .nav-menu,
#mushroom-nav.open .nav-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) rotate(0deg);
}

#mushroom-nav:hover .cap-1 {
    transform: translate(-5px, -3px) scale(1.1);
}

#mushroom-nav:hover .cap-2 {
    transform: translate(-8px, 5px) scale(1.15);
}

#mushroom-nav:hover .cap-3 {
    transform: translate(5px, 5px) scale(1.1);
}

.nav-menu li {
    padding: 0.4rem 0;
}

.nav-menu li:nth-child(1) { transform: translateX(0); }
.nav-menu li:nth-child(2) { transform: translateX(8px); }
.nav-menu li:nth-child(3) { transform: translateX(3px); }
.nav-menu li:nth-child(4) { transform: translateX(12px); }

.nav-link {
    color: var(--warm-light);
    text-decoration: none;
    font-family: 'Caveat', cursive;
    font-size: 1.15rem;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: var(--lichen-gold);
}

/* ---- Typography ---- */
h1, h2, h3 {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.caveat-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    color: #6b5b3e;
}

p {
    max-width: 38em;
}

a {
    color: var(--beetle-emerald);
    transition: color 0.3s ease;
}

a:hover {
    color: var(--amethyst-fungus);
}

/* ---- Skeleton Loading ---- */
.skeleton-target {
    position: relative;
}

.skeleton-target.loading::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--warm-light);
    border-radius: inherit;
    animation: skeleton-pulse 1.8s ease-in-out infinite;
    z-index: 2;
}

.skeleton-target.loading > * {
    opacity: 0;
}

.skeleton-target.revealed > * {
    animation: content-reveal 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes skeleton-pulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.6; }
    100% { opacity: 0.3; }
}

@keyframes content-reveal {
    0% { opacity: 0; transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

/* ---- Spore Prints ---- */
.spore-print {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 2s ease;
}

.spore-print.visible {
    opacity: 0.18;
}

.spore-print-1 {
    width: 450px;
    height: 450px;
    background: conic-gradient(
        from 0deg,
        var(--amethyst-fungus) 0deg,
        transparent 3deg,
        transparent 12deg,
        var(--amethyst-fungus) 15deg,
        transparent 18deg,
        transparent 27deg,
        var(--amethyst-fungus) 30deg,
        transparent 33deg
    );
    top: 10%;
    right: -5%;
}

.spore-print-2 {
    width: 300px;
    height: 300px;
    background: conic-gradient(
        from 45deg,
        var(--lichen-gold) 0deg,
        transparent 4deg,
        transparent 15deg,
        var(--lichen-gold) 18deg,
        transparent 22deg,
        transparent 33deg,
        var(--lichen-gold) 36deg,
        transparent 40deg
    );
    bottom: 20%;
    left: 5%;
}

.spore-print-3 {
    width: 200px;
    height: 200px;
    background: conic-gradient(
        from 90deg,
        var(--beetle-emerald) 0deg,
        transparent 5deg,
        transparent 18deg,
        var(--beetle-emerald) 22deg,
        transparent 27deg
    );
    top: 40%;
    left: 50%;
}

/* ========================================
   SECTION 1: THE CANOPY
   ======================================== */
.layer-canopy {
    min-height: 110vh;
    background: var(--birch-parchment);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 8vw;
    overflow: hidden;
}

.canopy-content {
    position: relative;
    z-index: 10;
    margin-left: 5vw;
}

.site-title {
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--deep-loam);
    margin-bottom: 1rem;
}

.site-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

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

.site-title .dot {
    color: var(--chanterelle-amber);
}

.subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--dried-sage);
    transform: rotate(-2deg);
    opacity: 0;
    transition: opacity 0.8s ease-out 0.3s;
    margin-left: 0.5rem;
}

.subtitle.visible {
    opacity: 1;
}

.mycelial-invite {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 150px;
    z-index: 10;
}

.mycelial-path {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 2s cubic-bezier(0.22, 1, 0.36, 1);
}

.mycelial-path.drawn {
    stroke-dashoffset: 0;
}

/* ========================================
   SECTION 2: THE UNDERSTORY
   ======================================== */
.layer-understory {
    min-height: 120vh;
    position: relative;
    overflow: hidden;
    padding: 10vh 5vw;
    background: var(--secondary-light);
}

.understory-bg-split {
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 100%;
    background: var(--burrow-earth);
    clip-path: polygon(0 0, 85% 0, 100% 100%, 0% 100%);
    z-index: 0;
}

.understory-content {
    position: relative;
    z-index: 10;
}

.section-heading {
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: var(--birch-parchment);
    transform: rotate(-2deg);
    margin-bottom: 4rem;
    margin-left: 3vw;
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.section-heading.visible {
    opacity: 1;
}

.card-cluster {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.forest-card {
    position: relative;
    background: var(--card-bg);
    padding: 2rem 2.2rem;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s ease;
    box-shadow: 8px 12px 32px rgba(107, 63, 160, 0.15), -4px -8px 24px rgba(26, 107, 74, 0.08);
}

.forest-card:hover {
    transform: translateY(-4px);
}

.card-1 {
    border-radius: 12px 45px 8px 32px;
    transform: rotate(-1deg);
    margin-top: 2rem;
}

.card-2 {
    border-radius: 32px 8px 38px 12px;
    transform: rotate(1.5deg);
    margin-top: 0;
}

.card-3 {
    border-radius: 8px 28px 42px 15px;
    transform: rotate(0.5deg);
    margin-top: -1rem;
}

.card-4 {
    border-radius: 38px 12px 8px 42px;
    transform: rotate(-2deg);
    margin-top: 1rem;
}

.forest-card h3 {
    font-size: 1.3rem;
    color: var(--deep-loam);
    margin-bottom: 0.8rem;
    position: relative;
    z-index: 2;
}

.forest-card p {
    color: var(--bark-dark);
    font-weight: 300;
    position: relative;
    z-index: 2;
    line-height: 1.72;
}

/* Lichen Patches */
.lichen-patch {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    opacity: 0.2;
    transition: background 0.4s ease, transform 0.4s ease;
    z-index: 1;
}

.lichen-emerald {
    background: radial-gradient(ellipse at 30% 40%, var(--beetle-emerald), transparent);
    top: -20px;
    right: -30px;
}

.lichen-amethyst {
    background: radial-gradient(ellipse at 60% 30%, var(--amethyst-fungus), transparent);
    bottom: -25px;
    left: -20px;
}

.lichen-gold {
    background: radial-gradient(ellipse at 40% 60%, var(--lichen-gold), transparent);
    top: -15px;
    left: -25px;
}

.lichen-amber {
    background: radial-gradient(ellipse at 50% 40%, var(--chanterelle-amber), transparent);
    bottom: -20px;
    right: -25px;
}

.forest-card:hover .lichen-emerald {
    background: radial-gradient(ellipse at 30% 40%, var(--amethyst-fungus), transparent);
    transform: scale(1.1) rotate(10deg);
}

.forest-card:hover .lichen-amethyst {
    background: radial-gradient(ellipse at 60% 30%, var(--beetle-emerald), transparent);
    transform: scale(1.1) rotate(-8deg);
}

.forest-card:hover .lichen-gold {
    background: radial-gradient(ellipse at 40% 60%, var(--amethyst-fungus), transparent);
    transform: scale(1.15) rotate(5deg);
}

.forest-card:hover .lichen-amber {
    background: radial-gradient(ellipse at 50% 40%, var(--amethyst-fungus), transparent);
    transform: scale(1.1) rotate(-12deg);
}

/* ========================================
   SECTION 3: THE ROOT NETWORK
   ======================================== */
.layer-roots {
    min-height: 120vh;
    background: var(--deep-loam);
    position: relative;
    padding: 10vh 5vw;
    overflow: hidden;
}

.mycelial-network {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.network-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 3s cubic-bezier(0.22, 1, 0.36, 1);
}

.network-line.drawn {
    stroke-dashoffset: 0;
}

.roots-content {
    position: relative;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem 6rem;
    max-width: 1000px;
    margin: 0 auto;
    padding-top: 5vh;
}

.root-node {
    position: relative;
    padding: 2rem;
}

.node-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: -1;
    animation: glow-pulse 4s ease-in-out infinite alternate;
}

@keyframes glow-pulse {
    0% { box-shadow: 0 0 12px 6px var(--glow-color); }
    100% { box-shadow: 0 0 20px 10px var(--glow-color); }
}

.glow-amethyst { --glow-color: rgba(107, 63, 160, 0.15); }
.glow-emerald { --glow-color: rgba(26, 107, 74, 0.15); }
.glow-gold { --glow-color: rgba(184, 134, 11, 0.15); }
.glow-amber { --glow-color: rgba(212, 136, 58, 0.15); }

.root-node h3 {
    color: var(--birch-parchment);
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
}

.root-node p {
    color: var(--warm-light);
    font-weight: 300;
    line-height: 1.72;
}

.node-1 {
    transform: rotate(-1deg);
    margin-top: 3rem;
}

.node-2 {
    transform: rotate(1deg);
    margin-top: 8rem;
}

.node-3 {
    transform: rotate(0.5deg);
    margin-top: -2rem;
}

.node-4 {
    transform: rotate(-1.5deg);
    margin-top: 4rem;
}

.forest-quote {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 1.15rem;
    color: var(--warm-light);
    line-height: 1.6;
    border-left: 2px solid var(--amethyst-fungus);
    padding-left: 1.5rem;
    margin: 0;
}

.root-whisper {
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    color: var(--lichen-gold);
    transform: rotate(-3deg);
}

/* ========================================
   SECTION 4: THE DEEP EARTH
   ======================================== */
.layer-deep {
    min-height: 100vh;
    background: var(--burrow-earth);
    position: relative;
    padding: 10vh 5vw 0;
    overflow: hidden;
}

.crystal {
    position: absolute;
    z-index: 5;
}

.crystal-1 {
    width: 160px;
    height: 160px;
    top: 10%;
    right: 5%;
    animation: crystal-rotate 60s linear infinite;
    filter: drop-shadow(0 0 8px rgba(107, 63, 160, 0.3));
}

.crystal-2 {
    width: 100px;
    height: 150px;
    bottom: 25%;
    left: 3%;
    animation: crystal-rotate 80s linear infinite reverse;
    filter: drop-shadow(0 0 6px rgba(26, 107, 74, 0.2));
}

.crystal-3 {
    width: 80px;
    height: 80px;
    top: 50%;
    right: 15%;
    animation: crystal-rotate 90s linear infinite;
    filter: drop-shadow(0 0 5px rgba(184, 134, 11, 0.2));
}

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

.deep-content {
    position: relative;
    z-index: 10;
    max-width: 480px;
    margin: 0 auto;
    text-align: left;
}

.deep-heading {
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--birch-parchment);
    margin-bottom: 2rem;
}

.deep-text p {
    color: var(--warm-light);
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

.deep-note {
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: var(--lichen-gold);
    transform: rotate(-2deg);
    display: inline-block;
    margin-top: 1rem;
}

/* Final Spore Print */
.final-spore-print {
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        var(--amethyst-fungus) 0deg,
        transparent 4deg,
        transparent 10deg,
        var(--amethyst-fungus) 14deg,
        transparent 18deg,
        transparent 24deg,
        var(--amethyst-fungus) 28deg,
        transparent 32deg,
        transparent 38deg,
        var(--amethyst-fungus) 42deg,
        transparent 46deg
    );
    opacity: 0.1;
    margin: 4rem auto;
    animation: final-rotate 120s linear infinite;
    position: relative;
}

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

/* Fade to Black */
.fade-to-black {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15vh;
    background: linear-gradient(to bottom, transparent, var(--true-dark));
    z-index: 20;
    pointer-events: none;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
    .card-cluster {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .roots-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .node-1, .node-2, .node-3, .node-4 {
        margin-top: 0;
    }

    .spore-print-1 {
        width: 250px;
        height: 250px;
    }

    .spore-print-2 {
        width: 180px;
        height: 180px;
    }

    .spore-print-3 {
        width: 120px;
        height: 120px;
    }

    .final-spore-print {
        width: 280px;
        height: 280px;
    }

    .crystal-1 { width: 100px; height: 100px; }
    .crystal-2 { width: 70px; height: 105px; }
    .crystal-3 { width: 50px; height: 50px; }

    .canopy-content {
        margin-left: 0;
    }

    .layer-canopy {
        padding: 5vh 5vw;
    }

    .understory-bg-split {
        width: 100%;
        clip-path: polygon(0 0, 100% 0, 100% 60%, 0% 100%);
    }
}
