/* Light theme. All theme colours are declared here; widget internals are untouched. */
:root {
  --paper: #fffdf8;
  --surface: #ffffff;
  --ink: #28251f;
  --muted: #655f56;
  --rule: #d8d1c5;
  --accent: #974323;
  --band: #f3ede1;
  --clear: transparent;
  --shadow: #28251f12;
  --max: 850px;
  --heading: Georgia, 'Times New Roman', serif;
  --body: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
* { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 17px/1.7 var(--body); }
.site-nav, .home-page > .masthead, .home-page > main, footer { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.site-nav { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-block: 22px; border-bottom: 1px solid var(--rule); font-size: 14px; }
.site-nav .brand { color: var(--ink); font-weight: 600; text-decoration: none; }
.site-nav .nav-links { display: flex; flex-wrap: wrap; gap: 24px; }
.site-nav a, .home-page main a, footer a, .paper a, .credits a { color: var(--accent); text-underline-offset: 4px; }
.site-nav a:hover, footer a:hover { text-decoration-thickness: 2px; }
.masthead h1 { font-family: var(--heading); font-weight: 400; letter-spacing: -.04em; line-height: 1.05; margin: 0; overflow-wrap: anywhere; }
.kicker { margin: 0 0 22px; color: var(--accent); font: 600 11px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.home-page > .masthead { padding-block: 64px 52px; }
.home-page .masthead h1 { font-size: clamp(48px, 6.5vw, 88px); max-width: 900px; }
.lead { max-width: 650px; margin: 26px 0 24px; font-size: 21px; line-height: 1.5; }
.hero-link, .go { font: 600 12px/1.5 var(--mono); text-decoration: none; color: var(--accent); }
.hero-link { display: inline-block; padding-block: 12px; border-bottom: 1px solid var(--accent); }
.home-page main > section { margin-bottom: 52px; }
.home-page h2 { font-family: var(--heading); font-size: 32px; font-weight: 400; letter-spacing: -.02em; margin: 0 0 24px; line-height: 1.2; }
.section-head { display: flex; justify-content: space-between; gap: 20px; align-items: baseline; border-top: 2px solid var(--ink); padding-top: 20px; }
.section-head .kicker { margin: 0; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 24px; }
.card { position: relative; min-width: 0; background: var(--surface); border: 1px solid var(--rule); }
.card .thumb { display: block; width: 100%; height: 100%; object-fit: contain; background: var(--band); }
.card .thumb-empty { min-height: 180px; }
.card-body { padding: 32px; min-width: 0; }
.card h3 { font: 400 30px/1.18 var(--heading); letter-spacing: -.02em; margin: 0 0 18px; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a::after { content: ''; position: absolute; inset: 0; }
.card .paper a { position: relative; z-index: 1; }
.card .blurb { font-size: 16px; line-height: 1.65; margin: 18px 0; }
.card .go { display: inline-block; position: relative; z-index: 1; padding-block: 10px; }
.card:hover, .card:focus-within { background: var(--band); border-color: var(--accent); }
.card:hover .go { text-decoration: underline; text-underline-offset: 4px; }
.home-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 64px; border-top: 1px solid var(--rule); padding-top: 36px; }
.home-lower p { margin-top: 0; }
.home-page #how ul { padding-left: 22px; }
.home-page #how li { margin-bottom: 14px; }
.home-page #contact { border-top: 1px solid var(--rule); padding-top: 32px; max-width: 740px; }
.btn { display: inline-block; padding: 12px 20px; border: 1px solid var(--accent); color: var(--accent); font: 600 12px/1.6 var(--mono); text-decoration: none; }
.home-page main .btn.fill { background: var(--accent); color: var(--surface); }
footer { margin-block: 60px 32px; padding-top: 24px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; }
/* Keep the lesson header aligned to its article, allowing a separate contents rail. */
.lesson-page > .masthead { max-width: 1160px; margin-inline: auto; padding: 52px 300px 34px 24px; border-bottom: 1px solid var(--rule); }
.lesson-page .masthead h1 { font-size: clamp(34px, 4vw, 52px); }
.kicker a.home { color: var(--accent); text-decoration: none; }
.byline, .paper, .muted { color: var(--muted); font-size: 14px; line-height: 1.6; }
.byline { margin: 22px 0 12px; }
.paper { margin: 8px 0; overflow-wrap: anywhere; }
.layout { max-width: 1160px; margin-inline: auto; }
.layout main { min-width: 0; padding: 0 24px; }
.layout main > section { margin: 0 0 40px; }
.layout main > section > h2 { font: 400 30px/1.25 var(--heading); letter-spacing: -.025em; margin: 48px 0 18px; scroll-margin-top: 24px; }
.layout main > section > p { margin: 14px 0; }
.layout main > section > details { border: 1px solid var(--rule); background: var(--surface); padding: 12px 16px; margin: 10px 0; border-radius: 4px; }
.layout main > section > details > summary { cursor: pointer; font-weight: 600; line-height: 1.5; }
.pre-body { padding: 8px 0 4px; }
.widget { margin: 30px 0 40px; min-width: 0; }
.layout main > section > p code { font-family: var(--mono); font-size: .85em; padding: 2px 4px; background: var(--band); }
.credits { padding-left: 24px; font-size: 14px; }
.credits li { margin-bottom: 12px; }
.rights { color: var(--muted); font-size: 13px; }
.rights a { color: var(--accent); }
.toc { margin: 24px; font-size: 13px; }
.toc-toggle { min-height: 44px; padding: 10px 14px; border: 1px solid var(--rule); background: var(--surface); color: var(--accent); cursor: pointer; font: 600 11px/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.toc-list { list-style: none; padding: 0; margin: 16px 0 0; border-left: 1px solid var(--rule); }
.toc-list a { display: block; padding: 8px 12px; border-left: 2px solid var(--clear); margin-left: -1px; color: var(--muted); text-decoration: none; line-height: 1.45; }
.toc-list a:hover { color: var(--ink); background: var(--band); }
.toc-list a.current { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc.closed .toc-list { display: none; }
.lesson-page > noscript > p { max-width: 1160px; padding: 24px; margin-inline: auto; }
/* Navigation styles never select inside an interactive figure. */
.site-nav a:focus-visible, .hero-link:focus-visible, .card a:focus-visible, .btn:focus-visible, .toc a:focus-visible, .toc-toggle:focus-visible, .layout main > section > details > summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
@media (min-width: 1100px) {
 .layout { display: grid; grid-template-columns: minmax(0, 860px) 260px; gap: 40px; align-items: start; }
 .toc { order: 2; position: sticky; top: 24px; margin: 48px 24px 0 0; max-height: calc(100vh - 48px); overflow: auto; }
}
@media (max-width: 1099px) {
 .lesson-page > .masthead { max-width: var(--max); padding: 40px 24px 28px; }
 .layout { max-width: var(--max); }
}
@media (max-width: 640px) {
 body { font-size: 16px; }
 .site-nav, .home-page > .masthead, .home-page > main, footer { width: calc(100% - 40px); }
 .site-nav { gap: 12px; font-size: 12px; padding-block: 16px; }
 .site-nav .nav-links { gap: 14px; }
 .home-page > .masthead { padding-block: 40px 36px; }
 .home-page .masthead h1 { font-size: 52px; }
 .lead { font-size: 18px; margin-block: 20px; }
 .home-page h2 { font-size: 28px; }
 .section-head { display: block; }
 .section-head .kicker { margin-bottom: 16px; }
 .card-body { padding: 22px; }
 .card h3 { font-size: 27px; }
 .home-lower { grid-template-columns: 1fr; gap: 32px; }
 .lesson-page > .masthead { padding: 32px 20px 24px; }
 .lesson-page .masthead h1 { font-size: 34px; }
 .layout main { padding-inline: 20px; }
 .layout main > section > h2 { font-size: 26px; margin-top: 36px; }
 .toc { margin: 20px; }
 .widget { margin-block: 24px 32px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
/* A — Editorial: a broad feature and quiet serif reading rhythm. */
.card { display: grid; grid-template-columns: 46% 1fr; }
.card .thumb { border-right: 1px solid var(--rule); }
.home-page .masthead h1 { max-width: 720px; }
.home-page .masthead { position: relative; }
/* Multiple lessons use boxed cards; a lone lesson retains the broad feature. */
@media (min-width: 900px) {
 .cards:has(> li:nth-child(2)) { grid-template-columns: 1fr 1fr; }
 .cards:has(> li:nth-child(2)) > .card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
 .cards:has(> li:nth-child(2)) > .card .thumb { height: auto; aspect-ratio: 16/9; border-right: 0; border-bottom: 1px solid var(--rule); }
}
/* Phones: the thumbnail gets its own auto-height row. height: 100% on the image (line 39) let iOS Safari collapse the row and paint the image over the card text (owner 2026-10-23, iPhone screenshot). */
@media (max-width: 640px) { .card { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .card .thumb { height: auto; aspect-ratio: 16/9; border-right: 0; border-bottom: 1px solid var(--rule); } }
/* The rights page shares the editorial type and comfortable reading measure. */
.rights-page > .masthead, .rights-page > main { width: min(var(--max), calc(100% - 40px)); margin-inline: auto; }
.rights-page > .masthead { padding-block: 52px 28px; border-bottom: 1px solid var(--rule); }
.rights-page .masthead h1 { font-size: clamp(34px, 4vw, 52px); }
.rights-page main > section { margin-block: 36px; }
.rights-page h2 { font: 400 28px/1.25 var(--heading); }
.rights-page main a { color: var(--accent); overflow-wrap: anywhere; }
/* Figures keep a readable drawing width on phones and scroll sideways inside their card. Only the kit's drawing (the svg whose id ends in -svg) gets the minimum width; the card, controls and caption still wrap. */
@media (max-width: 700px) {
  .widget svg[id$="-svg"] { min-width: 680px; display: block; }
  .widget div:has(> svg[id$="-svg"]) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Page navigation and prose focus; figure internals retain their own styles. */
:where(a, button, summary, [tabindex]):not(.widget *):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
.skip-link {
  position: absolute;
  left: 20px;
  top: 12px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--surface);
  color: var(--accent);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.home-page main, footer { overflow-wrap: anywhere; }
/* Keep oversized figures within the page without changing their contents. */
.widget { max-width: 100%; overflow-x: auto; }
/* The shared runtime sets an inline outline:none on the focusable container. */
.widget:focus-visible { outline: 3px solid var(--accent) !important; outline-offset: 4px; }

/* Lesson tabs and tag filter (publish-spec §7.9) */
.card[hidden] { display: none; }
.lesson-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.tab, .ft-clear { font: 600 12px/1.5 var(--mono); padding: 8px 14px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.ft-clear { padding: 4px 10px; margin-left: 6px; }
.filter-status { margin: 0 0 20px; font-size: 14px; color: var(--muted); }
.card .tags { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; position: relative; z-index: 1; }
.tag { font: 500 11px/1.4 var(--mono); padding: 4px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer; }
.tag:hover, .tag[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.tab:focus-visible, .tag:focus-visible, .ft-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* code listings scroll inside their own box on narrow screens (dis-c-memory review R3, 2026-10-28) */
.lesson-page main pre { max-width: 100%; overflow-x: auto; box-sizing: border-box; }
/* Depth label, Brief and Deep (publish-spec §7.13) */
.card-depth, .depth-line { margin: 0 0 12px; color: var(--muted); font: 500 11px/1.6 var(--mono); letter-spacing: .06em; }
.card-depth { text-transform: uppercase; }
.depth-line .depth { text-transform: uppercase; }
.depth-line a { color: var(--accent); text-underline-offset: 4px; }
.depth-tabs { margin-top: -8px; }
.cards > .card.card-plain { grid-template-columns: 1fr; grid-template-rows: auto; }
#brief a, #close a { color: var(--accent); text-underline-offset: 4px; }
/* Upcoming lessons, announced by heading only (publish-spec §7.13) */
.soon { margin-top: 40px; border-top: 1px solid var(--rule); padding-top: 24px; }
.soon[hidden] { display: none; }
.directory .cards.soon-list { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.directory .cards.soon-list > .card { grid-template-columns: 1fr; grid-template-rows: auto; }
.card-soon .card-body { padding: 20px; }
.card-soon h3 { font-size: 21px; margin: 0 0 8px; }
.card-soon .card-depth { margin-bottom: 8px; }
.card-soon .paper { margin: 0; }
.card.card-soon:hover { background: var(--surface); border-color: var(--rule); }

/* Wide home page (owner 2026-11-11): the home page covers more of the screen and the lesson directory has three
   columns, four on wide screens. Lesson and rights pages keep their reading width. */
@media (min-width: 641px) {
 .home-page > .site-nav, .home-page > .masthead, .home-page > main, .home-page > footer { width: min(1560px, calc(100% - 64px)); }
}
@media (min-width: 900px) {
 .cards:has(> li:nth-child(2)) > .card:not(.card-soon) h3 { font-size: 24px; }
 .cards:has(> li:nth-child(2)) > .card:not(.card-soon) .card-body { padding: 24px; }
}
@media (min-width: 1200px) { .cards:has(> li:nth-child(2)) { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1560px) { .cards:has(> li:nth-child(2)) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* Card sizes: large spans two columns (a course or a first lesson), small is a compact card (a tool). */
@media (min-width: 641px) { .cards > .card.card-lg { grid-column: span 2; } }
.card-soon.card-lg h3 { font-size: 26px; }
.card-soon.card-lg .paper { font-size: 15px; margin-top: 8px; }
.cards > .card.card-sm .card-body { padding: 16px; }
.cards > .card.card-sm h3 { font-size: 19px; }
/* Slogan under the site name, the icon beside the name in the navigation, and a heading above a group of stages. */
.slogan { margin: 20px 0 0; color: var(--accent); font: italic 400 clamp(22px, 2.4vw, 30px)/1.3 var(--heading); }
.brand-mark { width: 28px; height: 28px; margin-right: 10px; vertical-align: middle; }
.group-head { margin: 0 0 20px; font: 400 26px/1.25 var(--heading); letter-spacing: -.02em; }
/* A stage's ready lessons sit above its coming-soon headings with the same gap as between cards. */
.stage .cards + .cards { margin-top: 16px; }
