/* ============================================================
   footprint.broker — Goblincore Brokerage
   Color Palette:
   - Deep Humus: #1a1208
   - Mahogany Shadow: #2d1b0e
   - Burnt Orange Flame: #d4621a
   - Oxidized Copper: #7a9e5a
   - Spore Gold: #c9a84c
   - Scanner Line: #ff6b2b
   - Aged Parchment: #e8dcc8
   - Dust Mote: #8a7d6b
   - Inner Fire: #ff8c42
   - Blood Rust: #8b2500
   ============================================================ */

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

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

body {
    background: #1a1208;
    color: #e8dcc8;
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    line-height: 1.7;
    overflow-x: hidden;
}

.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- HUD Compass (Fixed) --- */
#hud-compass {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    opacity: 0.8;
    transition: opacity 0.3s;
}

#hud-compass:hover {
    opacity: 1;
}

#hud-depth {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #ff6b2b;
    transition: all 0.3s;
}

#hud-depth.glitch-text {
    animation: hudGlitch 0.2s steps(3) 1;
}

@keyframes hudGlitch {
    0% { text-shadow: 2px 0 #00ffcc, -2px 0 #ff2200; transform: translateX(-2px); }
    33% { text-shadow: -1px 0 #ff2200, 1px 0 #00ffcc; transform: translateX(2px); }
    66% { text-shadow: 1px 0 #00ffcc, -1px 0 #ff2200; transform: translateX(-1px); }
    100% { text-shadow: none; transform: translateX(0); }
}

/* --- Fissure Glow Line --- */
#fissure-glow {
    position: fixed;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100vh;
    background: linear-gradient(180deg,
        transparent 0%,
        #ff8c42 15%,
        #d4621a 30%,
        #ff6b2b 50%,
        #d4621a 70%,
        #ff8c42 85%,
        transparent 100%
    );
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
    opacity: 0.6;
    filter: blur(2px);
    transition: opacity 0.5s, width 0.5s;
}

#fissure-glow.fissure-closed {
    opacity: 0;
    width: 0;
}

#fissure-glow.fissure-bright {
    opacity: 1;
    width: 6px;
    filter: blur(3px);
}

/* --- Glitch Overlay --- */
#glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 200;
    pointer-events: none;
}

#glitch-overlay.glitch-hidden {
    display: none;
}

#glitch-overlay.glitch-active {
    display: block;
}

.glitch-slice {
    position: absolute;
    left: 0;
    width: 100%;
    background: rgba(255, 107, 43, 0.08);
    mix-blend-mode: screen;
}

.glitch-slice-1 {
    top: 15%;
    height: 8%;
    transform: translateX(10px);
}

.glitch-slice-2 {
    top: 45%;
    height: 5%;
    transform: translateX(-15px);
}

.glitch-slice-3 {
    top: 75%;
    height: 6%;
    transform: translateX(8px);
}

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

/* --- Scan Line Texture --- */
.scan-lines::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 107, 43, 0.03) 2px,
        rgba(255, 107, 43, 0.03) 4px
    );
    pointer-events: none;
}

/* --- Sections / Descents --- */
.descent {
    position: relative;
    overflow: hidden;
}

#descent-1 { min-height: 100vh; }
#descent-2 { min-height: 120vh; }
#descent-3 { min-height: 100vh; }
#descent-4 { min-height: 130vh; }
#descent-5 { min-height: 100vh; }

/* --- Split Container --- */
.split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: inherit;
    position: relative;
}

