/* ============================================================
   monopole.systems — Botanical Graffiti Infrastructure
   ============================================================ */

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

:root {
    --deep-concrete: #141414;
    --dark-concrete: #1a1a1a;
    --weathered-wall: #d4d0c8;
    --fog-layer: #9a9a9a;
    --raw-surface: #f0ece4;
    --moss-stain: #4a6741;
    --ghost-mark: #2a2a2a;
    --diagonal-angle: -8deg;
    --diagonal-counter: 8deg;
}

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

body {
    background-color: var(--deep-concrete);
    color: var(--raw-surface);
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-optical-sizing: auto;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    line-height: 1.7;
    overflow-x: hidden;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ============================================================
   THE WALL (Hero)
   ============================================================ */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--deep-concrete);
}

.hero__noise-layer {
    position: absolute;
    inset: 0;
    filter: url(#concrete-grain);
    background-color: var(--deep-concrete);
    z-index: 0;
}

.hero__cracks {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.hero__cracks svg {
    width: 100%;
    height: 100%;
}

.crack-line {
    stroke: var(--ghost-mark);
    stroke-width: 1;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.crack-line.animate {
    animation: drawCrack 1200ms ease-out forwards;
}

@keyframes drawCrack {
    to {
        stroke-dashoffset: 0;
    }
}

.moss-bleed {
    fill: var(--moss-stain);
    opacity: 0;
    r: 0;
}

.moss-bleed.animate {
    animation: mossBloom 800ms ease-out forwards;
}

@keyframes mossBloom {
    to {
        opacity: 0.15;
        r: 40;
    }
}

.hero__content {
    position: relative;
    z-index: 2;
    text-align: center;
    transform: rotate(var(--diagonal-angle));
}

.hero__title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(3.5rem, 10vw, 8rem);
    color: var(--raw-surface);
    letter-spacing: -0.02em;
    line-height: 1.1;
    opacity: 0;
    transform: translateY(30px);
    filter: url(#spray-overspray);
}

.hero__title.animate {
    animation: titleRise 800ms ease-out forwards;
}

@keyframes titleRise {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero__subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 500;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--moss-stain);
    margin-top: 0.5em;
    opacity: 0;
    filter: url(#paper-grain);
}

.hero__subtitle.animate {
    animation: subtitleFade 600ms ease-out forwards;
}

@keyframes subtitleFade {
    to {
        opacity: 1;
    }
}

/* Drip lines */
.drip-lines {
    position: relative;
    width: 100%;
    height: 0;
    pointer-events: none;
}

.drip {
    position: absolute;
    left: var(--drip-left);
    top: 0;
    width: 2px;
    height: 0;
    background: linear-gradient(to bottom, var(--moss-stain), transparent);
    opacity: 0;
}

.drip.animate {
    animation: dripDown 1200ms ease-in forwards;
    animation-delay: var(--drip-delay, 0s);
}

@keyframes dripDown {
    0% {
        height: 0;
        opacity: 0.6;
    }
    100% {
        height: var(--drip-height, 100px);
        opacity: 0;
    }
}

/* Scroll indicator */
.hero__scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    opacity: 0;
}

.hero__scroll-indicator.animate {
    animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.8;
    }
}

/* ============================================================
   THE TUNNEL (Diagonal Sections)
   ============================================================ */
.tunnel-section {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    padding: 0;
}

.tunnel-section--dark {
    background-color: var(--dark-concrete);
}

.tunnel-section--dark::before {
    content: '';
    position: absolute;
    inset: 0;
    filter: url(#concrete-grain);
    background-color: var(--dark-concrete);
    z-index: 0;
    pointer-events: none;
}

.tunnel-section--light {
    background-color: var(--weathered-wall);
    color: var(--deep-concrete);
}

.tunnel-section--light::before {
    content: '';
    position: absolute;
    inset: 0;
    filter: url(#concrete-grain);
    background-color: var(--weathered-wall);
    z-index: 0;
    pointer-events: none;
}

/* Spray edge transition between sections */
.spray-edge {
    position: absolute;
    top: -30px;
    left: -5%;
    width: 110%;
    height: 60px;
    z-index: 2;
    pointer-events: none;
}

.tunnel-section--dark .spray-edge--top {
    background: var(--deep-concrete);
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 40%,
        97% 50%, 99% 60%, 95% 68%,
        98% 75%, 93% 80%, 96% 88%,
        92% 92%, 97% 100%, 0% 100%,
        3% 92%, 1% 85%, 5% 78%,
        2% 70%, 6% 62%, 3% 55%,
        7% 48%, 4% 40%, 6% 32%,
        2% 25%, 5% 18%, 1% 10%
    );
}

.tunnel-section--light .spray-edge--top {
    background: var(--weathered-wall);
    clip-path: polygon(
        0% 0%, 100% 0%, 100% 35%,
        96% 45%, 99% 55%, 94% 65%,
        97% 72%, 92% 78%, 95% 85%,
        91% 90%, 96% 95%, 100% 100%, 0% 100%,
        4% 95%, 2% 88%, 6% 80%,
        3% 72%, 7% 65%, 4% 58%,
        8% 50%, 5% 42%, 7% 35%,
        3% 28%, 5% 20%, 1% 12%
    );
}

/* The diagonal skew container */
.tunnel-section__skew {
    position: relative;
    z-index: 1;
    padding: 120px 5% 120px;
    transform: rotate(var(--diagonal-angle));
    transform-origin: center center;
    min-height: 100vh;
    display: flex;
    align-items: center;
    opacity: 0;
    will-change: transform, opacity;
}

.tunnel-section__skew.animate {
    animation: sectionTilt 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sectionTilt {
    from {
        opacity: 0;
        transform: translateY(60px) rotate(0deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) rotate(var(--diagonal-angle));
    }
}

/* Content within sections, counter-rotated */
.tunnel-section__content {
    transform: rotate(var(--diagonal-counter));
    max-width: 60ch;
    position: relative;
}

.tunnel-section__content--left {
    margin-left: 10%;
    margin-right: auto;
}

.tunnel-section__content--right {
    margin-left: auto;
    margin-right: 10%;
}

/* Section numbers */
.section-number {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(4rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    line-height: 1;
    opacity: 0.08;
    position: absolute;
    top: -40px;
    left: -20px;
}

.tunnel-section--light .section-number {
    color: var(--deep-concrete);
}

.tunnel-section--dark .section-number {
    color: var(--raw-surface);
}

/* Section annotations (Caveat) */
.section-annotation {
    font-family: 'Caveat', cursive;
    font-weight: 500;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--moss-stain);
    margin-bottom: 0.5em;
    text-transform: lowercase;
    filter: url(#paper-grain);
}

/* Section headings */
.section-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-style: italic;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 1em;
    filter: url(#spray-overspray);
}

.tunnel-section--dark .section-heading {
    color: var(--raw-surface);
}

.tunnel-section--light .section-heading {
    color: var(--deep-concrete);
}

/* Section body text */
.section-body {
    max-width: 60ch;
    margin-bottom: 1.2em;
}

.tunnel-section--dark .section-body {
    color: var(--raw-surface);
}

.tunnel-section--light .section-body {
    color: var(--deep-concrete);
}

/* Dense content with two columns (deeper sections) */
.tunnel-section__content--dense {
    max-width: 80ch;
}

.dense-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Spore dots */
.spore-dots {
    position: absolute;
    top: 0;
    left: -30px;
    width: calc(100% + 60px);
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

/* Fern spirals */
.fern-spiral {
    position: absolute;
    width: 120px;
    height: 120px;
    pointer-events: none;
    z-index: 0;
}

.fern-spiral--corner {
    bottom: -20px;
    left: -40px;
}

.fern-spiral--corner-right {
    top: -20px;
    right: -40px;
}

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

.fern-path {
    stroke: var(--fog-layer);
    stroke-width: 1.5;
    stroke-opacity: 0.4;
    fill: none;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.fern-path.animate {
    animation: unfurlFern 1500ms ease-out forwards;
}

@keyframes unfurlFern {
    to {
        stroke-dashoffset: 0;
    }
}

/* ============================================================
   MYCELIUM NETWORKS
   ============================================================ */
.mycelium-zone {
    position: relative;
    height: 120px;
    width: 100%;
    overflow: hidden;
    z-index: 1;
}

.mycelium-zone--dense {
    height: 150px;
}

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

.mycelium-trunk {
    stroke: var(--moss-stain);
    stroke-width: 1.5;
    fill: none;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0ms linear;
}

.mycelium-branch--secondary {
    stroke: var(--moss-stain);
    stroke-width: 1;
    fill: none;
    stroke-opacity: 0.7;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0ms linear;
}

.mycelium-branch--tertiary {
    stroke: var(--moss-stain);
    stroke-width: 0.75;
    fill: none;
    stroke-opacity: 0.5;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 0ms linear;
}

/* ============================================================
   THE ROOT SYSTEM (Footer)
   ============================================================ */
.root-system {
    position: relative;
    background-color: var(--deep-concrete);
    padding: 60px 5% 40px;
    overflow: hidden;
}

.root-system::before {
    content: '';
    position: absolute;
    inset: 0;
    filter: url(#concrete-grain);
    background-color: var(--deep-concrete);
    z-index: 0;
    pointer-events: none;
}

.root-system__branches {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
}

.root-svg {
    width: 100%;
    height: auto;
    display: block;
}

.root-trunk {
    stroke: var(--moss-stain);
    stroke-width: 2;
    fill: none;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.root-trunk.animate {
    animation: drawRoot 1500ms ease-out forwards;
}

.root-branch--primary {
    stroke: var(--moss-stain);
    stroke-width: 1.5;
    fill: none;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
}

.root-branch--primary.animate {
    animation: drawRoot 1000ms ease-out forwards;
    animation-delay: 400ms;
}

.root-branch--secondary {
    stroke: var(--moss-stain);
    stroke-width: 1;
    fill: none;
    stroke-opacity: 0.7;
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
}

.root-branch--secondary.animate {
    animation: drawRoot 800ms ease-out forwards;
    animation-delay: 800ms;
}

@keyframes drawRoot {
    to {
        stroke-dashoffset: 0;
    }
}

.root-node {
    fill: var(--deep-concrete);
    stroke: var(--moss-stain);
    stroke-width: 1.5;
    opacity: 0;
    transition: fill 300ms ease, opacity 300ms ease;
}

.root-node.animate {
    opacity: 1;
}

.root-node-link:hover .root-node {
    fill: var(--moss-stain);
}

.root-label {
    font-family: 'Caveat', cursive;
    font-weight: 500;
    font-size: 14px;
    fill: var(--fog-layer);
    opacity: 0;
    transition: fill 300ms ease, opacity 300ms ease;
}

.root-label.animate {
    opacity: 1;
}

.root-node-link:hover .root-label {
    fill: var(--moss-stain);
}

.root-node-link {
    cursor: pointer;
    text-decoration: none;
}

.root-system__info {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--ghost-mark);
}

.root-system__tagline {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--raw-surface);
    letter-spacing: -0.02em;
}

.root-system__anno {
    font-family: 'Caveat', cursive;
    font-weight: 500;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--moss-stain);
    margin-top: 0.3em;
}

/* ============================================================
   LINK INTERACTION PATTERN
   ============================================================ */
a:not(.root-node-link) {
    color: var(--fog-layer);
    text-decoration: none;
    background-image: linear-gradient(var(--moss-stain), var(--moss-stain));
    background-size: 0% 2px;
    background-position: left bottom;
    background-repeat: no-repeat;
    transition: color 250ms ease, background-size 250ms ease;
    position: relative;
}

a:not(.root-node-link):hover {
    color: var(--moss-stain);
    background-size: 100% 2px;
}

a:not(.root-node-link)::before {
    content: '';
    position: absolute;
    inset: -4px -8px;
    background-color: var(--moss-stain);
    opacity: 0;
    clip-path: url(#ginkgo-leaf);
    transition: opacity 250ms ease;
    z-index: -1;
}

a:not(.root-node-link):hover::before {
    opacity: 0.08;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --diagonal-angle: -4deg;
        --diagonal-counter: 4deg;
    }

    .tunnel-section__content--left {
        margin-left: 5%;
    }

    .tunnel-section__content--right {
        margin-right: 5%;
    }

    .dense-columns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .tunnel-section__content--dense {
        max-width: 60ch;
    }

    .fern-spiral {
        width: 80px;
        height: 80px;
    }

    .root-label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    :root {
        --diagonal-angle: 0deg;
        --diagonal-counter: 0deg;
    }

    .hero__content {
        transform: rotate(0deg);
    }

    .tunnel-section__skew {
        padding: 80px 5% 80px;
    }

    @keyframes sectionTilt {
        from {
            opacity: 0;
            transform: translateY(60px) rotate(0deg);
        }
        to {
            opacity: 1;
            transform: translateY(0) rotate(0deg);
        }
    }

    .section-number {
        font-size: clamp(3rem, 15vw, 5rem);
    }

    .root-svg {
        height: 200px;
    }

    .root-label {
        font-size: 10px;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .crack-line.animate {
        animation: none;
        stroke-dashoffset: 0;
    }

    .moss-bleed.animate {
        animation: none;
        opacity: 0.15;
        r: 40;
    }

    .hero__title.animate {
        animation: none;
        opacity: 1;
        transform: translateY(0);
    }

    .hero__subtitle.animate {
        animation: none;
        opacity: 1;
    }

    .drip.animate {
        animation: none;
        height: var(--drip-height, 100px);
        opacity: 0.3;
    }

    .hero__scroll-indicator.animate {
        animation: none;
        opacity: 0.6;
    }

    .tunnel-section__skew.animate {
        animation: none;
        opacity: 1;
        transform: translateY(0) rotate(var(--diagonal-angle));
    }

    .fern-path.animate {
        animation: none;
        stroke-dashoffset: 0;
    }

    .root-trunk.animate,
    .root-branch--primary.animate,
    .root-branch--secondary.animate {
        animation: none;
        stroke-dashoffset: 0;
    }

    .root-node.animate,
    .root-label.animate {
        opacity: 1;
    }

    .mycelium-trunk,
    .mycelium-branch--secondary,
    .mycelium-branch--tertiary {
        stroke-dashoffset: 0;
    }
}