/* ==========================================================================
   site.css

   1. Tokens        5. Hero and field     9.  Footer and icons     13. Motion
   2. Base          6. Sections           10. Pages and write-ups
   3. Marks         7. Lists and cards    11. Art
   4. Header        8. About              12. The rectangle game

   The one recurring gesture: a point opens sideways out of a hairline (scaleX 0 -> 1).
   The field does it to blacked-out lattice points; the nav, list rows and the proof
   tombstone do it to their own small marks.
   ========================================================================== */


/* 1. Tokens
   ========================================================================== */

:root {
  --font-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* The statement, titles and headings. Switched by data-type on <html>. */
  --font-display: var(--font-sans);
  --display-weight: 500;
  --display-tracking: -0.022em;
  --display-scale: 1;

  --step--1: clamp(0.72rem, 0.7rem + 0.1vw, 0.8rem);
  --step-0: clamp(1rem, 0.97rem + 0.14vw, 1.0625rem);
  --step-1: clamp(1.2rem, 1.12rem + 0.4vw, 1.45rem);
  --step-2: clamp(1.5rem, 1.3rem + 0.9vw, 2.1rem);
  --step-3: clamp(1.7rem, 1rem + 2vw, 3.75rem);
  --step-4: clamp(2.1rem, 1.2rem + 3.4vw, 5rem);

  --gutter: clamp(1.25rem, 4vw, 6rem);
  --header-h: 4.5rem;
  --measure: 40rem;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bloom: cubic-bezier(0.7, 0, 0.2, 1);

  /* Dark is the default. */
  color-scheme: dark;
  --bg: #1d1e21;
  --bg-raise: #26272b;
  --fg: #f3f1ec;
  --fg-2: #b4b1aa;
  --fg-3: #85837c;
  --rule: rgb(243 241 236 / 0.13);
  --mark: #2f5bff;
  --accent-text: #8ea5ff;

  /* The lattice: the colour of its tiles and hairlines. */
  --lat-ink: #f3f1ec;
  --mark-2: #7aa2ff;        /* a second colour, for the other rectangle of a confusable pair */
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f0e9;
  --bg-raise: #e9e5dc;
  --fg: #17181c;
  --fg-2: #55544f;
  --fg-3: #716f69;
  --rule: rgb(23 24 28 / 0.15);
  --mark: #2446e8;
  --accent-text: #1f3bcc;
  --lat-ink: #17181c;
  --mark-2: #2446e8;
}

