/* ============================================
   aiice.quest - Sentient Forest Design System
   ============================================ */

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

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

body {
    background-color: #050D05;
    color: #E8F5E9;
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.75;
    overflow-x: hidden;
}

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

/* --- Biome Sections --- */
.biome-section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Section 1: Canopy Layer --- */
#canopy {
    background-color: #0B3D0B;
    background-image:
        radial-gradient(ellipse 80px 120px at 15% 20%, rgba(30, 120, 30, 0.35) 0%, transparent 70%),
        radial-gradient(ellipse 120px 90px at 75% 35%, rgba(25, 100, 25, 0.3) 0%, transparent 70%),
        radial-gradient(ellipse 60px 100px at 40% 70%, rgba(35, 130, 35, 0.25) 0%, transparent 70%),
        radial-gradient(ellipse 100px 70px at 85% 80%, rgba(20, 90, 20, 0.3) 0%, transparent 70%),
        radial-gradient(ellipse 90px 140px at 25% 55%, rgba(28, 110, 28, 0.2) 0%, transparent 70%),
        radial-gradient(ellipse 70px 110px at 60% 15%, rgba(22, 95, 22, 0.25) 0%, transparent 70%),
        radial-gradient(ellipse 110px 80px at 50% 50%, rgba(18, 85, 18, 0.15) 0%, transparent 60%);
}

/* --- Section 2: Trunk Layer --- */
#trunk {
    background-color: #1A0F00;
    clip-path: url(#torn-edge-1);
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(40, 25, 5, 0.3) 3px,
            rgba(40, 25, 5, 0.3) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 17px,
            rgba(50, 30, 8, 0.15) 17px,
            rgba(50, 30, 8, 0.15) 18px
        ),
        linear-gradient(180deg, rgba(26, 15, 0, 1) 0%, rgba(20, 12, 0, 1) 100%);
}

/* --- Section 3: Understory Layer --- */
#understory {
    background-color: #0D2818;
    clip-path: url(#torn-edge-2);
    background-image:
        radial-gradient(circle 60px at 20% 30%, rgba(168, 230, 163, 0.08) 0%, transparent 100%),
        radial-gradient(circle 45px at 60% 20%, rgba(168, 230, 163, 0.06) 0%, transparent 100%),
        radial-gradient(circle 80px at 80% 60%, rgba(168, 230, 163, 0.07) 0%, transparent 100%),
        radial-gradient(circle 35px at 35% 75%, rgba(168, 230, 163, 0.09) 0%, transparent 100%),
        radial-gradient(circle 55px at 70% 85%, rgba(168, 230, 163, 0.05) 0%, transparent 100%),
        radial-gradient(circle 70px at 10% 60%, rgba(168, 230, 163, 0.08) 0%, transparent 100%),
        radial-gradient(circle 50px at 50% 50%, rgba(168, 230, 163, 0.04) 0%, transparent 100%),
        radial-gradient(circle 40px at 90% 30%, rgba(168, 230, 163, 0.06) 0%, transparent 100%);
}

/* --- Section 4: Root Network Layer --- */
#roots {
    background-color: #050D05;
    clip-path: url(#torn-edge-3);
}

/* --- Section Content --- */
.section-content {
    position: relative;
    z-index: 2;
    max-width: 720px;
    width: 90%;
    padding: 80px 20px;
    text-align: left;
}

/* --- Typography --- */

/* Primary Headings - Josefin Sans */
.canopy-title {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(48px, 10vw, 96px);
    color: #39FF14;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.1;
    margin-bottom: 40px;
    text-shadow: 0 0 30px rgba(57, 255, 20, 0.3), 0 0 60px rgba(57, 255, 20, 0.1);
}

.section-heading {
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 700;
    font-size: clamp(36px, 6vw, 64px);
    color: #39FF14;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.15;
    margin-bottom: 40px;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.25);
}

/* Secondary Headings - Rajdhani */
.sub-heading {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: clamp(24px, 4vw, 36px);
    color: #A8E6A3;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 50px;
    margin-bottom: 25px;
}

.micro-heading {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: clamp(16px, 2.5vw, 22px);
    color: #A8E6A3;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

/* Body Text - DM Sans */
.body-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(15px, 2vw, 18px);
    color: #E8F5E9;
    line-height: 1.75;
    margin-bottom: 30px;
}

.canopy-subtitle {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(16px, 2.2vw, 20px);
    color: #E8F5E9;
    line-height: 1.75;
    max-width: 600px;
}

.micro-text {
    font-family: 'DM Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(13px, 1.5vw, 15px);
    color: #E8F5E9;
    line-height: 1.65;
    opacity: 0.85;
}

