/* ============================================================
   HHASSL.com - Deep Forest Research Station
   Glassmorphism + Data Visualization + F-Pattern Layout
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --old-growth: #1B3A2D;
    --canopy: #2D6B4F;
    --understory: #4A9E73;
    --amber-resin: #D4A017;
    --bracket-fungus: #C45D3E;
    --forest-floor: #0F1A14;
    --morning-fog: #E8EDE9;
    --lichen: #B8C5BA;

    --glass-bg: rgba(45, 107, 79, 0.55);
    --glass-blur: blur(18px) saturate(1.4);
    --glass-border: 1px solid rgba(74, 158, 115, 0.3);
    --glass-highlight: inset 0 1px 0 rgba(232, 237, 233, 0.1);

    --font-headline: 'Roboto Slab', serif;
    --font-body: 'Source Sans 3', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --max-width: 1440px;
    --gutter: 24px;
}

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

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

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.0625rem;
    line-height: 1.8;
    color: var(--morning-fog);
    background-color: var(--forest-floor);
    overflow-x: hidden;
    position: relative;
}

/* --- Forest Backdrop (Panning Background) --- */
#forest-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background:
        linear-gradient(
            135deg,
            rgba(15, 26, 20, 0.85) 0%,
            rgba(27, 58, 45, 0.7) 25%,
            rgba(45, 107, 79, 0.5) 50%,
            rgba(27, 58, 45, 0.7) 75%,
            rgba(15, 26, 20, 0.85) 100%
        ),
        repeating-linear-gradient(
            0deg,
            rgba(27, 58, 45, 0.3) 0px,
            rgba(15, 26, 20, 0.4) 2px,
            rgba(45, 107, 79, 0.2) 4px,
            rgba(27, 58, 45, 0.35) 8px,
            rgba(15, 26, 20, 0.3) 12px,
            rgba(74, 158, 115, 0.15) 14px,
            rgba(27, 58, 45, 0.4) 18px,
            rgba(15, 26, 20, 0.35) 22px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(45, 107, 79, 0.15) 0px,
            transparent 1px,
            transparent 60px,
            rgba(45, 107, 79, 0.1) 61px
        );
    background-size: 200% 200%, 100% 100%, 100% 100%;
    will-change: background-position;
    animation: panForest 80s linear infinite;
    filter: brightness(0.35);
}

@keyframes panForest {
    0% { background-position: 0% 0%, 0 0, 0 0; }
    25% { background-position: 50% 30%, 0 0, 0 0; }
    50% { background-position: 100% 50%, 0 0, 0 0; }
    75% { background-position: 50% 70%, 0 0, 0 0; }
    100% { background-position: 0% 100%, 0 0, 0 0; }
}

/* --- Topographic Contour Layer --- */
#topo-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

#topo-layer svg {
    width: 100%;
    height: 100%;
}

/* --- Scroll Position Indicator --- */
#scroll-indicator {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: rgba(45, 107, 79, 0.25);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid rgba(74, 158, 115, 0.2);
}

.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid var(--lichen);
    background: transparent;
    cursor: pointer;
    transition: all 300ms ease-out;
    position: relative;
}

.indicator-dot.active {
    background: var(--amber-resin);
    border-color: var(--amber-resin);
    box-shadow: 0 0 8px rgba(212, 160, 23, 0.5);
}

.indicator-dot:hover {
    transform: scale(1.3);
    border-color: var(--morning-fog);
}

/* Ring-growth loading indicator on active dot */
.indicator-dot.active::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(212, 160, 23, 0.3);
}

.indicator-dot.active::after {
    content: '';
    position: absolute;
    top: -9px;
    left: -9px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid rgba(212, 160, 23, 0.15);
}

/* --- Viewport Sections --- */
.viewport-section {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 72px 60px 72px;
}

