/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Fira Sans', sans-serif;
    background-color: #0F1A0A;
    color: #8B9A7D;
    overflow-x: hidden;
    line-height: 1.75;
}

/* Canopy Layer */
.canopy-layer {
    position: relative;
    height: 100vh;
    width: 100%;
    background: linear-gradient(180deg, #0F1A0A 0%, #0F1A0A 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaves-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

/* Leaf Silhouettes - CSS-generated shapes */
.leaf {
    position: absolute;
    opacity: 0.15;
    animation: leaf-float 8s ease-in-out infinite;
}

.leaf-1 {
    width: 120px;
    height: 140px;
    top: 10%;
    left: 5%;
    background-color: #2D5A27;
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 50% 85%, 18% 100%, 0% 38%);
    animation-delay: 0s;
    animation: leaf-float 9s ease-in-out infinite;
}

.leaf-2 {
    width: 150px;
    height: 160px;
    top: 20%;
    right: 10%;
    background-color: #7AE582;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0.1;
    animation-delay: 1s;
}

.leaf-3 {
    width: 100px;
    height: 130px;
    top: 15%;
    left: 30%;
    background-color: #2D5A27;
    clip-path: polygon(50% 0%, 95% 30%, 85% 100%, 50% 90%, 15% 100%, 5% 30%);
    opacity: 0.12;
    animation-delay: 0.5s;
}

.leaf-4 {
    width: 130px;
    height: 150px;
    top: 35%;
    right: 20%;
    background-color: #B8A44C;
    clip-path: polygon(50% 5%, 100% 35%, 95% 95%, 50% 85%, 5% 95%, 0% 35%);
    opacity: 0.08;
    animation-delay: 2s;
}

.leaf-5 {
    width: 110px;
    height: 145px;
    top: 45%;
    left: 15%;
    background-color: #7AE582;
    clip-path: polygon(50% 0%, 100% 40%, 80% 100%, 50% 80%, 20% 100%, 0% 40%);
    opacity: 0.11;
    animation-delay: 1.5s;
}

.leaf-6 {
    width: 140px;
    height: 155px;
    top: 5%;
    right: 35%;
    background-color: #2D5A27;
    clip-path: polygon(30% 0%, 100% 20%, 95% 100%, 50% 90%, 5% 100%, 0% 20%);
    opacity: 0.13;
    animation-delay: 0.8s;
}

.leaf-7 {
    width: 125px;
    height: 140px;
    top: 50%;
    right: 5%;
    background-color: #B8A44C;
    clip-path: polygon(50% 0%, 100% 35%, 85% 95%, 50% 80%, 15% 95%, 0% 35%);
    opacity: 0.09;
    animation-delay: 2.5s;
}

.leaf-8 {
    width: 115px;
    height: 135px;
    top: 25%;
    left: 50%;
    background-color: #2D5A27;
    clip-path: polygon(50% 0%, 95% 30%, 90% 100%, 50% 85%, 10% 100%, 5% 30%);
    opacity: 0.14;
    animation-delay: 1.2s;
}

.leaf-9 {
    width: 135px;
    height: 150px;
    top: 55%;
    left: 40%;
    background-color: #7AE582;
    clip-path: polygon(40% 0%, 100% 25%, 95% 85%, 50% 100%, 5% 85%, 0% 25%);
    opacity: 0.10;
    animation-delay: 2.2s;
}

.leaf-10 {
    width: 120px;
    height: 140px;
    top: 60%;
    right: 40%;
    background-color: #B8A44C;
    clip-path: polygon(50% 0%, 100% 40%, 80% 95%, 50% 85%, 20% 95%, 0% 40%);
    opacity: 0.12;
    animation-delay: 0.3s;
}

.leaf-11 {
    width: 110px;
    height: 130px;
    top: 70%;
    left: 70%;
    background-color: #2D5A27;
    clip-path: polygon(50% 5%, 95% 35%, 85% 100%, 50% 90%, 15% 100%, 5% 35%);
    opacity: 0.11;
    animation-delay: 1.8s;
}

.leaf-12 {
    width: 140px;
    height: 160px;
    top: 65%;
    left: 10%;
    background-color: #7AE582;
    clip-path: polygon(35% 0%, 100% 30%, 90% 100%, 50% 85%, 10% 100%, 0% 30%);
    opacity: 0.09;
    animation-delay: 2.7s;
}

.leaf-13 {
    width: 125px;
    height: 145px;
    top: 40%;
    right: 60%;
    background-color: #B8A44C;
    clip-path: polygon(50% 0%, 100% 35%, 88% 95%, 50% 88%, 12% 95%, 0% 35%);
    opacity: 0.13;
    animation-delay: 0.6s;
}

.leaf-14 {
    width: 115px;
    height: 135px;
    top: 75%;
    right: 50%;
    background-color: #2D5A27;
    clip-path: polygon(45% 0%, 95% 25%, 92% 100%, 50% 90%, 8% 100%, 5% 25%);
    opacity: 0.10;
    animation-delay: 2.3s;
}

.leaf-15 {
    width: 130px;
    height: 150px;
    top: 80%;
    left: 35%;
    background-color: #7AE582;
    clip-path: polygon(50% 0%, 100% 40%, 82% 100%, 50% 85%, 18% 100%, 0% 40%);
    opacity: 0.12;
    animation-delay: 1.1s;
}

.leaf-16 {
    width: 120px;
    height: 140px;
    top: 30%;
    left: 75%;
    background-color: #B8A44C;
    clip-path: polygon(40% 0%, 100% 20%, 98% 100%, 50% 88%, 2% 100%, 0% 20%);
    opacity: 0.08;
    animation-delay: 2.8s;
}

.leaf-17 {
    width: 110px;
    height: 135px;
    top: 85%;
    right: 20%;
    background-color: #2D5A27;
    clip-path: polygon(50% 5%, 100% 30%, 85% 100%, 50% 90%, 15% 100%, 0% 30%);
    opacity: 0.14;
    animation-delay: 0.7s;
}

.leaf-18 {
    width: 135px;
    height: 155px;
    top: 55%;
    right: 70%;
    background-color: #7AE582;
    clip-path: polygon(50% 0%, 95% 35%, 90% 100%, 50% 88%, 10% 100%, 5% 35%);
    opacity: 0.11;
    animation-delay: 1.9s;
}

.leaf-19 {
    width: 125px;
    height: 145px;
    top: 10%;
    right: 45%;
    background-color: #B8A44C;
    clip-path: polygon(45% 0%, 100% 25%, 92% 95%, 50% 85%, 8% 95%, 0% 25%);
    opacity: 0.09;
    animation-delay: 2.4s;
}

.leaf-20 {
    width: 120px;
    height: 140px;
    top: 72%;
    left: 58%;
    background-color: #2D5A27;
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 50% 85%, 18% 100%, 0% 38%);
    opacity: 0.13;
    animation-delay: 0.4s;
}

