/* how to build — site.css
   One file, no dependencies. Read it top to bottom:
   1 tokens (colors, type)   2 base   3 header and footer
   4 page text   5 blocks (steps, asides, code, tabs, brief, cards, pager)
   6 landing page   7 motion and print */

/* 1. Tokens ------------------------------------------------------------ */

:root {
  color-scheme: light;
  --bg: #fbf8f3;          /* warm paper */
  --surface: #ffffff;
  --sunk: #f3eee6;
  --ink: #1f1c18;
  --ink-2: #4a443c;
  --muted: #6f685e;
  --line: #e6ded1;
  --line-2: #d6ccbc;

  --warm: #c4470a;        /* the warm accent: ember orange */
  --warm-bright: #e8590c;
  --warm-soft: #fdebdc;
  --cool: #0b7268;        /* the cool accent: deep teal */
  --cool-soft: #ddf3ef;
  --danger: #b4232a;
  --danger-soft: #fbe5e3;

  --code-bg: #1d1f24;
  --code-ink: #e9e6df;
  --code-bar: #26292f;
  --code-muted: #9a978f;

  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px -12px rgba(60, 40, 20, .18);
  --radius: 14px;
  --radius-s: 8px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "New York", ui-serif, Georgia, Cambria, "Noto Serif", "DejaVu Serif", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;

  --measure: 44rem;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121315;
    --surface: #1a1c1f;
    --sunk: #16171a;
    --ink: #eee9e1;
    --ink-2: #cdc6bb;
    --muted: #a19a8f;
    --line: #2b2e33;
    --line-2: #3a3e44;
    --warm: #ff8f4d;
    --warm-bright: #ff7a2e;
    --warm-soft: #33210f;
    --cool: #5ed6c6;
    --cool-soft: #10302c;
    --danger: #ff8a80;
    --danger-soft: #3a1717;
    --code-bg: #0b0c0e;
    --code-ink: #e9e6df;
    --code-bar: #17191c;
    --code-muted: #8d8a83;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121315;
  --surface: #1a1c1f;
  --sunk: #16171a;
  --ink: #eee9e1;
  --ink-2: #cdc6bb;
  --muted: #a19a8f;
  --line: #2b2e33;
  --line-2: #3a3e44;
  --warm: #ff8f4d;
  --warm-bright: #ff7a2e;
  --warm-soft: #33210f;
  --cool: #5ed6c6;
  --cool-soft: #10302c;
  --danger: #ff8a80;
  --danger-soft: #3a1717;
  --code-bg: #0b0c0e;
  --code-ink: #e9e6df;
  --code-bar: #17191c;
  --code-muted: #8d8a83;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -14px rgba(0, 0, 0, .7);
}

/* 2. Base -------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;            /* 18px on a phone */
  line-height: 1.65;
  overflow-wrap: break-word;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
@media (min-width: 48rem) { body { font-size: 1.1875rem; } }

img, svg, video, canvas { max-width: 100%; height: auto; }

a {
  color: var(--cool);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}
a:hover { color: var(--warm); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--warm-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: var(--warm-soft); color: var(--ink); }

button { font: inherit; color: inherit; }

.skip {
  position: absolute; left: -999px; top: 8px;
  background: var(--surface); padding: .5rem .8rem; border-radius: var(--radius-s);
}
.skip:focus { left: 8px; z-index: 10; }

/* 3. Header and footer ------------------------------------------------- */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 14px max(var(--gutter), calc(50% - 36rem));
  background: var(--bg);
  box-shadow: 0 1px 0 var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand::before {
  content: "";
  width: 1.35rem; height: 1.35rem;
  border-radius: 6px;
  background: url("/img/favicon.svg") center / contain no-repeat;
}
.brand:hover { color: var(--ink); }

.top nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: 1rem;
}
.top nav a {
  color: var(--ink-2);
  text-decoration: none;
  padding: .4rem .65rem;
  border-radius: 999px;
}
.top nav a:hover { background: var(--sunk); color: var(--ink); }
.menu {
  font: inherit; color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 999px;
  padding: .4rem .8rem; cursor: pointer; line-height: 1.4;
}
.menu:hover, .menu[aria-expanded="true"] { color: var(--ink); border-color: var(--warm); }
@media (min-width: 80rem) { .menu { display: none; } }
@media (max-width: 39.99rem) { .top nav > a { display: none; } }
.top nav a[aria-current="page"] { color: var(--ink); background: var(--sunk); }

