/* Plain single-column page: big section titles, bullet points, video pairs side by side. */
:root {
  --bg: #ffffff;
  --band: #f4f6f7;
  --ink: #1b1f24;
  --soft: #4f5862;
  --faint: #7b848d;
  --line: #e2e6e9;
  --accent: #0d6772;
  --ok: #1f6b3d;
  --ok-bg: #e2f1e7;
  --part: #7a5a00;
  --part-bg: #f7eccb;
  --bad: #9a3412;
  --bad-bg: #fbe5dc;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --wide: 1180px;      /* one container for everything: text, tables, figures, part cards */
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.65;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img, video { max-width: 100%; display: block; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--band); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
sub { font-size: 0.72em; }

.wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.wrap.wide { max-width: var(--wide); }
/* Text, tables, figures and the task matrix all span the container, so their edges line up. */

/* Navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 10px max(20px, env(safe-area-inset-right, 0px)) 10px max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 20px;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 17px; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.nav a { font-size: 15px; color: var(--soft); text-decoration: none; }
.nav a:hover, .nav a[aria-current="true"] { color: var(--accent); }

/* Banner: the concept illustration runs edge to edge under the navigation, cropped to a wide strip */
.banner { margin: 0; position: relative; }
.banner a { display: block; background: #0b1a24; }
.banner img { display: block; width: 100%; height: clamp(200px, 44vh, 560px); object-fit: cover; object-position: center 42%; border: 0; border-radius: 0; }
/* The caption sits in a translucent box in the picture's lower-right corner */
.banner figcaption { position: absolute; right: 16px; bottom: 14px; max-width: min(62%, 560px); margin: 0; padding: 6px 10px; border-radius: 6px; background: rgba(8, 14, 20, 0.62); color: #f2f5f7; font-size: 13px; line-height: 1.4; text-align: left; backdrop-filter: blur(2px); }

/* Title */
.title-block { padding-top: 28px; padding-bottom: 8px; }
.byline { margin: 0 0 8px; color: var(--faint); font-size: 15px; }
h1 {
  margin: 0;
  font-size: clamp(30px, 4.6vw, 42px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.lede { margin: 14px 0 0; font-size: 20px; color: var(--soft); }

/* Parts: collapsed by default; each part is a grey card that opens and closes it */
.part-block { margin-top: 16px; }
.part-block:first-of-type, .part-block[open] + .part-block { margin-top: 48px; }
.part { display: block; cursor: pointer; list-style: none; }
.part::marker { content: ""; }
.part::-webkit-details-marker { display: none; }
.part:focus-visible { outline: none; }
.part-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: calc(100% - 2 * max(20px, env(safe-area-inset-left, 0px)));
  max-width: calc(var(--wide) - 40px);
  margin: 0 auto;
  padding: 22px 24px 20px;
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.part:hover .part-head { border-color: #cfd5da; }
.part:focus-visible .part-head { outline: 2px solid var(--accent); outline-offset: 2px; }
.part-label { display: block; margin: 0; font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.part-title { margin: 2px 0 0 !important; font-size: clamp(30px, 5vw, 44px) !important; }
.part:hover .part-title { color: var(--accent); }
.part-toggle { flex: none; width: 14px; height: 14px; margin-right: 4px; border-right: 3px solid var(--soft); border-bottom: 3px solid var(--soft); transform: translateY(-4px) rotate(45deg); transition: transform 0.2s; }
.part-block[open] .part-toggle { transform: translateY(4px) rotate(-135deg); }
@media (prefers-reduced-motion: reduce) { .part-toggle { transition: none; } }

/* Sections */
section { padding-top: 40px; }
h2 {
  margin: 0 0 14px;
  font-size: clamp(28px, 3.6vw, 36px);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h3 { margin: 26px 0 8px; font-size: 22px; line-height: 1.3; font-weight: 700; }
.sub { margin: -6px 0 16px; color: var(--soft); }

/* Bullet points: bold lead-in, then plain text */
.points { margin: 0; padding-left: 1.1em; display: grid; gap: 12px; }
.points li::marker { color: var(--accent); }
.points b { font-weight: 700; }

.refs { margin: 0; padding-left: 1.1em; display: grid; gap: 10px; }
.refs span { color: var(--faint); }

/* Figures */
.figure { margin: 22px 0 0; }
.figure img, .figure video { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); background: #000; }
.figure img { background: var(--bg); }
.figure figcaption { margin-top: 8px; font-size: 15px; color: var(--soft); }
/* Figures stay as wide as the text; a click opens the full-resolution file (pinch-zoom on phones). */
.figure a { display: block; }
.media-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.media-2 .figure { margin-top: 22px; min-width: 0; }

/* Tables */
.table-wrap { overflow-x: auto; margin-top: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 14px; font-weight: 600; color: var(--soft); border-bottom: 2px solid var(--line); }
td { font-variant-numeric: tabular-nums; }
.note { margin: 12px 0 0; font-size: 15px; color: var(--soft); }
/* Part 3 tables: settings (row headers) and success rates (numeric) */
table.plain th[scope="row"] { width: 160px; text-align: left; vertical-align: top; padding: 8px 10px 8px 0; font-size: 15px; color: var(--ink); border-bottom: 1px solid var(--line); }
table.plain td { padding: 8px 0; font-size: 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plain thead th { text-align: left; padding: 0 10px 6px 0; }
table.rates th, table.rates td { padding: 6px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.rates th[scope="row"] { text-align: left; font-weight: 500; color: var(--ink); font-size: 16px; }
table.rates thead th { text-align: right; }
table.rates thead th:first-child { text-align: left; }
table.rates td { text-align: right; }
table.rates tbody tr:nth-child(odd) td, table.rates tbody tr:nth-child(odd) th { background: var(--band); }
.nowrap { white-space: nowrap; }

/* Stat row */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 22px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 14px; color: var(--soft); }

/* Result chips */
.chip {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.part { color: var(--part); background: var(--part-bg); }
.chip.bad { color: var(--bad); background: var(--bad-bg); }

/* Before / after */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 6px; }
.btn {
  font: 600 15px/1 var(--sans);
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.case { padding-top: 26px; margin-top: 26px; border-top: 1px solid var(--line); }
.case h3 { margin-top: 0; font-size: 26px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pair figure { margin: 0; min-width: 0; }
.pair figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.pair video { width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; background: #000; }
.side { font-weight: 700; font-size: 17px; }
.side.before { color: var(--bad); }
.side.after { color: var(--ok); }

.notes { margin-top: 16px; }
.notes > div { min-width: 0; }
.notes h4 { margin: 0 0 6px; font-size: 18px; }
.notes ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; font-size: 16.5px; }

/* All tasks: tasks × conditions matrix (desktop first; scrolls sideways on narrow screens) */
#all-tasks .wrap.wide { max-width: 1320px; }
.matrix-wrap { overflow-x: auto; margin: 6px -6px 0; }
.matrix { width: 100%; min-width: 980px; border-collapse: separate; border-spacing: 6px; table-layout: fixed; }
.matrix th, .matrix td { padding: 0; border: 0; vertical-align: middle; }
.matrix thead th { padding: 0 2px 2px; text-align: left; font-size: 14.5px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.matrix thead th span { display: block; font-size: 12.5px; font-weight: 400; color: var(--faint); }
.matrix thead th:first-child, .matrix tbody th { width: 190px; }
.matrix tbody th { position: sticky; left: 0; z-index: 1; padding-right: 4px; text-align: left; font-weight: 400; background: var(--bg); }
.matrix thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg); }
.matrix tbody th b { display: block; font-size: 15px; line-height: 1.3; }
.row-meta { display: block; margin-top: 4px; font-size: 13px; color: var(--faint); }
.row-change { display: block; margin-top: 3px; font-size: 13px; line-height: 1.3; color: var(--soft); }
.matrix video { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 5px; background: #000; cursor: zoom-in; }
.matrix video:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Enlarged clip */
.lightbox { width: min(1100px, 94vw); padding: 0; border: 0; border-radius: 10px; background: var(--bg); overflow: hidden; }
.lightbox::backdrop { background: rgba(10, 14, 18, 0.72); }
.lightbox video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.lightbox-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; font-size: 15px; }

/* All tasks */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 8px; }
.gallery figure { margin: 0; min-width: 0; }
.gallery video { width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; background: #000; }
.gallery figcaption { margin-top: 6px; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }

footer { margin-top: 64px; padding: 24px 0 40px; border-top: 1px solid var(--line); font-size: 14px; color: var(--faint); }
footer p { margin: 0; }

@media (max-width: 900px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  body { font-size: 17px; }
  /* Results table: task and both scores on one line, the change underneath */
  .results thead tr, .results tbody tr { display: grid; grid-template-columns: 1fr 76px 76px; column-gap: 8px; align-items: center; }
  .results thead tr { border-bottom: 2px solid var(--line); }
  .results tbody tr { row-gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .results th, .results td { padding: 0; border: 0; }
  .results th { padding: 6px 0; font-size: 13px; line-height: 1.3; }
  .results th:nth-child(4) { display: none; }
  .results td:first-child { font-weight: 600; line-height: 1.35; }
  .results td:nth-child(4) { grid-column: 1 / -1; font-size: 15px; color: var(--soft); }
  .pair, .media-2 { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .nav ul { gap: 2px 14px; }
  .banner figcaption { right: 10px; bottom: 10px; max-width: 78%; font-size: 12px; padding: 5px 8px; }
}
