/* ========================================
   sim-ai.org — Simulation AI
   Forest-green dopamine aesthetic
   ======================================== */

:root {
    --midnight-canopy: #0b1a0f;
    --deep-forest: #0d2818;
    --moss-floor: #1a3a24;
    --sage-breath: #c2d9b4;
    --lichen-gray: #8fa882;
    --electric-chlorophyll: #39ff14;
    --hot-magenta: #ff2d7b;
    --solar-pollen: #f5e642;
    --data-honey: #d4a843;
    --forest-glass: rgba(11, 26, 15, 0.85);
    --warm-forest: #2d4a22;
    --deep-forest-ink: #1a2e14;

    --scroll-progress: 0;
    --epoch: 0;
    --epoch-progress: 0;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: auto;
}

body {
    background: var(--midnight-canopy);
    color: var(--sage-breath);
    font-family: 'Source Sans 3', sans-serif;
    font-size: clamp(1rem, 1.15vw, 1.25rem);
    line-height: 1.8;
    font-weight: 400;
    overflow-x: hidden;
}

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

/* ---- Progress Indicator ---- */

#progress-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 100vh;
    z-index: 100;
}

#progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: var(--electric-chlorophyll);
    transition: height 0.1s linear;
}

.epoch-node {
    position: absolute;
    left: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--midnight-canopy);
    border: 1px solid var(--electric-chlorophyll);
    opacity: 0.5;
    transition: opacity 0.3s, background 0.3s;
}

.epoch-node.active {
    background: var(--electric-chlorophyll);
    opacity: 1;
}

/* ---- Canvas & SVG Layers ---- */

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

#flowing-curves {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
}

/* ---- Main & Sections ---- */

main {
    position: relative;
    z-index: 2;
}

.epoch {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#epoch-0 { min-height: 100vh; }
#epoch-1 { min-height: 150vh; }
#epoch-2 { min-height: 150vh; }
#epoch-3 { min-height: 150vh; }
#epoch-4 { min-height: 100vh; }

.epoch-content {
    position: relative;
    width: 100%;
    max-width: 1200px;
    padding: 4rem 2rem;
    margin: 0 auto;
}

/* ---- Typography ---- */

.headline {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 300;
    letter-spacing: 0.04em;
    color: var(--sage-breath);
    text-align: center;
    line-height: 1.1;
}

.epoch-headline {
    margin-bottom: 3rem;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.epoch-headline.visible {
    opacity: 1;
    transform: translateY(0);
}

.mono-label {
    font-family: 'Inconsolata', monospace;
    font-size: 0.8rem;
    color: var(--electric-chlorophyll);
    opacity: 0.5;
    letter-spacing: 0.08em;
}

/* ---- Epoch 0 — Initialization ---- */

.epoch-0-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

#seed-point {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--electric-chlorophyll);
    opacity: 0;
    animation: pulse-seed 2.5s ease-in-out infinite;
    animation-delay: 0.3s;
    margin-bottom: 3rem;
}

@keyframes pulse-seed {
    0%, 100% { transform: scale(0.9); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 1.0; }
}

.border-frame {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.border-frame.visible {
    opacity: 1;
}

.frame-line {
    position: absolute;
    overflow: visible;
}

.frame-line line {
    stroke: var(--electric-chlorophyll);
    stroke-opacity: 0.3;
    stroke-width: 1;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.frame-line.drawn line {
    stroke-dashoffset: 0;
}

.frame-top {
    top: 20px;
    left: 20px;
    width: calc(100% - 40px);
    height: 1px;
}

.frame-right {
    top: 20px;
    right: 20px;
    width: 1px;
    height: calc(100% - 40px);
}

.frame-bottom {
    bottom: 20px;
    left: 20px;
    width: calc(100% - 40px);
    height: 1px;
}

.frame-left {
    top: 20px;
    left: 20px;
    width: 1px;
    height: calc(100% - 40px);
}

#domain-title {
    opacity: 0;
}

#domain-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
}

#domain-title .letter.show {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ---- Capsules ---- */

.capsule {
    background: var(--forest-glass);
    border: 1px solid rgba(57, 255, 20, 0.3);
    border-radius: 2rem;
    padding: 2rem 2.5rem;
    position: relative;
    overflow: hidden;
}

.capsule h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--sage-breath);
    margin-bottom: 0.75rem;
}

