/* economic.wiki - Isometric Technical Encyclopedia */
/* Color Palette */
:root {
    --pearl-matte: #E8E4DF;
    --deep-graphite: #2C2C35;
    --charcoal: #3D3D47;
    --slate: #6B6B78;
    --blueprint-cyan: #2E86AB;
    --copper: #B87333;
    --fog: #F4F2EE;
    --ice-blue: #C5DDE8;
    --diagram-red: #C04040;
    --deep-navy: #1A1E2E;
    --graphite-border: #4A4A55;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 32px;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    color: var(--charcoal);
    line-height: 1.65;
    background-color: var(--pearl-matte);
    /* Isometric grid texture */
    background-image:
        repeating-linear-gradient(
            30deg,
            transparent,
            transparent 39px,
            rgba(107, 107, 120, 0.03) 39px,
            rgba(107, 107, 120, 0.03) 40px
        ),
        repeating-linear-gradient(
            150deg,
            transparent,
            transparent 39px,
            rgba(107, 107, 120, 0.03) 39px,
            rgba(107, 107, 120, 0.03) 40px
        );
    overflow-x: hidden;
}

/* Typography */
h1, h2 {
    font-family: 'Space Grotesk', sans-serif;
    color: var(--deep-graphite);
    line-height: 1.08;
    letter-spacing: 0.06em;
}

h1 {
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

h2 {
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    font-weight: 500;
}

h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    color: var(--deep-graphite);
    line-height: 1.2;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

/* Data Ribbon */
#data-ribbon {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    background-color: var(--deep-navy);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.ticker-track {
    display: flex;
    white-space: nowrap;
    animation: ticker 120s linear infinite;
}

#data-ribbon:hover .ticker-track {
    animation-play-state: paused;
}

.ticker-content {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.ticker-item {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    font-weight: 400;
    color: var(--ice-blue);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0 12px;
    cursor: default;
    transition: font-size 200ms ease-in-out;
}

.ticker-item:hover {
    font-size: 13px;
    border-bottom: 1px solid var(--copper);
}

.ticker-value {
    color: var(--copper);
    font-weight: 400;
}

.ticker-sep {
    color: var(--slate);
    font-size: 8px;
    opacity: 0.4;
}

@keyframes ticker {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Sidebar */
#sidebar {
    position: fixed;
    left: 0;
    top: 32px;
    height: calc(100vh - 32px);
    width: 60px;
    background-color: var(--pearl-matte);
    z-index: 900;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
    transition: width 300ms ease;
    box-shadow: 2px 0 8px rgba(44, 44, 53, 0.06);
    overflow: hidden;
}

#sidebar:hover {
    width: 240px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: border-color 200ms ease, opacity 200ms ease;
}

.sidebar-item.active {
    border-left-color: var(--copper);
}

.sidebar-item.active .sidebar-icon {
    opacity: 1;
}

.sidebar-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 200ms ease;
}

.sidebar-item:hover .sidebar-icon {
    opacity: 0.8;
}

.sidebar-label {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: 13px;
    color: var(--charcoal);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 200ms ease 100ms;
}

#sidebar:hover .sidebar-label {
    opacity: 1;
}

/* Hero Section */
#hero {
    margin-top: 32px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background-color: var(--pearl-matte);
    padding-left: 60px;
    transition: transform 400ms ease-in-out, opacity 400ms ease-in-out;
}

#hero.scrolled {
    transform: scale(0.85) translateY(-10vh);
    opacity: 0.6;
}

.hero-content {
    text-align: center;
    z-index: 10;
    position: relative;
    margin-bottom: 20px;
}

.hero-divider {
    width: 120px;
    height: 1px;
    background-color: var(--copper);
    margin: 16px auto;
}

.hero-subtitle {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    color: var(--slate);
    letter-spacing: 0.02em;
}

#hero-cityscape {
    width: 80vw;
    max-width: 1000px;
    height: auto;
    max-height: 60vh;
    position: relative;
    z-index: 5;
}

.building-label {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 14px;
    fill: var(--deep-graphite);
    transition: opacity 300ms ease;
}

.building:hover .building-label {
    opacity: 1 !important;
}

.building:hover .building-shadow {
    opacity: 0.2 !important;
}

