/* ===== Variables ===== */
:root {
    --bg: #fafaf8;
    --surface: #ffffff;
    --surface-alt: #f3f1ec;
    --border: #e5e2da;
    --text-primary: #1a1a18;
    --text-secondary: #6b6860;
    --accent-primary: #c0392b;
    --accent-secondary: #2c6e8a;
    --accent-warm: #d4824a;
    --accent-success: #3a7d44;
    --max-text: 860px;
    --max-chart: 1100px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: 'DM Sans', sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    overflow-x: hidden;
}

/* ===== Progress Bar ===== */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent-primary);
    width: 0%;
    z-index: 1001;
    transition: width 0.08s linear;
}

/* ===== Site Header ===== */
.site-header {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header__title {
    font-family: 'DM Serif Display', serif;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: 0.01em;
}

.site-header__nav {
    display: flex;
    gap: 1.75rem;
    list-style: none;
}

.site-header__nav a {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-decoration: none;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    transition: color 0.2s;
}

.site-header__nav a:hover,
.site-header__nav a.active {
    color: var(--accent-primary);
}

/* ===== Hero ===== */
.hero {
    padding: 5.5rem 1.5rem 4.5rem;
    max-width: var(--max-text);
    margin: 0 auto;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease 0.1s, transform 0.6s ease 0.1s;
}

.hero.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero__eyebrow {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-primary);
    margin-bottom: 1.25rem;
    font-weight: 500;
}

.hero__title {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 400;
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.hero__deck {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 680px;
    margin-bottom: 2.75rem;
    line-height: 1.75;
}

.hero__stats {
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.stat-chip__number {
    font-family: 'DM Serif Display', serif;
    font-size: 2.4rem;
    line-height: 1;
    color: var(--text-primary);
    display: block;
}

.stat-chip__label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.3rem;
    display: block;
}

/* ===== Analysis Sections ===== */
.analysis-section {
    padding: 4.5rem 0;
    border-top: 1px solid var(--border);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

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

.analysis-section:nth-of-type(even) {
    background: var(--surface-alt);
}

.section-inner {
    max-width: var(--max-text);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section-header {
    display: flex;
    align-items: baseline;
    gap: 0.85rem;
    margin-bottom: 0.75rem;
}

.section-number {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--accent-primary);
    background: rgba(192, 57, 43, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.section-title {
    font-family: 'DM Serif Display', serif;
    font-size: 1.65rem;
    font-weight: 400;
    line-height: 1.25;
    color: var(--text-primary);
}

.finding-statement {
    font-size: 1.02rem;
    color: var(--text-secondary);
    margin: 0.75rem 0 1.75rem;
    border-left: 3px solid var(--border);
    padding-left: 1rem;
    line-height: 1.6;
}

.section-inner p {
    margin-bottom: 1rem;
}

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

.section-inner strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ===== Stat Row (inline callouts) ===== */
.stat-row {
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
    margin: 1.75rem 0;
}

.stat-callout {
    display: inline-flex;
    flex-direction: column;
    border-left: 3px solid var(--accent-primary);
    padding: 0.5rem 1.25rem;
}

.stat-callout__number {
    font-family: 'DM Serif Display', serif;
    font-size: 2.6rem;
    line-height: 1;
    color: var(--accent-primary);
}

.stat-callout__label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Two-column layout for intro ===== */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    margin-top: 1.5rem;
}

.highlight-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent-secondary);
    padding: 1.5rem;
    border-radius: 4px;
}

/* ===== Country Cards ===== */
.country-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.75rem 0;
}

.country-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent-success);
    padding: 1.25rem;
    border-radius: 4px;
}

.country-card.gap {
    border-top-color: var(--accent-primary);
}

.country-card__name {
    font-family: 'DM Serif Display', serif;
    font-size: 1rem;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.country-card__detail {
    font-size: 0.83rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== Chart Containers ===== */
.chart-wrap {
    max-width: var(--max-chart);
    margin: 2rem auto;
    padding: 0 1rem;
}

.chart-wrap.narrow {
    max-width: var(--max-text);
}

.chart-container {
    width: 100%;
    min-height: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    position: relative;
}

.chart-container.tall {
    min-height: 580px;
}

.chart-container.medium {
    min-height: 380px;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-family: 'JetBrains Mono', monospace;
}

/* ===== Conclusion Section ===== */
/* Use double-class selector (specificity 0,2,0) to beat nth-of-type rule */
.analysis-section.conclusion-section {
    background: var(--text-primary);
    padding: 5rem 0;
    border-top: none;
    opacity: 1;
    transform: none;
}

.conclusion-section .section-title {
    color: #fafaf8;
}

.conclusion-section .section-number {
    color: #fafaf8;
    background: rgba(255, 255, 255, 0.12);
}

.conclusion-section p {
    color: rgba(250, 250, 248, 0.82);
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
    line-height: 1.8;
}

.conclusion-section .section-inner strong {
    color: #fafaf8;
    font-weight: 600;
}

/* ===== Plotly override ===== */
.js-plotly-plot .plotly .bg {
    fill: transparent !important;
}

/* ===== Footer ===== */
.site-footer {
    background: var(--surface-alt);
    border-top: 1px solid var(--border);
    padding: 2.5rem 1.5rem;
    text-align: center;
}

.site-footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
}

/* ===== Team Section ===== */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 1.75rem;
}

.team-member {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent-secondary);
    padding: 1.5rem;
    border-radius: 4px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.team-member:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.team-member__name {
    font-family: 'DM Serif Display', serif;
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-header__nav {
        display: none;
    }

    .hero {
        padding: 3.5rem 1.25rem 3rem;
    }

    .hero__stats {
        gap: 1.5rem;
    }

    .two-col,
    .chart-grid {
        grid-template-columns: 1fr;
    }

    .analysis-section {
        padding: 3rem 0;
    }

    .chart-container {
        min-height: 320px;
    }

    .chart-container.tall {
        min-height: 420px;
    }

    .stat-callout__number {
        font-size: 2rem;
    }
}
