/* Written by scripts/fonts.py; build/site.py puts it at the top of style.css, which the font addresses are relative to. */
@font-face { font-family: "Archivo"; font-weight: 700 800; font-display: swap; src: url("fonts/archivo-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Archivo"; font-weight: 700 800; font-display: swap; src: url("fonts/archivo-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-weight: 400 700; font-display: swap; src: url("fonts/inter-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-weight: 400 700; font-display: swap; src: url("fonts/inter-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* Layout: sunburst left, the heading and ranked list right, a year strip under both; one column on a phone. */
:root {
  --bg: #f3f5f6;
  --fg: #12171b;
  --muted: #5a656e;
  --line: #d9dfe3;
  --bar: #b9c2c8;
  --chip: #e6eaed;
  --g1: #2f3a42; --g2: #56636c; --g3: #7f8b94; --g4: #a9b3ba;
  --link: #1f63c4;
  --side-a: #0f8f6e; --side-b: #d6457f;  /* the two sides of compare: teal and magenta */
  --fade: 0.35;    /* how much of its colour a slice keeps when another one is picked */
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px; line-height: 1.4; }
a { color: inherit; }
.wrap {
  max-width: 1240px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: inline-flex; align-items: center; gap: .4em; font: 800 22px var(--display); text-decoration: none; padding-top: 16px; letter-spacing: .01em; }
.brand .logo { width: 1.3em; height: 1.3em; flex: none; }
.draft { background: #ffe08a; color: #12171b; font: 700 12px var(--body); padding: 2px 6px; border-radius: 4px; margin-left: 8px; vertical-align: middle; }

.top {
  display: grid; gap: 16px 56px; padding-block: 28px 24px;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  grid-template-areas: "chart head" "chart side" "years years";
  grid-template-rows: auto 1fr auto;
}
.head { grid-area: head; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.chart { grid-area: chart; position: relative; min-width: 0; align-self: start; padding: 8px 0 32px; }
.chart canvas { width: 100% !important; max-width: 580px; margin-inline: auto; height: auto !important; aspect-ratio: 1; touch-action: manipulation; display: block; }
.side { grid-area: side; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.years { grid-area: years; min-width: 0; }

.crumbs { font-size: 15px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.crumbs .blank { visibility: hidden; }
.crumbs a { color: var(--link); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .sep { color: var(--muted); }
.crumbs [aria-current] { color: var(--fg); }
h1 { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 3.6vw, 42px); line-height: 1.05; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* on a phone, Total | Per person sits beside the country box, and the breakdown with Compare under them */
@media (max-width: 560px) {
  .head .controls > .combo, .head .controls > .picker { order: -2; flex: 1 1 8em; min-width: 0; }
  .head .controls > .combo input.pick { width: 100%; }
  .head .controls > #per { order: -1; }
}

.picker { position: relative; }
.combo { position: relative; }
.combo ul {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; width: min(calc(100vw - 32px), 300px); max-height: min(60vh, 420px);
  overflow: auto; margin: 0; padding: 4px; list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .12);
}
.combo li { padding: 6px 8px; border-radius: 6px; font-size: 15px; cursor: pointer; }
.combo li[aria-selected], .combo li[role="option"]:hover { background: var(--chip); }
.combo li.grp { font: 700 12px var(--body); color: var(--muted); cursor: default; padding: 10px 8px 2px; background: none; }
.combo li.none { color: var(--muted); cursor: default; }
input.pick { width: 15em; max-width: 100%; cursor: text; text-overflow: ellipsis; }
input.pick:focus { outline: 2px solid var(--fg); outline-offset: 2px; }
.picker summary, input.pick {
  font: 600 15px var(--body); color: var(--fg); background: var(--chip);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 100%; cursor: pointer;
}
.picker summary { list-style: none; }
.picker summary::-webkit-details-marker { display: none; }
.picker summary::after { content: " ▾"; color: var(--muted); }
.picker-list {
  position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; width: min(92vw, 640px); max-height: 60vh; overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; columns: 2 200px; column-gap: 20px;
}
.picker-list h2 { font: 700 13px var(--body); color: var(--muted); margin: 8px 0 4px; break-after: avoid; }
.picker-list a { display: block; text-decoration: none; padding: 2px 0; font-size: 14px; }
.picker-list a:hover { text-decoration: underline; }

.modes { display: inline-flex; background: var(--chip); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.modes a { text-decoration: none; font: 500 14px var(--body); color: var(--muted); padding: 6px 11px; border-radius: 6px; }
.modes a[aria-current] { background: var(--bg); color: var(--fg); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
a:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, .strip:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.total { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.total .k { font-weight: 700; font-size: 17px; }
.total .v { font-weight: 700; font-size: 17px; text-align: right; font-variant-numeric: tabular-nums; }
.total .k2, .total .v2 { color: var(--muted); font-size: 14px; }
.total .v2 { text-align: right; font-variant-numeric: tabular-nums; }
.back { color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.back:hover { color: var(--fg); }

.list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; gap: 10px; align-items: center;
  padding: 5px 4px; border-radius: 6px; font-size: 15.5px; text-decoration: none;
}
a.row:hover { background: var(--chip); }
.row[aria-current] { background: var(--chip); font-weight: 600; }
.row .dot { width: 10px; height: 10px; border-radius: 50%; }
.row .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .n small { color: var(--muted); font-size: 13px; margin-left: 6px; font-weight: 400; }
.row .v { font-variant-numeric: tabular-nums; text-align: right; }
.row .p { font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); font-size: 13.5px; }
.row.zero { opacity: .45; }
.notes { color: var(--muted); font-size: 13.5px; line-height: 1.45; display: grid; gap: 4px; margin: 0; }
.notes p { margin: 0; }

.years { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: end; }
.play { all: unset; cursor: pointer; width: 38px; height: 38px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; margin-bottom: 18px; }
.play svg { width: 14px; height: 14px; fill: var(--fg); }
.strip { position: relative; height: 92px; cursor: pointer; touch-action: none; outline: none; }
.bars { position: absolute; inset: 0 0 20px 0; display: flex; align-items: flex-end; gap: 2px; }
.bars i { flex: 1; background: var(--bar); border-radius: 2px 2px 0 0; min-height: 2px; transition: background-color .15s; }
.bars i.hover { background: var(--g3); }
.bars i.on { background: var(--fg); }
.strip-tip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap; z-index: 2;
  background: #ffffff; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: 600 12.5px var(--body);
}
.ticks { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ticks span.on { color: var(--fg); font-weight: 600; }
.years:not(.ready) { visibility: hidden; }

.foot { color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-block: 10px 24px; }
.foot nav { display: flex; gap: 12px; }

@media (max-width: 820px) {
  .top { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "chart" "years" "side"; grid-template-rows: none; gap: 14px; padding-block: 16px 20px; }
  .chart { padding: 4px 0 8px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Below the top section: the history chart, then the top 15 or a country's ranks. */
.sr-only:not(:focus-within) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sr-only:focus-within { list-style: none; padding: 8px 0; margin: 0; display: grid; gap: 4px; font-size: 14px; }
.below { display: grid; gap: 20px 28px; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); padding-block: 8px 28px; border-top: 1px solid var(--line); }
.panel { margin: 0; min-width: 0; padding-top: 16px; }
.panel h2 { font: 700 17px var(--body); margin: 0 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.hist-box { position: relative; height: 320px; }
.second-box { position: relative; }
.second-note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.second-note:empty { display: none; }
.all-countries { grid-column: 1 / -1; }
.below:has(.growth) .second { grid-row: span 2; }
.growth-box { position: relative; height: 220px; }
.legend i.sq { border-radius: 2px; background: var(--g3); }
.legend i.ln { height: 2px; width: 14px; border-radius: 1px; background: var(--fg); }
.all-countries .columns { columns: 4 200px; column-gap: 24px; }
.all-countries h3 { font: 700 14px var(--body); color: var(--muted); margin: 12px 0 4px; break-after: avoid; }
.all-countries ul { list-style: none; margin: 0; padding: 0; }
.all-countries a { display: block; text-decoration: none; padding: 2px 0; font-size: 14px; }
.all-countries a:hover { text-decoration: underline; }
@media (max-width: 820px) {
  .below { grid-template-columns: minmax(0, 1fr); }
  .below:has(.growth) .second { grid-row: auto; }
  .hist-box { height: 260px; }
}

/* The written text: an explainer or intro, a country's sentences, the plain pages. */
.text { max-width: 720px; padding-block: 18px 6px; border-top: 1px solid var(--line); font-size: 16.5px; line-height: 1.6; }
.text h1 { margin-bottom: 14px; }
.text h2 { font: 700 19px var(--body); margin: 22px 0 6px; }
.text .sources { font-size: 13px; line-height: 1.5; color: var(--muted); }
.text .sources a { color: inherit; }
.text p { margin: 0 0 12px; }
.text ul { padding-left: 20px; margin: 0 0 12px; }
.text a { text-underline-offset: 2px; }
.text.plain { border-top: 0; padding-top: 24px; min-height: 60vh; }
.draft-note { font-size: 13.5px; color: var(--muted); }

/* The header: the name. */
[hidden] { display: none !important; }  /* the script shows what needs it (the per-person switch, Compare) */
.nojs { margin: 0; background: #ffe08a; color: var(--fg); font-size: 14.5px; text-align: center; padding: 10px 16px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 16px; }
@media (max-width: 820px) { .brand { font-size: 19px; } }
.bar .brand { padding-top: 0; }

/* The compare page: the two rings, each under its own country box and year, with the table beside them. */
.cmp {
  display: grid; gap: 32px 64px; padding-block: 28px 40px;
  grid-template-columns: minmax(0, 1.3fr) minmax(min-content, 1fr); grid-template-areas: "head head" "rings side";  /* the table never squeezes */
}
.cmp-nojs { margin: 0; color: var(--muted); }
.cmp-nojs a { color: var(--link); }
.cmp-rings { grid-area: rings; display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: start; min-width: 0; }
.cmp-ring { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.cmp-ring canvas { width: 86% !important; height: auto !important; aspect-ratio: 1; display: block; margin: 20px auto 0; touch-action: manipulation; }
.cmp-pick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-width: 0; }
.cmp-pick .combo { flex: 1 1 9em; min-width: 0; }
.cmp-pick input.pick { width: 100%; }
#pick-b .combo ul { left: auto; right: 0; }  /* the right-hand list opens leftward, staying on the page */
.cmp-pick select, .swap {
  font: 600 15px var(--body); color: var(--fg); background: var(--chip); border: 1px solid var(--line); border-radius: 8px; padding: 8px 6px; cursor: pointer;
}
.swap { padding: 7px 11px; font-weight: 500; font-size: 14px; }
.swap:hover { background: var(--bg); }
/* on a phone the three controls share one row: the swap button keeps only its arrows */
@media (max-width: 480px) { .swap-word { display: none; } .cmp-controls { gap: 6px; flex-wrap: nowrap; } .cmp-controls .modes a { padding: 6px 8px; } }
.cmp-total { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.cmp-total.muted { color: var(--muted); font-weight: 500; }
.cmp-ring.empty canvas { border: 2px dashed var(--line); border-radius: 50%; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.key.a { background: var(--side-a); }
.key.b { background: var(--side-b); }
.cmp-side { grid-area: side; display: flex; flex-direction: column; gap: 18px; padding-top: 4px; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.cmp-table caption { caption-side: bottom; text-align: left; color: var(--muted); font-size: 13px; padding-top: 6px; }
.cmp-table th, .cmp-table td { padding: 7px 6px; text-align: left; font-weight: 400; vertical-align: baseline; }
.cmp-table thead th { font-size: 13px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.cmp-table thead a { color: inherit; text-decoration: none; white-space: nowrap; }
.cmp-table thead a:hover { color: var(--fg); text-decoration: underline; }
.cmp-table .v { text-align: right; white-space: nowrap; }
.cmp-table .ch { color: var(--muted); font-size: 14px; }
.cmp-table tr.sum th, .cmp-table tr.sum td { font-weight: 700; border-bottom: 1px solid var(--line); }
.cmp-table tbody th { white-space: nowrap; }
.cmp-table tbody th a { text-decoration: none; }
.cmp-table tbody th a:hover { text-decoration: underline; }
.cmp-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.cmp-below { grid-template-columns: minmax(0, 1fr); }
.compare-link { font: 500 14px var(--body); color: var(--link); text-decoration: none; padding: 6px 4px; }
.compare-link:hover { text-decoration: underline; }
/* the table beside the rings needs the full width; narrower, it goes under them */
@media (max-width: 1240px) { .cmp { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "rings" "side"; } }
@media (max-width: 820px) {
  .cmp { gap: 24px; padding-block: 16px 24px; }
  .cmp-rings { gap: 16px; }
  .cmp-ring canvas { width: 100% !important; margin-top: 8px; }
  .cmp-total { font-size: 14px; }
  .cmp-table { font-size: 14px; }
  .cmp-table thead a, .cmp-table tbody th { white-space: normal; }
  .cmp-table .v { white-space: normal; }
  .cmp-pick select { padding: 7px 4px; }
}

/* a country's sentences on each sector and gas, folded away under one line */
.text details.parts { margin: 4px 0 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.text details.parts summary { cursor: pointer; font-weight: 600; color: var(--link); }
.text details.parts ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 10px; font-size: 15px; line-height: 1.55; }
.text details.parts li a { font-weight: 600; }

/* the bar that says the page is on an earlier year while the strip is out of sight */
.yearbar {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: flex; align-items: center; gap: 12px;
  background: var(--fg); color: var(--bg); font: 700 17px var(--body); padding: 5px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25); white-space: nowrap;
}
.yearbar button { all: unset; cursor: pointer; width: 32px; height: 32px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; }
.yearbar-play svg { width: 12px; height: 12px; fill: var(--fg); }
.yearbar-back svg { width: 11px; height: 11px; stroke: var(--fg); stroke-width: 1.8; stroke-linecap: round; }
.yearbar-year { font-variant-numeric: tabular-nums; }
/* a small copy of the strip: its bars, the year on it lit; pressing or dragging along it picks the year */
.yearbar-bars { display: flex; align-items: flex-end; gap: 1px; width: 112px; height: 26px; cursor: pointer; touch-action: none; }
.yearbar-bars i { flex: 1; min-height: 1px; background: var(--bg); opacity: .35; border-radius: 1px 1px 0 0; }
.yearbar-bars i.on { opacity: 1; }
/* sector and region colours, from build/tree.py */
:root { --c-electricity-heat: #eda100; --c-agriculture: #1baf7a; --c-buildings: #eb6834; --c-fuel-production: #6250d6; --c-transport: #e34948; --c-industrial-fuel: #2a78d6; --c-industrial-processes: #008300; --c-waste: #e87ba4; --r-asia: #2a78d6; --r-north-central-america: #eb6834; --r-europe: #1baf7a; --r-middle-east: #eda100; --r-africa: #e87ba4; --r-south-america: #008300; --r-oceania: #6250d6; --r-international: #e34948; }