.panel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.panel-archive {
    background: #1a1208;
    clip-path: url(#fissure-left);
}

.panel-overgrowth {
    background: #2d1b0e;
    clip-path: url(#fissure-right);
}

.split-reversed .panel-overgrowth {
    order: -1;
    clip-path: url(#fissure-left);
}

.split-reversed .panel-archive {
    clip-path: url(#fissure-right);
}

/* --- DESCENT 1: THE LOBBY --- */
.lobby-text {
    text-align: center;
    padding: 2rem;
    position: relative;
}

.title-footprint {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: clamp(3rem, 7vw, 6rem);
    letter-spacing: 0.02em;
    color: #c9a84c;
    text-shadow:
        2px 2px 0 #2d1b0e,
        -1px -1px 0 #2d1b0e,
        0 0 20px rgba(212, 98, 26, 0.3);
    line-height: 1.1;
}

.title-overgrown {
    color: #c9a84c;
    text-shadow:
        2px 2px 0 #2d1b0e,
        -1px -1px 0 #2d1b0e,
        0 0 30px rgba(212, 98, 26, 0.5),
        0 0 60px rgba(122, 158, 90, 0.2);
}

.title-broker {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 2.5vw, 2rem);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #ff6b2b;
    margin-top: 0.5rem;
    position: relative;
}

.title-broker::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 107, 43, 0.08) 2px,
        rgba(255, 107, 43, 0.08) 4px
    );
    pointer-events: none;
}

.lobby-overgrown {
    position: relative;
}

.fungi-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Path draw animation */
.fungi-draw {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: pathDraw 2s ease-out forwards;
}

.fungi-draw-circle {
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    animation: pathDraw 1.5s ease-out 1s forwards;
}

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

/* --- DESCENT 2: THE TRADING FLOOR --- */
.hud-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
}

.hud-frame {
    position: relative;
    padding: 1.5rem;
    background: rgba(26, 18, 8, 0.8);
    border: 1px solid rgba(212, 98, 26, 0.2);
    animation: hudFlicker 3s ease-in-out infinite;
}

.hud-frame::before,
.hud-frame::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: #ff6b2b;
    border-style: solid;
    opacity: 0.4;
}

.hud-frame::before {
    top: -1px;
    left: -1px;
    border-width: 2px 0 0 2px;
}

.hud-frame::after {
    bottom: -1px;
    right: -1px;
    border-width: 0 2px 2px 0;
}

/* Additional corners via inner element */
.hud-frame .hud-label::before,
.hud-frame .hud-label::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-color: #ff6b2b;
    border-style: solid;
    opacity: 0.4;
}

.hud-frame .hud-label::before {
    top: -1px;
    right: -1px;
    border-width: 2px 2px 0 0;
}

.hud-frame .hud-label::after {
    bottom: -1px;
    left: -1px;
    border-width: 0 0 2px 2px;
}

/* Scan line overlay on HUD frames */
.hud-frame > *:last-child::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255, 107, 43, 0.03) 2px,
        rgba(255, 107, 43, 0.03) 4px
    );
    pointer-events: none;
}

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

.hud-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: #ff6b2b;
    display: block;
    margin-bottom: 0.75rem;
    position: relative;
}

.hud-value {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: clamp(2rem, 4vw, 3.5rem);
    color: #e8dcc8;
    display: block;
    text-shadow:
        0 0 10px rgba(212, 98, 26, 0.6),
        0 0 20px rgba(212, 98, 26, 0.3),
        0 0 40px rgba(255, 140, 66, 0.2);
    line-height: 1.2;
}

.sparkline {
    width: 100%;
    height: 30px;
    margin-top: 0.5rem;
    opacity: 0.7;
}

/* Organic visualizations */
.organic-viz {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 2rem;
    width: 100%;
}

