:root {
  --bg: #f6f8fa;
  --card: #ffffff;
  --text: #1d1b20;
  --muted: #5f6368;
  --accent: #0369a1;
  --band: #b3e5fc;
  --line: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418;
    --card: #1b2026;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --accent: #7cc4f0;
    --band: #16384d;
    --line: #2c333b;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --card: #1b2026; --text: #e8eaed; --muted: #9aa0a6;
  --accent: #7cc4f0; --band: #16384d; --line: #2c333b; --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header {
  background: var(--band);
  padding: 40px 16px 32px;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
header .wrap { padding: 0; }
h1 { margin: 0 0 8px; font-size: clamp(28px, 5vw, 40px); line-height: 1.15; }
header p { margin: 0; max-width: 60ch; color: var(--text); opacity: .85; }
.hero {
  display: flex; gap: 32px; align-items: center; flex-wrap: wrap;
}
.hero-text { flex: 1 1 320px; min-width: 0; }
.hero img {
  width: 220px; max-width: 60vw; border-radius: 22px; box-shadow: var(--shadow);
  border: 6px solid #1d1b20;
}
nav.toc {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px;
}
nav.toc a {
  text-decoration: none; color: var(--text); background: var(--card);
  padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--line);
}
nav.toc a:hover { border-color: var(--accent); color: var(--accent); }
section { padding: 40px 0 8px; }
section > .wrap > h2 {
  font-size: 24px; margin: 0 0 4px; display: flex; align-items: baseline; gap: 12px;
}
section > .wrap > h2 span { color: var(--accent); font-size: 15px; font-weight: 700; }
section > .wrap > p.lead { margin: 0 0 20px; color: var(--muted); max-width: 70ch; }
.grid {
  display: grid; gap: 20px;
  /* Four to a row, always: every section is four or eight screens. A
     window too narrow for four gets two, never three. */
  grid-template-columns: repeat(4, 1fr);
}
figure {
  margin: 0; background: var(--card); border-radius: 16px; padding: 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
figure img {
  width: 100%; height: auto; display: block; border-radius: 12px;
  border: 1px solid var(--line); cursor: zoom-in; background: #fff;
}
figcaption { font-size: 14.5px; color: var(--muted); }
figcaption b { display: block; color: var(--text); font-size: 15.5px; margin-bottom: 2px; }
.num {
  display: inline-block; min-width: 26px; padding: 0 6px; margin-right: 6px;
  border-radius: 6px; background: var(--band); color: var(--text);
  font-size: 12px; font-weight: 700; text-align: center;
}
footer { padding: 40px 16px 56px; color: var(--muted); font-size: 14px; text-align: center; }
.how { margin: 14px 0 0; font-size: 14px; opacity: .8; }

/* The viewer: one picture at a time, stepped through with arrows, keys or a swipe. */
dialog {
  border: none; padding: 0; margin: 0; background: transparent;
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  color: #fff;
}
dialog[open] { display: flex; align-items: center; justify-content: center; }
dialog::backdrop { background: rgba(0,0,0,.92); }
dialog[open] { background: rgba(0,0,0,.6); }
dialog .shot {
  margin: 0; background: none; box-shadow: none; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
dialog .shot img {
  max-height: calc(100dvh - 90px); max-width: 88vw; width: auto; border: none;
  border-radius: 14px; cursor: default; touch-action: pan-y;
}
dialog .shot figcaption { color: #fff; font-size: 15px; font-weight: 600; text-align: center; }
dialog button {
  position: absolute; border: none; background: rgba(255,255,255,.14); color: #fff;
  cursor: pointer; border-radius: 999px; font: 32px/1 system-ui, sans-serif;
  width: 52px; height: 52px; display: grid; place-items: center;
}
dialog button:hover { background: rgba(255,255,255,.28); }
dialog .prev { left: 24px; top: 50%; transform: translateY(-50%); }
dialog .next { right: 24px; top: 50%; transform: translateY(-50%); }
dialog .close { right: 16px; top: 16px; width: 44px; height: 44px; font-size: 28px; }
dialog .hint { position: absolute; bottom: 10px; left: 0; right: 0; margin: 0;
  text-align: center; font-size: 13px; opacity: .7; }

@media (max-width: 900px) and (min-width: 701px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

/* A phone: each section is a row swiped sideways, the next picture peeking in,
   rather than a column of full-width screenshots taller than the screen. */
@media (max-width: 700px) {
  header { padding: 28px 0 24px; }
  header .wrap { padding: 0 16px; }
  .hero { gap: 20px; }
  .hero img { width: 170px; margin: 0 auto; }
  nav.toc { flex-wrap: nowrap; overflow-x: auto; margin: 16px -16px 0; padding: 0 16px 4px;
    scrollbar-width: none; }
  nav.toc::-webkit-scrollbar { display: none; }
  nav.toc a { white-space: nowrap; }
  section { padding-top: 28px; }
  .grid {
    display: flex; overflow-x: auto; gap: 14px; scroll-snap-type: x mandatory;
    margin: 0 -16px; padding: 4px 16px 16px; scroll-padding: 0 16px;
    scrollbar-width: none;
  }
  .grid::-webkit-scrollbar { display: none; }
  .grid figure { flex: 0 0 72vw; max-width: 300px; scroll-snap-align: start; }
  .grid figure:only-child { flex-basis: 100%; max-width: 320px; }
  dialog .prev, dialog .next { display: none; }
  dialog .shot { padding-top: 56px; }
  dialog .shot img { max-width: 94vw; max-height: calc(100dvh - 150px); }
  dialog .close { top: 8px; right: 8px; }
}