:root[data-accent="cobalt"] { --mark-2: #ff8d73; }
:root[data-accent="cobalt"][data-theme="light"] { --mark-2: #bf3410; }
:root[data-accent="vermilion"] { --mark: #ff5533; --accent-text: #ff8d73; }
:root[data-accent="vermilion"][data-theme="light"] { --mark: #ea4320; --accent-text: #bf3410; }
:root[data-accent="amber"] { --mark: #f2b13a; --accent-text: #f5c466; }
:root[data-accent="amber"][data-theme="light"] { --mark: #e0a019; --accent-text: #8a5a00; }
:root[data-accent="jade"] { --mark: #2ecf8f; --accent-text: #5fe0ab; }
:root[data-accent="jade"][data-theme="light"] { --mark: #10a36a; --accent-text: #0a7a4e; }
:root[data-accent="chalk"] { --mark: #e8e4da; --accent-text: #f3f1ec; }
:root[data-accent="chalk"][data-theme="light"] { --mark: #1b1c20; --accent-text: #17181c; }

/* ------------------------------------------------------------------ higher contrast
   --fg-3 is deliberately quiet: it carries captions, figure ticks, table headers and the rank
   gutters. At the default weight it sits near the AA floor, so when the reader has asked their
   system for more contrast the quiet greys move toward the foreground, rules firm up, and the
   decorative fades that carry no information are dropped. Only the tokens change, so every
   figure and canvas follows without knowing about it. */
@media (prefers-contrast: more) {
  :root {
    --fg-2: #ddd9d1;
    --fg-3: #b9b5ac;
    --rule: rgb(243 241 236 / 0.34);
    --accent-text: #b9c8ff;
  }
  :root[data-theme="light"] {
    --fg-2: #33342f;
    --fg-3: #46453f;
    --rule: rgb(23 24 28 / 0.38);
    --accent-text: #132a9e;
  }
  .fg__grid path { opacity: 0.9; }
  .tile--ghost { opacity: 0.6; }
  .field, .band { opacity: 0.45; }
  .lede .statement, .section__note, .row__desc, .problem__ask { color: var(--fg); }
  a, .link { text-decoration-thickness: 2px; }
  :focus-visible { outline-width: 3px; }
}

/* Some browsers expose the opposite preference. Honour it rather than ignoring it. */
@media (prefers-contrast: less) {
  :root { --fg-2: #a09d96; --fg-3: #77756f; }
}

:root[data-type="serif"] {
  --font-display: var(--font-serif);
  --display-weight: 400;
  --display-tracking: -0.018em;
  --display-scale: 1.08;
}


/* 2. Base
   ========================================================================== */

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

html {
  /* Everything is sized in rem, so on very large displays the whole page scales up with the field. */
  font-size: clamp(100%, 62.5% + 0.42vw, 131.25%);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--step-0)/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s, color 0.4s;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul[class], ol[class] { padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

::selection { background: var(--mark); color: #fff; }
:root[data-accent="chalk"] ::selection, :root[data-accent="amber"] ::selection { color: #17181c; }
:root[data-accent="chalk"][data-theme="light"] ::selection { color: #f3f0e9; }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: fixed; top: 0.75rem; left: 0.75rem; z-index: 100;
  padding: 0.6rem 0.9rem; border-radius: 6px;
  background: var(--fg); color: var(--bg); font-weight: 500;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

.mono, .label {
  font: 400 var(--step--1)/1.5 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.label { color: var(--fg-2); }

.link {
  text-decoration: underline;
  text-decoration-color: var(--mark);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
  transition: color 0.2s;
}
.link:hover { color: var(--accent-text); }


/* 3. Marks
   ========================================================================== */

/* A disc squeezed until it reads as a hairline. Opening it is the site's one gesture. */
.mark {
  display: inline-block;
  width: 0.6em; height: 0.6em;
  border-radius: 50%;
  background: var(--mark);
  transform: scaleX(0.14);
  transition: transform 0.45s var(--ease-bloom);
}
.mark.is-open { transform: none; }

/* A short run of marks spelling something in ASCII. Filled in by site.js. */
.bitstrip { display: inline-flex; gap: 3px; align-items: center; }
.bitstrip i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--mark);
  transform: scaleX(0.16);
  transition: transform 0.5s var(--ease-bloom);
  transition-delay: calc(var(--k, 0) * 22ms + 150ms);
}
.is-in .bitstrip i.o, .bitstrip.is-in i.o { transform: none; }


/* 4. Header
   ========================================================================== */

.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--header-h);
  padding: 0 var(--gutter);
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
}
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  transition: opacity 0.3s;
}
.site-header.is-stuck::before { opacity: 1; }

.brand { display: inline-flex; align-items: center; gap: 0.7rem; font-weight: 500; letter-spacing: -0.01em; }
.brand__mark { width: 1.25rem; height: 1.25rem; color: var(--mark); flex: none; }

.nav { display: flex; align-items: center; gap: clamp(0.7rem, 1.8vw, 1.6rem); }
.nav a {
  position: relative;
  padding: 0.4rem 0 0.4rem 0.95rem;
  font-size: 0.94rem; font-weight: 500;
  color: var(--fg-2);
  transition: color 0.2s;
}
.nav a::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 0.56rem; height: 0.56rem; margin-top: -0.28rem;
  border-radius: 50%;
  background: var(--mark);
  transform: scaleX(0.14);
  transition: transform 0.4s var(--ease-bloom);
}
.nav a:hover, .nav a[aria-current] { color: var(--fg); }
.nav a:hover::before, .nav a[aria-current]::before { transform: none; }

/* The GitHub mark in the header, sized to sit level with the nav links. */
.nav__icon {
  display: grid; place-items: center;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  color: var(--fg-2);
  transition: color 0.2s, background-color 0.2s;
}
.nav__icon svg { width: 1.1rem; height: 1.1rem; }
.nav__icon:hover { color: var(--fg); background: var(--rule); }
.nav__icon:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.theme-toggle {
  all: unset; box-sizing: border-box; cursor: pointer;
  width: 2rem; height: 2rem; display: grid; place-items: center;
  border-radius: 50%; color: var(--fg-2);
  transition: color 0.2s, background-color 0.2s;
}
.theme-toggle:hover { color: var(--fg); background: var(--rule); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.theme-toggle svg { width: 1rem; height: 1rem; transition: transform 0.5s var(--ease-out); }
:root[data-theme="light"] .theme-toggle svg { transform: rotate(180deg); }

@media (max-width: 720px) {
  .brand__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .nav { gap: 0.8rem; }
  .nav a { padding-left: 0; font-size: 0.86rem; }
  .nav a::before { display: none; }
  .nav a[aria-current] { text-decoration: underline; text-decoration-color: var(--mark); text-underline-offset: 0.3em; text-decoration-thickness: 2px; }
  .theme-toggle { width: 1.7rem; height: 1.7rem; }
}


/* 5. Hero and field
   ========================================================================== */

/* The field is pinned to the viewport for the length of .stage while the text scrolls over it. */
.stage { position: relative; }

.field {
  position: sticky; top: 0; z-index: 0;
  height: 100vh; height: 100svh;
  margin-bottom: -100vh; margin-bottom: -100svh;
  padding: var(--header-h) var(--gutter) 0;
  pointer-events: none;
}
.field canvas { width: 100%; height: 100%; }

.hero {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100svh;
  padding: calc(var(--header-h) + 2rem) var(--gutter) clamp(1.75rem, 5.5vh, 3.25rem);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: clamp(1rem, 2.5vh, 1.6rem);
}

.statement {
  max-width: 23ch;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: calc(var(--step-3) * var(--display-scale));
  line-height: 1.14;
  letter-spacing: var(--display-tracking);
  text-wrap: balance;
}

.fig {
  max-width: 40rem;
  font: 400 var(--step--1)/1.6 var(--font-mono);
  letter-spacing: 0.02em;
  color: var(--fg-2);
}
.fig b { margin-right: 0.6em; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg); }

.lede {
  position: relative; z-index: 1;
  padding: clamp(1.5rem, 5vh, 3.5rem) var(--gutter) clamp(5rem, 18vh, 11rem);
  display: grid; gap: 1.15em;
  font-size: calc(var(--step-3) * var(--display-scale));
}
.lede .statement { max-width: 27ch; color: var(--fg-2); }
.lede .statement strong { font-weight: inherit; color: var(--fg); }



/* 6. Sections
   ========================================================================== */

main { position: relative; z-index: 2; background: var(--bg); transition: background-color 0.4s; }

.section { padding: clamp(3.5rem, 9vh, 6.5rem) var(--gutter) 0; }
.section:last-child { padding-bottom: clamp(2rem, 6vh, 4rem); }

.section__head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
}
.section__head h2 { font: 500 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.section__head h2 span { color: var(--fg-3); margin-right: 0.9em; }

.section__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
  gap: 2rem var(--gutter);
  padding-top: clamp(2rem, 5vh, 3.5rem);
}
.section__note { max-width: 26ch; color: var(--fg-2); }

@media (max-width: 860px) {
  .section__body { grid-template-columns: minmax(0, 1fr); }
  .section__note { max-width: 46ch; }
}


/* 7. Lists and cards
   ========================================================================== */

.rows { border-top: 1px solid var(--rule); }

.row { border-bottom: 1px solid var(--rule); }
.row > a, .row > div {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr) auto;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  padding: 1.4rem 0;
}
.row__n { display: flex; align-items: baseline; gap: 0.55rem; font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; color: var(--fg-3); }
.row__title {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: var(--step-1);
  line-height: 1.25;
  letter-spacing: -0.012em;
  transition: transform 0.45s var(--ease-out);
}
/* A row with a description has 4 children, not 3, so the description is placed under the title
   rather than being auto-flowed into the meta column. */
.row__desc { grid-column: 2; grid-row: 2; margin-top: 0.4rem; max-width: 58ch; color: var(--fg-2); }
.row__desc ~ .row__meta { grid-column: 3; grid-row: 1; }
.row__meta { font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); text-align: right; white-space: nowrap; }
.row__meta em { font-style: normal; color: var(--fg-2); }

.row > a:hover .mark, .row > a:focus-visible .mark { transform: none; }
.row > a:hover .row__title { transform: translateX(0.35rem); }
.row > a:hover .row__n { color: var(--fg-2); }

.rows--compact .row > a, .rows--compact .row > div { grid-template-columns: 7.5rem minmax(0, 1fr) auto; padding: 1.05rem 0; }
.rows--compact .row__title { font-size: var(--step-0); font-family: var(--font-sans); font-weight: 500; letter-spacing: 0; }

@media (max-width: 640px) {
  .row > a, .row > div, .rows--compact .row > a, .rows--compact .row > div { grid-template-columns: 2.6rem minmax(0, 1fr); }
  .rows--compact .row > a, .rows--compact .row > div { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .row__meta { grid-column: 2; text-align: left; }
  .rows--compact .row__meta { grid-column: 1; }
  /* One column on a phone, so everything stacks and the explicit placement above must go. */
  .row__desc, .row__desc ~ .row__meta { grid-column: auto; grid-row: auto; }
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 2.25rem var(--gutter); }
.card { display: grid; gap: 0.7rem; align-content: start; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.card h3 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-1); line-height: 1.25; letter-spacing: -0.012em; }
.card p { color: var(--fg-2); }

.status { display: inline-flex; align-items: center; gap: 0.55rem; font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2); }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.85rem; }
.tags li { padding: 0.12rem 0.6rem; border: 1px solid var(--rule); border-radius: 999px; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-2); }


/* 8. About
   ========================================================================== */

.about { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2.5rem var(--gutter); }
/* On the home page the same block sits inside a section body, which is already a column, so the
   prose and the facts stack instead of sitting side by side. */
.about--inline { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
.about--inline .about__text { max-width: 44ch; }
.about__text { display: grid; gap: 1.1em; max-width: 34em; font-size: var(--step-1); line-height: 1.45; letter-spacing: -0.008em; }
.about__text p + p { color: var(--fg-2); }

.facts { display: grid; align-content: start; }
.facts > div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 1rem; padding: 0.85rem 0; border-top: 1px solid var(--rule); }
.facts > div:last-child { border-bottom: 1px solid var(--rule); }
.facts dt { font: 400 var(--step--1)/1.9 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.facts dd { color: var(--fg-2); }
.facts dd strong { font-weight: 500; color: var(--fg); }

@media (max-width: 860px) { .about { grid-template-columns: minmax(0, 1fr); } }


/* 9. Footer and icons
   ========================================================================== */

.site-footer { position: relative; z-index: 2; background: var(--bg); padding: clamp(4rem, 12vh, 8rem) var(--gutter) 2rem; transition: background-color 0.4s; }

.contact { display: grid; gap: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.contact__line {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: calc(clamp(1.45rem, 0.7rem + 3.4vw, 4.25rem) * var(--display-scale));
  line-height: 1.1;
  letter-spacing: calc(var(--display-tracking) * 1.3);
  overflow-wrap: anywhere;
}
.contact__line a { background: linear-gradient(var(--mark), var(--mark)) 0 100% / 100% 2px no-repeat; padding-bottom: 0.06em; transition: color 0.25s; }
.contact__line a:hover { color: var(--accent-text); }

/* Logos rather than words. Filled in by chrome.js. */
.icons { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.icon {
  display: grid; place-items: center;
  min-width: 2.75rem; height: 2.75rem; padding: 0 0.7rem;
  border: 1px solid var(--rule); border-radius: 999px;
  color: var(--fg-2);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s, transform 0.4s var(--ease-out);
}
.icon svg { width: 1.3rem; height: 1.3rem; }
.icon__word { font: 500 0.78rem/1 var(--font-mono); letter-spacing: 0.1em; }
.icon:hover { color: var(--bg); background: var(--fg); border-color: var(--fg); transform: translateY(-2px); }

.colophon {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 2rem;
  margin-top: clamp(4rem, 12vh, 7rem);
  font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-3);
}
.colophon button { all: unset; cursor: pointer; color: var(--fg-2); transition: color 0.2s; }
.colophon button:hover { color: var(--fg); }
.colophon button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; }


/* 10. Pages and write-ups
   ========================================================================== */

/* A short field across the top, in place of the home page's full-height one. */
.band { height: clamp(7rem, 19vh, 12rem); margin-top: var(--header-h); padding: 0 var(--gutter); pointer-events: none; }
.band canvas { width: 100%; height: 100%; }

.article, .page { position: relative; z-index: 2; padding: clamp(1.5rem, 4vh, 3rem) var(--gutter) 0; }
.page--plain { padding-top: calc(var(--header-h) + clamp(2rem, 7vh, 5rem)); }      /* a page with no band above it */
.page > .section, .article > .section { padding-inline: 0; }

.article__head, .page-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 1.5rem var(--gutter); padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.article__title, .page-title {
  max-width: 18ch;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: calc(var(--step-4) * var(--display-scale));
  line-height: 1.04;
  letter-spacing: calc(var(--display-tracking) * 1.3);
  text-wrap: balance;
}
.article__summary, .page-summary { margin-top: 1.5rem; max-width: 34em; font-size: var(--step-1); line-height: 1.45; color: var(--fg-2); }

.article__body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 2.5rem var(--gutter); padding-top: clamp(2.5rem, 7vh, 4.5rem); }
.article__aside { align-self: start; position: sticky; top: calc(var(--header-h) + 1.5rem); display: grid; gap: 1.75rem; }
.article__aside .facts > div { grid-template-columns: 5rem minmax(0, 1fr); }

.toc { display: grid; gap: 0.45rem; counter-reset: toc; }
.toc a { display: flex; gap: 0.7rem; color: var(--fg-2); font-size: 0.94rem; transition: color 0.2s; }
.toc a::before { counter-increment: toc; content: "\00a7" counter(toc); font: 400 var(--step--1)/1.9 var(--font-mono); color: var(--fg-3); }
.toc a:hover { color: var(--fg); }

@media (max-width: 860px) {
  .article__head, .page-head, .article__body { grid-template-columns: minmax(0, 1fr); }
  .article__aside { position: static; }
  .toc { display: none; }
}

.prose {
  max-width: var(--measure);
  font: 400 clamp(1.1rem, 1.05rem + 0.25vw, 1.22rem)/1.62 var(--font-serif);
  font-optical-sizing: auto;
  counter-reset: sec fig;
  hanging-punctuation: first;
}
.prose > * + * { margin-top: 1.15em; }

.prose h2 {
  margin-top: 2.6em;
  font: 600 var(--step-2)/1.18 var(--font-sans);
  letter-spacing: -0.02em;
  counter-increment: sec; counter-reset: thm;
}
.prose h2::before { content: "\00a7" counter(sec); display: block; margin-bottom: 0.7rem; font: 400 var(--step--1)/1 var(--font-mono); letter-spacing: 0.08em; color: var(--fg-3); }
.prose h3 { margin-top: 2em; font: 600 var(--step-1)/1.3 var(--font-sans); letter-spacing: -0.012em; }
.prose h2 + *, .prose h3 + * { margin-top: 0.8em; }

.prose a { text-decoration: underline; text-decoration-color: var(--mark); text-decoration-thickness: 1.5px; text-underline-offset: 0.18em; transition: color 0.2s; }
.prose a:hover { color: var(--accent-text); }
.prose strong { font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--fg-3); font-family: var(--font-mono); font-size: 0.85em; }

.prose blockquote { padding-left: 1.25rem; border-left: 2px solid var(--mark); font-style: italic; color: var(--fg-2); }

.prose code { padding: 0.12em 0.36em; border-radius: 4px; background: var(--bg-raise); font: 0.84em var(--font-mono); }
.prose pre { padding: 1.1rem 1.25rem; overflow-x: auto; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg-raise); font: 0.875rem/1.65 var(--font-mono); tab-size: 2; }
.prose pre code { padding: 0; background: none; font: inherit; }

.prose figure { margin-block: 2.2em; counter-increment: fig; }
.prose figcaption { margin-top: 0.85rem; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.02em; color: var(--fg-2); }
.prose figcaption::before { content: "Fig. " counter(fig) "\2002"; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg); }
/* A figure plate. The canvas is taken out of flow so its intrinsic size can never feed back into
   the plate's height, which is what made a figure grow without bound. */
.plate { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; padding: clamp(0.75rem, 2.5vw, 1.5rem); border: 1px solid var(--rule); border-radius: 8px; background: var(--bg-raise); color: var(--fg-3); }
.plate canvas { position: absolute; inset: clamp(0.75rem, 2.5vw, 1.5rem); width: auto; height: auto; }
.plate > svg { width: 100%; max-width: 30rem; height: auto; display: block; }
.plate > svg[hidden] { display: none; }
.plate--auto { aspect-ratio: auto; }
.plate--tall { aspect-ratio: 1 / 1.13; }
.figure__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.9rem; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.figure__controls button {
  all: unset; box-sizing: border-box; cursor: pointer; min-width: 2.4rem; padding: 0.3rem 0.7rem; text-align: center;
  border: 1px solid var(--rule); border-radius: 999px; color: var(--fg-2); transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}
.figure__controls button:hover { color: var(--fg); border-color: var(--fg-3); }
.figure__controls button[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.figure__controls button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; }
.figure__controls span { margin-right: 0.4rem; }

/* The rational tree (Problem 137). Vertices are tiles, as everywhere else on the site, and the
   ones reached by x -> -1/x are marked, which is the whole point: they are exactly the negatives. */
.tree137 { width: 100%; height: auto; display: block; }
.tree137__edges path { stroke: var(--rule); stroke-width: 1.4; }
.tree137__nodes rect { fill: var(--fg-2); }
.tree137__nodes .neg rect { fill: var(--mark); }
.tree137__nodes .leaf rect { fill: none; stroke: var(--fg-3); stroke-width: 1.6; }
.tree137__nodes .neg.leaf rect { stroke: var(--mark); }
.tree137__nodes text { fill: var(--fg-3); font: 400 11px var(--font-mono); }
.tree137__nodes .neg text { fill: var(--accent-text); }
.tree137__ranks text { fill: var(--fg-3); font: 400 10px var(--font-mono); opacity: 0.7; }
.tree137__counts text { fill: var(--fg-3); font: 500 11px var(--font-mono); opacity: 0.8; }
.tree137 .is-off { opacity: 0.12; }       /* a ghost of the rows not part of the sum */
.tree137 [data-rank] { transition: opacity 0.45s var(--ease-out), fill 0.45s var(--ease-out); }
:root[data-motion="calm"] .tree137 [data-rank] { transition: none; }

/* Reading a(n) = a(n-1) + a(n-3) off the drawing: the two rows being added are banded, the row
   they add up to is banded more strongly, and the counts in the right margin are the sum. */
.tree137__bands rect { fill: none; }
.tree137__bands rect.is-addend { fill: var(--fg); opacity: 0.055; }
.tree137__bands rect.is-total { fill: var(--mark); opacity: 0.11; }
.tree137__counts text.is-addend { fill: var(--fg); opacity: 1; font-weight: 500; }
.tree137__counts text.is-total { fill: var(--mark); opacity: 1; font-weight: 500; }
.tree137__counts text.is-miss { fill: var(--fg-2); opacity: 1; text-decoration: line-through; }
.tree137__bands rect.is-miss { fill: var(--fg-3); opacity: 0.14; }

/* The arithmetic, spelled out under the figure and kept in step with the buttons. */
.figure__sum {
  margin-top: 0.7rem; min-height: 1.6em;
  font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-2);
}
.figure__sum b { font-weight: 500; color: var(--mark); }
.figure__sum i { font-style: normal; color: var(--fg-3); }

