/* ============================================
   xanadu.wiki - Maximalist Enchanted Encyclopedia
   Forest Green Palette | Z-Pattern Layout
   ============================================ */

/* ---- CSS Custom Properties ---- */
:root {
    --deep-canopy: #0A1A0E;
    --moss-dark: #1A2E1A;
    --forest-ink: #2A4A30;
    --chlorophyll: #4A8A50;
    --lichen-gold: #B8A848;
    --pale-fern: #C8D8B8;
    --bright-moss: #88C878;

    --font-display: 'Source Serif 4', Georgia, serif;
    --font-body: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
}

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

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

body {
    background-color: var(--deep-canopy);
    color: var(--pale-fern);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.85;
    font-weight: 400;
    overflow-x: hidden;
}

/* ---- SVG Filters (hidden) ---- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ---- Noise Overlay ---- */
.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noise);
    opacity: 0.03;
    pointer-events: none;
    z-index: 1;
}

/* ============================================
   FIREFLY PARTICLES (CSS-only, fixed position)
   ============================================ */
.fireflies {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.firefly {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(184, 168, 72, 0.4);
    mix-blend-mode: screen;
    animation: fireflyFloat linear infinite;
}

@keyframes fireflyFloat {
    0% {
        transform: translateY(100vh) translateX(0px);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(var(--drift));
        opacity: 0;
    }
}

/* Individual firefly positions and timings */
.firefly-1 {
    left: 5%;
    width: 2px; height: 2px;
    --drift: 25px;
    animation-duration: 12s;
    animation-delay: 0s;
}
.firefly-2 {
    left: 12%;
    width: 3px; height: 3px;
    --drift: -20px;
    animation-duration: 9s;
    animation-delay: -2s;
}
.firefly-3 {
    left: 22%;
    width: 4px; height: 4px;
    --drift: 30px;
    animation-duration: 14s;
    animation-delay: -5s;
}
.firefly-4 {
    left: 30%;
    width: 2px; height: 2px;
    --drift: -15px;
    animation-duration: 10s;
    animation-delay: -1s;
}
.firefly-5 {
    left: 38%;
    width: 3px; height: 3px;
    --drift: 20px;
    animation-duration: 11s;
    animation-delay: -7s;
}
.firefly-6 {
    left: 45%;
    width: 2px; height: 2px;
    --drift: -28px;
    animation-duration: 13s;
    animation-delay: -3s;
}
.firefly-7 {
    left: 52%;
    width: 4px; height: 4px;
    --drift: 15px;
    animation-duration: 8s;
    animation-delay: -6s;
}
.firefly-8 {
    left: 60%;
    width: 3px; height: 3px;
    --drift: -22px;
    animation-duration: 15s;
    animation-delay: -4s;
}
.firefly-9 {
    left: 68%;
    width: 2px; height: 2px;
    --drift: 30px;
    animation-duration: 10s;
    animation-delay: -8s;
}
.firefly-10 {
    left: 75%;
    width: 3px; height: 3px;
    --drift: -18px;
    animation-duration: 12s;
    animation-delay: -1s;
}
.firefly-11 {
    left: 82%;
    width: 4px; height: 4px;
    --drift: 25px;
    animation-duration: 9s;
    animation-delay: -5s;
}
.firefly-12 {
    left: 90%;
    width: 2px; height: 2px;
    --drift: -30px;
    animation-duration: 14s;
    animation-delay: -2s;
}
.firefly-13 {
    left: 8%;
    width: 3px; height: 3px;
    --drift: 18px;
    animation-duration: 11s;
    animation-delay: -9s;
}
.firefly-14 {
    left: 35%;
    width: 2px; height: 2px;
    --drift: -25px;
    animation-duration: 13s;
    animation-delay: -6s;
}
.firefly-15 {
    left: 55%;
    width: 4px; height: 4px;
    --drift: 22px;
    animation-duration: 8s;
    animation-delay: -3s;
}
.firefly-16 {
    left: 18%;
    width: 3px; height: 3px;
    --drift: -12px;
    animation-duration: 10s;
    animation-delay: -7s;
}
.firefly-17 {
    left: 72%;
    width: 2px; height: 2px;
    --drift: 28px;
    animation-duration: 15s;
    animation-delay: -4s;
}
.firefly-18 {
    left: 95%;
    width: 3px; height: 3px;
    --drift: -20px;
    animation-duration: 11s;
    animation-delay: -10s;
}

/* ============================================
   Z-PATTERN LAYOUT
   ============================================ */
.z-row {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.z-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    position: relative;
    z-index: 2;
}

.z-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    max-width: 480px;
}

