/* =========================================
   namu.systems — Bauhaus Ecological Dashboard
   ========================================= */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --burgundy-deep: #3A1020;
    --bauhaus-yellow: #E8C840;
    --bauhaus-blue: #3870B0;
    --bauhaus-red: #C83838;
    --system-cream: #F0EBD8;
    --root-brown: #8A6840;
    --panel-dark: #2A0818;

    /* Cursor position (updated by JS) */
    --mx: 50%;
    --my: 50%;

    /* Typography */
    --font-serif: 'Lora', Georgia, serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--burgundy-deep);
    color: var(--system-cream);
    font-family: var(--font-serif);
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.75;
    overflow-x: hidden;
}

/* --- Cursor-Follow Spotlight --- */
#spotlight {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: radial-gradient(
        circle 200px at var(--mx) var(--my),
        rgba(240, 235, 216, 0.08) 0%,
        transparent 100%
    );
    transition: opacity 0.3s ease;
    opacity: 0;
}

#spotlight.active {
    opacity: 1;
}

/* --- Section Headings --- */
.section-heading {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: clamp(20px, 2.5vw, 36px);
    color: var(--system-cream);
    text-align: center;
    margin-bottom: 48px;
    letter-spacing: 0.02em;
}

/* =========================================
   SECTION 1: System Overview
   ========================================= */
#system-overview {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 80px 24px 0;
    background: var(--burgundy-deep);
    overflow: hidden;
}

.overview-content {
    text-align: center;
    z-index: 2;
    position: relative;
}

.site-title {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: clamp(24px, 3vw, 44px);
    color: var(--system-cream);
    opacity: 0;
    animation: fadeInTitle 800ms ease forwards;
    animation-delay: 800ms;
    letter-spacing: 0.03em;
}

.site-subtitle {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 13px;
    color: var(--root-brown);
    letter-spacing: 0.06em;
    margin-top: 8px;
    opacity: 0;
    animation: fadeInTitle 600ms ease forwards;
    animation-delay: 1200ms;
}

@keyframes fadeInTitle {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Metrics Bar --- */
.metrics-bar {
    display: flex;
    gap: 40px;
    margin-top: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.metric-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--root-brown);
}

.metric-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 28px;
    color: var(--bauhaus-yellow);
    font-variant-numeric: tabular-nums;
}

