/* Harnessing the Winds – article layout and type, in Ember's report style (ember-energy.org):
   a white page, navy text, Ember green accents, Poppins 400 and 600, sharp corners, no
   shadows. Charts follow Ember's chart design: the navy-to-green bar, a navy title (#192238)
   that states the finding, a #3E4860 subtitle, a #F5F7FA plot, horizontal gridlines only, no
   border, direct labels, energy-source colours from Ember's palette.json. Light is the
   default; a dark scheme follows prefers-color-scheme: dark from the Labs tokens. The map
   panel keeps the atlas's dark ocean and land in both schemes, so it reads as the atlas.

   Chart colours (charts.js reads these tokens; checked at drawn opacity under protan,
   deutan and tritan simulation: team/reports/T077-colour.md):
     --c-wind / --c-solar   Ember energy_sources (wind #0B6638, solar #13CE74)
     --c-context            solar and batteries alone, the context series
     --c-band-1 ... -5      latitude bands, 55°+ (1) to 0–15° (5), cold to warm */
:root {
    --el-navy: #192238;
    --el-canvas: #414F6F;
    --el-slate: #626E88;
    --el-muted: #B0B7C6;
    --el-white: #FFFFFF;
    --el-yellow: #FFC400;
    --ember-green: #13CE74;
    --ember-green-dark: #0B6638;

    --bg-page: #FFFFFF;
    --panel: #F5F7FA;
    --text: #192238;
    --body: #192238;
    --sub: #3E4860;
    --muted: #626E88;
    --divider: #D8DBE6;
    --grid: #D8DBE6;
    --axis: #B0B7C6;
    --accent: #109553;
    --link: #0B6638;
    --button: #13CE74;
    --button-hover: #109553;
    --on-button: #192238;

    --c-wind: #0B6638;
    --c-solar: #13CE74;
    --c-context: #626E88;
    --c-band-1: #203772;
    --c-band-2: #37A6E6;
    --c-band-3: #857572;
    --c-band-4: #E04B00;
    --c-band-5: #891B05;
    --c-highlight: #192238;

    /* The map panel: the atlas's ocean and land in both schemes. */
    --map-ocean: var(--el-canvas);
    --map-land: var(--el-slate);
    --map-panel: rgba(25, 34, 56, 0.94);
    --map-text: var(--el-white);
    --map-muted: var(--el-muted);
    --map-divider: rgba(255, 255, 255, 0.12);

    --font-sans: 'Poppins', system-ui, sans-serif;
    --article-w: min(46vw, 660px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: var(--el-navy);
        --panel: #202A44;
        --text: var(--el-white);
        --body: var(--el-white);
        --sub: var(--el-muted);
        --muted: var(--el-muted);
        --divider: rgba(255, 255, 255, 0.12);
        --grid: rgba(255, 255, 255, 0.12);
        --axis: rgba(255, 255, 255, 0.45);
        --accent: var(--ember-green);
        --link: var(--ember-green);

        --c-wind: #109553;
        --c-solar: #13CE74;
        --c-context: var(--el-muted);
        --c-band-1: #97CCED;
        --c-band-2: #37A6E6;
        --c-band-3: #B6B0AF;
        --c-band-4: #FCA311;
        --c-band-5: #E04B00;
        --c-highlight: var(--el-white);
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0; box-shadow: none; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg-page);
    color: var(--body);
    font-family: var(--font-sans);
    font-weight: 400;
    font-size: 17px;
    line-height: 1.65;
    overflow-x: hidden;
}

strong, b { font-weight: 600; }
a { color: var(--link); text-underline-offset: 0.15em; }

/* ---------- Layout: article left, map fixed right ---------- */
.layout { position: relative; }

.article {
    position: relative;
    z-index: 2;
    width: var(--article-w);
    min-width: 420px;
    background: var(--bg-page);
    border-right: 1px solid var(--divider);
}

.visual {
    position: fixed;
    top: 0;
    right: 0;
    width: calc(100% - max(var(--article-w), 420px));
    height: 100vh;
    z-index: 1;
    background: var(--map-ocean);
}

.map { position: absolute; inset: 0; background: var(--map-ocean); }
.leaflet-container { background: var(--map-ocean); font-family: var(--font-sans); }

/* ---------- Hero and highlights ---------- */
.hero {
    min-height: 88vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 3rem 3rem;
    border-bottom: 1px solid var(--divider);
}

