/* ============================================================
   archetypos.dev — Living Terminal / Forest Canopy
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
    --terminal-bg: #081c15;
    --terminal-text: #95d5b2;
    --terminal-accent: #40916c;
    --terminal-cursor: #b7e4c7;
    --specimen-bg: #d8f3dc;
    --specimen-headline: #1b4332;
    --specimen-body: #2d6a4f;
    --highlight: #52b788;
    --alert: #74c69d;
    --divider: #344e41;
    --mesh-x1: 30%;
    --mesh-y1: 20%;
    --mesh-x2: 70%;
    --mesh-y2: 80%;
    --mesh-x3: 50%;
    --mesh-y3: 50%;
}

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background: var(--terminal-bg);
    color: var(--terminal-text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---- Screen Sections ---- */
.screen {
    min-height: 100vh;
    position: relative;
    scroll-snap-align: start;
}

/* ---- Terminal Styles ---- */
.terminal-fullwidth,
.terminal-pane {
    background: var(--terminal-bg);
    background-image:
        radial-gradient(ellipse at var(--mesh-x1) var(--mesh-y1), rgba(64, 145, 108, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at var(--mesh-x2) var(--mesh-y2), rgba(149, 213, 178, 0.05) 0%, transparent 50%);
}

.terminal-fullwidth {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.terminal-inner {
    padding: 48px;
    width: 100%;
    max-width: 900px;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    line-height: 1.7;
    color: var(--terminal-text);
    font-feature-settings: 'liga' 1, 'calt' 1;
    text-shadow: 0 0 8px rgba(149, 213, 178, 0.3);
}

.terminal-pane .terminal-inner {
    max-width: none;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.terminal-lines {
    white-space: pre-wrap;
    word-break: break-word;
}

.term-line {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.term-line.hidden {
    opacity: 0;
    transform: translateY(8px);
}

.term-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.prompt {
    color: var(--highlight);
    font-weight: 700;
}

.entry-num {
    color: var(--terminal-accent);
}

.entry-name {
    color: var(--terminal-cursor);
    font-weight: 700;
}

/* ---- Cursor ---- */
.cursor {
    color: var(--terminal-cursor);
    font-family: 'JetBrains Mono', monospace;
    animation: cursorBlink 1s step-end infinite;
}

.cursor.blinking {
    animation: cursorBlink 1s step-end infinite;
}

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

/* ---- Boot Screen Typewriter ---- */
.screen-boot .terminal-fullwidth {
    flex-direction: column;
}

.screen-boot .terminal-inner {
    position: relative;
}

.boot-line {
    opacity: 0;
    animation: fadeInLine 0.3s forwards;
}

@keyframes fadeInLine {
    to { opacity: 1; }
}

/* ---- Magazine Spread Layout ---- */
.spread-grid {
    display: grid;
    grid-template-columns: 5fr 2px 7fr;
    min-height: 100vh;
}

.divider-stem {
    background: repeating-linear-gradient(
        to bottom,
        var(--terminal-accent) 0px,
        var(--terminal-accent) 8px,
        transparent 8px,
        transparent 16px
    );
    width: 2px;
}

/* ---- Specimen Pane ---- */
.specimen-pane {
    background: var(--specimen-bg);
    position: relative;
    overflow: hidden;
}

.specimen-inner {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.specimen-content {
    position: relative;
    z-index: 2;
    margin: 12vh 8vw;
}

.specimen-label {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--terminal-accent);
    display: block;
    margin-bottom: 1.5rem;
}

.specimen-headline {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    color: var(--specimen-headline);
    line-height: 1.1;
    margin-bottom: 1.5rem;
    font-variation-settings: 'SOFT' 100, 'WONK' 1;
}

.specimen-body {
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.4vw, 1.2rem);
    line-height: 1.65;
    color: var(--specimen-body);
    max-width: 48ch;
    transition: font-weight 0.8s ease;
}

.specimen-body.in-view {
    font-weight: 400;
}

/* ---- Gradient Mesh Canopy ---- */
.gradient-mesh-canopy {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(82, 183, 136, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(64, 145, 108, 0.12) 0%, transparent 45%),
        radial-gradient(ellipse at 50% 70%, rgba(116, 198, 157, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 30% 80%, rgba(149, 213, 178, 0.08) 0%, transparent 40%),
        radial-gradient(ellipse at 70% 50%, rgba(45, 106, 79, 0.10) 0%, transparent 50%),
        radial-gradient(ellipse at 10% 60%, rgba(183, 228, 199, 0.07) 0%, transparent 45%),
        radial-gradient(ellipse at 90% 80%, rgba(64, 145, 108, 0.09) 0%, transparent 40%);
}

.gradient-mesh-canopy.mesh-alt {
    background:
        radial-gradient(ellipse at 60% 20%, rgba(82, 183, 136, 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 25% 70%, rgba(64, 145, 108, 0.14) 0%, transparent 45%),
        radial-gradient(ellipse at 80% 60%, rgba(116, 198, 157, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 40% 40%, rgba(149, 213, 178, 0.10) 0%, transparent 40%),
        radial-gradient(ellipse at 15% 30%, rgba(45, 106, 79, 0.08) 0%, transparent 50%);
}

/* ---- SVG Containers ---- */
.svg-container,
.fibonacci-container {
    margin-top: 2rem;
    width: 100%;
    max-width: 360px;
}

.archetype-svg {
    width: 100%;
    height: auto;
}

.draw-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.05s linear;
}

/* ---- Fireflies ---- */
.fireflies {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
}

.firefly {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--terminal-cursor);
    box-shadow: 0 0 12px rgba(183, 228, 199, 0.6), 0 0 24px rgba(183, 228, 199, 0.3);
    animation: fireflyDrift var(--duration) ease-in-out infinite alternate;
    opacity: 0;
}

@keyframes fireflyDrift {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 0;
    }
    20% {
        opacity: 0.8;
    }
    50% {
        transform: translate(var(--dx), var(--dy)) scale(0.8);
        opacity: 0.6;
    }
    80% {
        opacity: 0.9;
    }
    100% {
        transform: translate(var(--dx2), var(--dy2)) scale(1.1);
        opacity: 0;
    }
}

.fireflies-dense .firefly {
    box-shadow: 0 0 16px rgba(183, 228, 199, 0.8), 0 0 32px rgba(183, 228, 199, 0.4);
}

/* ---- Section Divider ---- */
.section-divider {
    text-align: center;
    padding: 32px 0;
    background: var(--terminal-bg);
}

.ascii-trees {
    font-family: 'JetBrains Mono', monospace;
    color: var(--divider);
    font-size: 0.9rem;
    letter-spacing: 0;
    text-shadow: 0 0 6px rgba(52, 78, 65, 0.4);
}

/* ---- Revelation ---- */
.revelation {
    width: 100%;
    padding: 8vh 5vw;
    text-align: center;
    background: var(--terminal-bg);
    position: relative;
    z-index: 10;
    opacity: 1;
    transition: opacity 1s ease;
}

.revelation.hidden {
    opacity: 0;
}

.revelation.visible {
    opacity: 1;
}

.revelation-inner {
    max-width: 800px;
    margin: 0 auto;
}

.prompt-reveal {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--highlight);
    display: block;
    margin-bottom: 1rem;
    text-shadow: 0 0 8px rgba(149, 213, 178, 0.3);
}

.revelation-text {
    font-family: 'Fraunces', serif;
    font-weight: 900;
    font-size: clamp(2.4rem, 5vw, 4.8rem);
    color: var(--terminal-cursor);
    line-height: 1.1;
    font-variation-settings: 'SOFT' 100, 'WONK' 1;
    text-shadow: 0 0 30px rgba(183, 228, 199, 0.25);
}

/* ---- Colophon ---- */
.screen-colophon {
    position: relative;
}

.colophon-terminal {
    position: relative;
    overflow: hidden;
}

/* ---- Responsive (< 768px) ---- */
@media (max-width: 768px) {
    .spread-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .divider-stem {
        width: 100%;
        height: 2px;
        background: repeating-linear-gradient(
            to right,
            var(--terminal-accent) 0px,
            var(--terminal-accent) 8px,
            transparent 8px,
            transparent 16px
        );
    }

    .terminal-pane {
        min-height: 50vh;
    }

    .specimen-inner {
        min-height: 50vh;
    }

    .terminal-inner {
        padding: 24px;
    }

    .specimen-content {
        margin: 6vh 5vw;
    }

    .revelation-text {
        font-size: clamp(1.8rem, 6vw, 3rem);
    }
}

/* ---- Progress bar in boot ---- */
.progress-bar {
    display: inline;
    color: var(--highlight);
}

/* ---- Analysis content ---- */
.analysis-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fibonacci-container {
    max-width: 420px;
    margin-top: 2rem;
}

/* ---- Fern SVG decorative elements ---- */
.fern-decoration {
    position: absolute;
    opacity: 0.15;
    z-index: 1;
}

.fern-decoration svg {
    width: 200px;
    height: auto;
}

/* ---- Scrollbar styling ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--terminal-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--terminal-accent);
    border-radius: 3px;
}

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