/* economics.quest - Rammed Earth at Dusk */
/* Colors: #F4F0EA (bg), #E8DFD2 (surface), #3D3228 (deep), #2B2520 (text), #7A7068 (secondary), #B56B45 (accent), #C8825A (warm), #5B7B7A (cool) */
/* Fonts: Nunito Sans (body), DM Serif Display (display), IBM Plex Mono (mono) */

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

:root {
    --bg: #F4F0EA;
    --surface: #E8DFD2;
    --deep: #3D3228;
    --text-primary: #2B2520;
    --text-secondary: #7A7068;
    --accent: #B56B45;
    --accent-warm: #C8825A;
    --accent-cool: #5B7B7A;
    --font-body: 'Nunito Sans', sans-serif;
    --font-display: 'DM Serif Display', serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

html {
    scroll-behavior: smooth;
}

body {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
    background-color: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.65;
    font-feature-settings: 'liga' 1, 'kern' 1;
    overflow-x: hidden;
}

/* ========== GRID OVERLAY ========== */
.grid-overlay {
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    background:
        repeating-linear-gradient(
            90deg,
            rgba(43, 37, 32, 0.04) 0px,
            rgba(43, 37, 32, 0.04) 1px,
            transparent 1px,
            transparent 40px
        ),
        repeating-linear-gradient(
            0deg,
            rgba(43, 37, 32, 0.04) 0px,
            rgba(43, 37, 32, 0.04) 1px,
            transparent 1px,
            transparent 40px
        );
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--deep);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 100;
}

.sidebar-header {
    padding: 2.5rem 1.5rem 2rem;
}

.sidebar-logo {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--surface);
    letter-spacing: -0.02em;
}

.logo-accent {
    color: var(--accent);
}

.sidebar-nav-wrapper {
    position: relative;
    padding: 0 1.5rem;
    flex: 1;
}

.sidebar-indicator {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 36px;
    background: var(--accent);
    transition: top 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    border-radius: 1px;
}

.sidebar-links {
    list-style: none;
}

.sidebar-links li {
    margin-bottom: 0.25rem;
}

.sidebar-link {
    display: block;
    padding: 0.5rem 0 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
}

.sidebar-link:hover {
    color: var(--surface);
}

.sidebar-link.active {
    color: var(--accent-warm);
}

.sidebar-footer {
    padding: 2rem 1.5rem;
}

.sidebar-footnote {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.5;
    letter-spacing: 0.05em;
    line-height: 1.6;
}

/* ========== MOBILE HEADER ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--deep);
    z-index: 200;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
}

.mobile-logo {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--surface);
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--surface);
    transition: all 0.3s ease;
    border-radius: 1px;
}

.hamburger.open span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
}

.hamburger.open span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* ========== MOBILE OVERLAY ========== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(61, 50, 40, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 190;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.mobile-overlay.visible {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.mobile-nav-links {
    list-style: none;
    text-align: center;
}

.mobile-nav-links li {
    margin-bottom: 1.5rem;
}

.mobile-link {
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--surface);
    text-decoration: none;
    transition: color 0.3s ease;
}

.mobile-link:hover {
    color: var(--accent-warm);
}

/* ========== MAIN CONTENT ========== */
.main-content {
    position: relative;
    z-index: 2;
}

.content-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: clamp(3rem, 8vw, 7rem);
}

.section-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(2rem, 4vw, 5rem);
    align-items: center;
    max-width: 1200px;
    width: 100%;
}

.section-text {
    max-width: 600px;
}