.kicker, .label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 1rem;
}

.hero h1 {
    font-size: clamp(2.4rem, 5vw, 3.6rem);
    line-height: 1.08;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1.25rem;
}

.standfirst {
    font-size: 1.3rem;
    line-height: 1.45;
    color: var(--text);
    margin: 0 0 1.75rem;
    max-width: 34rem;
}

.byline { font-size: 0.88rem; color: var(--muted); margin: 0; }

.highlights {
    padding: 2.5rem 3rem;
    border-bottom: 1px solid var(--divider);
}

.highlights ul { list-style: none; margin: 0; padding: 0; }

.highlights li {
    position: relative;
    padding-left: 1.2rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    line-height: 1.6;
}

.highlights li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.62rem;
    width: 6px;
    height: 6px;
    background: var(--accent);
}

.highlights strong { color: var(--text); }

/* ---------- Takes ---------- */
.take {
    position: relative;
    padding: 4rem 3rem 22vh;
    border-bottom: 1px solid var(--divider);
}

.take-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--on-button);
    background: var(--button);
    width: 1.8rem;
    height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.take h2 {
    font-size: 1.65rem;
    line-height: 1.25;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1.25rem;
}

.take p { margin: 0 0 1.15rem; }

.take p.lead { font-size: 1.12rem; color: var(--text); }

.take sup { line-height: 0; }
.take sup a { text-decoration: none; font-weight: 600; padding: 0 0.1em; }

[data-n] { font-variant-numeric: tabular-nums; white-space: nowrap; }

.map-hint {
    font-size: 0.88rem;
    color: var(--muted);
    border-left: 2px solid var(--divider);
    padding-left: 0.8rem;
}

.cta {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.7rem 1.2rem;
    background: var(--button);
    color: var(--on-button);
    font-weight: 600;
    text-decoration: none;
}

.cta:hover { background: var(--button-hover); }

/* ---------- Charts (Ember chart anatomy: top bar, title, subtitle, plot, source) ---------- */
.chart {
    margin: 2.25rem 0 2.5rem;
    padding: 1.4rem 1.25rem 1rem;
    background: var(--panel);
    position: relative;
}

.chart::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 20%;
    height: 4px;
    background: linear-gradient(to right, #203772, #13CE74);
}

.chart-title {
    font-size: 1.08rem;
    line-height: 1.35;
    font-weight: 600;
    color: var(--text);
    margin: 0.2rem 0 0.35rem;
}

.chart-sub {
    font-size: 0.84rem !important;
    line-height: 1.45;
    color: var(--sub);
    margin: 0 0 0.9rem !important;
}

.chart-svg { width: 100%; min-height: 120px; }
.chart-svg svg { display: block; overflow: visible; }

.chart-key {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
    margin: 0 0 0.6rem;
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--muted);
}

.chart-key span { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.chart-key i { display: inline-block; width: 14px; height: 3px; flex: none; }
.chart-key b { color: var(--text); }

.chart-controls { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 0.5rem; }

.chart-controls button {
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--on-button);
    background: var(--button);
    border: 0;
    padding: 0.3rem 0.85rem;
    cursor: pointer;
    min-width: 4.6rem;
}

.chart-controls button:hover { background: var(--button-hover); }
.chart-controls button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.chart-source {
    font-size: 0.74rem !important;
    line-height: 1.4;
    color: var(--muted);
    margin: 0.75rem 0 0 !important;
}

/* ---------- Notes and sources ---------- */
.notes, .sources {
    padding: 2.5rem 3rem;
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--muted);
}

.notes ol, .sources ul { margin: 0; padding-left: 1.2rem; }
.notes li, .sources li { margin-bottom: 0.6rem; }
.sources { border-top: 1px solid var(--divider); }

