/* ============================================
   economics.quest — Surreal Architectural Descent
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --copper: #B87333;
    --pale-gold: #C9A96E;
    --indigo: #0F1729;
    --midnight-slate: #1A2238;
    --spectral-white: #E8E4DE;
    --verdigris: #5B8C7A;
    --oxidized-teal: #2D6B6B;
    --graphite: #3A3F4B;
    --black: #000000;

    --font-display: 'Instrument Serif', serif;
    --font-body: 'Source Serif 4', serif;
    --font-mono: 'DM Mono', monospace;

    --scroll-progress: 0;
}

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

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

body {
    background: var(--indigo);
    color: var(--spectral-white);
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.72;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- World Container --- */
.world {
    position: relative;
    width: 100%;
    perspective: 1200px;
}

/* --- Breathing Grid (Background) --- */
.breathing-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

.breathing-grid.visible {
    opacity: 1;
}

.grid-group {
    animation: breathe-grid 30s ease-in-out infinite;
}

.grid-line {
    stroke: var(--graphite);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
    opacity: 0.1;
}

@keyframes breathe-grid {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* --- Chambers (General) --- */
.chamber {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transform-style: preserve-3d;
}

.chamber-title {
    font-family: var(--font-display);
    font-weight: 400;
    color: var(--copper);
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.0;
    text-shadow: 0 0 40px rgba(184, 115, 51, 0.2);
}

/* ============================================
   CHAMBER ZERO: The Equilibrium Void
   ============================================ */
.chamber-zero {
    height: 100vh;
    background: var(--indigo);
    overflow: hidden;
}

.chamber-zero-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Supply-Demand Curves */
.sd-curves {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    max-width: 800px;
    height: auto;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.sd-curves.visible {
    opacity: 1;
}

.curve {
    fill: none;
    stroke: var(--spectral-white);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    opacity: 0.12;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: none;
}

.curve.animate {
    animation: draw-curve 2s ease-out forwards;
}

@keyframes draw-curve {
    to { stroke-dashoffset: 0; }
}

/* Breathing animation for curves */
.sd-curves.breathing .curve {
    animation: curve-breathe 20s ease-in-out infinite;
}

@keyframes curve-breathe {
    0%, 100% { opacity: 0.12; }
    50% { opacity: 0.18; }
}

/* Domain Title */
.domain-title {
    position: relative;
    z-index: 2;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(3rem, 8vw, 6rem);
    color: var(--copper);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.0;
    text-shadow: 0 0 40px rgba(184, 115, 51, 0.2);
    transform: perspective(800px) rotateX(8deg);
}

.domain-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
}

.domain-title .letter.visible {
    animation: letter-appear 0.4s ease-out forwards;
}

.domain-title .letter.dot {
    margin: 0 0.05em;
}

@keyframes letter-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Subtitle */
.subtitle {
    position: relative;
    z-index: 2;
    font-family: var(--font-body);
    font-style: italic;
    font-weight: 300;
    font-size: 1rem;
    color: var(--spectral-white);
    opacity: 0;
    margin-top: 1.5rem;
    transition: opacity 1s ease;
}

.subtitle.visible {
    opacity: 0.5;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 1s ease;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1px solid var(--spectral-white);
    opacity: 0.3;
    animation: pulse-indicator 2s ease-in-out infinite;
}

.scroll-line {
    width: 1px;
    height: 40px;
    background: var(--spectral-white);
    opacity: 0.3;
    animation: pulse-indicator 2s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.5; }
}

/* ============================================
   CHAMBER ONE: The Invisible Architecture
   ============================================ */
.chamber-one {
    min-height: 100vh;
    background: var(--indigo);
    overflow: hidden;
}

