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

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

body {
    background: #0F0A1A;
    color: #E8D5F5;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    line-height: 1.75;
    overflow-x: hidden;
}

/* ===== CRT Scan-lines ===== */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(15, 10, 26, 0.08) 2px,
        rgba(15, 10, 26, 0.08) 4px
    );
}

/* ===== Scroll Progress Indicator ===== */
.scroll-indicator {
    position: fixed;
    bottom: 2vh;
    right: 2vw;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2D1B4E;
    z-index: 999;
    transition: background-color 0.4s ease;
}

/* ===== Grove Base ===== */
.grove {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ===== Stars ===== */
.star-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.star {
    position: absolute;
    opacity: 0.4;
    animation: pulse-star var(--pulse-duration, 5s) ease-in-out infinite;
    animation-delay: var(--pulse-delay, 0s);
}

@keyframes pulse-star {
    0%, 100% {
        opacity: 0.4;
        fill: #C77DBA;
    }
    50% {
        opacity: 0.9;
        fill: #E84FAF;
    }
}

/* ===== Typography ===== */
.grove-heading {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    letter-spacing: 0.02em;
    color: #E8D5F5;
    margin-bottom: 0.5em;
}

.body-text {
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.4vw, 1.15rem);
    line-height: 1.75;
    color: #E8D5F5;
    max-width: 40ch;
}

/* #4A3562 muted purple for light background contexts */
.body-text-dark {
    color: #4A3562;
}

.season-label,
.grove-label {
    font-family: 'Homemade Apple', cursive;
    font-weight: 400;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #C77DBA;
}

