:root {
  --paper: #f5f2eb;
  --ink: #1c1b19;
  --muted: #6b665c;
  --rule: #d6d0c4;
  --sea: #dfe3e2;
  --link: #9a3412;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  display: flex;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--link); }

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: normal; }

/* ---------- Left column ---------- */

.side {
  width: 400px;
  flex: none;
  height: 100%;
  overflow-y: auto;
  padding: 28px 28px 20px;
  border-right: 1px solid var(--rule);
  background: var(--paper);
}

.head h1 { margin: 0; font-size: 36px; line-height: 1.1; }
.head p { margin: 8px 0 0; }
.live { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.live.stale { color: #92400e; }
.live.error { color: #b91c1c; }

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 22px 0 0;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--rule);
}

.metrics button {
  font: inherit;
  font-size: 14px;
  padding: 2px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.metrics button:hover { color: var(--ink); }
.metrics button.on { color: var(--ink); border-bottom-color: var(--ink); }

.search { margin-top: 18px; }

/* ---------- Now / Then and now / Deserts ---------- */

.modes { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 22px; border: 1px solid var(--ink); }
.modes button { font: inherit; font-size: 14px; padding: 8px 6px; border: 0; background: none; color: var(--ink); cursor: pointer; }
.modes button + button { border-left: 1px solid var(--ink); }
.modes button:hover { background: #ebe6db; }
.modes button.on { background: var(--ink); color: var(--paper); }

body:not([data-mode="live"]) .metrics, body:not([data-mode="live"]) .live, body:not([data-mode="live"]) .legend .scale { display: none; }

.history-controls { margin-top: 18px; padding-bottom: 6px; }
.views { display: flex; gap: 18px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.views button { font: inherit; font-size: 14px; padding: 2px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.views button:hover { color: var(--ink); }
.views button.on { color: var(--ink); border-bottom-color: var(--ink); }
.years { display: flex; align-items: center; gap: 12px; }
.year-ends { display: flex; justify-content: space-between; margin: 2px 64px 0 46px; font-size: 11px; color: var(--muted); }
.years input { flex: 1; accent-color: var(--ink); }
.years output { font-family: Georgia, serif; font-size: 22px; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.play { width: 34px; height: 34px; flex: none; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-size: 12px; }
.play:hover { background: var(--ink); color: var(--paper); }

.compare { display: flex; align-items: flex-end; gap: 14px; margin-top: 14px; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.compare > div { display: flex; flex-direction: column; }
.compare span { font-size: 13px; color: var(--muted); }
.compare strong { font-family: Georgia, serif; font-weight: normal; font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.compare .arrow { font-size: 22px; color: var(--muted); padding-bottom: 18px; }
.compare .change { margin-left: auto; align-self: center; padding: 4px 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.compare .change.good { background: #cfe0c3; color: #1f5a35; }
.compare .change.bad { background: #f2c09a; color: #7a2a1d; }
.answer { display: flex; flex-direction: column; gap: 4px; margin-top: 20px; padding: 14px 16px; background: #fff; border-left: 4px solid #9c5a1e; }
.answer strong { font-family: Georgia, serif; font-weight: normal; font-size: 24px; line-height: 1.2; }
.answer span { font-size: 14px; }
.explain { font-size: 14px; margin: 16px 0 0; }
.tag { padding: 0 6px; font-weight: 600; }
.tag.sand { background: #e3c27c; color: #4a3210; }
.tag.red { background: #c2562e; color: #fff; }
.tag.green { background: #5f9e6e; color: #fff; }
.ranking.deserts td:first-child { padding-left: 2px; }
.link { font: inherit; font-size: 14px; background: none; border: 0; padding: 0; margin-top: 14px; color: var(--link); cursor: pointer; }

.chart { display: block; width: 100%; height: auto; margin: 4px 0 6px; overflow: visible; }
.chart .c-axis { stroke: var(--rule); }
.chart .c-lab { font-size: 10px; fill: var(--muted); }
.chart .c-val { font-size: 10.5px; fill: var(--ink); font-weight: 600; }
.chart .c-ref { stroke: #2f7d4f; stroke-dasharray: 4 3; }
.chart .c-ref-t { font-size: 10px; fill: #2f7d4f; }

.legend .steps div { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
.legend .steps i { width: 14px; height: 10px; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.1); }
.legend .steps i.desert { background: rgba(244, 222, 170, 0.9); border-color: rgba(110, 60, 15, 0.8); }
.search label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.search input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.search input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }

.side h2 { font-size: 19px; margin: 26px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.summary { margin: 22px 0 0; font-size: 15px; }
.summary b { font-variant-numeric: tabular-nums; }

/* Ranking table */
.ranking { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ranking td { padding: 6px 0; border-top: 1px solid var(--rule); vertical-align: baseline; }
.ranking tr { cursor: pointer; }
.ranking tr:hover td { background: #ebe6db; }
.ranking .nr { width: 30px; color: var(--muted); font-size: 13px; }
.ranking .city { color: var(--muted); font-size: 13px; }
.ranking .val { text-align: right; white-space: nowrap; }

.sw { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1px solid rgba(0, 0, 0, 0.15); vertical-align: -1px; }

/* One country */
.back { font: inherit; font-size: 14px; background: none; border: 0; color: var(--link); cursor: pointer; padding: 0; margin-top: 22px; }
.country h3 { margin: 12px 0 0; font-size: 28px; line-height: 1.15; }

.score { display: flex; align-items: baseline; gap: 12px; margin-top: 14px; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.score strong { font-family: Georgia, serif; font-weight: normal; font-size: 46px; line-height: 1; font-variant-numeric: tabular-nums; }

.pollutant { margin-top: 16px; }
.pollutant .row { display: flex; justify-content: space-between; font-size: 14px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; margin-top: 5px; background: #e4dfd4; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; }
.bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }

.credits { margin-top: 32px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); }

/* ---------- Globe ---------- */

.map { position: relative; flex: 1; min-width: 0; height: 100%; background: var(--paper); }
#globe { position: absolute; inset: 0; }

.legend {
  position: absolute;
  right: 20px;
  bottom: 18px;
  font-size: 12px;
  color: var(--muted);
}
.legend strong { display: block; margin-bottom: 5px; color: var(--ink); font-weight: 600; }
.legend .scale { display: flex; }
.legend .scale div { width: 62px; }
.legend .scale i { display: block; height: 10px; }
.legend .scale span { display: block; margin-top: 3px; }
.legend .none { margin-top: 6px; }

/* Tooltip on the globe */
.tip { padding: 8px 10px; background: #fff; border: 1px solid var(--ink); font: 13px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); min-width: 180px; }
.tip strong { display: block; font-size: 15px; font-family: Georgia, serif; font-weight: normal; }
.tip .line { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  html, body { height: auto; }
  .map { height: 60vh; border-bottom: 1px solid var(--rule); }
  .side { width: auto; height: auto; border-right: 0; padding: 20px 16px; }
  .head h1 { font-size: 30px; }
  .legend { right: 12px; bottom: 10px; }
  body:not([data-mode="live"]) .legend { left: 8px; right: 8px; bottom: 6px; padding: 6px 8px; background: rgba(245, 242, 235, 0.92); }
  .legend .steps { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; font-size: 11px; }
  .legend .steps div { line-height: 1.45; }
  .legend .scale div { width: 48px; }
  body { flex-direction: column; }
  .map { order: -1; flex: none; overflow: hidden; }
}
