/* ===== CSS Custom Properties ===== */
:root {
    --deep-canopy: #0B1F14;
    --undergrowth: #1A3A28;
    --terminal-green: #4ADE80;
    --fern: #4A6741;
    --lichen: #C8D5C0;
    --bark: #8B7D6B;
    --fog: #E8EDE5;
    --ember: #B8860B;

    --font-station: 'Share Tech Mono', monospace;
    --font-data: 'IBM Plex Mono', monospace;
    --font-body: 'Source Sans 3', sans-serif;
    --font-accent: 'Cormorant Garamond', serif;
}

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

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) var(--deep-canopy);
}

body {
    background: var(--deep-canopy);
    color: var(--lichen);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    font-weight: 400;
    line-height: 1.85;
    overflow-x: hidden;
}

::selection {
    background: var(--terminal-green);
    color: var(--deep-canopy);
}

::-webkit-scrollbar {
    width: 6px;
}

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

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

/* ===== Navigation Bar ===== */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0.6rem 1.5rem;
    background: rgba(11, 31, 20, 0.85);
    backdrop-filter: blur(10px);
}

.nav-domain {
    font-family: var(--font-station);
    font-size: 0.75rem;
    color: var(--fog);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.progress-bar {
    width: 100%;
    height: 1px;
    background: rgba(74, 103, 65, 0.3);
    margin-top: 0.4rem;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--terminal-green);
    transition: width 0.1s linear;
}

/* ===== Split Screen Container ===== */
.split-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* ===== Panels ===== */
.panel {
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
}

.panel-left {
    width: 55%;
    background: linear-gradient(180deg, #0B1F14 0%, #1A3A28 40%, #0B1F14 100%);
    position: relative;
}

.panel-right {
    width: 45%;
    background: var(--undergrowth);
    position: relative;
}

/* ===== Panel Divider ===== */
.panel-divider {
    position: fixed;
    left: 55%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(74, 103, 65, 0.2);
    z-index: 500;
    pointer-events: none;
}

/* ===== Background Overlays ===== */

/* Grid overlay on left panel */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(74, 103, 65, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 103, 65, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 1;
}

/* Contour lines overlay on left panel */
.contour-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 120px,
            rgba(200, 213, 192, 0.03) 120px,
            rgba(200, 213, 192, 0.03) 121px,
            transparent 121px,
            transparent 200px,
            rgba(200, 213, 192, 0.03) 200px,
            rgba(200, 213, 192, 0.03) 201px
        );
    pointer-events: none;
    z-index: 1;
}

/* Dot matrix overlay on right panel */
.dot-matrix-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(rgba(74, 222, 128, 0.04) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 1;
}

/* ===== Left Panel Sections ===== */
.left-section {
    min-height: 100vh;
    padding: 4rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.opening-visual {
    min-height: 100vh;
}

.root-survey-visual {
    min-height: 200vh;
    gap: 2rem;
}

.canopy-visual {
    min-height: 170vh;
    gap: 2rem;
}

.deep-forest-visual {
    min-height: 200vh;
    background: var(--deep-canopy);
}

.terminal-close-visual {
    min-height: 100vh;
    background: var(--deep-canopy);
}

/* ===== Glassmorphic Cards ===== */
.glass-card {
    background: rgba(26, 58, 40, 0.55);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-top: 1px solid rgba(74, 222, 128, 0.12);
    border-left: 1px solid rgba(74, 222, 128, 0.12);
    border-right: none;
    border-bottom: none;
    border-radius: 2px;
    box-shadow: 0 8px 32px rgba(11, 31, 20, 0.5);
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Scan lines on glass cards */
.glass-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(11, 31, 20, 0.08) 2px,
        rgba(11, 31, 20, 0.08) 3px
    );
    pointer-events: none;
    z-index: 10;
}