.capsule p {
    color: var(--lichen-gray);
    font-size: 0.95rem;
    line-height: 1.7;
}

.capsule-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
}

/* Border animate */
.border-animate {
    border-color: transparent;
    position: relative;
}

.border-animate::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid rgba(57, 255, 20, 0.4);
    border-radius: 2rem;
    clip-path: inset(0 100% 100% 0);
    transition: clip-path 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.border-animate.in-view::before {
    clip-path: inset(0 0 0 0);
}

/* ---- Epoch 1 — Growth ---- */

.branch-container {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    max-width: 600px;
    margin: 0 auto;
}

.branch-container .capsule:nth-child(1) { align-self: flex-start; }
.branch-container .capsule:nth-child(2) { align-self: flex-end; }
.branch-container .capsule:nth-child(3) { align-self: center; }

/* ---- Epoch 2 — Complexity ---- */

.topo-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    opacity: 0.15;
    pointer-events: none;
}

.topo-map {
    position: relative;
    width: 100%;
    height: 100%;
}

.topo-ring {
    position: absolute;
    border: 1px solid rgba(57, 255, 20, 0.15);
    top: 50%;
    left: 50%;
}

.topo-ring:nth-child(1) { width: 90%; height: 85%; border-radius: 48% 52% 45% 55% / 52% 48% 55% 45%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(2) { width: 78%; height: 74%; border-radius: 45% 55% 50% 50% / 48% 52% 48% 52%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(3) { width: 66%; height: 63%; border-radius: 52% 48% 43% 57% / 55% 45% 52% 48%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(4) { width: 54%; height: 52%; border-radius: 47% 53% 55% 45% / 50% 50% 47% 53%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(5) { width: 43%; height: 41%; border-radius: 50% 50% 48% 52% / 53% 47% 50% 50%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(6) { width: 33%; height: 31%; border-radius: 46% 54% 52% 48% / 49% 51% 53% 47%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(7) { width: 22%; height: 21%; border-radius: 55% 45% 48% 52% / 52% 48% 45% 55%; transform: translate(-50%, -50%); }
.topo-ring:nth-child(8) { width: 12%; height: 11%; border-radius: 50%; transform: translate(-50%, -50%); }

.complexity-capsules {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    max-width: 550px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.glass-capsule {
    background: rgba(11, 26, 15, 0.7);
    backdrop-filter: blur(4px);
    text-align: center;
}

/* ---- Epoch 3 — Emergence ---- */

#epoch-3 {
    overflow: hidden;
}

.emergence-title {
    color: var(--hot-magenta);
}

.emergence-capsules {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    max-width: 600px;
    margin: 0 auto;
}

.emergence-capsule {
    border-color: transparent;
}

.emergence-capsule::before {
    border-color: rgba(255, 45, 123, 0.4);
}

.emergence-capsule h3 {
    color: var(--solar-pollen);
}

.burst-color {
    color: var(--hot-magenta);
    opacity: 0.8;
}

.scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(57, 255, 20, 0.03) 0px,
        rgba(57, 255, 20, 0.03) 1px,
        transparent 1px,
        transparent 4px
    );
    z-index: 1;
}

/* ---- Epoch 4 — Insight ---- */

#epoch-4 {
    background: var(--warm-forest);
}

.epoch-4-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.insight-headline {
    color: var(--data-honey);
}

.insight-curve {
    width: 100%;
    max-width: 900px;
    height: 80px;
    margin: 2rem auto;
    opacity: 0.6;
}

.insight-text {
    max-width: 38ch;
    margin: 0 auto;
}

.insight-statement {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 700;
    line-height: 1.9;
    color: var(--sage-breath);
    max-width: 30ch;
    margin: 0 auto 2rem;
}

.insight-complete {
    opacity: 0.3;
    transition: opacity 3s ease;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
    .epoch-content {
        padding: 3rem 1.5rem;
    }

    .branch-container,
    .complexity-capsules,
    .emergence-capsules {
        max-width: 100%;
    }

    .capsule {
        padding: 1.5rem 1.8rem;
    }

    .topo-container {
        width: 300px;
        height: 300px;
    }
}