.z-left {
    grid-column: 1;
}

.z-right {
    grid-column: 2;
}

.z-left.z-content {
    justify-self: end;
}

.z-right.z-content {
    justify-self: start;
}

.z-visual {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* ============================================
   TYPEWRITER EFFECT
   ============================================ */
.typewriter {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--pale-fern);
    position: relative;
    display: inline-block;
}

.typewriter-text {
    overflow: hidden;
    white-space: nowrap;
    display: inline-block;
    max-width: 0;
    vertical-align: bottom;
    transition: none;
}

.typewriter-text.typing {
    animation: typewrite var(--type-duration, 2s) steps(var(--type-steps, 20), end) forwards;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--forest-ink);
    vertical-align: bottom;
    margin-left: 2px;
    animation: cursorBlink 530ms step-end infinite;
    opacity: 0;
}

.typewriter-cursor.active {
    opacity: 1;
}

@keyframes typewrite {
    from {
        max-width: 0;
    }
    to {
        max-width: 100%;
    }
}

@keyframes cursorBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero-section {
    background: linear-gradient(135deg, var(--deep-canopy) 0%, var(--moss-dark) 50%, var(--deep-canopy) 100%);
}

.hero-section .z-content {
    max-width: 600px;
    padding: 3rem 4rem;
    position: relative;
}

.hero-section .typewriter {
    font-size: clamp(3rem, 8vw, 5.5rem);
    line-height: 1.1;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-size: 1.15rem;
    color: var(--bright-moss);
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease 2.5s, transform 0.8s ease 2.5s;
}

.hero-section.in-view .hero-subtitle {
    opacity: 1;
    transform: translateY(0);
}

.accent-line {
    width: 80px;
    height: 2px;
    background: var(--lichen-gold);
    margin-top: 1.2rem;
    box-shadow: 0 0 12px rgba(184, 168, 72, 0.3);
    opacity: 0;
    transform: scaleX(0);
    transform-origin: left;
    transition: opacity 0.6s ease 2s, transform 0.6s ease 2s;
}

.hero-section.in-view .accent-line {
    opacity: 1;
    transform: scaleX(1);
}

.fern-accent {
    position: absolute;
    left: -20px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, transparent, var(--chlorophyll), transparent);
    opacity: 0.4;
}