.glass-card-opening {
    width: 90%;
    max-width: 420px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass-card-roots {
    width: 95%;
    max-width: 500px;
    padding: 1.5rem;
    min-height: 500px;
}

.glass-card-root-detail {
    width: 70%;
    max-width: 300px;
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.root-detail-1 {
    align-self: flex-start;
    margin-left: 5%;
}

.root-detail-2 {
    align-self: flex-end;
    margin-right: 5%;
}

.glass-card-canopy {
    width: 85%;
    max-width: 400px;
    padding: 1.2rem 1.5rem;
}

.canopy-layer-1 {
    align-self: flex-start;
    margin-left: 5%;
    z-index: 5;
}

.canopy-layer-2 {
    align-self: flex-end;
    margin-right: 5%;
    z-index: 4;
}

.canopy-layer-3 {
    align-self: flex-start;
    margin-left: 10%;
    z-index: 3;
}

.glass-card-deep {
    width: 95%;
    max-width: 420px;
    padding: 2rem;
    min-height: 500px;
    backdrop-filter: blur(8px) saturate(1.1);
    -webkit-backdrop-filter: blur(8px) saturate(1.1);
}

/* ===== SVG Diagrams ===== */
.tree-svg {
    width: 100%;
    max-height: 500px;
}

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

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

.mini-diagram {
    width: 100%;
    max-width: 120px;
}

.canopy-diagram {
    width: 100%;
    margin-top: 0.5rem;
}

.sparkline-container {
    margin-top: 0.5rem;
}

.sparkline-svg {
    width: 100%;
}

/* Annotation text on glass cards */
.annotation {
    font-family: var(--font-data);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    font-weight: 300;
    letter-spacing: 0.04em;
    color: #8FA88A;
    opacity: 0.7;
}

/* ===== Right Panel Sections ===== */
.right-section {
    min-height: 100vh;
    padding: 5rem 2.5rem 4rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.opening-data {
    min-height: 100vh;
    justify-content: center;
    align-items: flex-start;
}

.root-data {
    min-height: 200vh;
    justify-content: flex-start;
    padding-top: 6rem;
    gap: 3rem;
}

.canopy-data {
    min-height: 170vh;
    justify-content: flex-start;
    padding-top: 6rem;
    gap: 3rem;
}

.deep-data {
    min-height: 200vh;
    justify-content: flex-start;
    padding-top: 6rem;
    gap: 3rem;
}

.terminal-close-data {
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    background: var(--deep-canopy);
}

/* ===== Terminal Header ===== */
.terminal-header {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
    margin-bottom: 1rem;
}

.station-title {
    font-family: var(--font-station);
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fog);
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
}

.cursor-blink {
    font-family: var(--font-station);
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--terminal-green);
    animation: blink 1s step-end infinite;
}

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

.cursor-final {
    animation: blink-final 1s step-end 3;
    animation-fill-mode: forwards;
}

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

.terminal-line {
    font-family: var(--font-data);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    font-weight: 300;
    letter-spacing: 0.04em;
    color: rgba(143, 168, 138, 0.7);
}

.terminal-glow {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74, 222, 128, 0.08) 0%, transparent 70%);
    top: 50%;
    left: 30%;
    transform: translate(-50%, -50%);
    animation: glow-pulse 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

/* ===== Log Entries ===== */
.log-entry {
    border-left: 1px solid rgba(74, 222, 128, 0.3);
    padding-left: 1.5rem;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.log-entry.visible {
    opacity: 1;
    transform: translateX(0);
}

.log-timestamp {
    font-family: var(--font-data);
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    font-weight: 300;
    letter-spacing: 0.04em;
    color: var(--bark);
    display: block;
    margin-bottom: 0.4rem;
}

.data-header {
    font-family: var(--font-station);
    font-size: clamp(1rem, 2vw, 1.4rem);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fog);
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.3);
    margin-bottom: 0.8rem;
}

.data-body {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    font-weight: 400;
    line-height: 1.85;
    color: var(--lichen);
}