.chamber-one-inner {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

/* Rotating Geometry */
.rotating-geometry {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    max-width: 700px;
    opacity: 0.15;
    transition: transform 0.1s linear, opacity 0.5s ease;
    will-change: transform;
}

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

.arch-curve {
    fill: none;
    stroke: var(--spectral-white);
    stroke-width: 1;
    opacity: 0.3;
    vector-effect: non-scaling-stroke;
}

.arch-horizon {
    stroke: var(--copper);
    stroke-width: 1;
    opacity: 0.4;
    vector-effect: non-scaling-stroke;
}

/* Text Panels */
.text-panel {
    position: relative;
    max-width: 680px;
    padding: 2.5rem 3rem;
    margin: 2rem 0;
    background: rgba(26, 34, 56, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(93, 140, 122, 0.2);
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.25rem);
    color: var(--spectral-white);
    line-height: 1.72;
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
    will-change: transform, opacity;
}

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

.text-panel .chamber-title {
    font-size: clamp(1.8rem, 4vw, 3rem);
    margin-bottom: 1rem;
}

.panel-left {
    align-self: flex-start;
    margin-left: 8vw;
    transform: translateX(-60px) rotate(-1deg);
}

.panel-left.visible {
    transform: translateX(0) rotate(-1deg);
}

.panel-right {
    align-self: flex-end;
    margin-right: 8vw;
    transform: translateX(60px) rotate(2deg);
}

.panel-right.visible {
    transform: translateX(0) rotate(2deg);
}

.panel-bottom {
    align-self: center;
    transform: translateY(60px) rotate(-1.5deg);
}

.panel-bottom.visible {
    transform: translateY(0) rotate(-1.5deg);
}

/* ============================================
   CHAMBER TWO: The Weighing Room
   ============================================ */
.chamber-two {
    min-height: 100vh;
    background: var(--indigo);
    overflow: hidden;
}

.chamber-two-inner {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
}

.chamber-two-title {
    margin-bottom: 4rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.chamber-two-title.visible {
    opacity: 1;
}

/* Balance Beam Assembly */
.balance-beam {
    position: relative;
    width: 60vw;
    max-width: 900px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.6s ease;
    will-change: transform;
}

.balance-beam.visible {
    opacity: 1;
}

/* The horizontal bar */
.beam-bar {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 3px;
    background: var(--copper);
    transform-origin: center center;
    transform: translate(-50%, -50%) scaleX(0);
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    z-index: 2;
}

.beam-bar.assembled {
    transform: translate(-50%, -50%) scaleX(1);
}

/* Fulcrum triangle */
.fulcrum {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    z-index: 3;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fulcrum.assembled {
    transform: translateX(-50%) scale(1);
}

.fulcrum-svg {
    width: 40px;
    height: 60px;
}

.fulcrum-svg polygon {
    fill: var(--copper);
}

/* Platforms */
.platform {
    position: absolute;
    top: 50%;
    width: 20vw;
    max-width: 280px;
    transform: translateY(-40px);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
    z-index: 1;
}

.platform.assembled {
    transform: translateY(0);
    opacity: 1;
}

.platform-left {
    left: 0;
}

.platform-right {
    right: 0;
}

.platform-content {
    padding: 1.5rem;
    border: 2px solid var(--pale-gold);
    background: rgba(26, 34, 56, 0.5);
    transition: opacity 0.4s ease;
}

.platform-label {
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    color: var(--verdigris);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.8rem;
}

.platform-content p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.85rem, 1.4vw, 1rem);
    color: var(--spectral-white);
    line-height: 1.65;
}

.platform-base {
    width: 100%;
    height: 2px;
    background: var(--pale-gold);
    margin-top: 0.5rem;
}

/* Pull Quote */
.pull-quote {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--pale-gold);
    text-align: center;
    max-width: 680px;
    margin-top: 5rem;
    padding-top: 3rem;
    border-top: 1px solid rgba(93, 140, 122, 0.3);
    opacity: 0;
    transition: opacity 1s ease;
}

.pull-quote.visible {
    opacity: 1;
}

/* ============================================
   CHAMBER THREE: The Flow Corridors
   ============================================ */
.chamber-three {
    min-height: 100vh;
    background: var(--indigo);
    overflow: hidden;
}

.chamber-three-inner {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
}