@keyframes leaf-float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(20px) rotate(3deg);
    }
}

/* Domain Stamp */
.domain-stamp {
    position: relative;
    z-index: 10;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 600;
    color: #F5F0E1;
    letter-spacing: 0.04em;
    text-shadow:
        2px 2px 0px rgba(0, 0, 0, 0.3),
        4px 4px 8px rgba(61, 43, 31, 0.5);
    text-transform: uppercase;
    transform: scaleY(0.95);
    word-spacing: 0.1em;
}

/* Scroll-driven leaf parting effect via JavaScript */
.leaves-container.reveal {
    animation: canopy-open 0.8s ease-out forwards;
}

@keyframes canopy-open {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0.3;
    }
}

/* Understory Layer */
.understory-layer {
    position: relative;
    background: linear-gradient(180deg, #0F1A0A 0%, #0F1A0A 100%);
    padding: 50vh 0;
    min-height: 300vh;
}

/* Journal Pages */
.journal-page {
    position: relative;
    max-width: 600px;
    width: 90%;
    margin: 80vh auto;
    padding: 50px 45px;
    background-color: #F5F0E1;
    color: #3D2B1F;
    font-size: 16px;
    line-height: 1.75;
    clip-path: polygon(
        0% 0%, 98% 1%, 99% 3%, 100% 5%, 99% 8%, 98% 2%, 97% 0%,
        95% 0%, 92% 1%, 88% 0%, 85% 1%, 82% 0%, 80% 2%, 75% 0%,
        70% 1%, 65% 0%, 60% 2%, 55% 0%, 50% 1%, 45% 0%, 40% 2%,
        35% 0%, 30% 1%, 25% 0%, 20% 2%, 15% 0%, 10% 1%, 5% 0%,
        2% 1%, 0% 3%, 0% 100%, 2% 99%, 5% 100%, 10% 99%, 15% 100%,
        20% 98%, 25% 100%, 30% 99%, 35% 100%, 40% 98%, 45% 100%,
        50% 99%, 55% 100%, 60% 98%, 65% 100%, 70% 99%, 75% 100%,
        80% 98%, 85% 100%, 88% 99%, 92% 100%, 95% 99%, 97% 100%,
        100% 99%, 100% 95%, 99% 92%, 100% 88%, 99% 85%, 100% 80%,
        98% 75%, 100% 70%, 99% 65%, 100% 60%, 98% 55%, 100% 50%,
        99% 45%, 100% 40%, 98% 35%, 100% 30%, 99% 25%, 100% 20%,
        98% 15%, 100% 10%, 99% 5%, 100% 2%
    );
    transform: rotate(var(--rotation, 0deg));
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.05);
}