/* ===== Inline Sparklines ===== */
.inline-sparkline {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.sparkline-inline {
    width: 100%;
    max-width: 200px;
}

.sparkline-label {
    font-family: var(--font-data);
    font-size: 0.65rem;
    font-weight: 300;
    letter-spacing: 0.04em;
    color: rgba(143, 168, 138, 0.5);
}

/* ===== Bridge Sections ===== */
.bridge {
    width: 100%;
    min-height: 80vh;
    background: var(--deep-canopy);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    position: relative;
    z-index: 600;
}

.bridge-svg {
    width: 100%;
    max-width: 1200px;
    margin-bottom: 3rem;
}

.bridge-text {
    font-family: var(--font-accent);
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    font-weight: 300;
    font-style: italic;
    color: var(--fog);
    text-align: center;
    max-width: 700px;
    line-height: 1.7;
}

.bridge-2 {
    position: relative;
}

.growth-ring-svg {
    max-width: 500px;
}

.ring-labels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.ring-label {
    position: absolute;
    font-family: var(--font-data);
    font-size: 0.7rem;
    font-weight: 300;
    color: var(--lichen);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ring-label.visible {
    opacity: 1;
}

.ring-label-latest {
    color: var(--ember);
    font-weight: 400;
}

/* ===== Terminal Close ===== */
.terminal-fade {
    width: 100%;
    height: 100%;
    background: var(--deep-canopy);
}

.terminal-close-content {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.terminal-final {
    font-size: clamp(1.2rem, 3vw, 2rem);
    text-shadow: 0 0 12px rgba(74, 222, 128, 0.4);
}

/* ===== SVG Path Animations ===== */
.tree-path,
.root-path,
.watershed-path,
.bridge-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.tree-path.drawn,
.root-path.drawn,
.watershed-path.drawn,
.bridge-path.drawn {
    stroke-dashoffset: 0;
}

.root-node {
    transition: opacity 0.5s ease;
}

.root-node.visible {
    opacity: 1;
}

.ring-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.ring-path.drawn {
    stroke-dashoffset: 0;
}

/* ===== Responsive Design ===== */

/* Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
    .split-container {
        flex-direction: column;
    }

    .panel-left,
    .panel-right {
        width: 100%;
    }

    .panel-left {
        min-height: auto;
    }

    .left-section {
        min-height: 50vh;
    }

    .root-survey-visual { min-height: 100vh; }
    .canopy-visual { min-height: 80vh; }
    .deep-forest-visual { min-height: 100vh; }
    .terminal-close-visual { min-height: 50vh; }

    .right-section {
        min-height: auto;
        padding: 3rem 2rem;
    }

    .root-data,
    .canopy-data,
    .deep-data {
        min-height: auto;
    }

    .panel-divider {
        display: none;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .split-container {
        flex-direction: column;
    }

    .panel-left,
    .panel-right {
        width: 100%;
        overflow-y: visible;
    }

    .panel-divider {
        display: none;
    }

    .left-section {
        min-height: 60vh;
        padding: 3rem 1.5rem;
    }

    .root-survey-visual { min-height: 80vh; }
    .canopy-visual { min-height: 60vh; }
    .deep-forest-visual { min-height: 80vh; }
    .terminal-close-visual { min-height: 40vh; }

    .right-section {
        min-height: auto;
        padding: 3rem 1.5rem;
    }

    .root-data,
    .canopy-data,
    .deep-data {
        min-height: auto;
        gap: 2rem;
    }

    .glass-card {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        width: 95% !important;
        max-width: none !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .canopy-layer-1,
    .canopy-layer-2,
    .canopy-layer-3 {
        align-self: center;
    }

    .root-detail-1,
    .root-detail-2 {
        align-self: center;
    }

    .bridge {
        min-height: 60vh;
        padding: 3rem 1.5rem;
    }

    .nav-bar {
        padding: 0.4rem 1rem;
    }

    .station-title {
        font-size: clamp(1.4rem, 6vw, 2rem);
    }

    .log-entry {
        padding-left: 1rem;
    }
}

/* ===== Scroll Snap (gentle) ===== */
.panel-left,
.panel-right {
    scroll-snap-type: y proximity;
}

.left-section,
.right-section {
    scroll-snap-align: start;
}
