:root {
  color-scheme: light dark;
  --bg: #fafaf9;
  --surface: #ffffff;
  --soft: #f0f2f1;
  --text: #1b2125;
  --muted: #5a666d;
  --line: #dce1e3;
  --link: #1b5ea8;
  --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 6px 20px rgb(0 0 0 / 4%);
  --radius: 10px;
  --chip-edge: rgb(128 128 128 / 60%);
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  /* LCZ 1 to 10 and A to G, the colors of the maps */
  --lcz-strip: linear-gradient(90deg, #8b0000 0 5.88%, #ff0000 0 11.76%, #ffa500 0 17.65%, #ffff00 0 23.53%,
    #ffff80 0 29.41%, #ffffc0 0 35.29%, #c0c0c0 0 41.18%, #808080 0 47.06%, #ffc0cb 0 52.94%, #800080 0 58.82%,
    #008000 0 64.71%, #00ff00 0 70.59%, #80ff80 0 76.47%, #00ffff 0 82.35%, #808000 0 88.24%, #ffe4c4 0 94.12%,
    #0000ff 0);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --surface: #171b1e;
    --soft: #1d2226;
    --text: #e3e7e9;
    --muted: #98a4ab;
    --line: #2a3136;
    --link: #7fb4f2;
    --shadow: none;
    --chip-edge: rgb(255 255 255 / 40%);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 1.75rem; letter-spacing: -0.01em; margin-bottom: 16px; }
h3 { font-size: 1.2rem; margin-top: 40px; }
h4 { font-size: 1rem; }
p, ul, ol { margin: 0 0 14px; }
ul, ol { padding-left: 1.3em; }
li { margin-bottom: 4px; }
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--soft);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.intro { max-width: 46em; }
.note { color: var(--muted); font-size: 0.9rem; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-header::before { content: ""; display: block; height: 4px; background: var(--lcz-strip); }
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 24px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.nav ul { display: flex; flex-wrap: wrap; gap: 2px 18px; list-style: none; margin: 0; padding: 0; }
.nav li { margin: 0; }
.nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.nav a:hover { color: var(--text); }
.nav .brand { color: var(--text); font-weight: 700; }

/* Hero */
.hero { padding: 64px 0 56px; }
.eyebrow { color: var(--muted); font-size: 0.9rem; margin-bottom: 10px; }
h1 { font-size: clamp(2rem, 5.2vw, 3.2rem); letter-spacing: -0.02em; max-width: 16em; margin-bottom: 18px; }
.lead { font-size: 1.2rem; max-width: 40em; }
.team { color: var(--muted); max-width: 46em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.button {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin: 40px 0 0; }
.facts div { display: flex; flex-direction: column; border-left: 3px solid var(--c); padding-left: 12px; }
.facts dt { color: var(--muted); font-size: 0.9rem; }
.facts dd { margin: auto 0 0; font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-figure { margin: 40px 0 0; }
.hero-figure img { display: block; width: 100%; height: auto; border-radius: 6px; }
.hero-figure figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

/* Sections */
main > section:not(.hero) { padding: 56px 0; border-top: 1px solid var(--line); }
main > section, h3[id] { scroll-margin-top: 64px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin: 24px 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 6px;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; font-size: 1.05rem; }
.card ul { padding-left: 1.1em; }
.source .kicker { color: var(--muted); font-size: 0.9rem; margin-top: -8px; }
.source .used { font-size: 0.9rem; border-top: 1px solid var(--line); padding-top: 10px; }
.split { display: grid; gap: 24px 40px; margin-top: 24px; align-items: start; }
.split > * { min-width: 0; }
.steps li { margin-bottom: 8px; }

.classes { list-style: none; padding: 0; columns: 2 170px; column-gap: 24px; }
.classes li { display: flex; align-items: center; gap: 8px; break-inside: avoid; }
.classes li::before, .swatch::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--c);
  box-shadow: inset 0 0 0 1px var(--chip-edge);
}
.swatch { display: inline-flex; align-items: center; gap: 7px; }
.classes b { min-width: 1.4em; font-variant-numeric: tabular-nums; }
.classes-block h3 { margin-top: 16px; }

/* Method */
.formula {
  font-family: "Cambria Math", Cambria, "Times New Roman", serif;
  font-size: 1.15rem;
  background: var(--soft);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}
.formula var { font-style: italic; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.setup th { width: 34%; color: var(--muted); font-weight: 600; }
.setup td { text-align: left; }
.compare th:nth-child(2), .compare td:nth-child(2) { text-align: left; }
.split > div > h3:first-child { margin-top: 0; }

/* Figures from the presentation */
.plot { margin: 24px 0; }
.plot a {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}
.plot img { display: block; width: 100%; height: auto; }
.plot.narrow { max-width: 820px; }
.plot figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }
.split .plot { margin: 0; }
details { margin: 16px 0; }
summary { cursor: pointer; font-weight: 600; }
.caveats ul { margin-top: 10px; color: var(--muted); font-size: 0.9rem; }

/* City map viewer */
.notice {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 6px;
}
.notice pre { margin: 0 0 14px; }
.viewer { margin-top: 20px; }
.viewer-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button, .zoom button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
}
.tabs button { padding: 6px 16px; border-radius: 999px; }
.tabs button[aria-selected="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.zoom { display: flex; align-items: center; gap: 6px; }
.zoom button { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; font-size: 1.05rem; }
.zoom button:hover, .tabs button:hover { border-color: var(--muted); }
#zoom-level { color: var(--muted); font-size: 0.9rem; min-width: 3.5em; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 10px 0; }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.panel { margin: 0; min-width: 0; }
.panel figcaption { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  background: #000;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
}
.panels.zoomed .frame { touch-action: none; }
.panels.dragging .frame { cursor: grabbing; }
.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  -webkit-user-drag: none;
}
.frame img.classmap { image-rendering: pixelated; }
.frame::before, .frame::after {
  content: "";
  position: absolute;
  z-index: 1;
  display: none;
  pointer-events: none;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 45%);
}
.frame::before { left: var(--cx); top: 0; bottom: 0; width: 1px; }
.frame::after { top: var(--cy); left: 0; right: 0; height: 1px; }
.panels.hover .frame::before, .panels.hover .frame::after { display: block; }

