/*
  Data pages (ports, chokepoints, countries, about), rendered by the API
  (api/flowglobe_api/site.py). Same chart-table world as the globe: one
  neutral ramp, ink for data, magenta only for what is pointed at, Barlow
  for words and IBM Plex Mono for positions, codes and times. Tokens are
  copied from web/src/style.css; change both together.
*/
:root {
  --page: #f3f5f5;
  --surface: #fbfcfc;
  --raised: #e9eeee;
  --ink: #17242c;
  --ink-2: #4a5961;
  --ink-3: #606e75;
  --rule: rgba(23, 36, 44, 0.1);
  --rule-2: rgba(23, 36, 44, 0.24);
  --accent: #a3186d;
  --sans: "Barlow", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  /* One scale: meta, labels, body, tables, lead, section heads, figures, titles. */
  --t-xs: 12px;
  --t-s: 13px;
  --t-m: 16px;
  --t-table: 15px; /* the globe's body size, for dense tables */
  --t-lead: 18px;
  --t-l: 20px;
  --t-figure: 28px;
  --t-xl: 34px;
  --radius: 4px;
  --bar: 48px;
  --measure: 720px;
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-m);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a {
  color: inherit;
  text-decoration-color: var(--rule-2);
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-color: currentColor;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.mono {
  font-family: var(--mono);
  font-size: 0.88em;
}
/* Read by screen readers, not shown. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Top bar: the globe's, without the search. */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  height: var(--bar);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-size: 17px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.topbar nav {
  display: flex;
  align-self: stretch;
  gap: 24px;
  overflow-x: auto;
}
.topbar nav a {
  display: flex;
  align-items: center;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.topbar nav a:hover {
  color: var(--ink);
}
.topbar nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* Search, at the right of the bar as on the globe. */
.find {
  margin-left: auto;
  width: min(320px, 36vw);
}
.find input {
  width: 100%;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-s);
}

/* One reading column, left-aligned under the wordmark. */
.page {
  max-width: calc(var(--measure) + 48px);
  padding: 32px 24px 48px;
}
h1 {
  margin: 0;
  font-size: var(--t-xl);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0 0 12px;
  font-size: var(--t-l);
  font-weight: 500;
  line-height: 1.3;
}
p {
  margin: 0 0 12px;
}
h3 {
  margin: 24px 0 8px;
  font-size: var(--t-m);
  font-weight: 500;
}
section {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.crumbs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: var(--t-s);
  color: var(--ink-2);
}
.crumbs a + a::before {
  content: "/";
  margin-right: 8px;
  color: var(--ink-3);
}
.place {
  margin: 8px 0 20px;
  color: var(--ink-2);
}
/* Pages without a place line still leave the title room to breathe. */
h1 + .lead {
  margin-top: 16px;
}
.lead {
  font-size: var(--t-lead);
  line-height: 1.45;
  max-width: 64ch;
}
.of {
  color: var(--ink-3);
  font-size: var(--t-s);
  font-weight: 400;
  line-height: 1; /* smaller text must not push its row's line taller */
}
.note,
.source {
  color: var(--ink-2);
  font-size: var(--t-s);
  max-width: 72ch;
}
.source {
  margin-top: 40px;
}

/* The figures: label above number, flat, on one rule. */
.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 24px;
  margin: 24px 0 16px;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.figures dt {
  color: var(--ink-2);
  font-size: var(--t-s);
}
.figures dd {
  margin: 2px 0 0;
  font-size: var(--t-figure);
  line-height: 1.2;
}
/* The unit beside a figure: "€96.5 billion", "155.8 million t". */
.figures .unit {
  color: var(--ink-2);
  font-size: var(--t-m);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: var(--t-s);
}
.actions a:first-child {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* Tables: numbers right-aligned, rules between rows, no fill. */
.table-wrap {
  overflow-x: auto;
  margin: 0 -24px;
  padding: 0 24px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-table);
}
thead th {
  color: var(--ink-2);
  font-size: var(--t-s);
  font-weight: 400;
  text-align: left;
  vertical-align: bottom;
  padding: 0 12px 6px 0;
  border-bottom: 1px solid var(--rule-2);
}
/* A row is 40px: 8 above the text, a 24px line, then 7 and the 1px rule. */
tbody th,
tbody td {
  padding: 8px 12px 7px 0;
  line-height: 24px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  font-weight: 400;
  vertical-align: baseline;
}
td.nowrap {
  white-space: nowrap;
}
th.num,
td.num {
  text-align: right;
  white-space: nowrap;
}
th:last-child,
td:last-child {
  padding-right: 0;
}
.ranking tbody th a {
  font-weight: 500;
  text-decoration: none;
}
.ranking tbody th a:hover {
  text-decoration: underline;
}

details.numbers summary {
  width: fit-content;
  color: var(--ink-2);
  font-size: var(--t-s);
  cursor: pointer;
}
details.numbers[open] summary {
  margin-bottom: 12px;
}

.faq dt {
  margin-top: 16px;
  font-weight: 500;
}
.faq dd {
  margin: 4px 0 0;
  max-width: 68ch;
}

.columns {
  columns: 3 200px;
  column-gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.columns li {
  break-inside: avoid;
  padding: 4px 0;
}
.near {
  margin: 0;
  padding: 0;
  list-style: none;
}
.near li {
  padding: 4px 0;
}

/* Charts: one series in ink over a recessive grid; the hovered week in magenta. */
.chart-fig {
  margin: 0;
}
.chart-fig figcaption {
  margin-top: 8px;
  color: var(--ink-2);
  font-size: var(--t-s);
}
.plot {
  position: relative;
  height: 220px;
  margin-top: 8px;
  touch-action: pan-y;
}
.plot svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.plot .series {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
/* A second measure on the same axis: muted and dashed, named in the legend. */
.plot .series-2 {
  stroke: var(--ink-3);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}
.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: var(--t-s);
}
.legend .key {
  width: 20px;
  border-top: 2px solid var(--ink);
}
.legend .key-2 {
  margin-left: 16px;
  border-top: 2px dashed var(--ink-3);
}
.plot .grid {
  stroke: var(--rule-2);
  stroke-dasharray: 2 4;
  vector-effect: non-scaling-stroke;
}
.plot .axis,
.plot .cross {
  stroke: var(--ink-3);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.ytick,
.xtick {
  position: absolute;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}
.ytick,
.xtick {
  white-space: nowrap;
}
/* The label sits on the page colour, so a line passing behind stays readable. */
.ytick {
  left: 0;
  padding: 0 4px 0 0;
  background: var(--page);
  transform: translateY(-140%);
}
.xtick {
  top: calc(100% + 6px);
  transform: translateX(-50%);
}
.xtick-start {
  transform: none;
}
.xtick-end {
  transform: translateX(-100%);
}
.plot .dot {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
}
.plot .chart-tip {
  position: absolute;
  top: -30px;
  padding: 2px 8px;
  background: var(--ink);
  border-radius: var(--radius);
  color: var(--surface);
  font-size: var(--t-xs);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.chart-fig figcaption {
  margin-top: 28px;
}
.empty {
  color: var(--ink-2);
}

.page-foot {
  max-width: calc(var(--measure) + 48px);
  padding: 24px;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: var(--t-xs);
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    gap: 0 20px;
    padding: 0 16px;
  }
  .topbar > .wordmark,
  .topbar nav {
    height: var(--bar);
  }
  .find {
    order: 3;
    width: 100%;
    margin: 0 0 12px;
  }
  .find input {
    height: 40px;
    font-size: var(--t-m);
  }
  .topbar nav {
    gap: 16px;
  }
  .page {
    padding: 24px 16px 40px;
  }
  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }
  h1 {
    font-size: 28px;
  }
  .lead {
    font-size: var(--t-m);
  }
  .figures dd {
    font-size: 24px;
  }
  .plot {
    height: 170px;
  }
  .page-foot {
    padding: 16px;
  }
}
/* On a phone the five sections fit the bar only if the last one is "About". */
@media (max-width: 480px) {
  .nav-more {
    display: none;
  }
}

/* "Put this chart on your site": the code to copy. */
.embed-code {
  margin-top: 16px;
}
.embed-code textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--rule-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--t-xs);
  resize: none;
}

/* An embedded chart: no bar, no footer, just the figure and its credit. */
.embed {
  background: var(--surface);
}
.embed main {
  padding: 16px 16px 12px;
}
.embed h1 {
  font-size: var(--t-l);
}
.embed-lead {
  margin: 4px 0 0;
  color: var(--ink-2);
}
.embed .plot {
  height: 200px;
  margin-top: 36px;
}
.embed .chart-fig figcaption {
  font-size: var(--t-xs);
}