/* --- Glass Panel Base --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-highlight), 0 8px 32px rgba(15, 26, 20, 0.4);
    border-radius: 4px;
    position: relative;
}

/* Bark texture border effect via pseudo-element */
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 4px;
    pointer-events: none;
    border: 2px solid transparent;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(27, 58, 45, 0.4) 0px,
            rgba(15, 26, 20, 0.3) 1px,
            transparent 2px,
            transparent 4px
        ) border-box;
    -webkit-mask: linear-gradient(transparent 0, transparent 0) padding-box, linear-gradient(#fff, #fff) border-box;
    mask: linear-gradient(transparent 0, transparent 0) padding-box, linear-gradient(#fff, #fff) border-box;
    -webkit-mask-composite: destination-out;
    mask-composite: exclude;
}

/* --- Hero Section --- */
#hero {
    min-height: 100vh;
    align-items: stretch;
    padding: 0 0 0 48px;
}

.hero-panel {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    padding: 80px 60px;
}

.hero-content {
    max-width: var(--max-width);
}

.hero-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 4.5rem;
    letter-spacing: 0.02em;
    color: var(--morning-fog);
    line-height: 1.1;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1.125rem;
    color: var(--lichen);
    margin-bottom: 48px;
    max-width: 600px;
}

/* Sensor Readouts */
.sensor-readouts {
    display: flex;
    gap: 48px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.readout {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.readout-label {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lichen);
}

.readout-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 1.75rem;
    letter-spacing: 0.04em;
    color: var(--amber-resin);
    min-width: 120px;
}

.readout-unit {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--lichen);
    text-transform: lowercase;
}

.hero-coordinates {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.875rem;
    letter-spacing: 0.04em;
    color: var(--lichen);
    margin-top: 24px;
}

.coordinate-sep {
    margin: 0 8px;
    color: rgba(184, 197, 186, 0.4);
}

/* --- Canopy Break Dividers --- */
.canopy-break {
    position: relative;
    z-index: 2;
    height: 80px;
    width: 100%;
    background: transparent;
    margin-left: 48px;
}

/* --- Data Bands --- */
.data-band {
    min-height: auto;
    padding: 40px 72px 40px 72px;
    align-items: flex-start;
}

.data-band-inner {
    display: grid;
    grid-template-columns: 4fr 8fr;
    gap: var(--gutter);
    max-width: var(--max-width);
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    box-shadow: var(--glass-highlight), 0 8px 32px rgba(15, 26, 20, 0.4);
    border-radius: 4px;
    padding: 48px;
    transform: scale(0.97);
    opacity: 0;
    transition: transform 600ms ease-out, opacity 600ms ease-out;
}

.data-band-inner.visible {
    transform: scale(1);
    opacity: 1;
}

.data-band-label {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-right: 24px;
    border-right: 1px solid rgba(74, 158, 115, 0.2);
}

.section-label {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 2.25rem;
    letter-spacing: 0.02em;
    color: var(--morning-fog);
    line-height: 1.2;
    transition: transform 300ms ease-out;
}

.section-label:hover {
    transform: scale(1.05);
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-value {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 1.5rem;
    letter-spacing: 0.04em;
    color: var(--amber-resin);
}

.metric-desc {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: 0.875rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lichen);
}

.data-band-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.data-band-content p {
    color: var(--morning-fog);
    font-size: 1.0625rem;
    line-height: 1.8;
}

/* --- Inline Radial Chart --- */
.inline-chart {
    display: flex;
    justify-content: center;
    padding: 20px 0;
}

.radial-chart {
    width: 200px;
    height: 200px;
}

/* --- Data Labels (generic hover scale) --- */
.data-label {
    font-family: var(--font-headline);
    font-weight: 400;
    font-size: 1.125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--morning-fog);
    transition: transform 300ms ease-out;
    display: inline-block;
}

.data-label:hover {
    transform: scale(1.05);
}

/* --- Network Section --- */
#network-section {
    min-height: 100vh;
    padding: 60px 72px 60px 72px;
}

.network-panel {
    width: 100%;
    max-width: var(--max-width);
    padding: 48px;
}

.network-title {
    margin-bottom: 8px;
}

.network-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1rem;
    color: var(--lichen);
    margin-bottom: 32px;
}

.mono-accent {
    font-family: var(--font-mono);
    color: var(--amber-resin);
    letter-spacing: 0.04em;
}

.network-container {
    width: 100%;
    aspect-ratio: 12 / 7;
    position: relative;
}

#network-graph {
    width: 100%;
    height: 100%;
}

/* Network node styles */
.network-node {
    transition: transform 250ms ease-out, filter 250ms ease-out;
    cursor: pointer;
}