.chamber-three-title {
    margin-bottom: 3rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.chamber-three-title.visible {
    opacity: 1;
}

/* Pipe Network */
.pipe-network {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.pipe {
    fill: none;
    stroke: var(--oxidized-teal);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    opacity: 0.6;
}

.currency-particle {
    fill: var(--spectral-white);
    opacity: 0.4;
}

.currency-particle.gold {
    fill: var(--pale-gold);
    opacity: 0.25;
}

/* Flow Text */
.flow-text {
    position: relative;
    z-index: 1;
    max-width: 280px;
    margin: 3rem 0;
    padding: 1.5rem 2rem;
    background: rgba(15, 23, 41, 0.85);
    border-left: 1px solid rgba(93, 140, 122, 0.3);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.flow-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.flow-text p {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: clamp(0.9rem, 1.4vw, 1.05rem);
    color: var(--spectral-white);
    line-height: 1.72;
}

.flow-text-1 {
    align-self: flex-start;
    margin-left: 15vw;
}

.flow-text-2 {
    align-self: flex-end;
    margin-right: 15vw;
}

.flow-text-3 {
    align-self: center;
}

/* ============================================
   CHAMBER FOUR: The Question Archive
   ============================================ */
.chamber-four {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.chamber-four-inner {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    z-index: 1;
}

.chamber-four-title {
    margin-bottom: 4rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.chamber-four-title.visible {
    opacity: 1;
}

/* Library Background Layers */
.library-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    will-change: transform;
}

.library-layer-1 {
    background: repeating-linear-gradient(
        90deg,
        var(--midnight-slate) 0px,
        var(--midnight-slate) 30px,
        var(--graphite) 30px,
        var(--graphite) 31px,
        var(--midnight-slate) 31px,
        var(--midnight-slate) 65px,
        var(--graphite) 65px,
        var(--graphite) 66px
    );
    opacity: 0.3;
    z-index: 0;
}

.library-layer-2 {
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        transparent 40px,
        rgba(58, 63, 75, 0.3) 40px,
        rgba(58, 63, 75, 0.3) 41px,
        transparent 41px,
        transparent 85px,
        rgba(58, 63, 75, 0.3) 85px,
        rgba(58, 63, 75, 0.3) 86px
    );
    opacity: 0.2;
    z-index: 0;
}

.library-layer-3 {
    background: repeating-linear-gradient(
        90deg,
        transparent 0px,
        transparent 50px,
        rgba(58, 63, 75, 0.15) 50px,
        rgba(58, 63, 75, 0.15) 51px,
        transparent 51px,
        transparent 95px,
        rgba(58, 63, 75, 0.15) 95px,
        rgba(58, 63, 75, 0.15) 96px
    );
    opacity: 0.15;
    z-index: 0;
}

/* Question Blocks */
.question-block {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 3em 2rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease, transform 1s ease;
}

.question-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.question-annotation {
    display: block;
    font-family: var(--font-mono);
    font-weight: 300;
    font-size: clamp(0.65rem, 1vw, 0.8rem);
    color: var(--verdigris);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.question-text {
    font-family: var(--font-display);
    font-style: italic;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--pale-gold);
    line-height: 1.3;
    max-width: 680px;
    margin: 0 auto;
}

/* Final Darkness Overlay */
.final-darkness {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50vh;
    background: linear-gradient(to bottom, transparent, var(--black));
    z-index: 10;
    pointer-events: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .balance-beam {
        width: 90vw;
        flex-direction: column;
        height: auto;
    }

    .platform {
        position: relative;
        width: 80vw;
        max-width: none;
    }

    .platform-left,
    .platform-right {
        left: auto;
        right: auto;
    }

    .beam-bar {
        display: none;
    }

    .fulcrum {
        display: none;
    }

    .text-panel {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .panel-left {
        margin-left: 1rem;
        align-self: center;
    }

    .panel-right {
        margin-right: 1rem;
        align-self: center;
    }

    .flow-text-1 {
        margin-left: 2rem;
    }

    .flow-text-2 {
        margin-right: 2rem;
    }

    .rotating-geometry {
        width: 90vw;
    }
}