.figure__key { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; margin-top: 0.7rem; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-3); }
.figure__key span { display: inline-flex; align-items: center; gap: 0.45rem; }
.figure__key i { width: 0.7rem; height: 0.7rem; border-radius: 2px; background: var(--fg-2); }
.figure__key i.neg { background: var(--mark); }
.figure__key i.leaf { background: none; border: 1.5px solid var(--fg-3); }

/* ---------------------------------------------------------------- plotted figures
   The double pendulum plots are redrawn from the paper's data as SVG that carries no colour of
   its own, so they follow the theme like every other figure on the site. Curves are tinted by
   data-i, which the generator stamps in drawing order. */
/* Inlined, not <img>: an SVG loaded through <img> is isolated from this stylesheet, so the
   classes below would never reach it and every path would fall back to a black fill. */
.plate > svg.dpfig { width: 100%; max-width: 42rem; height: auto; display: block; }
.fg__grid path { fill: none; stroke: var(--rule); stroke-width: 1; opacity: 0.55; }
.fg__axis { stroke: var(--fg-3); stroke-width: 1.1; fill: none; }
/* Scoped under .fg so these outrank ".diagram text", which is also (0,1,1) and later in the
   file. Without the scope every label in a figure came out one size and one colour. */
.fg .fg__tick { fill: var(--fg-3); font: 400 10px var(--font-mono); letter-spacing: 0; }
.fg .fg__label { fill: var(--fg-2); font: 400 11px var(--font-mono); letter-spacing: 0.04em; }
.fg .fg__note { fill: var(--fg-3); font: 400 10px var(--font-mono); letter-spacing: 0; }
.fg .fg__noteB { fill: var(--mark); font: 400 10px var(--font-mono); letter-spacing: 0; }
.fg .fg__noteE { fill: var(--fg-2); font: 400 10px var(--font-mono); letter-spacing: 0; }
.fg .fg__key { fill: var(--fg-3); font: 400 9px var(--font-mono); letter-spacing: 0; }