/* Trade ship animation */
.trade-ship {
    animation: shipSlide 6s linear infinite;
}

@keyframes shipSlide {
    0%, 100% { transform: translateX(-10px); }
    50% { transform: translateX(10px); }
}

/* Cross-Section Strips */
.cross-section {
    width: 100%;
    height: 120px;
    position: relative;
    margin-left: 60px;
    width: calc(100% - 60px);
}

.cross-section svg {
    display: block;
}

/* Gear rotation animations */
.gear-rotate {
    animation: rotate 8s linear infinite;
}

.gear-rotate-reverse {
    animation: rotate 5s linear infinite reverse;
}

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

/* Conveyor items */
.conveyor-item {
    animation: slide 6s linear infinite;
}

.conveyor-item-2 {
    animation-delay: -2s;
}

.conveyor-item-3 {
    animation-delay: -4s;
}

@keyframes slide {
    from { transform: translateX(320px); }
    to { transform: translateX(600px); }
}

/* Liquid fill animations */
.liquid-fill {
    animation: liquidFill 4s ease-in-out infinite;
}

.liquid-fill-2 {
    animation: liquidFill2 4s ease-in-out infinite;
    animation-delay: -1.5s;
}

@keyframes liquidFill {
    0%, 100% { y: 70; height: 28; }
    50% { y: 50; height: 48; }
}

@keyframes liquidFill2 {
    0%, 100% { y: 65; height: 33; }
    50% { y: 40; height: 58; }
}

/* Flow liquid animations */
.flow-liquid {
    animation: flowFill 5s ease-in-out infinite;
}

.flow-liquid-2 {
    animation: flowFill 5s ease-in-out infinite;
    animation-delay: -1.5s;
}

.flow-liquid-3 {
    animation: flowFill 5s ease-in-out infinite;
    animation-delay: -3s;
}

@keyframes flowFill {
    0%, 100% { width: 80; }
    50% { width: 280; }
}

/* Ship animations in cross-section */
.ship-right {
    animation: shipRight 10s linear infinite;
}

.ship-left {
    animation: shipLeft 12s linear infinite;
}

@keyframes shipRight {
    from { transform: translateX(140px); }
    to { transform: translateX(1060px); }
}

@keyframes shipLeft {
    from { transform: translateX(1060px); }
    to { transform: translateX(140px); }
}

/* Money flow animation */
.money-flow {
    animation: moneySlide 4s linear infinite;
}

@keyframes moneySlide {
    from { transform: translateX(0); }
    to { transform: translateX(230px); }
}

/* Reserve level animation */
.reserve-level {
    animation: reserveFill 6s ease-in-out infinite;
}

@keyframes reserveFill {
    0%, 100% { y: 60; height: 33; }
    50% { y: 35; height: 58; }
}

/* Rate needle animation */
.rate-needle {
    animation: needleSwing 4s ease-in-out infinite;
}

@keyframes needleSwing {
    0%, 100% { transform: rotate(-20deg); }
    50% { transform: rotate(20deg); }
}

/* Policy balance animation */
.policy-balance {
    animation: balanceTilt 6s ease-in-out infinite;
}

@keyframes balanceTilt {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

/* Main Content */
#content {
    padding-left: 60px;
    position: relative;
}

/* Bento Section */
.bento-section {
    padding: 40px 24px 24px 24px;
    scroll-margin-top: 32px;
}

.section-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 24px;
    padding-left: 8px;
}

.section-label {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(2.5rem, 5vw, 5rem);
    color: var(--blueprint-cyan);
    line-height: 1;
    opacity: 0.35;
}

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
}

/* Cell Sizes */
.bento-cell {
    padding: 24px;
    position: relative;
    border: 1px solid rgba(74, 74, 85, 0.15);
    transition: transform 200ms ease-out, box-shadow 200ms ease-out;
    overflow: hidden;
}

.bento-cell:nth-child(odd) {
    background-color: var(--fog);
}

.bento-cell:nth-child(even) {
    background-color: var(--pearl-matte);
}

.bento-cell:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 0 0 var(--copper), 0 8px 20px rgba(44, 44, 53, 0.1);
    z-index: 2;
}