.theme {
  width: 2.5rem; height: 2.5rem;
  margin-left: .25rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  padding: 0;
}
.theme::before {               /* a half-filled circle: light on one side, dark on the other */
  content: "";
  width: 1rem; height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
  transition: transform .3s ease;
}
:root[data-theme="dark"] .theme::before { transform: rotate(180deg); }
.theme:hover { border-color: var(--warm); }
html:not(.js) .theme { display: none; }

.foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .9rem;
  padding: 2rem var(--gutter) 2.5rem;
  text-align: center;
}
.foot a { color: var(--ink-2); }

/* 4. Page text --------------------------------------------------------- */

.page {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 2rem var(--gutter) 4rem;
}
/* A wide page keeps the same text column as every other page; only the
   cards grid breaks out of it, centred, up to 66rem. */
.page.wide > .cards {
  width: min(66rem, 100vw - 2 * var(--gutter));
  margin-left: calc(50% - min(33rem, 50vw - var(--gutter)));
}

@media (min-width: 48rem) { .page { padding-top: 3.5rem; } }

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -.015em;
  text-wrap: balance;
}
h1 {
  font-size: clamp(2.1rem, 1.5rem + 3vw, 3.4rem);
  margin: .2rem 0 1rem;
  letter-spacing: -.025em;
}
h2 {
  font-size: clamp(1.55rem, 1.25rem + 1.4vw, 2.1rem);
  margin: 3.25rem 0 .8rem;
}
h3 { font-size: clamp(1.2rem, 1.1rem + .5vw, 1.4rem); margin: 2.2rem 0 .5rem; }
h4 { font-size: 1.05rem; margin: 1.6rem 0 .4rem; font-family: var(--sans); letter-spacing: 0; }

h2 + p, h3 + p { margin-top: 0; }

p, ul, ol, dl, table, blockquote { margin: 0 0 1.1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin: .3rem 0; }
li::marker { color: var(--muted); }

strong { font-weight: 650; }

hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 3rem 0;
}

.kicker {
  margin: 0;
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--cool);
}
.kicker a { color: inherit; text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
/* site.js puts the kicker and a previous/next row on one line */
.pagehead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .3rem 1rem; }
.pagehead .kicker { margin: 0; }
nav.pagerow { display: flex; gap: .15rem; margin-left: auto; font-size: .85rem; }
nav.pagerow a {
  color: var(--muted); text-decoration: none; padding: .2rem .55rem; border-radius: 999px;
  max-width: 13rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
nav.pagerow a:hover { color: var(--ink); background: var(--sunk); }

.lead {
  font-size: clamp(1.2rem, 1.1rem + .5vw, 1.4rem);
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 2rem;
}

.muted { color: var(--muted); }

code, kbd, samp { font-family: var(--mono); font-size: .86em; }

:not(pre) > code {
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .08em .35em;
  overflow-wrap: anywhere;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  text-align: center;
  padding: .05em .4em;
  border: 1px solid var(--line-2);
  border-bottom-width: 3px;
  border-radius: 6px;
  background: var(--surface);
  font-size: .8em;
  line-height: 1.4;
}

blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--line-2);
  color: var(--ink-2);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  display: block;
  overflow-x: auto;
}
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 650; color: var(--ink-2); border-bottom-color: var(--line-2); }

/* 5. Blocks ------------------------------------------------------------ */

/* Code blocks. Dark in both themes. Long lines scroll inside the block only. */
pre {
  margin: 0 0 1.25rem;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius-s);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: .9rem;
  line-height: 1.6;
  tab-size: 2;
  max-width: 100%;
}
pre code { font-size: inherit; background: none; border: 0; padding: 0; color: inherit; white-space: pre; }

/* site.js wraps each pre in .code and adds a bar with the language and Copy */
.code {
  margin: 0 0 1.25rem;
  border-radius: var(--radius-s);
  background: var(--code-bg);
  overflow: hidden;
  max-width: 100%;
}
.code pre { margin: 0; border-radius: 0; padding-top: .75rem; }
.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  background: var(--code-bar);
  padding: .3rem .4rem .3rem .9rem;
  font: 600 .72rem/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--code-muted);
}