/* Fern illustration */
.fern-illustration {
    width: 100%;
    max-width: 400px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* ============================================
   SECTION TWO
   ============================================ */
.section-two {
    background: var(--deep-canopy);
}

.root-illustration {
    width: 100%;
    max-width: 400px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.root-svg {
    width: 100%;
    max-height: 70vh;
}

/* Content Card */
.content-card {
    background: var(--moss-dark);
    border: 1px solid rgba(74, 138, 80, 0.15);
    border-radius: 4px;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

/* Lichen-colony border texture effect */
.content-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 6px;
    background:
        radial-gradient(circle at 15% 15%, rgba(74, 138, 80, 0.15) 2px, transparent 2px),
        radial-gradient(circle at 85% 20%, rgba(74, 138, 80, 0.12) 3px, transparent 3px),
        radial-gradient(circle at 10% 80%, rgba(74, 138, 80, 0.1) 2px, transparent 2px),
        radial-gradient(circle at 90% 85%, rgba(74, 138, 80, 0.13) 3px, transparent 3px),
        radial-gradient(circle at 50% 5%, rgba(184, 168, 72, 0.08) 2px, transparent 2px),
        radial-gradient(circle at 50% 95%, rgba(184, 168, 72, 0.08) 2px, transparent 2px);
    pointer-events: none;
    z-index: 0;
}

.content-card > * {
    position: relative;
    z-index: 1;
}

.content-card h2 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    margin-bottom: 1.5rem;
}

.content-card p {
    margin-bottom: 1.2rem;
    color: var(--pale-fern);
    opacity: 0.9;
}

/* Seed bullet items */
.seed-bullets {
    margin-top: 1.5rem;
}

.seed-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: var(--bright-moss);
    font-size: 0.95rem;
}

.seed-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* ============================================
   SECTION THREE
   ============================================ */
.section-three {
    background: linear-gradient(180deg, var(--deep-canopy) 0%, var(--moss-dark) 40%, var(--deep-canopy) 100%);
}

.seed-illustration {
    width: 100%;
    max-width: 400px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.seed-svg,
.overlay-fern-svg,
.overlay-lichen-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-height: 70vh;
}

.seed-svg {
    z-index: 3;
}

.overlay-fern-svg {
    z-index: 2;
}

.overlay-lichen-svg {
    z-index: 1;
}

/* ============================================
   SECTION FOUR (Closing)
   ============================================ */
.section-four {
    background: var(--deep-canopy);
    display: flex;
    align-items: center;
    justify-content: center;
}

.closing-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 4rem 2rem;
    width: 100%;
}

.botanical-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 0;
}

.closing-botanical {
    width: 100%;
    max-width: 1200px;
    height: auto;
}

.closing-title {
    font-size: 2rem;
    position: relative;
    z-index: 2;
}

.closing-text {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--bright-moss);
    margin-top: 1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease 2.5s, transform 0.8s ease 2.5s;
    position: relative;
    z-index: 2;
}

.section-four.in-view .closing-text {
    opacity: 1;
    transform: translateY(0);
}

.accent-line-closing {
    width: 120px;
    height: 2px;
    background: var(--lichen-gold);
    margin: 1.5rem auto 0;
    box-shadow: 0 0 20px rgba(184, 168, 72, 0.4);
    opacity: 0;
    transform: scaleX(0);
    transition: opacity 0.6s ease 3s, transform 0.6s ease 3s;
    position: relative;
    z-index: 2;
}

.section-four.in-view .accent-line-closing {
    opacity: 1;
    transform: scaleX(1);
}

/* ============================================
   GRADIENT OVERLAYS (Maximalist layering)
   ============================================ */
.z-row::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(74, 138, 80, 0.05), transparent 60%),
        radial-gradient(ellipse at 80% 30%, rgba(136, 200, 120, 0.03), transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(184, 168, 72, 0.02), transparent 40%);
    pointer-events: none;
    z-index: 1;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .z-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .z-left,
    .z-right {
        grid-column: 1;
    }

    .z-content {
        max-width: 100%;
        padding: 2rem 1.5rem;
    }

    .z-left.z-content,
    .z-right.z-content {
        justify-self: stretch;
    }

    .hero-section .z-content {
        max-width: 100%;
        padding: 2rem 1.5rem;
    }

    .hero-section .typewriter {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .z-visual {
        min-height: 40vh;
    }

    .section-two .z-visual {
        order: -1;
    }

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

/* ============================================
   SELECTION STYLING
   ============================================ */
::selection {
    background: var(--chlorophyll);
    color: var(--deep-canopy);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--deep-canopy);
}

::-webkit-scrollbar-thumb {
    background: var(--forest-ink);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--chlorophyll);
}