.size-1x1 {
    grid-column: span 1;
    grid-row: span 1;
}

.size-2x1 {
    grid-column: span 2;
    grid-row: span 1;
}

.size-2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

/* Cell Icon */
.cell-icon {
    margin-bottom: 12px;
    display: block;
}

/* Cell Content */
.bento-cell h3 {
    margin-bottom: 10px;
}

.bento-cell p {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    color: var(--charcoal);
    line-height: 1.65;
    max-width: 68ch;
}

/* Accent Numerals */
.accent-numeral {
    display: block;
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(2.5rem, 5vw, 5rem);
    color: var(--blueprint-cyan);
    margin-top: 16px;
    line-height: 1;
}

.accent-label {
    display: block;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.85vw, 0.85rem);
    color: var(--slate);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 4px;
}

/* Flow Arrow Overlay */
#flow-arrows-overlay {
    position: absolute;
    top: 0;
    left: 60px;
    width: calc(100% - 60px);
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

#flow-arrows-overlay path {
    transition: stroke-opacity 300ms ease;
}

#flow-arrows-overlay path.highlight {
    stroke-opacity: 1;
}

.arrow-marker {
    transition: transform 300ms ease;
}

/* Footer - Colophon */
#colophon {
    background-color: var(--deep-navy);
    padding: 60px 24px;
    margin-left: 60px;
    display: flex;
    justify-content: center;
    min-height: 200px;
}

.footer-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-globe {
    opacity: 0.7;
}

.footer-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 14px;
    color: var(--ice-blue);
    letter-spacing: 0.06em;
}

.footer-rule {
    width: 80px;
    height: 1px;
    border: none;
    background-color: var(--slate);
    opacity: 0.2;
}

.footer-copyright {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 11px;
    color: var(--slate);
    letter-spacing: 0.02em;
}

/* Scroll Reveal Animation */
.bento-cell {
    opacity: 0;
    transform: translateY(40px);
    transition: transform 400ms ease-out, opacity 400ms ease-out, box-shadow 200ms ease-out;
}

.bento-cell.visible {
    opacity: 1;
    transform: translateY(0);
}

.bento-cell.visible:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 0 0 var(--copper), 0 8px 20px rgba(44, 44, 53, 0.1);
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .gear-rotate,
    .gear-rotate-reverse,
    .conveyor-item,
    .liquid-fill,
    .liquid-fill-2,
    .flow-liquid,
    .flow-liquid-2,
    .flow-liquid-3,
    .trade-ship,
    .ship-right,
    .ship-left,
    .money-flow,
    .reserve-level,
    .rate-needle,
    .policy-balance,
    .ticker-track {
        animation: none;
    }

    .bento-cell {
        opacity: 1;
        transform: none;
    }
}

/* Responsive: Tablet */
@media (max-width: 1024px) {
    #sidebar {
        display: none;
    }

    #hero {
        padding-left: 0;
    }

    .cross-section {
        margin-left: 0;
        width: 100%;
    }

    #content {
        padding-left: 0;
    }

    #colophon {
        margin-left: 0;
    }

    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    #flow-arrows-overlay {
        left: 0;
        width: 100%;
    }
}

/* Responsive: Mobile */
@media (max-width: 640px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }

    .size-2x1,
    .size-2x2 {
        grid-column: span 1;
    }

    .size-2x2 {
        grid-row: span 1;
    }

    #hero-cityscape {
        width: 95vw;
        max-height: 45vh;
    }

    h1 {
        font-size: clamp(1.8rem, 8vw, 3rem);
    }

    .section-header {
        padding-left: 4px;
    }

    .bento-section {
        padding: 24px 12px;
    }

    /* Bottom navigation bar on mobile */
    body::after {
        content: '';
        display: block;
        height: 60px;
    }
}

/* Selection color */
::selection {
    background-color: var(--ice-blue);
    color: var(--deep-graphite);
}

/* Link styles within cells */
.bento-cell a {
    color: var(--blueprint-cyan);
    text-decoration: none;
    border-bottom: 1px solid rgba(46, 134, 171, 0.3);
    transition: border-color 200ms ease;
}

.bento-cell a:hover {
    border-bottom-color: var(--blueprint-cyan);
}