.fg__curve { fill: none; stroke: var(--mark); stroke-width: 1.5; }
.fg__curve[data-i="0"] { stroke: var(--fg-3); }
.fg__curve[data-i="1"] { stroke: var(--fg-2); }
.fg__curve[data-i="2"] { stroke: var(--mark-2); }
.fg__curve[data-i="3"] { stroke: var(--mark); }
.fg__curve[data-i="4"] { stroke: var(--mark); opacity: 0.72; }
.fg__curve[data-i="5"] { stroke: var(--mark); opacity: 0.48; }

.fg__sat, .fg__tol { stroke: var(--fg-3); stroke-width: 1; fill: none; stroke-dasharray: 3 4; }
.fg__drop { stroke: var(--mark); stroke-width: 1; fill: none; stroke-dasharray: 2 3; }
.fg__pert { fill: none; stroke: var(--fg); stroke-width: 2.1; }
.fg__energy { fill: none; stroke: var(--fg-2); stroke-width: 1.6; }
.fg__fitA { fill: none; stroke: var(--fg-3); stroke-width: 1.2; }
.fg__fitB { fill: none; stroke: var(--mark); stroke-width: 1.2; }
.fg__ptA { fill: var(--fg-2); }
.fg__ptB { fill: var(--mark); }

/* ------------------------------------------------------------------ search
   Keyboard first: "/" or Ctrl/Cmd+K opens it, arrows move, Enter goes. The panel sits high
   rather than centred, so the results grow downward into empty space instead of shifting. */
.search { position: fixed; inset: 0; z-index: 90; display: grid; justify-items: center; }
.search__scrim { position: absolute; inset: 0; background: rgb(0 0 0 / 0.55); backdrop-filter: blur(3px); }
.search__panel {
  position: relative; width: min(46rem, calc(100vw - 2rem));
  margin-top: clamp(3rem, 12vh, 8rem); max-height: min(34rem, 74vh);
  display: flex; flex-direction: column;
  background: var(--bg-raise); border: 1px solid var(--rule); border-radius: 10px;
  box-shadow: 0 1.4rem 3.5rem rgb(0 0 0 / 0.5); overflow: hidden;
}
.search__bar { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--rule); }
.search__input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--fg);
  font: 400 var(--step-0)/1.5 var(--font-sans);
}
.search__input::placeholder { color: var(--fg-3); }
.search__input::-webkit-search-cancel-button { display: none; }
.search__count, .search__esc { flex: none; font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; color: var(--fg-3); }
.search__esc { all: unset; cursor: pointer; padding: 0.15rem 0.45rem; border: 1px solid var(--rule); border-radius: 4px; font: 400 var(--step--1)/1.5 var(--font-mono); color: var(--fg-3); }
.search__esc:hover { color: var(--fg); border-color: var(--fg-3); }
.search__list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.search__hit {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.15rem 1rem;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--rule); text-decoration: none; color: inherit;
}
.search__hit:last-child { border-bottom: 0; }
.search__hit.is-active { background: rgb(from var(--mark) r g b / 0.14); }
.search__t { font-weight: 500; }
.search__t b, .search__d b { font-weight: 600; color: var(--accent-text); }
.search__d { grid-column: 1; color: var(--fg-2); font-size: var(--step--1); line-height: 1.5; }
.search__k { grid-row: 1; grid-column: 2; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); white-space: nowrap; }
.search__empty { padding: 1.1rem 1rem; color: var(--fg-3); }
html.is-searching { overflow: hidden; }