.page-1 {
    --rotation: -1.5deg;
    margin-left: -8%;
}

.page-2 {
    --rotation: 2deg;
    margin-right: -5%;
}

.page-3 {
    --rotation: -1deg;
    margin-left: -10%;
}

.page-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 2rem;
    font-weight: 500;
    color: #3D2B1F;
    letter-spacing: 0.02em;
    margin-bottom: 20px;
    border-bottom: 2px solid #B8A44C;
    padding-bottom: 15px;
}

.journal-page p {
    margin-bottom: 16px;
    color: #5C4A32;
}

.annotation {
    font-family: 'Caveat', cursive;
    font-size: 14px;
    color: #8B9A7D;
    margin-top: 20px;
    display: block;
    text-align: right;
    font-style: italic;
}

.botanical-art {
    width: 100%;
    max-width: 200px;
    height: 250px;
    margin: 30px 0;
    opacity: 0.7;
}

.draw-on-scroll {
    stroke-dashoffset: 200;
    animation: draw-line 2s ease-in-out forwards;
}

@keyframes draw-line {
    to {
        stroke-dashoffset: 0;
    }
}

/* Root Layer */
.root-layer {
    position: relative;
    height: 100vh;
    width: 100%;
    background: linear-gradient(180deg, #0A0F07 0%, #0A0F07 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.foxfire-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.foxfire {
    position: absolute;
    width: 6px;
    height: 6px;
    left: var(--x);
    top: var(--y);
    border-radius: 50%;
    background: radial-gradient(circle at center, #7AE582 0%, rgba(122, 229, 130, 0.5) 50%, transparent 70%);
    animation: pulse-attention 3s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(122, 229, 130, 0.6);
}

.foxfire:nth-child(1) { animation-delay: 0s; }
.foxfire:nth-child(2) { animation-delay: 0.2s; }
.foxfire:nth-child(3) { animation-delay: 0.4s; }
.foxfire:nth-child(4) { animation-delay: 0.6s; }
.foxfire:nth-child(5) { animation-delay: 0.8s; }
.foxfire:nth-child(6) { animation-delay: 1s; }
.foxfire:nth-child(7) { animation-delay: 1.2s; }
.foxfire:nth-child(8) { animation-delay: 1.4s; }
.foxfire:nth-child(9) { animation-delay: 1.6s; }
.foxfire:nth-child(10) { animation-delay: 1.8s; }
.foxfire:nth-child(11) { animation-delay: 2s; }
.foxfire:nth-child(12) { animation-delay: 2.2s; }
.foxfire:nth-child(13) { animation-delay: 2.4s; }
.foxfire:nth-child(14) { animation-delay: 2.6s; }
.foxfire:nth-child(15) { animation-delay: 2.8s; }

@keyframes pulse-attention {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.4);
    }
}