/* ===== SVG Common ===== */
.tree-path {
    stroke: #9B7EB5;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ===== Grove 1: Canopy ===== */
.grove-canopy {
    background: #0F0A1A;
    height: 100vh;
}

.tree-canopy {
    position: absolute;
    left: 5vw;
    top: 15vh;
    height: 65vh;
    width: auto;
    z-index: 2;
}

.tree-canopy .tree-path {
    transition: stroke-dashoffset 3s ease-out;
}

.grove-canopy.visible .tree-canopy .tree-path {
    stroke-dashoffset: 0 !important;
}

.grove-title {
    position: absolute;
    right: 8vw;
    top: 25vh;
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    letter-spacing: 0.02em;
    color: #E8D5F5;
    z-index: 3;
}

.title-char {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.3s ease;
    transition-delay: calc(2s + var(--i) * 0.05s);
}

.grove-canopy.visible .title-char {
    opacity: 1;
}

.grove-subtitle {
    position: absolute;
    right: 8vw;
    top: calc(25vh + clamp(3rem, 6vw, 5.5rem));
    font-family: 'Homemade Apple', cursive;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    letter-spacing: 0.08em;
    color: #C77DBA;
    opacity: 0;
    transition: opacity 0.8s ease 3.5s;
    z-index: 3;
}

.grove-canopy.visible .grove-subtitle {
    opacity: 1;
}

/* ===== Grove 2: Rings ===== */
.grove-rings {
    background: #1E1230;
}

.tree-rings {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    height: 50vh;
    width: auto;
    z-index: 2;
}

.tree-rings .ring {
    stroke: #9B7EB5;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s ease-out;
}

.grove-rings.visible .ring {
    stroke-dashoffset: 0 !important;
}

.grove-rings.visible .ring:nth-child(1) { transition-delay: 0s; }
.grove-rings.visible .ring:nth-child(2) { transition-delay: 0.2s; }
.grove-rings.visible .ring:nth-child(3) { transition-delay: 0.4s; }
.grove-rings.visible .ring:nth-child(4) { transition-delay: 0.6s; }
.grove-rings.visible .ring:nth-child(5) { transition-delay: 0.8s; }
.grove-rings.visible .ring:nth-child(6) { transition-delay: 1.0s; }
.grove-rings.visible .ring:nth-child(7) { transition-delay: 1.2s; }
.grove-rings.visible .ring:nth-child(8) { transition-delay: 1.4s; }
.grove-rings.visible .ring:nth-child(9) { transition-delay: 1.6s; }
.grove-rings.visible .ring:nth-child(10) { transition-delay: 1.8s; }
.grove-rings.visible .ring:nth-child(11) { transition-delay: 2.0s; }
.grove-rings.visible .ring:nth-child(12) { transition-delay: 2.2s; }

.rings-text-top {
    position: absolute;
    left: 10vw;
    top: 10vh;
    z-index: 3;
    max-width: 35ch;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}

.grove-rings.visible .rings-text-top {
    opacity: 1;
    transform: translateY(0);
}

.rings-text-bottom {
    position: absolute;
    right: 12vw;
    bottom: 15vh;
    z-index: 3;
    max-width: 35ch;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.8s, transform 0.8s ease 0.8s;
}

.grove-rings.visible .rings-text-bottom {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Grove 3: Roots ===== */
.grove-roots {
    background: #0F0A1A;
}

.root-system {
    position: absolute;
    right: 0;
    top: 20vh;
    width: 45vw;
    height: auto;
    z-index: 2;
}

.root-path {
    transition: stroke-dashoffset 2s ease-out;
}

.grove-roots.visible .root-path {
    stroke-dashoffset: 0 !important;
}

.diagonal-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

.connect-line {
    stroke: #9B7EB5;
    stroke-width: 0.15;
    opacity: 0.3;
    transition: stroke-dashoffset 1.5s ease-out 0.5s;
}

.grove-roots.visible .connect-line {
    stroke-dashoffset: 0 !important;
}

.roots-text {
    position: absolute;
    left: 8vw;
    top: 12vh;
    z-index: 3;
    max-width: 35ch;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}

.grove-roots.visible .roots-text {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Grove 4: Seasons ===== */
.grove-seasons {
    background: #1E1230;
}

.season-tree {
    position: absolute;
    left: calc(10vw + var(--i) * 18vw);
    top: calc(10vh + var(--i) * 18vh);
    z-index: 3;
    text-align: center;
    transform: scale(0);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: calc(var(--i) * 0.3s);
}

.grove-seasons.visible .season-tree {
    transform: scale(1);
}

.season-tree svg {
    width: 150px;
    height: 180px;
    display: block;
    margin-bottom: 0.5rem;
}

.season-spring {
    stroke: #F5A0C8;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.season-summer {
    stroke: #9B7EB5;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.season-autumn {
    stroke: #E84FAF;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.season-winter {
    stroke: #C77DBA;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 4 8;
}

/* ===== Grove 5: Seed ===== */
.grove-seed {
    background: #0F0A1A;
}

.seed-icon {
    position: absolute;
    left: 50%;
    top: 40%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 50px;
    z-index: 3;
}

.seed-path {
    stroke: #9B7EB5;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    animation: pulse-seed 4s ease-in-out infinite;
}

@keyframes pulse-seed {
    0%, 100% {
        stroke: #9B7EB5;
    }
    50% {
        stroke: #E84FAF;
    }
}

.seed-text {
    position: absolute;
    left: 45%;
    top: 55%;
    transform: translateX(-50%);
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    color: #E8D5F5;
    white-space: nowrap;
    z-index: 3;
    opacity: 0;
    transition: opacity 1s ease 1s;
}

.grove-seed.visible .seed-text {
    opacity: 1;
}

.seed-translation {
    position: absolute;
    left: 45%;
    top: calc(55% + clamp(2rem, 4vw, 3.5rem));
    transform: translateX(-50%);
    font-family: 'Homemade Apple', cursive;
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 0.08em;
    color: #C77DBA;
    white-space: nowrap;
    z-index: 3;
    opacity: 0;
    transition: opacity 1s ease 1.5s;
}

.grove-seed.visible .seed-translation {
    opacity: 1;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .tree-canopy {
        left: 2vw;
        height: 50vh;
    }

    .grove-title {
        right: 5vw;
        top: 15vh;
    }

    .grove-subtitle {
        right: 5vw;
        top: calc(15vh + clamp(3rem, 6vw, 5.5rem));
    }

    .root-system {
        width: 60vw;
    }

    .season-tree {
        left: calc(5vw + var(--i) * 20vw);
        top: calc(8vh + var(--i) * 20vh);
    }

    .season-tree svg {
        width: 100px;
        height: 120px;
    }

    .tree-path {
        stroke-width: 1;
    }

    .season-spring,
    .season-summer,
    .season-autumn,
    .season-winter {
        stroke-width: 1;
    }
}