.network-node:hover {
    filter: drop-shadow(0 0 8px rgba(212, 160, 23, 0.6));
}

.network-edge {
    transition: opacity 250ms ease-out;
}

.network-edge.highlight {
    opacity: 0.8 !important;
}

/* Pulse animation for key nodes */
@keyframes nodePulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(212, 160, 23, 0.3)); }
    50% { filter: drop-shadow(0 0 12px rgba(212, 160, 23, 0.7)); }
}

.node-pulse {
    animation: nodePulse 3s ease-in-out infinite;
}

/* --- Treemap Section --- */
#treemap-section {
    min-height: 100vh;
    padding: 60px 72px;
}

.treemap-panel {
    width: 100%;
    max-width: var(--max-width);
    padding: 48px;
}

.treemap-title {
    margin-bottom: 8px;
}

.treemap-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: 1rem;
    color: var(--lichen);
    margin-bottom: 32px;
}

.treemap-container {
    width: 100%;
    aspect-ratio: 2 / 1;
    position: relative;
}

#treemap {
    width: 100%;
    height: 100%;
}

.treemap-cell {
    transition: transform 300ms ease-out, fill 500ms ease-out;
    cursor: pointer;
    transform-origin: center;
}

.treemap-cell:hover {
    filter: brightness(1.2);
}

.treemap-cell-text {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: rgba(232, 237, 233, 0.7);
    pointer-events: none;
}

/* Treemap Tooltip */
.treemap-tooltip {
    position: absolute;
    background: rgba(15, 26, 20, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(74, 158, 115, 0.4);
    border-radius: 3px;
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--morning-fog);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease-out;
    z-index: 50;
    white-space: nowrap;
    letter-spacing: 0.04em;
}

.treemap-tooltip.visible {
    opacity: 1;
}

.treemap-tooltip .tooltip-label {
    color: var(--lichen);
    display: block;
    margin-bottom: 4px;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.treemap-tooltip .tooltip-value {
    color: var(--amber-resin);
    font-size: 0.9375rem;
}

/* --- Coda Section --- */
#coda {
    min-height: 40vh;
    padding: 60px 72px;
}

.coda-panel {
    width: 100%;
    max-width: var(--max-width);
    padding: 48px;
}

.coda-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.coda-timestamp {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.875rem;
    letter-spacing: 0.04em;
    color: var(--amber-resin);
}

.coda-coordinates {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.8125rem;
    letter-spacing: 0.04em;
    color: var(--lichen);
}

.coda-note {
    font-family: var(--font-body);
    font-weight: 400;
    font-style: italic;
    font-size: 1.0625rem;
    line-height: 1.8;
    color: var(--morning-fog);
    max-width: 720px;
    margin-top: 12px;
}

/* --- Animations for viewport entry --- */
.glass-panel {
    transform: scale(0.97);
    opacity: 0;
    transition: transform 600ms ease-out, opacity 600ms ease-out;
}

.glass-panel.visible {
    transform: scale(1);
    opacity: 1;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
    #scroll-indicator {
        display: none;
    }

    .viewport-section {
        padding: 30px 16px;
    }

    #hero {
        padding: 0;
    }

    .hero-panel {
        padding: 40px 24px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .sensor-readouts {
        flex-direction: column;
        gap: 24px;
    }

    .readout-value {
        font-size: 1.25rem;
    }

    .data-band {
        padding: 20px 16px;
    }

    .data-band-inner {
        grid-template-columns: 1fr;
        padding: 24px;
    }

    .data-band-label {
        border-right: none;
        border-bottom: 1px solid rgba(74, 158, 115, 0.2);
        padding-right: 0;
        padding-bottom: 24px;
    }

    .section-label {
        font-size: 1.75rem;
    }

    .canopy-break {
        height: 40px;
        margin-left: 0;
    }

    #network-section,
    #treemap-section,
    #coda {
        padding: 30px 16px;
    }

    .network-panel,
    .treemap-panel,
    .coda-panel {
        padding: 24px;
    }

    .network-container {
        aspect-ratio: 4 / 3;
    }

    .treemap-container {
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2rem;
    }

    .section-label {
        font-size: 1.5rem;
    }
}