.root-content {
    position: relative;
    z-index: 5;
    text-align: center;
}

.root-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: 3rem;
    font-weight: 500;
    color: #7AE582;
    letter-spacing: 0.03em;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(122, 229, 130, 0.3);
    opacity: 0;
    animation: fade-in 2s ease-out 0.5s forwards;
}

.root-text {
    font-size: 1.5rem;
    color: #B8A44C;
    max-width: 500px;
    margin: 0 auto;
    opacity: 0;
    animation: fade-in 2s ease-out 1s forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mycelium Layer */
.mycelium-layer {
    position: relative;
    height: 100vh;
    width: 100%;
    background: linear-gradient(180deg, #0A0F07 0%, #0F1A0A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-direction: column;
}

.mycelium-network {
    position: absolute;
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
    opacity: 0;
    animation: fade-in 1s ease-out 0.3s forwards;
}

.mycelium-branch {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: draw-mycelium 3s ease-in-out forwards;
}

.mycelium-branch[style*="--branch-delay: 0s"] {
    animation-delay: 0.2s;
}

.mycelium-branch[style*="--branch-delay: 0.3s"] {
    animation-delay: 0.5s;
}

.mycelium-branch[style*="--branch-delay: 0.6s"] {
    animation-delay: 0.8s;
}

.mycelium-branch[style*="--branch-delay: 0.9s"] {
    animation-delay: 1.1s;
}

.mycelium-branch[style*="--branch-delay: 1.2s"] {
    animation-delay: 1.4s;
}

.mycelium-branch[style*="--branch-delay: 1.5s"] {
    animation-delay: 1.7s;
}

.mycelium-branch[style*="--branch-delay: 1.8s"] {
    animation-delay: 2s;
}

@keyframes draw-mycelium {
    from {
        stroke-dashoffset: 500;
    }
    to {
        stroke-dashoffset: 0;
    }
}

.mycelium-nodes {
    position: absolute;
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 800px;
}

.node {
    position: absolute;
    left: var(--x);
    top: var(--y);
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: node-fade 1.5s ease-out forwards;
}

.node:nth-child(1) { animation-delay: 0.8s; }
.node:nth-child(2) { animation-delay: 1s; }
.node:nth-child(3) { animation-delay: 1.2s; }
.node:nth-child(4) { animation-delay: 1.4s; }
.node:nth-child(5) { animation-delay: 1.6s; }
.node:nth-child(6) { animation-delay: 1.8s; }
.node:nth-child(7) { animation-delay: 2s; }

@keyframes node-fade {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.node-label {
    font-family: 'Caveat', cursive;
    font-size: 14px;
    color: #7AE582;
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(122, 229, 130, 0.4);
}

.mycelium-closing {
    position: relative;
    z-index: 10;
    text-align: center;
    font-size: 1.1rem;
    color: #8B9A7D;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0;
    animation: fade-in 1.5s ease-out 2.5s forwards;
    letter-spacing: 0.02em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .domain-stamp {
        font-size: 2.5rem;
    }

    .journal-page {
        width: 95%;
        padding: 30px 25px;
        max-width: 100%;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .root-title {
        font-size: 2rem;
    }

    .root-text {
        font-size: 1.1rem;
    }

    .mycelium-network {
        width: 95%;
        height: auto;
    }
}

@media (max-width: 480px) {
    .domain-stamp {
        font-size: 2rem;
    }

    .journal-page {
        padding: 20px 15px;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .botanical-art {
        max-width: 150px;
    }
}

/* Pulse-attention helper class for links */
a {
    color: #B8A44C;
    text-decoration: underline;
    transition: color 0.3s ease;
}

a:hover {
    color: #7AE582;
    text-shadow: 0 0 10px rgba(122, 229, 130, 0.4);
}