.copy {
  border: 1px solid transparent;
  background: transparent;
  color: var(--code-muted);
  border-radius: 6px;
  padding: .45rem .7rem;
  font: 600 .78rem/1 var(--sans);
  white-space: nowrap;
  letter-spacing: .02em;
  text-transform: none;
  cursor: pointer;
  min-height: 2rem;
}
.copy:hover { color: #fff; border-color: #4a4e56; }
.copy.done { color: #7ee8d6; }

/* Steps: big numerals down the left, a thin line joining them */
ol.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 1.5rem 0 2rem;
}
ol.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 1.75rem 2.6rem;
  margin: 0;
  min-width: 0;
}
ol.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -.15rem;
  width: 2.1rem;
  text-align: center;
  font: 700 2rem/1 var(--serif);
  color: var(--warm);
  font-variant-numeric: lining-nums;
}
ol.steps > li::after {
  content: "";
  position: absolute;
  left: 1.05rem; top: 2.3rem; bottom: .6rem;
  width: 2px;
  background: var(--line);
  border-radius: 2px;
}
ol.steps > li:last-child::after { display: none; }
/* a divider in the list: the point where the thing works on its own */
ol.steps > li.mark { counter-increment: none; padding-top: .15rem; color: var(--ink-2); font-size: .95rem; }
ol.steps > li.mark::before { content: ""; width: .75rem; height: .75rem; left: .68rem; top: .4rem; border-radius: 50%; background: var(--cool); }
@media (min-width: 40rem) { ol.steps > li.mark::before { left: .95rem; width: .8rem; height: .8rem; } }
ol.steps > li > :first-child { margin-top: 0; }
ol.steps > li > :last-child { margin-bottom: 0; }
ol.steps > li > p:first-child,
ol.steps > li > strong:first-child { font-weight: 600; }
@media (min-width: 40rem) {
  ol.steps > li { padding-left: 4rem; }
  ol.steps > li::before { width: 2.6rem; font-size: 2.5rem; }
  ol.steps > li::after { left: 1.3rem; top: 2.8rem; }
}

.see {
  font-size: .95rem;
  color: var(--ink-2);
  border-left: 3px solid var(--cool);
  padding: .1rem 0 .1rem .75rem;
}

/* Asides: check (teal, a tick), note (paper, an i), warn (red, a bang) */
aside.check, aside.note, aside.warn {
  position: relative;
  margin: 1.5rem 0;
  padding: 1rem 1.1rem 1rem 3.25rem;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.6;
}
aside.check::before, aside.note::before, aside.warn::before {
  position: absolute;
  left: 1rem; top: 1.05rem;
  width: 1.5rem; height: 1.5rem;
  display: grid; place-items: center;
  border-radius: 50%;
  font: 700 .9rem/1 var(--sans);
}
aside > :first-child { margin-top: 0; }
aside > :last-child { margin-bottom: 0; }
aside h2, aside h3, aside h4 {
  font-family: var(--sans);
  font-size: 1rem;
  letter-spacing: 0;
  margin: 0 0 .35rem;
}
aside pre, aside .code { margin-bottom: .8rem; }

