/* ========================================
   economic.wiki - Styles
   Isometric technical docs aesthetic
   ======================================== */

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

:root {
    --page-white: #ffffff;
    --blueprint-dark: #1a2744;
    --blueprint-line: #2d4a7a;
    --demand-orange: #e67e22;
    --supply-teal: #1abc9c;
    --text-charcoal: #2c3e50;
    --caption-gray: #7f8c8d;
    --sidebar-tint: #f8f9fa;
    --sidebar-width: 240px;
    --content-max: 740px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    line-height: 1.7;
    color: var(--text-charcoal);
    background: var(--page-white);
    display: flex;
    min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-tint);
    border-right: 1px solid #e0e3e6;
    overflow-y: auto;
    z-index: 100;
    padding: 24px 0;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px;
    border-bottom: 1px solid #e0e3e6;
    margin-bottom: 16px;
}

.logo-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.sidebar-title {
    font-family: 'Sora', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--blueprint-dark);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 0 12px;
}

.sidebar-nav details {
    margin-bottom: 4px;
}

.sidebar-nav summary {
    font-family: 'Sora', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-charcoal);
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: background 0.2s;
}

.sidebar-nav summary:hover {
    background: #e8ebed;
}

.sidebar-nav summary::before {
    content: '+';
    font-family: 'Sora', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--caption-gray);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.sidebar-nav details[open] > summary::before {
    content: '\2212';
}

.sidebar-nav summary::-webkit-details-marker {
    display: none;
}

.sidebar-nav ul {
    list-style: none;
    padding: 2px 0 8px 28px;
}

.sidebar-nav li {
    margin-bottom: 1px;
}

.nav-link {
    font-family: 'Sora', sans-serif;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--caption-gray);
    text-decoration: none;
    display: block;
    padding: 5px 10px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
    color: var(--text-charcoal);
    background: #e8ebed;
}

.nav-link.active {
    color: var(--supply-teal);
    background: rgba(26, 188, 156, 0.08);
    font-weight: 500;
}

/* === Sidebar Toggle (mobile) === */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    width: 36px;
    height: 36px;
    background: var(--page-white);
    border: 1px solid #e0e3e6;
    border-radius: 6px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-charcoal);
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

.sidebar-toggle.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.sidebar-toggle.open span:nth-child(2) {
    opacity: 0;
}
.sidebar-toggle.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    position: relative;
}

/* === Hero Section === */
.hero {
    position: relative;
    width: 100%;
    min-height: 420px;
    background: linear-gradient(135deg, var(--blueprint-dark) 0%, #0d1a30 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px 40px;
}

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

.hero-title {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 2.6rem;
    font-weight: 700;
    color: var(--page-white);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-family: 'Sora', sans-serif;
    font-size: 1.05rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 0.01em;
}

/* === Isometric City === */
.isometric-city {
    position: relative;
    width: 850px;
    max-width: 100%;
    height: 220px;
    perspective: 800px;
    z-index: 5;
}

.building {
    position: absolute;
    width: 32px;
    height: var(--height);
    left: var(--left);
    bottom: var(--top);
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateZ(45deg);
    transition: height 0.4s ease, filter 0.3s;
    cursor: pointer;
}

/* Building top face */
.building::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: top left;
}

/* Building front face */
.building::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20px;
    transform-origin: bottom left;
    transform: rotateX(-90deg);
}

/* Finance buildings - deep blue */
.building-finance {
    background: #3a6db5;
}
.building-finance::before {
    background: #4a82cc;
}
.building-finance::after {
    background: #2d5a94;
}

/* Tech buildings - teal */
.building-tech {
    background: #1abc9c;
}
.building-tech::before {
    background: #2ee8c2;
}
.building-tech::after {
    background: #149a7d;
}

/* Manufacturing buildings - orange */
.building-mfg {
    background: #e67e22;
}
.building-mfg::before {
    background: #f0923e;
}
.building-mfg::after {
    background: #c96a15;
}

/* Services buildings - purple */
.building-services {
    background: #8e44ad;
}
.building-services::before {
    background: #a85cc5;
}
.building-services::after {
    background: #713691;
}

/* Agriculture buildings - green */
.building-agri {
    background: #27ae60;
}
.building-agri::before {
    background: #33c96f;
}
.building-agri::after {
    background: #1e8c4d;
}

.building:hover {
    filter: brightness(1.2);
}

.building.highlight {
    filter: brightness(1.3);
    z-index: 10;
}

.building.dimmed {
    filter: brightness(0.5) saturate(0.4);
}

/* Sector Legend */
.sector-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 10;
    margin-top: 20px;
}

.legend-item {
    font-family: 'Sora', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: color 0.2s;
}