.map-tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  box-shadow: 0 4px 16px rgb(0 0 0 / 18%);
  max-width: min(320px, calc(100vw - 16px));
}
.map-tooltip div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 10px; }
.map-tooltip div > span { color: var(--muted); }
.map-tooltip b { font-weight: 600; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  font-size: 0.9rem;
}
.legend li { margin: 0; }
.legend.errors { margin-top: 8px; color: var(--muted); }

.scores { display: grid; gap: 24px 40px; margin-top: 28px; }
.scores h4 { margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.stats div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.stats dt { color: var(--muted); font-size: 0.85rem; }
.stats dd { margin: 0; font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Run it yourself */
pre {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  font: 0.88rem/1.6 var(--mono);
}
pre code { background: none; padding: 0; font-size: inherit; white-space: inherit; }
pre .comment { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 32px 0 48px; color: var(--muted); font-size: 0.9rem; }
.site-footer p { max-width: 60em; }

@media (min-width: 640px) {
  /* Both rows of maps fit on the screen */
  .viewer-bar, .panels { max-width: max(600px, calc(100vh - 150px)); }
  .panels { gap: 14px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 860px) {
  .split { grid-template-columns: 1fr 1fr; }
  .scores { grid-template-columns: 1fr 1fr; }
  .scores .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 639px) {
  .site-header { position: static; }
  .nav ul { gap: 2px 14px; }
  .hero { padding-top: 40px; }
  h2 { font-size: 1.5rem; }
  .stats dd { font-size: 1.2rem; }
}

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