.section-number {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    opacity: 0.5;
    display: block;
    margin-bottom: 1rem;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    font-weight: 400;
    letter-spacing: -0.025em;
    line-height: 1.05;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.typewriter-container {
    margin-bottom: 1.5rem;
}

.typewriter-text {
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    opacity: 0.85;
    min-height: 4.5em;
}

.typewriter-text::after {
    content: '';
    display: inline-block;
    width: 0.55em;
    height: 1.1em;
    background: var(--accent-warm);
    animation: blink 0.8s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

.typewriter-text.done::after {
    display: none;
}

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

.typewriter-data {
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 0.08em;
    color: var(--accent);
    opacity: 0;
    margin-bottom: 1.5rem;
    min-height: 1.5em;
}

.typewriter-data::after {
    content: '';
    display: inline-block;
    width: 0.55em;
    height: 1.1em;
    background: var(--accent-warm);
    animation: blink 0.8s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

.typewriter-data.done::after {
    display: none;
}

.typewriter-data.typing {
    opacity: 1;
}

.section-body {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.65;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
}

.section-body:last-child {
    margin-bottom: 0;
}

/* ========== REVEAL ANIMATIONS ========== */
.reveal-el {
    opacity: 0;
    transform: translateY(30px);
    transition:
        opacity 0.7s cubic-bezier(0.25, 0.1, 0.25, 1),
        transform 0.7s cubic-bezier(0.25, 0.1, 0.25, 1);
    transition-delay: calc(var(--stagger-index, 0) * 120ms);
}

.reveal-el.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========== INTERSTITIALS ========== */
.interstitial {
    height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(
        180deg,
        var(--bg) 0%,
        var(--surface) 50%,
        var(--bg) 100%
    );
}

.interstitial-number {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    opacity: 0.3;
}

/* ========== 3D CITY VIGNETTES ========== */
.city-vignette {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    perspective: 800px;
}

/* --- Inquiry: Cluster of towers --- */
.iso-scene {
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(45deg);
    position: relative;
    width: 250px;
    height: 200px;
}

.building {
    position: absolute;
    bottom: 0;
    transform-style: preserve-3d;
}

.building::before,
.building::after {
    content: '';
    position: absolute;
}

.b1 {
    left: 10px;
    width: 40px;
    height: 120px;
    background: linear-gradient(180deg, var(--surface), var(--accent-warm));
    box-shadow: 20px 20px 40px rgba(43, 37, 32, 0.15);
}
.b1::before {
    width: 40px;
    height: 20px;
    bottom: 100%;
    left: 0;
    background: var(--bg);
    transform: rotateX(90deg) translateZ(10px);
    transform-origin: bottom;
}
.b1::after {
    width: 20px;
    height: 120px;
    left: 100%;
    top: 0;
    background: var(--accent);
    opacity: 0.6;
    transform: rotateY(90deg) translateZ(10px);
    transform-origin: left;
}

.b2 {
    left: 60px;
    width: 35px;
    height: 80px;
    background: linear-gradient(180deg, var(--surface), var(--text-secondary));
    box-shadow: 20px 20px 40px rgba(43, 37, 32, 0.15);
}
.b2::before {
    width: 35px;
    height: 18px;
    bottom: 100%;
    left: 0;
    background: var(--bg);
    transform: rotateX(90deg) translateZ(9px);
    transform-origin: bottom;
}
.b2::after {
    width: 18px;
    height: 80px;
    left: 100%;
    top: 0;
    background: var(--text-secondary);
    opacity: 0.5;
    transform: rotateY(90deg) translateZ(9px);
    transform-origin: left;
}

.b3 {
    left: 105px;
    width: 45px;
    height: 160px;
    background: linear-gradient(180deg, var(--surface), var(--accent-warm));
    box-shadow: 20px 20px 40px rgba(43, 37, 32, 0.15);
}
.b3.highlighted {
    background: linear-gradient(180deg, var(--accent-warm), var(--accent));
}
.b3::before {
    width: 45px;
    height: 22px;
    bottom: 100%;
    left: 0;
    background: var(--bg);
    transform: rotateX(90deg) translateZ(11px);
    transform-origin: bottom;
}
.b3::after {
    width: 22px;
    height: 160px;
    left: 100%;
    top: 0;
    background: var(--accent);
    opacity: 0.7;
    transform: rotateY(90deg) translateZ(11px);
    transform-origin: left;
}

.b4 {
    left: 160px;
    width: 38px;
    height: 100px;
    background: linear-gradient(180deg, var(--surface), var(--text-secondary));
    box-shadow: 20px 20px 40px rgba(43, 37, 32, 0.15);
}
.b4::before {
    width: 38px;
    height: 19px;
    bottom: 100%;
    left: 0;
    background: var(--bg);
    transform: rotateX(90deg) translateZ(9.5px);
    transform-origin: bottom;
}
.b4::after {
    width: 19px;
    height: 100px;
    left: 100%;
    top: 0;
    background: var(--text-secondary);
    opacity: 0.5;
    transform: rotateY(90deg) translateZ(9.5px);
    transform-origin: left;
}

.b5 {
    left: 210px;
    width: 30px;
    height: 60px;
    background: linear-gradient(180deg, var(--surface), var(--accent-warm));
    box-shadow: 20px 20px 40px rgba(43, 37, 32, 0.15);
}
.b5::before {
    width: 30px;
    height: 15px;
    bottom: 100%;
    left: 0;
    background: var(--bg);
    transform: rotateX(90deg) translateZ(7.5px);
    transform-origin: bottom;
}
.b5::after {
    width: 15px;
    height: 60px;
    left: 100%;
    top: 0;
    background: var(--accent);
    opacity: 0.4;
    transform: rotateY(90deg) translateZ(7.5px);
    transform-origin: left;
}

/* --- Exchange: Towers of varying heights --- */
.exchange-scene {
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(45deg);
    position: relative;
    width: 280px;
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.tower {
    width: 30px;
    position: relative;
    transform-style: preserve-3d;
    box-shadow: 15px 15px 30px rgba(43, 37, 32, 0.12);
}

.tower::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 15px;
    top: -15px;
    left: 0;
    background: var(--bg);
    transform: rotateX(90deg) translateZ(7.5px);
    transform-origin: bottom;
}

.tower::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 100%;
    left: 100%;
    top: 0;
    background: rgba(43, 37, 32, 0.2);
    transform: rotateY(90deg) translateZ(7.5px);
    transform-origin: left;
}

.t1 { height: 90px; background: linear-gradient(180deg, var(--surface), var(--text-secondary)); }
.t2 { height: 130px; background: linear-gradient(180deg, var(--surface), var(--accent-warm)); }
.t3 { height: 170px; background: linear-gradient(180deg, var(--surface), var(--text-secondary)); }
.t3.tower-accent { background: linear-gradient(180deg, var(--accent-warm), var(--accent)); }
.t3.tower-accent::after { background: var(--accent); opacity: 0.6; }
.t4 { height: 110px; background: linear-gradient(180deg, var(--surface), var(--text-secondary)); }
.t5 { height: 145px; background: linear-gradient(180deg, var(--surface), var(--accent-warm)); }
.t6 { height: 75px; background: linear-gradient(180deg, var(--surface), var(--text-secondary)); }
.t7 { height: 100px; background: linear-gradient(180deg, var(--surface), var(--accent-warm)); }

/* --- Archive: Low columnar structure --- */
.archive-scene {
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(45deg);
    position: relative;
    width: 280px;
    height: 180px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.archive-building {
    position: relative;
    width: 260px;
    height: 100px;
    transform-style: preserve-3d;
}

.archive-base {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20px;
    background: var(--text-secondary);
    box-shadow: 15px 15px 30px rgba(43, 37, 32, 0.15);
}

.archive-roof {
    position: absolute;
    top: 0;
    left: -10px;
    width: calc(100% + 20px);
    height: 12px;
    background: var(--deep);
    box-shadow: 15px 15px 30px rgba(43, 37, 32, 0.1);
}

.column {
    position: absolute;
    bottom: 20px;
    width: 8px;
    height: 68px;
    background: linear-gradient(180deg, var(--surface), var(--accent-warm));
    box-shadow: 4px 4px 8px rgba(43, 37, 32, 0.1);
}

.c1 { left: 15px; }
.c2 { left: 55px; }
.c3 { left: 95px; }
.c4 { left: 135px; }
.c5 { left: 175px; }
.c6 { left: 215px; }
.c7 { left: 245px; }

/* --- Forum: Circular arrangement --- */
.forum-scene {
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(45deg);
    position: relative;
    width: 240px;
    height: 240px;
    animation: forum-rotate 30s linear infinite;
}

@keyframes forum-rotate {
    0% { transform: rotateX(-25deg) rotateY(45deg); }
    100% { transform: rotateX(-25deg) rotateY(60deg); }
}

.forum-block {
    position: absolute;
    width: 28px;
    height: 40px;
    background: linear-gradient(180deg, var(--surface), var(--accent-warm));
    box-shadow: 10px 10px 20px rgba(43, 37, 32, 0.12);
    transform-style: preserve-3d;
}

.forum-block::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 100%;
    left: 100%;
    top: 0;
    background: rgba(43, 37, 32, 0.15);
    transform: rotateY(90deg) translateZ(7px);
    transform-origin: left;
}

.fb1 { top: 20px; left: 106px; height: 35px; }
.fb2 { top: 55px; left: 175px; height: 45px; }
.fb3 { top: 120px; left: 195px; height: 30px; }
.fb4 { top: 175px; left: 165px; height: 38px; }
.fb5 { top: 195px; left: 95px; height: 42px; }
.fb6 { top: 165px; left: 25px; height: 35px; }
.fb7 { top: 100px; left: 5px; height: 48px; }
.fb8 { top: 40px; left: 35px; height: 32px; }

.forum-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;
    background: var(--accent-cool);
    opacity: 0.3;
    box-shadow: 0 0 30px rgba(91, 123, 122, 0.3);
}

/* --- Pipeline: Horizontal bars --- */
.pipeline-scene {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 280px;
}

.pipe {
    height: 16px;
    background: linear-gradient(90deg, var(--surface), var(--text-secondary));
    border-radius: 2px;
    box-shadow: 4px 4px 12px rgba(43, 37, 32, 0.1);
    transition: width 0.6s ease;
}

.p1 { width: 85%; }
.p2 { width: 65%; }
.p3 { width: 100%; }
.p3.pipe-accent {
    background: linear-gradient(90deg, var(--accent-cool), var(--accent));
    animation: pipe-pulse 3s ease-in-out infinite;
}
.p4 { width: 45%; }
.p5 { width: 75%; }
.p6 { width: 55%; }
.p7 { width: 90%; }

@keyframes pipe-pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* --- Horizon: Cityscape silhouette --- */
.horizon-scene {
    width: 100%;
    max-width: 400px;
    height: 200px;
    display: flex;
    align-items: flex-end;
}

.skyline {
    width: 100%;
    height: 120px;
    background:
        linear-gradient(90deg,
            transparent 0%, transparent 5%,
            var(--deep) 5%, var(--deep) 10%,
            transparent 10%, transparent 12%,
            var(--text-secondary) 12%, var(--text-secondary) 18%,
            transparent 18%, transparent 20%,
            var(--deep) 20%, var(--deep) 22%,
            transparent 22%, transparent 25%,
            var(--accent) 25%, var(--accent) 32%,
            transparent 32%, transparent 35%,
            var(--text-secondary) 35%, var(--text-secondary) 40%,
            transparent 40%, transparent 42%,
            var(--deep) 42%, var(--deep) 48%,
            transparent 48%, transparent 52%,
            var(--accent-warm) 52%, var(--accent-warm) 58%,
            transparent 58%, transparent 60%,
            var(--text-secondary) 60%, var(--text-secondary) 65%,
            transparent 65%, transparent 68%,
            var(--deep) 68%, var(--deep) 72%,
            transparent 72%, transparent 75%,
            var(--accent) 75%, var(--accent) 80%,
            transparent 80%, transparent 85%,
            var(--text-secondary) 85%, var(--text-secondary) 90%,
            transparent 90%, transparent 95%,
            var(--deep) 95%, var(--deep) 100%
        );
    background-size: 100% 100%;
    mask-image: linear-gradient(
        to top,
        black 0%,
        black 30%,
        transparent 100%
    );
    -webkit-mask-image: linear-gradient(
        to top,
        black 0%,
        black 30%,
        transparent 100%
    );
    opacity: 0.4;
}

/* ========== FOOTER ========== */
.site-footer {
    background: var(--deep);
    padding: clamp(3rem, 6vw, 5rem);
}

.footer-inner {
    max-width: 600px;
}

.footer-logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--surface);
    display: block;
    margin-bottom: 1rem;
}

.footer-text {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.footer-year {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    opacity: 0.4;
}

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

    .sidebar {
        display: none;
    }

    .mobile-header {
        display: flex;
    }

    .main-content {
        padding-top: 56px;
    }

    .grid-overlay {
        left: 0;
    }

    .section-inner {
        grid-template-columns: 1fr;
    }

    .content-section {
        padding: clamp(2rem, 6vw, 4rem);
    }

    .city-vignette {
        min-height: 200px;
        transform: scale(0.75);
    }
}

@media (max-width: 600px) {
    body {
        font-size: 16px;
    }

    .section-title {
        font-size: clamp(2rem, 8vw, 3.5rem);
    }

    .typewriter-text {
        font-size: 14px;
    }

    .city-vignette {
        transform: scale(0.6);
    }
}