/* The header trigger. Hidden until search.js unhides it, so it never dangles without its script. */
.nav__search { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.5rem; border: 1px solid var(--rule); border-radius: 5px; color: var(--fg-3); font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; }
.nav__search:hover { color: var(--fg); border-color: var(--fg-3); }
.nav__search kbd { font: inherit; color: var(--fg-3); }
@media (max-width: 860px) { .nav__search kbd { display: none; } }

/* ------------------------------------------------------------------ publications
   A published thing gets its cover shown, because a cover is the one piece of a book that is
   designed to be recognised. The rest of the block is the site's usual furniture, so the cover
   reads as an artefact set into the page rather than a product shot pasted on. */
.pub {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  padding: clamp(1.75rem, 4vh, 2.75rem) 0;
  border-top: 1px solid var(--rule);
}
.pub__cover {
  position: relative; display: block; border-radius: 3px;
  /* the spine edge: a dark strip down the left, then the page block on the right */
  box-shadow:
    inset 0.55rem 0 0 -0.45rem rgb(0 0 0 / 0.55),
    0.35rem 0.4rem 0 -0.2rem var(--bg-raise),
    0.7rem 0.8rem 1.6rem -0.5rem rgb(0 0 0 / 0.45);
  transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out);
}
.pub__cover img {
  display: block; width: 100%; height: auto; aspect-ratio: 282 / 375;
  border-radius: 3px; border: 1px solid var(--rule);
}
.pub__cover:hover, .pub__cover:focus-visible {
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow:
    inset 0.55rem 0 0 -0.45rem rgb(0 0 0 / 0.55),
    0.45rem 0.5rem 0 -0.2rem var(--bg-raise),
    0.9rem 1.1rem 2rem -0.5rem rgb(0 0 0 / 0.5);
}
.pub__title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-2); line-height: 1.18; letter-spacing: -0.014em; margin-top: 0.5rem; }
.pub__by { margin-top: 0.7rem; color: var(--fg-2); max-width: 52ch; }
.pub__desc { margin-top: 0.9rem; color: var(--fg-2); max-width: 56ch; }
.pub__facts { display: flex; flex-wrap: wrap; gap: 0.35rem 1.6rem; margin-top: 1.1rem; font: 400 var(--step--1)/1.9 var(--font-mono); letter-spacing: 0.05em; color: var(--fg-3); }
.pub__facts b { font-weight: 400; color: var(--fg-2); }
.pub__links { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: 1.15rem; }

@media (max-width: 640px) {
  .pub { grid-template-columns: minmax(0, 1fr); }
  .pub__cover { max-width: 11rem; }
}
:root[data-motion="calm"] .pub__cover, .no-motion .pub__cover { transition: none; }
:root[data-motion="calm"] .pub__cover:hover, .no-motion .pub__cover:hover { transform: none; }

/* Lattice pictures: the tile motif reused for blackouts, tilings, colourings, lattice paths and
   board positions. sitefig.Grid emits these classes. */
.tile { fill: var(--fg-2); }
.tile--off { fill: none; stroke: var(--fg-3); stroke-width: 1.4; }
.tile--mark { fill: var(--mark); }
.tile--mark2 { fill: var(--mark-2); }
.tile--ghost { fill: var(--fg-3); opacity: 0.35; }
.cellfill { fill: var(--mark); opacity: 0.12; }
.cellfill--alt { fill: var(--fg); opacity: 0.07; }
.edge { fill: none; stroke: var(--fg-3); stroke-width: 1.6; stroke-linecap: round; }
.edge--mark { stroke: var(--mark); stroke-width: 2.1; }
.edge--mark2 { stroke: var(--mark-2); stroke-width: 2.1; }
.edge--faint { stroke: var(--rule); stroke-width: 1.2; }

/* ------------------------------------------------- the live double pendulum
   .plate canvas is absolutely positioned for the background fields, which would take this one
   out of flow and collapse the plate around it. This canvas sizes itself, so put it back. */
.pendulum { position: relative; width: 100%; }
.plate .pendulum canvas { position: static; inset: auto; display: block; width: 100%; height: auto; }
.pendulum__out {
  margin-top: 0.7rem; min-height: 1.5em;
  font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.03em; color: var(--fg-3);
}

/* The four-class cycle: a positive takes three steps to make another positive. */
.plate > svg.cycle137 { max-width: 19rem; margin-inline: auto; }
.cycle137__nodes circle { fill: var(--bg); stroke: var(--fg-3); stroke-width: 1.4; }
.cycle137__nodes .neg circle { stroke: var(--mark); }
.cycle137__nodes text { fill: var(--fg-2); font: 400 10px var(--font-mono); }
.cycle137__arrows .a { stroke: var(--fg-3); stroke-width: 1.4; fill: none; }
.cycle137__arrows .a.on { stroke: var(--mark); stroke-width: 2; }
.cycle137 marker.head path { fill: var(--fg-3); }
.cycle137 marker.head.on path { fill: var(--mark); }
.cycle137__note { fill: var(--fg-3); font: 400 10px var(--font-mono); }

/* Line drawings inside a write-up take their colours from the page. */
.diagram { display: block; width: 100%; height: auto; }
.diagram .g { fill: #2ecf8f; }
.diagram .r { fill: #e04a2c; }
.diagram .frame { fill: none; stroke: var(--fg); stroke-width: 1.5; }
.diagram text { fill: var(--fg-2); font: 400 11px var(--font-mono); letter-spacing: 0.04em; }
.diagram .arrow { fill: none; stroke: var(--fg-2); stroke-width: 1.4; }

.prose table { width: 100%; border-collapse: collapse; font: 400 0.94rem/1.5 var(--font-sans); font-variant-numeric: tabular-nums; }
.prose th { padding: 0 1rem 0.6rem 0; text-align: left; font: 500 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); border-bottom: 1px solid var(--fg-3); }
.prose td { padding: 0.6rem 1rem 0.6rem 0; border-bottom: 1px solid var(--rule); }

/* Theorem-like environments, numbered within their section: <div class="thm" data-kind="Theorem">. */
.thm { padding-left: 1.25rem; border-left: 2px solid var(--mark); counter-increment: thm; }
.thm > * + * { margin-top: 0.8em; }
.thm::before { content: attr(data-kind) " " counter(sec) "." counter(thm); display: block; margin-bottom: 0.45rem; font: 600 0.78rem/1.4 var(--font-sans); letter-spacing: 0.07em; text-transform: uppercase; }
.thm[data-name]::before { content: attr(data-kind) " " counter(sec) "." counter(thm) " \00b7  " attr(data-name); }
.thm--stated { font-style: italic; }
.thm--stated .katex { font-style: normal; }

.proof > * + * { margin-top: 0.8em; }
/* Floated so it runs into the first line. It lives on .proof itself so attr(data-of) can see the attribute. */
.proof::before { content: "Proof."; float: left; margin-right: 0.45em; font-style: italic; }
.proof[data-of]::before { content: "Proof of " attr(data-of) "."; }
/* The tombstone is a disc, naturally. */
.proof > :last-child::after { content: ""; float: right; width: 0.55em; height: 0.55em; margin: 0.62em 0 0 1em; border-radius: 50%; background: var(--mark); }

.prose .katex { font-size: 1.08em; }
.prose .katex-display { margin: 1.5em 0; padding: 0.15em 0; overflow-x: auto; overflow-y: hidden; }
.prose pre, .prose .katex-display { scrollbar-width: thin; scrollbar-color: var(--fg-3) transparent; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gutter); margin-top: clamp(4rem, 10vh, 7rem); padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.pager a { display: grid; gap: 0.5rem; }
.pager a:last-child { text-align: right; justify-items: end; }
.pager strong { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-1); line-height: 1.25; letter-spacing: -0.012em; transition: color 0.2s; }
.pager a:hover strong { color: var(--accent-text); }