.organic-svg {
    width: 100%;
    height: auto;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.organic-svg.visible {
    opacity: 1;
    transform: translateY(0);
}

.ring-draw, .myc-draw, .shroom-draw, .decay-draw {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease-out;
}

.organic-svg.visible .ring-draw,
.organic-svg.visible .myc-draw,
.organic-svg.visible .shroom-draw,
.organic-svg.visible .decay-draw {
    stroke-dashoffset: 0;
}

/* --- DESCENT 3: THE VAULT --- */
.descent-merged {
    display: flex;
    align-items: center;
    justify-content: center;
}

.vault-panoramic {
    width: 100%;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vault-illustration {
    width: 100%;
    max-width: 1200px;
    height: auto;
}

.vault-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 2s ease-out;
}

.descent-merged.in-view .vault-draw {
    stroke-dashoffset: 0;
}

/* --- DESCENT 4: THE NETWORK --- */
.mycelium-network {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

#mycelium-svg {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.myc-branch {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.2s ease-out;
    filter: drop-shadow(0 0 4px rgba(255, 107, 43, 0.3));
}

.myc-node {
    transition: opacity 0.5s ease, r 0.3s ease;
}

.myc-branch.visible {
    stroke-dashoffset: 0;
}

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

@keyframes nodePulse {
    0%, 100% { transform-origin: center; r: inherit; }
    50% { transform-origin: center; }
}

.myc-node.pulse {
    animation: nodePulseAnim 2s ease-in-out infinite;
}

@keyframes nodePulseAnim {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; filter: drop-shadow(0 0 6px #ff6b2b); }
}

.network-text-blocks {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    justify-content: center;
    max-width: 500px;
}

.text-block {
    padding: 1.5rem;
}

.body-text {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    line-height: 1.7;
    color: #e8dcc8;
    margin-top: 0.75rem;
}

/* --- DESCENT 5: THE ROOT --- */
.descent-final {
    display: flex;
    align-items: center;
    justify-content: center;
}

.root-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 4rem 2rem;
}

#spore-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(80vw, 600px);
    height: min(80vw, 600px);
    pointer-events: none;
}

.spore-orbit-svg {
    width: 100%;
    height: 100%;
}

.spore-group {
    transform-origin: 300px 300px;
    animation: orbit 30s linear infinite;
}

@keyframes orbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.root-text {
    position: relative;
    z-index: 10;
    max-width: 40ch;
    text-align: center;
}

.closing-statement {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    line-height: 1.9;
    color: #e8dcc8;
}

.domain-final {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    text-transform: lowercase;
    color: #8a7d6b;
    margin-top: 3rem;
    position: relative;
    z-index: 10;
}

.domain-final::after {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ff6b2b, transparent);
    margin-top: 0.5rem;
    animation: scanPass 4s ease-in-out 1;
}

@keyframes scanPass {
    0% { width: 0; opacity: 0; }
    50% { width: 100%; opacity: 1; }
    100% { width: 100%; opacity: 0.5; }
}

/* --- Glitch Effect Styles (applied via JS) --- */
.glitch-active-page {
    animation: pageGlitch 0.2s steps(3) 1;
}

@keyframes pageGlitch {
    0% {
        text-shadow: 2px 0 #00ffcc, -2px 0 #ff2200;
        filter: hue-rotate(10deg);
    }
    33% {
        text-shadow: -1px 0 #ff2200, 1px 0 #00ffcc;
        filter: hue-rotate(-5deg);
    }
    66% {
        text-shadow: 1px 0 #00ffcc, -2px 0 #ff2200;
        filter: hue-rotate(5deg);
    }
    100% {
        text-shadow: none;
        filter: none;
    }
}

/* --- Mobile Adaptation --- */
@media (max-width: 768px) {
    .split-container {
        grid-template-columns: 1fr;
    }

    .panel-archive,
    .panel-overgrowth {
        clip-path: none;
    }

    .split-reversed .panel-overgrowth {
        order: -1;
        clip-path: none;
    }

    .split-reversed .panel-archive {
        clip-path: none;
    }

    #fissure-glow {
        top: 50%;
        left: 0;
        width: 100vw;
        height: 4px;
        background: linear-gradient(90deg,
            transparent 0%,
            #ff8c42 15%,
            #d4621a 30%,
            #ff6b2b 50%,
            #d4621a 70%,
            #ff8c42 85%,
            transparent 100%
        );
        transform: translateY(-50%);
    }

    .panel {
        min-height: 50vh;
    }

    .hud-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        padding: 1.5rem;
    }

    .organic-viz {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        padding: 1.5rem;
    }

    .hud-frame::before,
    .hud-frame::after {
        width: 8px;
        height: 8px;
    }

    .title-footprint {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .title-broker {
        font-size: clamp(0.8rem, 4vw, 1.5rem);
    }

    .network-text-blocks {
        padding: 1.5rem;
    }
}

/* --- Selection --- */
::selection {
    background: rgba(212, 98, 26, 0.4);
    color: #e8dcc8;
}