.footer-text {
    font-family: 'Share Tech Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    color: #39FF14;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
    text-align: center;
    margin-top: 60px;
}

/* --- Typewriter Cursor --- */
.cursor {
    font-family: 'Share Tech Mono', monospace;
    color: #39FF14;
    font-weight: 400;
    animation: blink-cursor 530ms step-end infinite;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.4);
}

.cursor.fade-out {
    animation: cursor-fade 400ms ease-out forwards;
}

.cursor.hidden {
    display: none;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes cursor-fade {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Typewriter text uses Share Tech Mono when inside typewrite elements */
.typewrite .typewrite-text {
    font-family: inherit;
}

/* Only the canopy title and footer specifically use mono */
.canopy-title .typewrite-text,
.footer-text .typewrite-text {
    font-family: 'Share Tech Mono', monospace;
}

/* --- Collage Layers --- */
.collage-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.collage-fragment {
    position: absolute;
    transform: translate(-50%, -50%);
}

/* Circle fragments */
.frag-circle {
    border-radius: 50%;
    border: 1.5px solid;
}

/* Ellipse fragments */
.frag-ellipse {
    border-radius: 50%;
    border: 1px solid;
}

/* Leaf shape fragments */
.frag-leaf {
    border-radius: 0 70% 0 70%;
    border: 1px solid;
}

/* Stem fragments */
.frag-stem {
    border-radius: 2px;
    border: 1px solid;
}

/* Venation pattern */
.frag-venation {
    border-radius: 0;
    border-left: 1px solid;
    border-bottom: 1px solid;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Bark fragments */
.frag-bark {
    border-radius: 3px;
    background: repeating-linear-gradient(
        0deg,
        rgba(40, 25, 5, 0.3) 0px,
        transparent 1px,
        transparent 4px
    );
    border: 1px solid;
}

/* Ring fragments */
.frag-ring {
    border-radius: 50%;
    border: 1px solid;
    background: radial-gradient(circle, transparent 40%, rgba(40, 25, 5, 0.2) 41%, transparent 42%,
                                transparent 55%, rgba(40, 25, 5, 0.15) 56%, transparent 57%,
                                transparent 70%, rgba(40, 25, 5, 0.1) 71%, transparent 72%);
}

/* Torn paper edge */
.frag-torn {
    clip-path: polygon(5% 0%, 95% 3%, 100% 8%, 92% 100%, 8% 97%, 0% 92%);
}

/* Dappled light fragments */
.frag-dapple {
    border-radius: 50%;
    background: radial-gradient(circle, rgba(168, 230, 163, 0.15) 0%, transparent 70%);
}

/* Fern fragments */
.frag-fern {
    border-radius: 0 80% 0 80%;
    border: 1px solid;
}

/* Moss fragments */
.frag-moss {
    border-radius: 40% 60% 50% 50%;
    background: radial-gradient(circle, rgba(46, 204, 64, 0.12) 0%, transparent 70%);
}

/* Root fragments */
.frag-root {
    border-radius: 2px;
    border: 0.8px solid #1B5E20;
    transform-origin: center left;
}

/* Node fragments */
.frag-node {
    border-radius: 50%;
    background: radial-gradient(circle, rgba(27, 94, 32, 0.4) 0%, transparent 70%);
    border: 1px solid rgba(27, 94, 32, 0.3);
}

/* Mycelium fragments */
.frag-mycelium {
    border-radius: 1px;
    background: linear-gradient(90deg, rgba(27, 94, 32, 0.3) 0%, transparent 100%);
}

/* --- Canopy Section Fragments --- */
.frag-1 { top: 15%; left: 10%; width: 80px; height: 80px; border-color: rgba(46, 204, 64, 0.25); transform: translate(-50%, -50%) rotate(5deg); opacity: 0.5; }
.frag-2 { top: 25%; left: 80%; width: 120px; height: 60px; border-color: rgba(57, 255, 20, 0.15); transform: translate(-50%, -50%) rotate(-3deg); opacity: 0.3; }
.frag-3 { top: 40%; left: 20%; width: 60px; height: 90px; border-color: rgba(168, 230, 163, 0.2); transform: translate(-50%, -50%) rotate(8deg); opacity: 0.45; }
.frag-4 { top: 60%; left: 70%; width: 50px; height: 50px; border-color: rgba(27, 94, 32, 0.3); opacity: 0.6; }
.frag-5 { top: 70%; left: 15%; width: 8px; height: 120px; border-color: rgba(46, 204, 64, 0.2); transform: translate(-50%, -50%) rotate(2deg); opacity: 0.35; }
.frag-6 { top: 30%; left: 55%; width: 100px; height: 45px; border-color: rgba(57, 255, 20, 0.12); transform: translate(-50%, -50%) rotate(-5deg); opacity: 0.25; }
.frag-7 { top: 80%; left: 85%; width: 45px; height: 70px; border-color: rgba(168, 230, 163, 0.18); transform: translate(-50%, -50%) rotate(6deg); opacity: 0.4; }
.frag-8 { top: 50%; left: 5%; width: 35px; height: 35px; border-color: rgba(46, 204, 64, 0.2); opacity: 0.55; }
.frag-9 { top: 20%; left: 45%; width: 70px; height: 70px; border-color: rgba(27, 94, 32, 0.2); opacity: 0.3; }
.frag-10 { top: 75%; left: 40%; width: 90px; height: 40px; border-color: rgba(57, 255, 20, 0.1); transform: translate(-50%, -50%) rotate(4deg); opacity: 0.2; }
.frag-11 { top: 10%; left: 65%; width: 40px; height: 55px; border-color: rgba(168, 230, 163, 0.15); transform: translate(-50%, -50%) rotate(-7deg); opacity: 0.35; }
.frag-12 { top: 88%; left: 25%; width: 55px; height: 55px; border-color: rgba(46, 204, 64, 0.18); opacity: 0.4; }

/* --- Trunk Section Fragments --- */
.frag-13 { top: 12%; left: 8%; width: 100px; height: 150px; border-color: rgba(80, 50, 10, 0.3); transform: translate(-50%, -50%) rotate(-2deg); opacity: 0.5; }
.frag-14 { top: 30%; left: 85%; width: 90px; height: 90px; border-color: rgba(60, 38, 8, 0.25); opacity: 0.35; }
.frag-15 { top: 50%; left: 15%; width: 6px; height: 180px; border-color: rgba(46, 204, 64, 0.15); transform: translate(-50%, -50%) rotate(3deg); opacity: 0.3; }
.frag-16 { top: 65%; left: 90%; width: 80px; height: 120px; border-color: rgba(80, 50, 10, 0.2); transform: translate(-50%, -50%) rotate(4deg); opacity: 0.4; }
.frag-17 { top: 80%; left: 25%; width: 70px; height: 70px; border-color: rgba(60, 38, 8, 0.2); opacity: 0.25; }
.frag-18 { top: 20%; left: 50%; width: 130px; height: 90px; background: rgba(40, 25, 5, 0.15); border: 1px solid rgba(80, 50, 10, 0.15); transform: translate(-50%, -50%) rotate(-3deg); opacity: 0.3; }
.frag-19 { top: 45%; left: 75%; width: 60px; height: 100px; border-color: rgba(80, 50, 10, 0.2); transform: translate(-50%, -50%) rotate(5deg); opacity: 0.35; }
.frag-20 { top: 70%; left: 5%; width: 5px; height: 140px; border-color: rgba(46, 204, 64, 0.12); transform: translate(-50%, -50%) rotate(-2deg); opacity: 0.25; }
.frag-21 { top: 90%; left: 60%; width: 50px; height: 50px; border-color: rgba(60, 38, 8, 0.15); opacity: 0.2; }
.frag-22 { top: 55%; left: 40%; width: 110px; height: 70px; background: rgba(40, 25, 5, 0.1); border: 1px solid rgba(80, 50, 10, 0.1); transform: translate(-50%, -50%) rotate(2deg); opacity: 0.2; }

/* --- Understory Section Fragments --- */
.frag-23 { top: 10%; left: 20%; width: 120px; height: 120px; opacity: 0.7; }
.frag-24 { top: 25%; left: 75%; width: 50px; height: 75px; border-color: rgba(46, 204, 64, 0.2); transform: translate(-50%, -50%) rotate(15deg); opacity: 0.4; }
.frag-25 { top: 45%; left: 10%; width: 90px; height: 90px; opacity: 0.5; }
.frag-26 { top: 35%; left: 55%; width: 80px; height: 60px; opacity: 0.45; }
.frag-27 { top: 60%; left: 85%; width: 40px; height: 60px; border-color: rgba(46, 204, 64, 0.15); transform: translate(-50%, -50%) rotate(-12deg); opacity: 0.35; }
.frag-28 { top: 75%; left: 30%; width: 100px; height: 100px; opacity: 0.6; }
.frag-29 { top: 80%; left: 65%; width: 70px; height: 50px; opacity: 0.4; }
.frag-30 { top: 15%; left: 45%; width: 35px; height: 55px; border-color: rgba(46, 204, 64, 0.18); transform: translate(-50%, -50%) rotate(20deg); opacity: 0.3; }
.frag-31 { top: 55%; left: 40%; width: 80px; height: 80px; opacity: 0.35; }
.frag-32 { top: 90%; left: 15%; width: 60px; height: 45px; opacity: 0.5; }

/* --- Root Section Fragments --- */
.frag-33 { top: 15%; left: 12%; width: 4px; height: 120px; transform: translate(-50%, -50%) rotate(25deg); opacity: 0.5; }
.frag-34 { top: 20%; left: 80%; width: 30px; height: 30px; opacity: 0.4; }
.frag-35 { top: 40%; left: 5%; width: 3px; height: 100px; transform: translate(-50%, -50%) rotate(-15deg); opacity: 0.4; }
.frag-36 { top: 50%; left: 90%; width: 25px; height: 25px; opacity: 0.35; }
.frag-37 { top: 70%; left: 20%; width: 3px; height: 80px; transform: translate(-50%, -50%) rotate(30deg); opacity: 0.3; }
.frag-38 { top: 60%; left: 50%; width: 200px; height: 3px; opacity: 0.2; }
.frag-39 { top: 80%; left: 70%; width: 20px; height: 20px; opacity: 0.3; }
.frag-40 { top: 85%; left: 35%; width: 3px; height: 90px; transform: translate(-50%, -50%) rotate(-20deg); opacity: 0.25; }

/* --- Data Overlay --- */
.data-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.data-coord {
    position: absolute;
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #1B5E20;
    opacity: 0.3;
    letter-spacing: 0.05em;
}

.root-data .data-coord {
    color: #1B5E20;
    opacity: 0.4;
}

/* --- Vine SVGs --- */
.vine-svg {
    position: fixed;
    top: 0;
    width: 80px;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

.vine-left {
    left: 0;
}

.vine-right {
    right: 0;
}

.vine-path,
.vine-branch {
    stroke-linecap: round;
    stroke: #2ECC40;
}

/* --- Canopy Flowing Curves --- */
.canopy-curves {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 1;
    pointer-events: none;
}

.flowing-curve {
    stroke-linecap: round;
}

/* --- Stream SVG (Understory) --- */
.stream-svg {
    position: absolute;
    top: 50%;
    left: 0;
    width: 110%;
    height: 30%;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
    overflow: visible;
}

.stream-line {
    stroke-linecap: round;
}

.stream-1 {
    animation: stream-flow-1 8s ease-in-out infinite alternate;
    will-change: transform;
}

.stream-2 {
    animation: stream-flow-2 13s ease-in-out infinite alternate;
    will-change: transform;
}

.stream-3 {
    animation: stream-flow-3 21s ease-in-out infinite alternate;
    will-change: transform;
}

@keyframes stream-flow-1 {
    0% { transform: translateX(0); }
    100% { transform: translateX(-80px); }
}

@keyframes stream-flow-2 {
    0% { transform: translateX(0); }
    100% { transform: translateX(60px); }
}

@keyframes stream-flow-3 {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50px); }
}

/* --- Root Dendrite SVG --- */
.root-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.root-dendrite {
    stroke-linecap: round;
}

/* --- Content Cards (Understory) --- */
.content-card {
    background: rgba(232, 245, 233, 0.06);
    border: 1px solid rgba(168, 230, 163, 0.12);
    border-radius: 4px;
    padding: 30px 25px;
    margin-bottom: 25px;
    position: relative;
}

.card-1 {
    transform: rotate(-0.5deg);
}

.card-2 {
    transform: rotate(0.8deg);
    margin-left: 15px;
}

.card-3 {
    transform: rotate(-0.3deg);
    margin-left: -10px;
}

.content-card .body-text {
    margin-bottom: 0;
}

/* --- Root Grid --- */
.root-content {
    max-width: 900px;
}

.root-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px 40px;
    margin-top: 30px;
}

.root-col {
    padding: 20px;
    border-left: 2px solid rgba(27, 94, 32, 0.3);
}

.root-heading {
    font-size: clamp(28px, 5vw, 48px);
}

.root-footer {
    border-top: 1px solid rgba(27, 94, 32, 0.25);
    padding-top: 40px;
    margin-top: 50px;
}

/* --- Typewriter elements initially hidden --- */
.typewrite .typewrite-text {
    display: inline;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .vine-svg {
        width: 40px;
    }

    .section-content {
        padding: 60px 15px;
    }

    .root-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .root-content {
        max-width: 720px;
    }

    .content-card {
        padding: 20px 18px;
        margin-left: 0 !important;
    }

    .card-1, .card-2, .card-3 {
        transform: none;
    }

    .data-overlay {
        display: none;
    }
}

@media (max-width: 480px) {
    .vine-svg {
        display: none;
    }

    .canopy-title {
        font-size: 40px;
    }

    .section-heading {
        font-size: 30px;
    }
}
