:root {
  --bg: #0e1012;
  --panel: #15181b;
  --panel-2: #1b1f23;
  --line: #2a2f34;
  --text: #eceef0;
  --muted: #9aa3aa;
  --a: #f2a541;
  --b: #5ec4d6;
  --stage: #4c5054;
  /* cost chart: checked for colour-blind separation on the panel colour */
  --cost-1: #3987e5;
  --cost-2: #d55181;
  --cost-3: #9085e9;
  --radius: 14px;
  --gutter: clamp(16px, 4vw, 40px);
  --max: 1560px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

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

a { color: inherit; text-underline-offset: 3px; }
a:hover { color: #fff; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot--a { background: var(--a); }
.dot--b { background: var(--b); }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--gutter);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 650; letter-spacing: -0.01em; text-decoration: none; white-space: nowrap;
}
.brand__x { color: var(--muted); font-weight: 400; margin: 0 2px; }
.top__nav { display: flex; gap: clamp(12px, 2.4vw, 28px); font-size: 14px; }
.top__nav a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.top__nav a:hover { color: var(--text); }

/* ---------- intro */
main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

.intro { padding: clamp(28px, 5vw, 64px) 0 clamp(20px, 3vw, 36px); max-width: 900px; }
.intro h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 58px); line-height: 1.04; letter-spacing: -0.03em; font-weight: 700;
  text-wrap: balance;
}
.intro p { margin: 0; color: #c3c9ce; font-size: clamp(16px, 1.4vw, 19px); max-width: 68ch; }

/* ---------- controls */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.bar--top { margin-bottom: 12px; }
.bar--bottom { margin-top: 12px; }
.group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group__label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }

.seg { display: inline-flex; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.seg button, .chip {
  font: inherit; font-size: 14px; color: var(--muted); cursor: pointer;
  border: 0; background: none; border-radius: 999px; padding: 7px 14px; white-space: nowrap;
  transition: background-color .15s, color .15s, border-color .15s;
}
.seg button:hover, .chip:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--text); color: #101214; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--panel); }
.chip[aria-pressed="true"] { color: var(--text); border-color: #59616a; background: var(--panel-2); }
#layers .chip::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px;
  border-radius: 2px; border: 1.5px solid currentColor; vertical-align: 1px;
}
#layers .chip[aria-pressed="true"]::before { background: currentColor; }
#spin { margin-left: auto; }

button:focus-visible, a:focus-visible, .wipe:focus-visible {
  outline: 2px solid #fff; outline-offset: 2px;
}

/* ---------- stage */
.stage {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  height: clamp(420px, 70vh, 820px);
  border-radius: var(--radius); overflow: hidden;
  background: var(--bg);
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
}
.stage:active { cursor: grabbing; }

.pane { position: relative; min-width: 0; min-height: 0; background: var(--stage); overflow: hidden; }
.pane canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pane::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 95% at 50% 45%, transparent 45%, rgba(0, 0, 0, .42) 100%);
}

.tag {
  position: absolute; z-index: 3; top: 14px; left: 14px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(14, 16, 18, .72); backdrop-filter: blur(8px);
  font-size: 14px; pointer-events: none;
}
.tag__meta { color: #b5bcc2; font-variant-numeric: tabular-nums; }
.tag__meta:empty { display: none; }
.tag__wip { color: var(--b); }

.loading {
  position: absolute; z-index: 2; inset: 0; display: grid; place-content: center; gap: 12px;
  text-align: center; font-size: 14px; color: #dfe3e6; pointer-events: none;
  background: rgba(30, 33, 36, .55);
  transition: opacity .5s;
}
.loading i { display: block; width: 180px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .18); overflow: hidden; }
.loading b { display: block; height: 100%; width: 0; background: #fff; transition: width .2s; }
.loading.is-done { opacity: 0; }
.loading.is-error { color: #ffb4a8; }

.wipe { display: none; }

.stage[data-mode="wipe"] { display: block; }
.stage[data-mode="wipe"] .pane { position: absolute; inset: 0; }
.stage[data-mode="wipe"] .pane--b { clip-path: inset(0 0 0 var(--wipe)); }
.stage[data-mode="wipe"] .tag--b { left: auto; right: 14px; }
.stage[data-mode="wipe"] .wipe {
  display: block; position: absolute; z-index: 5; top: 0; bottom: 0; left: var(--wipe);
  width: 44px; margin-left: -22px; cursor: ew-resize; touch-action: none;
}
.wipe::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px;
  background: rgba(255, 255, 255, .9); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.wipe span {
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .45);
}
.wipe span::before, .wipe span::after {
  content: ""; position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border: 2px solid #15181b; border-top: 0; border-right: 0;
}
.wipe span::before { left: 10px; transform: rotate(45deg); }
.wipe span::after { right: 10px; transform: rotate(-135deg); }

.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); max-width: 90ch; }