/* The home page's index of the other pages: a table of contents in large type. */
.directory { border-top: 1px solid var(--rule); }
.directory a {
  display: grid; grid-template-columns: 3.25rem minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 0.4rem 1.5rem; align-items: baseline;
  padding: clamp(1rem, 2.6vh, 1.6rem) 0;
  border-bottom: 1px solid var(--rule);
}
.directory__n { display: flex; align-items: baseline; gap: 0.55rem; font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; color: var(--fg-3); }
.directory__name {
  font-family: var(--font-display); font-weight: var(--display-weight);
  font-size: calc(var(--step-3) * var(--display-scale)); line-height: 1.1; letter-spacing: var(--display-tracking);
  transition: transform 0.45s var(--ease-out);
}
.directory__what { color: var(--fg-2); max-width: 44ch; }
.directory__go { color: var(--fg-3); transition: transform 0.45s var(--ease-out), color 0.2s; }
.directory a:hover .mark, .directory a:focus-visible .mark { transform: none; }
.directory a:hover .directory__name { transform: translateX(0.4rem); }
.directory a:hover .directory__go { transform: translateX(0.35rem); color: var(--fg); }
@media (max-width: 760px) {
  .directory a { grid-template-columns: 2.6rem minmax(0, 1fr) auto; }
  .directory__what { grid-column: 2 / -1; grid-row: 2; }
}

/* One thing, given room: what I am working on now. */
.feature { display: grid; gap: 1.25rem; max-width: 46rem; }
.feature h3 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-2); line-height: 1.18; letter-spacing: -0.018em; text-wrap: balance; }
.feature p { color: var(--fg-2); font-size: var(--step-1); line-height: 1.45; }
.feature .feature__links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }


/* 11. Art
   ========================================================================== */

/* Columns rather than rows, so each piece keeps its own proportions. */
.gallery { columns: 3 17rem; column-gap: clamp(1rem, 2.5vw, 2rem); padding-top: clamp(2rem, 6vh, 4rem); }
.gallery figure { break-inside: avoid; margin: 0 0 clamp(1.5rem, 3vw, 2.5rem); }
.gallery button { all: unset; display: block; width: 100%; cursor: zoom-in; border-radius: 3px; overflow: hidden; }
.gallery button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 4px; }
.gallery img, .art__ph { display: block; width: 100%; height: auto; transition: transform 0.9s var(--ease-out); }
.gallery button:hover img, .gallery button:hover .art__ph { transform: scale(1.02); }
.gallery figcaption { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.7rem; color: var(--fg-2); font-size: 0.94rem; }
.gallery figcaption span:last-child { flex: none; font: 400 var(--step--1)/1.9 var(--font-mono); letter-spacing: 0.06em; color: var(--fg-3); }

/* Stand-in for a piece that has not been added yet. Replace the <div> with an <img>. */
.art__ph {
  aspect-ratio: var(--ratio, 4 / 5);
  display: grid; place-items: center;
  border: 1px solid var(--rule);
  background:
    radial-gradient(circle at center, var(--fg-3) 0 1px, transparent 1.5px) 0 0 / 1.25rem 1.25rem,
    var(--bg-raise);
  color: var(--fg-3); font: 400 var(--step--1)/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
}

.lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: clamp(1rem, 4vw, 3rem);
  border: 0; background: var(--bg); color: var(--fg);
  display: none; grid-template-rows: minmax(0, 1fr) auto; gap: 1rem;
}
.lightbox[open] { display: grid; }
.lightbox::backdrop { background: var(--bg); }
.lightbox__stage { display: grid; place-items: center; min-height: 0; }
.lightbox__stage img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.lightbox__stage .art__ph { height: 100%; width: auto; max-width: 100%; }
.lightbox__bar { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.lightbox__caption { display: flex; gap: 1.25rem; color: var(--fg-2); }
.lightbox__bar button { all: unset; cursor: pointer; padding: 0.5rem 0.75rem; font: 400 var(--step--1)/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); border-radius: 999px; }
.lightbox__bar button:hover { color: var(--fg); background: var(--rule); }
.lightbox__bar button:focus-visible { outline: 2px solid var(--accent-text); }


/* 12. The rectangle game
   ========================================================================== */

/* Problem 001, playable (assets/js/rectangle-game.js). The points are the same object as in the
   background: a tile facing you is visible, a tile turned edge-on is blacked out. */