details.byhand { margin: 1rem 0 1.4rem; border-left: 3px solid var(--line, #ccc); padding: .2rem 0 .2rem 1rem; }
details.byhand summary { cursor: pointer; font-weight: 600; }
details.byhand summary:hover { text-decoration: underline; }
details.byhand[open] summary { margin-bottom: .6rem; }
details.byhand > :last-child { margin-bottom: 0; }

aside.check {
  background: var(--cool-soft);
  border: 1px solid color-mix(in srgb, var(--cool) 30%, transparent);
}
aside.check::before { content: ""; background: var(--cool); }
aside.check::after {                /* the tick, drawn with two borders so no font is needed */
  content: "";
  position: absolute;
  left: 1.5rem; top: 1.38rem;
  width: .32rem; height: .6rem;
  border: solid var(--bg);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
aside.check h2, aside.check h3, aside.check h4 { color: var(--cool); }

aside.note {
  background: var(--sunk);
  border: 1px dashed var(--line-2);
}
aside.note::before {
  content: "i";
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  border: 2px solid var(--muted);
  color: var(--muted);
}

aside.warn {
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-left: 5px solid var(--danger);
}
aside.warn::before { content: "!"; background: var(--danger); color: var(--bg); }
aside.warn h2, aside.warn h3, aside.warn h4 { color: var(--danger); }

/* OS tabs. With JS: a row of tabs and one panel. Without JS: all panels stacked. */
.tabs { margin: 1.5rem 0; min-width: 0; }
.tabs > button { display: none; }
.tabs > section {
  border-top: 1px solid var(--line);
  padding-top: .5rem;
  margin-bottom: 1rem;
  min-width: 0;
}
.tabs-on .tabs > button {
  display: inline-block;
  position: relative;
  margin: 0 .2rem -1px 0;
  padding: .55rem 1rem;
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  z-index: 1;
}
.tabs-on .tabs > button:hover { color: var(--ink); background: var(--sunk); }
.tabs-on .tabs > button[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-2);
}
.tabs-on .tabs > button[aria-selected="true"]::after {   /* warm line on top of the active tab */
  content: "";
  position: absolute;
  left: -1px; right: -1px; top: -1px;
  height: 3px;
  border-radius: 10px 10px 0 0;
  background: var(--warm-bright);
}
.tabs-on .tabs > section {
  border: 1px solid var(--line-2);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  background: var(--surface);
  padding: 1.1rem 1rem .4rem;
  margin: 0;
}
@media (min-width: 40rem) { .tabs-on .tabs > section { padding: 1.4rem 1.4rem .6rem; } }
.tabs-on .tabs > section[hidden] { display: none; }
/* a section's own leading heading is for the no-JS view; the tab says it already */
.tabs-on .tabs > section > :is(h3, h4, h5):first-child { display: none; }
.tabs > section > :is(h3, h4, h5):first-child { margin-top: .6rem; }

/* The brief: a card you paste to the agent */
.brief {
  position: relative;
  margin: 1.75rem 0 2rem;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.1rem 1.1rem;
  font-size: 1rem;
  line-height: 1.6;
  overflow: hidden;
}
.brief::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--warm-bright), var(--cool));
}
@media (min-width: 40rem) { .brief { padding: 1.5rem 1.6rem 1.3rem; } }
.brief > :last-child { margin-bottom: 0; }
.brief h2, .brief h3, .brief h4 { font-family: var(--sans); font-size: 1.05rem; letter-spacing: 0; margin: 1.1rem 0 .3rem; }
.brief ol, .brief ul { padding-left: 1.3rem; }
.brief-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: -.25rem 0 .9rem;
  padding-bottom: .7rem;
  border-bottom: 1px dashed var(--line-2);
}
.brief-label {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--warm);
}
.brief .copy {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
  padding: .55rem .9rem;
  font-size: .85rem;
}
.brief .copy:hover { background: var(--warm); border-color: var(--warm); color: #fff; }
.brief .copy.done { background: var(--cool); border-color: var(--cool); color: var(--bg); }

/* Difficulty stars */
.stars { font-family: "Segoe UI Symbol","Apple Symbols","Noto Sans Symbols2","DejaVu Sans",system-ui,sans-serif;
  color: var(--warm-bright);
  letter-spacing: .12em;
  font-size: .95em;
  white-space: nowrap;
}

/* The project cards */
ul.cards {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
  display: grid;
  gap: 1rem;
  counter-reset: card;
}
@media (min-width: 40rem) { ul.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64rem) { .page.wide ul.cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

ul.cards > li {
  counter-increment: card;
  position: relative;
  margin: 0;
  padding: 1.15rem 1.15rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .35rem;
  transition: transform .18s ease, border-color .18s ease;
  font-size: 1rem;
  line-height: 1.55;
}
ul.cards > li:hover { transform: translateY(-2px); border-color: var(--line-2); }
ul.cards > li:focus-within { border-color: var(--warm); }
ul.cards > li > * { margin: 0; }
ul.cards .card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 1.6rem;
}
ul.cards .card-top::before {
  content: counter(card, decimal-leading-zero);
  font: 600 .8rem/1 var(--mono);
  color: var(--muted);
  order: -1;
}
ul.cards .card-top .stars { margin-left: auto; }
ul.cards h3 {
  font-size: 1.35rem;
  margin: .1rem 0 .1rem;
}
ul.cards h3 a { color: var(--ink); text-decoration: none; }
ul.cards h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
ul.cards h3 a:focus-visible { outline: none; }
ul.cards li:has(h3 a:focus-visible) { outline: 3px solid var(--warm-bright); outline-offset: 3px; }
ul.cards .teaches { color: var(--muted); font-size: .93rem; margin-top: auto; padding-top: .4rem; }
ul.cards .teaches strong { color: var(--ink-2); font-weight: 600; }
ul.cards .tag {
  position: relative;
  z-index: 1;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--cool-soft);
  color: var(--cool);
  text-decoration: none;
  white-space: nowrap;
}
a.tag:hover { background: var(--cool); color: var(--bg); }
ul.cards > li.is-done { border-color: color-mix(in srgb, var(--cool) 55%, transparent); }
ul.cards > li.is-done h3::after {
  content: "done";
  padding: .2rem .45rem;
  border-radius: 999px;
  background: var(--cool-soft);
  white-space: pre;
  margin-left: .6rem;
  font: 700 .72rem/1 var(--sans);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--cool);
  vertical-align: middle;
}