/* ---------- content blocks */
.block { padding: clamp(48px, 8vw, 104px) 0 0; }
.block h2 { margin: 0 0 10px; font-size: clamp(24px, 3vw, 36px); letter-spacing: -0.02em; line-height: 1.12; }
.block__lead { margin: 0 0 28px; color: #c3c9ce; max-width: 70ch; }
.block h3 { margin: 40px 0 14px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; }

.row { display: grid; gap: 12px; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.shot { margin: 0; }
.shot button {
  display: block; width: 100%; padding: 0; border: 0; background: var(--panel); cursor: zoom-in;
  border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9.6;
}
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.shot button:hover img { transform: scale(1.025); }
.shot figcaption { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 14px; color: #c3c9ce; }
.shot figcaption small { color: var(--muted); font-size: 13px; }
.dot--ref { background: #8b949c; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }

/* ---------- facts */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.facts { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 560px; }
.facts th, .facts td { padding: 11px 16px; text-align: right; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.facts thead th { border-top: 0; font-size: 14px; white-space: nowrap; }
.facts th:first-child, .facts td:first-child { text-align: left; font-weight: 400; color: #c3c9ce; }
.facts thead th .dot { margin-right: 7px; }
.facts tr.is-head td {
  background: var(--panel-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em;
}
.facts td small { color: var(--muted); display: block; font-size: 12.5px; }
.facts .is-ref { color: var(--muted); }
.note { margin: 14px 0 0; font-size: 13px; color: var(--muted); max-width: 90ch; }

/* ---------- costs */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-bottom: 22px; }
.tile { padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tile__name { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #c3c9ce; }
.tile__value { margin: 6px 0 8px; font-size: clamp(38px, 5vw, 56px); font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.tile__meta { margin: 0; font-size: 13.5px; color: var(--muted); }
.tile__meta + .tile__meta { margin-top: 2px; }
.tile__open { color: var(--text); }

.chart { margin: 0 0 22px; padding: 20px 22px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.chart figcaption { font-size: 15px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 18px; padding: 0; list-style: none; font-size: 13.5px; color: #c3c9ce; }
.legend li { display: flex; align-items: center; gap: 7px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }

.bars { position: relative; padding-bottom: 26px; }
.bars__grid { position: absolute; inset: 0 0 26px; pointer-events: none; }
.bars__grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.bars__grid span {
  position: absolute; bottom: -22px; transform: translateX(-50%);
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bars__grid span:first-of-type { transform: none; }
.bars__grid span:last-of-type { transform: translateX(-100%); }
.cost-row { position: relative; padding: 8px 0 12px; }
.cost-row__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 14px; }
.cost-row__head span { display: inline-flex; align-items: center; gap: 8px; color: #c3c9ce; }
.cost-row__head b { display: none; font-variant-numeric: tabular-nums; }
.cost-row__line { display: flex; align-items: center; gap: 10px; }
.cost-row__line b { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-row__stack { display: flex; gap: 2px; height: 20px; flex: none; }
.seg-part {
  position: relative; min-width: 2px; height: 100%; padding: 0; border: 0; cursor: default;
  transition: filter .12s;
}
.seg-part::after { content: ""; position: absolute; inset: -8px 0; }
.seg-part:last-child { border-radius: 0 4px 4px 0; }
.seg-part:hover, .seg-part:focus-visible { filter: brightness(1.22); }

.tip {
  position: fixed; z-index: 40; pointer-events: none; max-width: 260px;
  padding: 9px 12px; border-radius: 8px; border: 1px solid #3a4046;
  background: #0b0d0f; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); font-size: 13px; color: #c3c9ce;
}
.tip b { display: block; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.tip span { display: block; }
.tip__key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }

.facts th .swatch { margin-right: 8px; }
.facts .is-sum th, .facts .is-sum td { font-weight: 700; color: var(--text); }
.facts .is-sum td small { font-weight: 400; }
.facts td.is-empty { color: var(--muted); }

/* ---------- footer */
.foot {
  max-width: var(--max); margin: clamp(56px, 9vw, 120px) auto 0; padding: 32px var(--gutter) 56px;
  border-top: 1px solid var(--line);
  display: grid; gap: 28px 56px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  font-size: 14px; color: var(--muted);
}
.foot h3 { margin: 0 0 8px; font-size: 14px; color: var(--text); }
.foot p { margin: 0 0 10px; max-width: 70ch; }
.foot__stamp { font-variant-numeric: tabular-nums; }

/* ---------- lightbox */
.lightbox {
  border: 0; padding: 0; background: transparent; color: var(--text);
  max-width: min(96vw, 1800px); max-height: 96vh;
}
.lightbox::backdrop { background: rgba(6, 7, 8, .9); }
.lightbox img { display: block; max-width: 100%; max-height: 86vh; border-radius: 10px; margin: 0 auto; }
.lightbox p { margin: 10px 0 0; text-align: center; font-size: 14px; color: #c3c9ce; }
.lightbox button {
  position: fixed; top: 16px; right: 16px; font: inherit; font-size: 14px; cursor: pointer;
  color: var(--text); background: rgba(30, 33, 36, .9); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
}

/* ---------- small screens */
@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; height: min(84vh, 760px); }
  .top__nav a:nth-child(n+2) { display: none; }
  .bars__grid span:nth-of-type(even) { display: none; }
  .facts { min-width: 0; font-size: 14px; }
  .facts th, .facts td { padding: 10px 10px; }
  .facts td small { font-size: 12px; }
  .cost-row__head b { display: block; }
  .cost-row__line b { display: none; }
  .row { grid-template-columns: 1fr; }
  #spin { margin-left: 0; }
  .bar--top .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 4px; scrollbar-width: none; }
  .tag { top: 10px; left: 10px; font-size: 13px; }
  .stage[data-mode="wipe"] .tag--b { right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .shot img, .loading, .loading b { transition: none; }
}