.game {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 2rem clamp(1.5rem, 4vw, 3.5rem); align-items: center;
  padding: clamp(1.25rem, 3vw, 2.5rem);
  border: 1px solid var(--rule); border-radius: 14px; background: var(--bg-raise);
}
.game__board svg { display: block; width: 100%; height: auto; margin-inline: auto; overflow: visible; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.pt { cursor: pointer; outline: none; }
.pt__hit { fill: transparent; }
.pt__tile {
  fill: var(--lat-ink); opacity: 0.2;
  transform-box: fill-box; transform-origin: center;
  transition: transform 0.5s var(--ease-bloom), opacity 0.5s, fill 0.3s;
}
/* Toggling a point turns the tile. The pinch and the flash are what make the turn readable. */
.pt.is-turning .pt__tile { animation: tile-turn 0.5s var(--ease-bloom); }
@keyframes tile-turn {
  45% { transform: scaleX(0.03); fill: var(--mark); opacity: 0.9; }
}
.pt:hover .pt__tile { opacity: 0.36; }
.pt.is-out .pt__tile { transform: scaleX(0.07); opacity: 0.75; }
.pt.is-out:hover .pt__tile { opacity: 1; }
.pt.is-lit .pt__tile { fill: var(--mark); opacity: 1; transform: scale(1.14); }
.pt__ring {
  fill: none; stroke: var(--mark); stroke-width: 3; opacity: 0;
  transform-box: fill-box; transform-origin: center; transform: scale(0.7);
  transition: opacity 0.25s, transform 0.4s var(--ease-out);
}
.pt.is-pick .pt__ring, .pt.is-shared .pt__ring { opacity: 1; transform: none; }
.pt.is-shared .pt__ring { stroke: var(--fg); }
.pt:focus-visible .pt__hit { stroke: var(--accent-text); stroke-width: 3; stroke-dasharray: 7 7; }
.game[data-mode="guess"] .pt:not(.is-out) { cursor: default; }

.game__rect {
  fill: var(--mark); fill-opacity: 0.1; stroke: var(--mark); stroke-width: 4; stroke-linejoin: round;
  stroke-dasharray: 1;
  animation: game-trace 0.9s var(--ease-out) backwards;       /* drawn whole if animation is off */
}
.game__rect--b { fill: var(--mark-2); stroke: var(--mark-2); }
@keyframes game-trace { from { stroke-dashoffset: 1; } }

/* A confusable pair. Each is traced, held, then cleared while the other takes its turn; the cycle
   repeats until something else is asked for. Drawn together they would sit on top of each other. */
/* backwards: during its delay the second one holds the 0% frame, where the stroke is dashed
   entirely out of sight, so it waits its turn instead of sitting there fully drawn. */
.game__rect.is-cycling { animation: pair-cycle 5s var(--ease-out) infinite backwards; }
.game__rect--b.is-cycling { animation-delay: 2.5s; }
.game__rect.is-hidden { display: none; }
@keyframes pair-cycle {
  0%   { stroke-dashoffset: 1; opacity: 1; fill-opacity: 0; }
  18%  { stroke-dashoffset: 0; opacity: 1; fill-opacity: 0.12; }
  42%  { stroke-dashoffset: 0; opacity: 1; fill-opacity: 0.12; }
  50%  { stroke-dashoffset: 0; opacity: 0; fill-opacity: 0; }
  100% { stroke-dashoffset: 0; opacity: 0; fill-opacity: 0; }
}

.game__panel { display: grid; gap: 1.1rem; align-content: start; }
.game__sizes { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem 1rem; }
.game__pick { display: grid; gap: 0.4rem; }
.game__pick > span { grid-column: 1 / -1; color: var(--fg-3); }
.game__pick { grid-template-columns: repeat(4, auto); justify-content: start; }
.game__times { padding-bottom: 0.45rem; color: var(--fg-3); }
.game__pick button, .game__actions button {
  all: unset; box-sizing: border-box; cursor: pointer; text-align: center;
  min-width: 2.4rem; padding: 0.45rem 0.7rem;
  border: 1px solid var(--rule); border-radius: 999px;
  font: 500 var(--step--1)/1.2 var(--font-mono); letter-spacing: 0.06em; color: var(--fg-2);
  transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}
.game__actions button { padding: 0.6rem 1rem; text-transform: uppercase; }
.game__pick button:hover, .game__actions button:hover { color: var(--fg); border-color: var(--fg-3); }
.game__pick button[aria-pressed="true"], .game__actions button.is-primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.game__actions button.is-primary:hover { background: var(--accent-text); border-color: var(--accent-text); color: var(--bg); }
.game button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; }
.game__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.game__count { font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-3); }
.game__status { min-height: 6.5em; font-size: var(--step-1); line-height: 1.4; letter-spacing: -0.008em; }
.game__status[data-tone="good"]::before, .game__status[data-tone="bad"]::before {
  content: ""; display: inline-block; width: 0.5em; height: 0.5em; margin-right: 0.55em; vertical-align: 0.12em; background: var(--mark);
}
.game__status[data-tone="bad"]::before { background: var(--mark-2); }

.game__hint { padding-top: 1rem; border-top: 1px solid var(--rule); color: var(--fg-2); }
.game__hint summary { cursor: pointer; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2); }
.game__hint summary:hover { color: var(--fg); }
.game__hint p { margin-top: 0.7rem; }
.game__meter { height: 4px; margin-top: 0.9rem; border-radius: 2px; background: var(--rule); overflow: hidden; }
.game__meter::before { content: ""; display: block; height: 100%; width: calc(var(--fill, 0) * 100%); background: var(--mark); transition: width 0.4s var(--ease-out); }
.game__meter.is-over::before { background: var(--mark-2); }

@media (max-width: 860px) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .game__status { min-height: 0; }
}

/* A still version of the same board, for figures: <div class="board" data-board="..#/.#." ...>. */
.board { display: grid; gap: 0.5rem; width: fit-content; }
.board__row { display: flex; gap: 0.5rem; }
.board i { width: 1.5rem; height: 1.5rem; background: var(--lat-ink); opacity: 0.2; }
.board i.out { opacity: 0.75; transform: scaleX(0.08); }

/* The CV: a label column on the left, entries on the right. */
.cv { display: grid; gap: clamp(2rem, 5vh, 3.25rem); padding-top: clamp(1.5rem, 4vh, 2.5rem); }
.cv__block { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 1rem var(--gutter); padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.cv__block > h2 { font: 500 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
.cv__entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 1.5rem; align-items: baseline; }
.cv__entry + .cv__entry { margin-top: 1.75rem; padding-top: 1.75rem; border-top: 1px solid var(--rule); }
.cv__title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-1); line-height: 1.25; letter-spacing: -0.012em; }
.cv__where { font-family: var(--font-sans); font-size: var(--step-0); font-weight: 400; color: var(--fg-2); }
.cv__where::before { content: " · "; color: var(--fg-3); }
.cv__when { grid-column: 2; grid-row: 1; text-align: right; white-space: nowrap; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-3); }
.cv__what { grid-column: 1 / -1; color: var(--fg-2); }
.cv__entry ul { grid-column: 1 / -1; display: grid; gap: 0.35rem; margin-top: 0.5rem; padding-left: 1.1rem; color: var(--fg-2); }
.cv__entry li::marker { color: var(--fg-3); }
@media (max-width: 860px) {
  .cv__block { grid-template-columns: minmax(0, 1fr); }
  .cv__entry { grid-template-columns: minmax(0, 1fr); }
  .cv__when { grid-column: 1; grid-row: auto; text-align: left; }
}

/* The problems index */
.problem { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 1.25rem var(--gutter); padding: clamp(2rem, 5vh, 3rem) 0; border-top: 1px solid var(--rule); }
.problem:last-child { border-bottom: 1px solid var(--rule); }
.problem__id { display: grid; gap: 0.8rem; align-content: start; justify-items: start; }
/* The problem number is also the progress meter: it fills from the bottom to --p as the work
   gets done, and goes solid accent once the problem is finished. */
.problem__n {
  font: 400 clamp(2.4rem, 1.6rem + 2.6vw, 4.25rem)/1 var(--font-mono); letter-spacing: -0.04em;
  color: var(--fg-3);
  background-image: linear-gradient(to top, var(--mark) var(--p, 0%), var(--fg-3) var(--p, 0%));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.problem__n.is-solved { font-weight: 700; background-image: none; -webkit-text-fill-color: var(--mark); color: var(--mark); }
@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .problem__n { -webkit-text-fill-color: var(--fg-3); color: var(--fg-3); }
}
.problem__body { display: grid; gap: 1rem; max-width: 46rem; }
.problem__body h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--step-2); line-height: 1.18; letter-spacing: -0.018em; text-wrap: balance; }
.problem__body h2 a { transition: color 0.2s; }
.problem__body h2 a:hover { color: var(--accent-text); }
.problem__ask { font-size: var(--step-1); line-height: 1.45; color: var(--fg); }
.problem__body p, .problem__body li { color: var(--fg-2); }
.problem__body ul { display: grid; gap: 0.4rem; padding-left: 1.1rem; }
.problem__body li::marker { color: var(--fg-3); }
.problem__links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font: 400 var(--step--1)/1.6 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; }
@media (max-width: 860px) { .problem { grid-template-columns: minmax(0, 1fr); } }


/* 13. Motion
   ========================================================================== */

/* Intro: boot.js adds .intro-pending before first paint; the field clears it on cue. */
[data-reveal] {
  transition:
    opacity 0.8s ease-out calc(var(--i, 0) * 110ms),
    transform 1s var(--ease-out) calc(var(--i, 0) * 110ms);
}
.intro-pending [data-reveal] { opacity: 0; transform: translateY(14px); transition: none; }
.intro-pending .site-header[data-reveal] { transform: none; }