/* --- Root Network SVG --- */
#root-network {
    width: 100%;
    max-width: 1200px;
    height: auto;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.root-path {
    fill: none;
    stroke: var(--root-brown);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.root-primary {
    stroke-width: 2;
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: drawRoot 1500ms ease forwards;
}

.root-secondary {
    stroke-width: 1.5;
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    animation: drawRoot 1500ms ease forwards;
    animation-delay: 600ms;
}

.mycorrhizal-path {
    fill: none;
    stroke: var(--system-cream);
    stroke-width: 1;
    stroke-dasharray: 4 4;
    stroke-dashoffset: 300;
    opacity: 0.5;
    animation: drawMycorrhizal 2000ms ease forwards;
    animation-delay: 1000ms;
}

@keyframes drawRoot {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes drawMycorrhizal {
    to {
        stroke-dashoffset: 0;
    }
}

.root-node {
    fill: var(--system-cream);
    opacity: 0;
    animation: fadeNode 400ms ease forwards;
    animation-delay: 1200ms;
}

.canopy-circle {
    fill: none;
    stroke: var(--root-brown);
    stroke-width: 1;
    opacity: 0.15;
}

.seed-node {
    opacity: 0;
    animation: pulseSeed 1500ms ease forwards;
}

@keyframes pulseSeed {
    0% { opacity: 0; r: 2; }
    30% { opacity: 1; r: 8; }
    100% { opacity: 1; r: 6; }
}

@keyframes fadeNode {
    from { opacity: 0; }
    to { opacity: 0.8; }
}


/* =========================================
   SECTION 2: Dashboard Grid
   ========================================= */
#dashboard {
    padding: 100px 24px 80px;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

/* --- Panel Base --- */
.panel,
.projection-panel {
    background: var(--panel-dark);
    border: 2px solid rgba(240, 235, 216, 0.15);
    padding: 24px;
    position: relative;
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s ease, transform 0.5s ease, border-color 0.4s ease, box-shadow 0.3s ease;
}

.panel.visible,
.projection-panel.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Panel accent colors */
.panel-yellow {
    border-color: rgba(232, 200, 64, 0.7);
}

.panel-blue {
    border-color: rgba(56, 112, 176, 0.7);
}

.panel-red {
    border-color: rgba(200, 56, 56, 0.7);
}

/* Flash animation on scroll-in */
@keyframes panelFlash {
    0% { border-color: rgba(240, 235, 216, 0.15); }
    30% { border-color: var(--flash-color); }
    100% { border-color: var(--settle-color); }
}

.panel-yellow.flash {
    animation: panelFlashYellow 400ms ease forwards;
}
.panel-blue.flash {
    animation: panelFlashBlue 400ms ease forwards;
}
.panel-red.flash {
    animation: panelFlashRed 400ms ease forwards;
}

@keyframes panelFlashYellow {
    0% { border-color: rgba(232, 200, 64, 0.3); }
    30% { border-color: #E8C840; }
    100% { border-color: rgba(232, 200, 64, 0.7); }
}

@keyframes panelFlashBlue {
    0% { border-color: rgba(56, 112, 176, 0.3); }
    30% { border-color: #3870B0; }
    100% { border-color: rgba(56, 112, 176, 0.7); }
}

@keyframes panelFlashRed {
    0% { border-color: rgba(200, 56, 56, 0.3); }
    30% { border-color: #C83838; }
    100% { border-color: rgba(200, 56, 56, 0.7); }
}

/* Hover: border pulse */
.panel:hover,
.projection-panel:hover {
    animation: borderPulse 400ms ease;
}

.panel-yellow:hover {
    box-shadow: 0 0 20px rgba(232, 200, 64, 0.15);
}

.panel-blue:hover {
    box-shadow: 0 0 20px rgba(56, 112, 176, 0.15);
}

.panel-red:hover {
    box-shadow: 0 0 20px rgba(200, 56, 56, 0.15);
}

/* Panel sizes */
.panel-wide {
    grid-column: span 2;
}

.panel-tall {
    grid-row: span 2;
}

/* --- Panel Corners (Bauhaus geometric ornaments) --- */
.panel-corner {
    position: absolute;
    width: 8px;
    height: 8px;
}

.panel-yellow .panel-corner { background: var(--bauhaus-yellow); }
.panel-blue .panel-corner { background: var(--bauhaus-blue); }
.panel-red .panel-corner { background: var(--bauhaus-red); }

.panel-corner-tl {
    top: -1px;
    left: -1px;
}

.panel-corner-tr {
    top: -1px;
    right: -1px;
    border-radius: 0 0 0 50%;
}

.panel-corner-bl {
    bottom: -1px;
    left: -1px;
    clip-path: polygon(0% 0%, 100% 100%, 0% 100%);
}

.panel-corner-br {
    bottom: -1px;
    right: -1px;
    border-radius: 50% 0 0 0;
}

/* --- Panel Label --- */
.panel-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--root-brown);
    display: block;
    margin-bottom: 16px;
}

/* --- Panel Body --- */
.panel-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* --- Conic Gradient Gauges --- */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gauge-single {
    margin: 0 auto;
}

.conic-gauge {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    --gauge-value: 0;
    background: conic-gradient(
        var(--gauge-color, #E8C840) 0deg,
        var(--gauge-color, #E8C840) calc(var(--gauge-value) * 3.6deg),
        rgba(240, 235, 216, 0.1) calc(var(--gauge-value) * 3.6deg),
        rgba(240, 235, 216, 0.1) 360deg
    );
    transition: --gauge-value 600ms ease;
}

.conic-gauge::after {
    content: '';
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--panel-dark);
}

.gauge-value {
    position: relative;
    z-index: 1;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 14px;
    color: var(--system-cream);
    font-variant-numeric: tabular-nums;
}

.gauge-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--root-brown);
    text-align: center;
}

/* --- Bar Indicators (Soil Chemistry) --- */
.bar-indicator {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 8px;
}

.bar-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--root-brown);
}

.bar-track {
    height: 6px;
    background: rgba(240, 235, 216, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    background: var(--bar-color, var(--bauhaus-yellow));
    border-radius: 3px;
    transition: width 800ms ease;
}

.bar-fill.animated {
    width: calc(var(--bar-target) * 1%);
}

.bar-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 13px;
    color: var(--system-cream);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* --- Root Network Panel --- */
.mini-root-svg {
    width: 120px;
    height: 120px;
}

.root-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.stat-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--root-brown);
}