.model-status {
    margin: 1.25rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.model-status.is-error { color: var(--accent); }
.colophon { margin-top: 1.5rem; font-size: 0.78rem; }

/* ---------- Map overlays (the atlas's panels: navy, sharp, no shadow) ---------- */
.map-caption {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 500;
    max-width: min(340px, calc(100% - 2rem));
    padding: 0.7rem 0.9rem;
    background: var(--map-panel);
    border: 1px solid var(--map-divider);
}

.map-caption-title { font-size: 0.92rem; font-weight: 600; color: var(--map-text); line-height: 1.3; }
.map-caption-sub { font-size: 0.76rem; color: var(--map-muted); line-height: 1.4; margin-top: 0.15rem; }

.map-controls { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.55rem; }
.map-controls[hidden] { display: none; }
.map-controls-label { font-size: 0.72rem; color: var(--map-muted); margin-right: 0.2rem; }

.map-controls button {
    font: inherit;
    font-size: 0.75rem;
    color: var(--map-muted);
    background: transparent;
    border: 1px solid var(--map-divider);
    padding: 0.15rem 0.6rem;
    cursor: pointer;
}

.map-controls button.is-active { color: var(--el-navy); background: var(--ember-green); border-color: var(--ember-green); font-weight: 600; }
.map-controls input[type="range"] { flex: 1; min-width: 120px; accent-color: var(--ember-green); }
.map-controls .map-year-label { font-size: 0.9rem; font-weight: 600; color: var(--map-text); font-variant-numeric: tabular-nums; min-width: 2.6rem; text-align: right; }
.map-controls button[data-map-play] { color: var(--el-navy); background: var(--ember-green); border-color: var(--ember-green); font-weight: 600; min-width: 3.6rem; }

.map-legend {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 500;
    width: 230px;
    padding: 0.65rem 0.8rem;
    background: var(--map-panel);
    border: 1px solid var(--map-divider);
    font-size: 0.74rem;
    color: var(--map-muted);
}

.map-legend[hidden], .map-legend:empty { display: none; }
.legend-title { font-weight: 600; color: var(--map-text); margin-bottom: 0.4rem; font-size: 0.78rem; }
.legend-bar { height: 8px; }
.legend-labels { display: flex; justify-content: space-between; margin: 0.2rem 0 0.35rem; font-variant-numeric: tabular-nums; }
.legend-chip { display: flex; align-items: center; gap: 0.45rem; line-height: 1.5; }
.legend-chip i { display: inline-block; width: 11px; height: 11px; flex: none; outline: 1px solid rgba(176, 183, 198, 0.35); outline-offset: -1px; }

.map-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 500;
    max-width: 260px;
    padding: 0.45rem 0.75rem;
    background: var(--map-panel);
    border: 1px solid var(--map-divider);
    font-size: 0.74rem;
    color: var(--map-text);
}

.map-status[hidden] { display: none; }

.map-tooltip {
    position: absolute;
    z-index: 600;
    pointer-events: none;
    max-width: 260px;
    padding: 0.5rem 0.65rem;
    background: var(--map-panel);
    border: 1px solid var(--map-divider);
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--map-text);
}

.map-tooltip[hidden] { display: none; }
.tt-head { font-weight: 600; color: var(--map-text); margin-bottom: 0.15rem; }

/* ---------- Phone and narrow tablet: map pinned on top ---------- */
@media (max-width: 900px) {
    body { font-size: 16px; }

    .layout { display: flex; flex-direction: column; }

    .visual {
        position: sticky;
        top: 0;
        order: -1;
        z-index: 3;
        width: 100%;
        height: 42vh;
        height: 42svh;
        border-bottom: 1px solid var(--divider);
    }

    .article {
        width: 100%;
        min-width: 0;
        border-right: 0;
    }

    .hero { min-height: 0; padding: 2.25rem 1rem 2rem; }
    .standfirst { font-size: 1.12rem; }
    .highlights, .notes, .sources { padding: 2rem 1rem; }
    .take { padding: 2.5rem 1rem 3rem; }
    .take h2 { font-size: 1.4rem; }
    .chart { margin: 1.75rem 0; }

    .map-caption { top: 0.5rem; left: 0.5rem; padding: 0.45rem 0.6rem; max-width: calc(100% - 1rem); }
    .map-caption-title { font-size: 0.8rem; }
    .map-caption-sub { font-size: 0.68rem; }
    .map-legend { left: 0.5rem; bottom: 0.5rem; width: 168px; padding: 0.4rem 0.5rem; font-size: 0.62rem; }
    .legend-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 0.4rem; }
    .legend-title { font-size: 0.7rem; margin-bottom: 0.25rem; }
    .legend-chip { line-height: 1.35; }
    .map-status { top: auto; bottom: 0.5rem; right: 0.5rem; max-width: 55%; font-size: 0.66rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { scroll-behavior: auto !important; }
}