.legend-item:hover {
    color: var(--page-white);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

/* === Concept Sections === */
.concept-section {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 60px 30px;
    border-bottom: 1px solid #eef0f2;
}

.concept-section:last-of-type {
    border-bottom: none;
}

.section-heading {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-charcoal);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.section-intro {
    font-size: 1.05rem;
    color: var(--caption-gray);
    margin-bottom: 30px;
    line-height: 1.7;
}

.concept-section p {
    margin-bottom: 18px;
    line-height: 1.7;
}

.concept-section strong {
    color: var(--text-charcoal);
    font-weight: 700;
}

.concept-section em {
    font-style: italic;
    color: var(--supply-teal);
}

/* === Blueprint Diagram Panels === */
.blueprint-panel {
    background: var(--blueprint-dark);
    border-radius: 8px;
    padding: 24px;
    margin: 30px 0;
    overflow: hidden;
    position: relative;
    /* Blueprint grid overlay */
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 24px,
            rgba(45, 74, 122, 0.3) 24px,
            rgba(45, 74, 122, 0.3) 25px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 24px,
            rgba(45, 74, 122, 0.3) 24px,
            rgba(45, 74, 122, 0.3) 25px
        );
    background-color: var(--blueprint-dark);
}

.diagram-svg {
    width: 100%;
    height: auto;
    display: block;
}

.diagram-label {
    font-family: 'Sora', sans-serif;
}

.diagram-mono {
    font-family: 'Fira Code', monospace;
}

.blueprint-panel figcaption {
    font-family: 'Sora', sans-serif;
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    line-height: 1.5;
}

/* Curve interactions */
.curve {
    transition: stroke-width 0.2s ease, filter 0.2s ease;
    cursor: pointer;
}

.curve:hover {
    stroke-width: 4;
    filter: drop-shadow(0 0 6px currentColor);
}

/* Equilibrium dot pulse */
.equilibrium-dot {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { r: 6; opacity: 1; }
    50% { r: 9; opacity: 0.7; }
}

/* === Equation Blocks === */
.equation-block {
    border: 1px solid #e8ebed;
    border-left: 4px solid var(--supply-teal);
    border-radius: 0 6px 6px 0;
    padding: 16px 20px;
    margin: 24px 0;
    background: var(--sidebar-tint);
}

.equation-label {
    font-family: 'Sora', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--caption-gray);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 8px;
}

.equation {
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-charcoal);
    background: none;
    display: block;
}

/* === Connector SVG === */
.connector-svg {
    position: absolute;
    top: 0;
    left: 50%;
    width: 60px;
    height: 100%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 0;
    opacity: 0;
}

.connector-line {
    stroke-dasharray: 8, 6;
    animation: dash 20s linear infinite;
}

@keyframes dash {
    to {
        stroke-dashoffset: -200;
    }
}

/* === Related Concepts Grid === */
.related-concepts {
    max-width: 900px;
    margin: 0 auto;
    padding: 60px 30px 40px;
}

.related-concepts .section-heading {
    text-align: center;
    margin-bottom: 30px;
}

.concept-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.concept-card {
    background: var(--page-white);
    border: 1px solid #e8ebed;
    border-radius: 8px;
    padding: 24px;
    text-decoration: none;
    color: var(--text-charcoal);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: block;
}

.concept-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(26, 39, 68, 0.1);
    border-color: var(--supply-teal);
}

.card-icon {
    margin-bottom: 14px;
}

.concept-card h3 {
    font-family: 'Sora', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-charcoal);
}

.concept-card p {
    font-size: 0.85rem;
    color: var(--caption-gray);
    line-height: 1.55;
}

/* === Footer === */
.site-footer {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 30px;
    text-align: center;
    border-top: 1px solid #eef0f2;
}

.site-footer p {
    font-family: 'Sora', sans-serif;
    font-size: 0.8rem;
    color: var(--caption-gray);
}

/* === Scroll Animations === */
.concept-section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.concept-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.related-concepts {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.related-concepts.visible {
    opacity: 1;
    transform: translateY(0);
}

/* === Responsive: Mobile (<768px) === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .sidebar-toggle {
        display: flex;
    }

    .main-content {
        margin-left: 0;
    }

    .hero {
        min-height: 320px;
        padding: 50px 20px 30px;
    }

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

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

    .isometric-city {
        transform: scale(0.5);
        transform-origin: center center;
        height: 140px;
    }

    .concept-section {
        padding: 40px 20px;
    }

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

    .blueprint-panel {
        padding: 16px;
        margin: 20px -10px;
        border-radius: 6px;
    }

    .concept-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .related-concepts {
        padding: 40px 20px;
    }

    .sector-legend {
        gap: 12px;
    }

    .legend-item {
        font-size: 0.7rem;
    }
}

/* === Tablet (768px - 1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
    .concept-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

/* === Scrollbar Styling (sidebar) === */
.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #d1d5d9;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #b0b5ba;
}