/* "Mark done" toggles made by site.js from [data-done] */
html:not(.js) [data-done] { display: none; }
.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin: .5rem 0 1rem;
  padding: .6rem 1rem .6rem .75rem;
  min-height: 2.75rem;
  border: 1.5px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
}
.done-toggle::before {
  content: "";
  width: 1.15rem; height: 1.15rem;
  border: 2px solid var(--muted);
  border-radius: 5px;
  display: grid; place-items: center;
  font-size: .8rem; line-height: 1;
}
.done-toggle:hover { border-color: var(--cool); }
.done-toggle[aria-pressed="true"] { border-color: var(--cool); background: var(--cool-soft); color: var(--cool); }
.done-toggle { position: relative; }
.done-toggle[aria-pressed="true"]::before { background: var(--cool); border-color: var(--cool); }
.done-toggle[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 1.18rem; top: 50%;
  width: .3rem; height: .58rem;
  margin-top: -.38rem;
  border: solid var(--bg);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

/* Prev / next */
nav.pager {
  display: grid;
  gap: .75rem;
  margin: 4rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
@media (min-width: 40rem) { nav.pager { grid-template-columns: 1fr 1fr; } }
nav.pager a {
  display: block;
  padding: .9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
  line-height: 1.35;
}
nav.pager a::before {
  display: block;
  margin-bottom: .2rem;
  font: 700 .72rem/1.2 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  content: "Previous";
}
/* site.js marks links as .prev or .next from their arrows; without JS, position decides */
html:not(.js) nav.pager a:last-child:not(:first-child),
html:not(.js) nav.pager a:only-child { text-align: right; }
html:not(.js) nav.pager a:last-child:not(:first-child)::before,
html:not(.js) nav.pager a:only-child::before { content: "Next"; }
nav.pager a.next { text-align: right; }
nav.pager a.next::before { content: "Next"; }
@media (min-width: 40rem) {
  nav.pager a.next { grid-column: 2; }
  nav.pager a.prev { grid-column: 1; }
}
nav.pager a:hover { border-color: var(--warm); color: var(--ink); }

/* 6. Landing and index pages ------------------------------------------- */

.hero { padding: 1rem 0 .5rem; }
.hero h1 { font-size: clamp(2.5rem, 1.6rem + 4.6vw, 4.6rem); line-height: 1.02; margin-bottom: 1.25rem; }
.hero h1 em { font-style: italic; color: var(--warm); }
.hero .lead { max-width: 36rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.75rem 0 0; }

.button {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 3rem;
  padding: .7rem 1.25rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 650;
  font-size: 1rem;
  text-decoration: none;
  border: 1.5px solid var(--ink);
}
.button:hover { background: var(--warm); border-color: var(--warm); color: #fff; text-decoration: none; }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.button.ghost:hover { border-color: var(--warm); color: var(--warm); background: transparent; }

/* What it costs: a short list of prices */
.deal {
  list-style: none;
  padding: 0;
  display: grid;
  gap: .75rem;
}
@media (min-width: 40rem) { .deal { grid-template-columns: 1fr 1fr; } }
.deal li {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 1rem;
}
.deal .price {
  display: block;
  font: 700 1.6rem/1.1 var(--serif);
  color: var(--ink);
  margin-bottom: .3rem;
}
.deal .price.free { color: var(--cool); }

/* The path: the eight chapters as a numbered track */
ol.path {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  counter-reset: ch;
  border-left: 2px solid var(--line);
  margin-left: .85rem;
}
ol.path > li {
  counter-increment: ch;
  position: relative;
  margin: 0;
  padding: .55rem 0 .85rem 1.6rem;
}
ol.path > li::before {
  content: counter(ch);
  position: absolute;
  left: -.85rem; top: .7rem;
  width: 1.6rem; height: 1.6rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--line-2);
  font: 700 .8rem/1 var(--sans);
  color: var(--ink-2);
}
ol.path > li:first-child::before { background: var(--warm-bright); border-color: var(--warm-bright); color: #fff; }
ol.path > li.is-done::before { background: var(--cool); border-color: var(--cool); color: var(--bg); }
ol.path a {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 650;
  color: var(--ink);
  text-decoration: none;
}
ol.path a:hover { color: var(--warm); }
ol.path p { margin: .1rem 0 0; color: var(--muted); font-size: .98rem; }

/* A small preview of the project cards on the landing page */
.peek {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.peek li {
  display: flex;
  align-items: baseline;
  gap: .9rem;
  margin: 0;
  padding: .8rem 1.1rem;
  border-top: 1px solid var(--line);
  font-size: 1rem;
}
.peek li:first-child { border-top: 0; }
.peek .stars { flex: 0 0 3.2rem; }
.peek b { font-family: var(--serif); font-size: 1.1rem; }

.first-win {
  margin: 1.5rem 0;
  padding: 1.5rem 1.1rem .5rem;
  border-radius: calc(var(--radius) + 4px);
  background: var(--warm-soft);
  border: 1px solid color-mix(in srgb, var(--warm) 25%, transparent);
}
@media (max-width: 39.99rem) {     /* full bleed on phones so the steps inside get the width */
  .first-win { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); border-radius: 0; border-left: 0; border-right: 0; padding-left: var(--gutter); padding-right: var(--gutter); }
}
@media (min-width: 40rem) { .first-win { padding: 2rem 1.75rem .75rem; } }
.first-win > h2:first-child { margin-top: 0; }
.first-win .brief { background: var(--surface); }
.demo {
  margin: 1.25rem 0 1.5rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.demo canvas {
  display: block; width: 100%; aspect-ratio: 16 / 10;
  touch-action: none; cursor: pointer; outline-offset: -3px;
}
.demo .demo-cap { margin: 0; padding: .7rem 1rem; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }

/* 7. Motion and print -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
  ul.cards > li:hover { transform: none; }
}

@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --sunk: #f4f4f4; --ink: #000; --ink-2: #222; --muted: #444;
    --line: #ccc; --line-2: #999; --code-bg: #f4f4f4; --code-ink: #000; --code-bar: #e8e8e8;
    --warm: #000; --cool: #000; --cool-soft: #fff; --warm-soft: #fff; --danger-soft: #fff;
  }
  body { font-size: 11pt; display: block; }
  .top nav, .theme, .copy, .done-toggle, [data-done], nav.pager, .skip, .hero-actions { display: none !important; }
  .page { max-width: none; padding: 0; }
  pre, pre code { white-space: pre-wrap; overflow: visible; }
  pre, .code, aside, .brief, ul.cards > li { break-inside: avoid; box-shadow: none; }
  .tabs > button { display: none !important; }
  .tabs > section, .tabs > section[hidden] { display: block !important; border: 0; padding: 0; }
  .tabs > section > :is(h3, h4, h5):first-child { display: block !important; }
  a { color: #000; }
  .page a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; color: #444; }
  ul.cards h3 a::after { content: none; }
}

/* briefs are prose: wrap on phones */
.brief pre, .brief pre code { white-space: pre-wrap; overflow-wrap: anywhere; }

/* 9. Contents panel (built by site.js from the h2s). On a wide screen it sits
   to the right of the text column and can be folded to a tab. On narrower
   screens it is a folded list under the lead. */
.contents { font-size: .9rem; }
.contents ol { list-style: none; margin: 0; padding: 0; }
.contents li { margin: 0; padding: 0; }
.contents a {
  display: block; padding: .28rem .6rem; color: var(--muted); text-decoration: none;
  border-left: 2px solid var(--line); line-height: 1.35;
}
.contents a:hover { color: var(--ink); }
.contents a.is-here { color: var(--ink); border-left-color: var(--warm-bright); }
.contents .contents-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  margin: 0 0 .5rem; font-family: var(--sans, inherit); font-size: .78rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.contents button {
  font: inherit; color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: .1rem .55rem; cursor: pointer; line-height: 1.4;
}
.contents button:hover { color: var(--ink); border-color: var(--line-2); }
details.contents { margin: 0 0 1.6rem; }
details.contents summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.contents[open] summary { margin-bottom: .5rem; }
details.contents ol { margin-left: .2rem; }

@media (min-width: 80rem) {
  details.contents { display: none; }
  aside.contents {
    position: fixed; top: 6.5rem;
    left: calc(50% + 22rem + var(--gutter) + 2.5rem);
    width: 14rem; max-height: calc(100vh - 8rem); overflow: auto;
  }
  aside.contents.is-folded { width: auto; }
  aside.contents.is-folded ol, aside.contents.is-folded .contents-head span { display: none; }
  aside.contents.is-folded .contents-head { margin: 0; }
}
@media (max-width: 79.99rem) { aside.contents { display: none; } }
@media print { .contents { display: none !important; } }

/* 10. Site navigation (built by site.js from /js/nav.js). On a wide screen it
   is a column to the left of the text; otherwise the Menu button in the
   header opens it as a drawer. */
nav.side { font-size: .9rem; }
nav.side .side-group + .side-group { margin-top: 1.4rem; }
nav.side .side-head {
  display: block; margin: 0 0 .4rem; padding: 0 .5rem;
  font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
}
nav.side .side-head:hover, nav.side .side-head[aria-current] { color: var(--ink); }
nav.side ol { list-style: none; margin: 0; padding: 0; }
nav.side li { margin: 0; padding: 0; }
nav.side li a {
  display: flex; align-items: baseline; gap: .45rem;
  padding: .3rem .5rem; border-radius: var(--radius-s);
  color: var(--ink-2); text-decoration: none; line-height: 1.35;
}
nav.side li a:hover { color: var(--ink); background: var(--sunk); }
nav.side li a[aria-current] { color: var(--ink); background: var(--sunk); font-weight: 600; }
nav.side .side-n { flex: 0 0 1.1rem; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
nav.side .side-stars { margin-left: auto; font-size: .75rem; color: var(--muted); letter-spacing: .05em; font-family: "Segoe UI Symbol","Apple Symbols","Noto Sans Symbols2","DejaVu Sans",system-ui,sans-serif; }
nav.side li.is-done > a::after { content: "\2713"; margin-left: auto; color: var(--cool); font-weight: 700; }
nav.side li.is-done > a .side-stars { margin-left: auto; }
nav.side li.is-done > a .side-stars + ::after, nav.side li.is-done > a:has(.side-stars)::after { margin-left: .4rem; }

@media (min-width: 80rem) {
  nav.side {
    position: fixed; top: 6.5rem;
    left: calc(50% - 22rem - var(--gutter) - 2.5rem - 13rem);
    width: 13rem; max-height: calc(100vh - 8rem); overflow: auto;
  }
}
@media (max-width: 79.99rem) {
  nav.side { display: none; }
  html.menu-open nav.side {
    display: block; position: fixed; z-index: 30;
    top: 4.25rem; bottom: 0; left: 0; width: min(20rem, 100%);
    padding: 1rem var(--gutter) 2rem; overflow: auto;
    background: var(--surface); border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
}
@media print { nav.side, nav.pagerow, .menu { display: none !important; } }