/* Further down the page, things settle into place as they scroll into view. */
.js [data-inview] { opacity: 0; transform: translateY(18px); }
.js [data-inview].is-in {
  opacity: 1; transform: none;
  transition: opacity 0.8s ease-out calc(var(--k, 0) * 70ms), transform 1s var(--ease-out) calc(var(--k, 0) * 70ms);
}

/* Calm: the reduced-motion version. boot.js sets data-motion from the visitor's system setting.
   Everything still arrives in the same order, but by fading. Nothing slides, scales or smooth-scrolls. */
:root[data-motion="calm"] { scroll-behavior: auto; }
:root[data-motion="calm"] *, :root[data-motion="calm"] *::before, :root[data-motion="calm"] *::after {
  transition-property: opacity, color, background-color, border-color !important;
  animation: none !important;
}
:root[data-motion="calm"] [data-reveal], :root[data-motion="calm"] [data-inview] { transform: none !important; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Set briefly by site.js when state has to change without being seen to (replaying the intro, ?t= freezes).
   Kept last so it outranks the calm rules above. */
:root.no-motion *, :root.no-motion *::before, :root.no-motion *::after { transition: none !important; animation: none !important; }
:root.no-motion { scroll-behavior: auto !important; }

@media print {
  .site-header, .field, .band, .colophon button { display: none; }
  body { background: #fff; color: #000; }
}

/* ---------------------------------------------------------- discipline fields (scratch)
   Four background grammars in one tile vocabulary, previewed on design/fields.html. Like every
   other figure these carry no colour of their own. */
.fld { width: 100%; height: auto; display: block; }
.fld__on { fill: var(--lat-ink); opacity: 0.82; }
.fld__dim { fill: var(--fg-3); opacity: 0.4; }
.fld__off { fill: var(--lat-ink); opacity: 0.3; }
.fld__neg { fill: none; stroke: var(--mark); stroke-width: 1.2; }
.fld__bond { fill: none; stroke: var(--fg-3); stroke-width: 1.1; opacity: 0.45; }
.fld__path { fill: none; stroke: var(--mark); stroke-width: 1.6; opacity: 0.85; }

/* A second heading inside the same section, for the split between in-progress and answered
   problems. Needs air above it because a run of problem cards precedes it. */
.section__head--again { margin-top: clamp(3rem, 7vh, 5rem); }

/* The right-hand column of a .pub. min-width:0 stops a long unbroken string, an ISBN or a URL,
   from forcing the grid wider than its track. */
.pub__body { min-width: 0; }

/* ------------------------------------------------------------------ research roadmap
   One lane per thread of work and one node per paper, in the order the papers came. A paper
   that is posted or submitted has its mark open, and a paper in progress keeps it as a
   hairline, so the site's one gesture doubles as the status. Four columns are fixed so the
   nodes line up from lane to lane. */
.rm__key { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-3); }
.rm__key span { display: inline-flex; align-items: center; gap: 0.55rem; }
.roadmap { display: grid; padding-top: clamp(1.25rem, 3vh, 2rem); }
.rm__lane { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 0.9rem var(--gutter); padding: 1.35rem 0; border-top: 1px solid var(--rule); }
.rm__lane:first-child { border-top: 0; }
.rm__thread { display: grid; gap: 0.3rem; align-content: start; font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2); }
.rm__thread a { transition: color 0.2s; }
.rm__thread a:hover { color: var(--accent-text); }
.rm__thread small { font-size: inherit; text-transform: none; letter-spacing: 0.02em; color: var(--fg-3); }
.rm__nodes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.rm__nodes > li { position: relative; }
/* the connector from one node to the next, at the height of the mark's centre */
.rm__nodes > li:not(:last-child)::after { content: ""; position: absolute; top: 0.375rem; left: 1.15rem; right: -0.85rem; height: 1px; background: var(--rule); }
.rm__node { display: grid; gap: 0.45rem; align-content: start; }
.rm__node .mark { display: block; font-size: 1.25rem; }
.rm__name { line-height: 1.3; color: var(--fg); transition: color 0.2s; }
.rm__node:hover .rm__name, .rm__node:focus-visible .rm__name { color: var(--accent-text); }
.rm__meta { font: 400 var(--step--1)/1.5 var(--font-mono); letter-spacing: 0.04em; color: var(--fg-3); }

@media (max-width: 860px) {
  .rm__lane { grid-template-columns: minmax(0, 1fr); }
  .rm__nodes { grid-template-columns: minmax(0, 1fr); gap: 0.9rem; }
  .rm__node { grid-template-columns: 0.75rem minmax(0, 1fr); column-gap: 0.9rem; row-gap: 0.15rem; }
  .rm__node .mark { grid-row: span 2; margin-top: 0.25rem; }
  .rm__nodes > li:not(:last-child)::after { top: 1.25rem; bottom: -0.65rem; left: 0.375rem; right: auto; width: 1px; height: auto; }
}

/* Authors under a paper title, and the venue line, on the research page */
.paper__by { color: var(--fg-2); }

/* The elephant walk figure. Same caveat as .pendulum: the content canvas inside a .plate needs
   position: static put back. The sliders take the accent for their thumb and track. */
.erw { position: relative; width: 100%; }
.plate .erw canvas { position: static; inset: auto; display: block; width: 100%; height: auto; cursor: crosshair; }
.figure__controls--sliders { gap: 0.6rem 1.1rem; }
.figure__controls label { display: inline-flex; align-items: center; gap: 0.55rem; text-transform: none; letter-spacing: 0.03em; }
.figure__controls input[type="range"] { width: clamp(7rem, 18vw, 11rem); accent-color: var(--mark); }
.figure__controls output { min-width: 2.6em; color: var(--fg-2); }

/* The Galton board of Problem 131. As with .pendulum and .erw, the canvas inside the plate needs
   position: static put back. */
.galton { position: relative; width: 100%; }
.plate .galton canvas { position: static; inset: auto; display: block; width: 100%; height: auto; }

/* The dimension-four figures (research/dimension-four.html). The path figure is SVG generated
   from the paper's own sample, and like .dpfig it carries no colour of its own. Loops are tinted
   by data-i in drawing order, longest first. The two live figures are canvases, so they need
   position: static put back inside the plate. */
.plate > svg.d4fig { width: 100%; max-width: 44rem; height: auto; display: block; }
.fg__bm { fill: none; stroke: var(--fg-3); stroke-width: 0.6; opacity: 0.55; stroke-linejoin: round; }
.fg__loop { fill: none; stroke: var(--mark); stroke-width: 1.1; stroke-linejoin: round; }
.fg__loop[data-i="0"] { opacity: 0.55; }
.fg__loop[data-i="1"] { opacity: 0.8; }
.fg__junction { fill: var(--bg-raise); stroke: var(--fg); stroke-width: 1.3; }
.fg__start { fill: var(--fg); }
.fg__contact { fill: none; stroke: var(--fg); stroke-width: 2.4; stroke-linecap: round; }
.fg__enc { fill: none; stroke: var(--fg-3); stroke-width: 1; }
.fg__encbig { fill: none; stroke: var(--mark); stroke-width: 1.6; }
.fg__encbig[data-i="0"] { opacity: 0.55; }
.fg__encbig[data-i="1"] { opacity: 0.8; }
.d4live { position: relative; width: 100%; }
.plate .d4live canvas { position: static; inset: auto; display: block; width: 100%; height: auto; }