.stat-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 18px;
    color: var(--system-cream);
    font-variant-numeric: tabular-nums;
}

/* --- Biodiversity Panel --- */
.biodiversity-body {
    flex-direction: column;
    align-items: center;
}

.bio-count {
    text-align: center;
    margin-bottom: 12px;
}

.bio-number {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 48px;
    color: var(--bauhaus-yellow);
    display: block;
    font-variant-numeric: tabular-nums;
}

.bio-unit {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--root-brown);
}

.bio-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.bio-item {
    text-align: center;
    padding: 8px;
    border: 1px solid rgba(232, 200, 64, 0.2);
}

.bio-item-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 20px;
    color: var(--system-cream);
    display: block;
    font-variant-numeric: tabular-nums;
}

.bio-item-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--root-brown);
}

/* --- Mycorrhizal Activity Panel --- */
.mycorrhizal-body {
    align-items: center;
    justify-content: space-between;
}

.myco-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.myco-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 160px;
}

/* --- Carbon Stats --- */
.carbon-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
}


/* =========================================
   SECTION 3: System Diagrams
   ========================================= */
#system-diagrams {
    padding: 100px 24px 80px;
    max-width: 1200px;
    margin: 0 auto;
}

.diagram-full {
    background: var(--panel-dark);
    border: 2px solid rgba(138, 104, 64, 0.4);
    padding: 32px;
    margin-bottom: 32px;
}

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

.diagram-path {
    fill: none;
    stroke: var(--root-brown);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease;
}

.diagram-path.draw {
    stroke-dashoffset: 0;
}

.diagram-root {
    stroke-width: 1.5;
}

.diagram-canopy {
    fill: none;
    stroke: var(--root-brown);
    stroke-width: 1.5;
    opacity: 0.4;
}

.diagram-canopy.small {
    stroke-width: 1;
    opacity: 0.3;
}

.ground-line {
    stroke: var(--root-brown);
    stroke-width: 1;
    stroke-dasharray: 6 4;
    opacity: 0.5;
}

.diagram-myco {
    fill: none;
    stroke: var(--system-cream);
    stroke-width: 1;
    stroke-dasharray: 4 4;
    opacity: 0.4;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 2s ease;
}

.diagram-myco.draw {
    stroke-dashoffset: 0;
}

.diagram-node {
    fill: var(--system-cream);
    opacity: 0;
    transition: opacity 0.5s ease, r 0.3s ease;
}

.diagram-node.visible {
    opacity: 0.7;
}

.diagram-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--root-brown);
    text-anchor: middle;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.diagram-description {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: clamp(14px, 1vw, 16px);
    line-height: 1.75;
    color: rgba(240, 235, 216, 0.7);
}


/* =========================================
   SECTION 4: Projections
   ========================================= */
#projections {
    padding: 80px 24px 60px;
    max-width: 1200px;
    margin: 0 auto;
}

.projections-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.projection-panel {
    text-align: center;
}

.projection-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.projection-counter {
    margin-top: 8px;
}

.counter-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 32px;
    color: var(--system-cream);
    display: block;
    font-variant-numeric: tabular-nums;
}

.counter-label {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--root-brown);
}


/* =========================================
   FOOTER
   ========================================= */
#site-footer {
    border-top: 1px solid rgba(138, 104, 64, 0.3);
    padding: 32px 24px;
    margin-top: 40px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-logo {
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 16px;
    color: var(--system-cream);
}

.footer-text {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--root-brown);
    letter-spacing: 0.04em;
}

.footer-status {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bauhaus-yellow);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bauhaus-yellow);
    animation: statusPulse 2s ease infinite;
}

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


/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .panel-wide {
        grid-column: span 2;
    }

    .panel-tall {
        grid-row: span 1;
    }

    .projections-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .metrics-bar {
        gap: 24px;
    }

    .mycorrhizal-body {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .panel-wide {
        grid-column: span 1;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .bar-indicator {
        grid-template-columns: 80px 1fr 36px;
    }

    .metrics-bar {
        gap: 16px;
    }

    .metric-value {
        font-size: 22px;
    }
}
