:root {
  --bg: #161616;
  --fg: #f2f1ee;
  --muted: #a9a8a3;
  --dim: #8a8983;
  --rule: #2e2e2c;
  --accent: #e5173f;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --pad: max(clamp(20px, 4.7vw, 94px), calc(50vw - 620px));   /* text measure tops out at 1240px; the art stays full-bleed */
}
* { box-sizing: border-box; margin: 0; }
html { background: var(--bg); }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--mono); font-size: 15px; line-height: 1.5;
  min-height: 100vh; -webkit-font-smoothing: antialiased;
  font-variant-ligatures: none;                      /* "c++" stays three characters */
}
a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }
.skip { position: absolute; left: var(--pad); top: -60px; padding: 8px 12px; background: var(--fg); color: var(--bg); z-index: 2; }
.skip:focus { top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: clamp(10px, 2.4vw, 40px) var(--pad) 0;
}
header a, .mark { display: inline-flex; align-items: center; min-height: 44px; }
.mark { font-size: clamp(22px, 2vw, 32px); font-weight: 500; }
header nav a:hover { text-decoration: underline; text-underline-offset: 5px; }

/* The art is full-bleed. On wide screens the introduction sits over its empty left half;
   on narrow ones everything stacks: art, its caption, then the introduction. */
.hero { position: relative; --stage-h: clamp(240px, 37vh, 410px); }
.stage { height: var(--stage-h); }
.stage canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; outline: none; }   /* focus is drawn round the planet, on the canvas */
.stage canvas.dragging { cursor: grabbing; }
.meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 32px;
  padding: 6px var(--pad) 0; font-size: 13px; line-height: 1.5;
}
.caption { color: var(--muted); }
.hint { display: flex; align-items: center; gap: 4px; min-height: 44px; color: var(--dim); font-variant-numeric: tabular-nums; }
#hint.reading { color: var(--fg); }
.meta { position: relative; }
.keys { position: absolute; left: var(--pad); top: 100%; color: var(--muted); white-space: nowrap; }   /* sits in the gap above the numbers: nothing moves */
kbd { display: inline-block; min-width: 22px; text-align: center; font: inherit; color: var(--fg); border: 1px solid var(--rule); border-radius: 2px; padding: 0 5px; margin: 0 2px 0 14px; }
kbd + kbd, kbd:first-child { margin-left: 0; }
.step {
  display: none; flex: none; width: 44px; height: 44px; background: none; border: 0; color: var(--fg);
  font: inherit; font-size: 20px; cursor: pointer; border-radius: 2px;
}
.step:focus-visible { outline: 2px solid var(--accent); outline-offset: -6px; }
.step:disabled { opacity: .28; cursor: default; }
.step:first-child { margin-left: -16px; }
.step:last-child { margin-right: -16px; }
@media (pointer: coarse) {                           /* touch: ‹ reading › is one control, there from the start */
  .step { display: block; }
  .hint { justify-content: space-between; }
  #hint { flex: 1; text-align: center; }
}

.intro { padding: 24px var(--pad) 16px; }
h1 {
  font-size: clamp(28px, 4.1vw, 60px); font-weight: 500;
  line-height: 1.08; letter-spacing: -.01em; text-wrap: balance; max-width: 22ch;
}
.sub {
  font-family: var(--sans); color: var(--muted);
  font-size: clamp(16px, 1.5vw, 22px); line-height: 1.45; margin-top: 20px; max-width: 58ch; text-wrap: pretty;
}
@media (min-width: 1280px) {
  /* intro and art share one grid cell, so the row is as tall as whichever needs more:
     a long introduction grows the art instead of spilling over the header and caption */
  .hero { display: grid; grid-template-columns: 100%; }
  .stage { grid-area: 1 / 1; height: auto; min-height: var(--stage-h); position: relative; }
  .stage canvas { position: absolute; inset: 0; }
  .meta { grid-row: 2; }
  .intro {
    grid-area: 1 / 1; position: relative; z-index: 1; justify-self: start;
    width: calc(min(580px, 38vw) + var(--pad)); padding: 24px 0 24px var(--pad);
    display: flex; flex-direction: column; justify-content: center; pointer-events: none;
  }
  .intro > * { pointer-events: auto; }
  h1 { font-size: clamp(34px, 3.1vw, 46px); max-width: 20ch; }
  .sub { font-size: clamp(16px, 1.3vw, 20px); margin-top: 28px; }
}

.content { padding: 0 var(--pad); }

.readout {
  display: grid; grid-template-columns: repeat(4, 1fr); align-items: start;
  gap: clamp(24px, 2.4vw, 48px); margin-top: clamp(22px, 2.4vw, 36px);
}
.readout div { display: flex; flex-direction: column; border-top: 1px solid var(--rule); padding-top: 16px; min-width: 0; }
.readout dt {
  order: 2; margin-top: 10px; font-size: 12px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
}
.readout .n {
  order: 1; font-weight: 500; font-size: clamp(26px, 2.8vw, 44px);
  line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.readout .more { order: 3; margin-top: 6px; font-size: 13px; color: var(--dim); }
/* The same 52 weeks as the ring, flattened: oldest on the left, this week in red. */
/* The same 52 weeks as the ring, laid flat: a dot-matrix bar chart to scrub along. */
.weeks { position: relative; margin-top: clamp(8px, 1vw, 12px); }
.spark { display: flex; align-items: flex-end; justify-content: space-between; height: 72px; padding-bottom: 10px; cursor: crosshair; touch-action: pan-y; border-radius: 2px; }
.spark:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.peak { position: absolute; top: 0; font-size: 12px; color: var(--dim); transform: translate(-50%, -4px); pointer-events: none; }
.spark i { position: relative; display: flex; flex-direction: column-reverse; gap: 2px; width: 5px; pointer-events: none; }
.spark b { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.spark i:empty::before { content: ""; width: 2px; height: 2px; margin: 0 auto 1px; border-radius: 50%; background: var(--dim); }
.spark i:last-child b { background: var(--accent); }    /* this week: the only red, like the moon */
.spark i.on b { background: var(--fg); }
.spark i.on:empty::before { width: 4px; height: 4px; background: var(--fg); }
.spark i:last-child.on b { background: var(--accent); }
.spark i.on::after {                                    /* the week being read */
  content: ""; position: absolute; left: 50%; top: 100%; width: 1px; height: 8px; margin: 2px 0 0 -.5px; background: var(--fg);
}
.axis { position: relative; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.axis b { position: absolute; top: 0; font-weight: 400; color: var(--fg); background: var(--bg); padding: 0 8px; transform: translateX(-50%); white-space: nowrap; }
.axis b:empty { display: none; }

/* This week: short entries, each with a small dot figure that plays once when it scrolls into view. */
.log { margin-top: clamp(36px, 3.4vw, 52px); }
.log h2 { font-size: 12px; font-weight: 400; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.log header, .log article {
  display: grid; grid-template-columns: 20ch minmax(0, 1fr) 290px; gap: 12px 24px; align-items: start;
  padding: 24px 0; border-top: 1px solid var(--rule);
}
.log header { border-top: 0; padding: 0 0 18px; align-items: end; }
.log header p { font-family: var(--sans); color: var(--muted); max-width: 62ch; }
.log .tag { font-size: 13px; color: var(--dim); }
.log .tag b { display: block; font-weight: 500; color: var(--fg); font-size: 15px; }
.log h3 { font-size: 18px; font-weight: 500; line-height: 1.3; text-wrap: balance; }
.log h3 + p { font-family: var(--sans); color: var(--muted); margin-top: 8px; max-width: 62ch; text-wrap: pretty; }
.log a { text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; }
.log a:hover { text-decoration-color: var(--fg); }
.viz { margin: 4px 0 0; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.viz .dots { display: grid; gap: 3px; justify-content: start; }
.viz i { width: 6px; height: 6px; border-radius: 50%; background: var(--rule); transition: background .3s, transform .3s; }
.viz i.on { background: var(--fg); }
.viz i.lo { background: var(--dim); transform: scale(.45); }
.viz i.bad { background: none; box-shadow: inset 0 0 0 1px var(--muted); }
.viz i.dif { animation: dif 1.6s steps(2, jump-none) infinite; }
@keyframes dif { 50% { background: var(--dim); } }
.viz figcaption { margin-top: 10px; min-height: 1.5em; }
.viz.days .dots { column-gap: 12px; }
.viz.days figcaption { display: grid; grid-template-columns: repeat(7, 6px); column-gap: 12px; justify-items: center; }
@media (prefers-reduced-motion: reduce) { .viz i { transition: none; } .viz i.dif { animation: none; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--fg); } }
@media (max-width: 960px) {
  .log header, .log article { grid-template-columns: 1fr; gap: 10px; }
  .log .tag b { display: inline; }
}

.work { margin-top: clamp(30px, 2.6vw, 38px); }
.work h2 { font-size: 12px; font-weight: 400; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.work ul { list-style: none; padding: 0; }
.work li > * {
  display: grid; grid-template-columns: 20ch 11ch minmax(0, 1fr) auto; gap: 24px;
  position: relative; padding: 14px 12px; margin: 0 -12px; align-items: baseline;
}
.work li > *::before, .work li:last-child > *::after {   /* rules stay on the page grid; the hover surface bleeds past it */
  content: ""; position: absolute; left: 12px; right: 12px; top: 0; height: 1px; background: var(--rule);
}
.work li:last-child > *::after { top: auto; bottom: 0; }
.work li > a:focus-visible { outline-offset: -2px; }
.work li > a:focus-visible { z-index: 1; }
.work li > a:focus-visible::before, .work li > a:focus-visible::after, .work li:has(> a:focus-visible) + li > *::before { display: none; }
.work li > div strong { color: var(--muted); font-weight: 400; }   /* private: not a link */
.work li > a:hover, .work li > a:focus-visible { background: rgba(255, 255, 255, .05); }
.work em { font-style: normal; color: var(--dim); font-size: 13px; }
.work p { font-family: var(--sans); color: var(--muted); }
.work strong { font-weight: 500; text-decoration: underline transparent; text-underline-offset: 5px; }
.work span { color: var(--dim); font-size: 13px; text-align: right; }
.work span i { font-style: normal; }
.work span b { font-weight: 400; }
.work li > div span { border: 1px solid var(--rule); border-radius: 2px; padding: 1px 6px; }   /* "private" reads as a tag, apart from the language */   /* ↗ opens the project; "private" rows are described, not linked */
.work a:hover strong { text-decoration-color: var(--fg); }
.work a:focus-visible strong { text-decoration-color: var(--accent); }
.work a:hover p, .work a:focus-visible p, .work a:hover span, .work a:focus-visible span { color: var(--fg); }
.work .all { display: inline-block; padding: 12px 0; margin-top: 6px; color: var(--muted); }
.work .all span { font-size: inherit; color: inherit; }
.work .all:hover { color: var(--fg); }

footer {
  padding: clamp(28px, 4vw, 56px) var(--pad) clamp(24px, 3vw, 48px);
  color: var(--dim); font-size: 13px;
}

@media (max-width: 1100px) {
  .readout { grid-template-columns: repeat(2, 1fr); row-gap: 28px; }
  .work li > * { grid-template-columns: 18ch 7ch minmax(0, 1fr) auto; gap: 16px; }
}
@media (max-width: 720px) {
  .readout dt { letter-spacing: .14em; }
  .hero { --stage-h: clamp(220px, 62vw, 300px); }
  .intro { padding-top: 26px; padding-bottom: 20px; }
  .meta { flex-direction: column; align-items: stretch; }
  .hint { justify-content: space-between; }
  /* one stat per line: number, then what it counts */
  .readout { grid-template-columns: 1fr; row-gap: 0; }
  .readout div { display: grid; grid-template-columns: 96px 1fr; column-gap: 16px; align-items: center; padding: 12px 0; }
  .readout .n { grid-row: 1 / 3; font-size: 28px; }
  .readout dt { margin-top: 0; align-self: end; }
  .readout .more { margin-top: 2px; align-self: start; }
  .roomy { display: none; }
  .spark i, .spark b { width: 4px; }
  .spark b { height: 4px; }
  .spark i { gap: 2px; }
  .work li > * { grid-template-columns: 1fr auto auto; gap: 4px 14px; }
  .work p { grid-column: 1 / -1; grid-row: 2; }
  .work em { grid-column: 2; grid-row: 1; }
  .work span { grid-column: 3; grid-row: 1; }
}

/* Titles in the week list link to their own pages. */
.log h3 a { text-decoration: none; }
.log h3 a:hover { text-decoration: underline; text-decoration-color: var(--dim); }
.log .more { display: inline-block; padding: 12px 0; margin-top: 6px; color: var(--muted); text-decoration: none; }
.log .more:hover { color: var(--fg); }

/* One entry on its own page, and the archive. */
a.mark { color: inherit; }
.post { padding: clamp(28px, 5vw, 72px) var(--pad) 0; }
.post .tag { font-size: 13px; color: var(--dim); }
.post .tag b { font-weight: 500; color: var(--fg); margin-right: 10px; }
.post h1 { font-size: clamp(28px, 3.4vw, 48px); max-width: 24ch; margin-top: 12px; }
.post .viz { margin: clamp(24px, 3vw, 40px) 0; }
.post .body { max-width: 66ch; }
.post .body p { font-family: var(--sans); font-size: 18px; line-height: 1.6; color: var(--muted); margin-top: 1em; }
.post .body p:first-child { color: var(--fg); }
.post .body a { text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; }
.post code { font-family: var(--mono); font-size: .88em; color: var(--fg); }
.post .turn { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 32px; margin-top: clamp(36px, 5vw, 64px); padding-top: 18px; border-top: 1px solid var(--rule); }
.post .turn a { padding: 12px 0; color: var(--muted); }
.post .turn a:hover { color: var(--fg); }
.archive { list-style: none; padding: 0; margin-top: 28px; max-width: 80ch; }
.archive li { border-top: 1px solid var(--rule); }
.archive a { display: grid; grid-template-columns: 12ch 14ch minmax(0, 1fr); gap: 16px; padding: 14px 0; align-items: baseline; }
.archive time, .archive span { font-size: 13px; color: var(--dim); }
.archive a:hover strong { text-decoration: underline; text-underline-offset: 5px; }
.archive strong { font-weight: 500; }
@media (max-width: 720px) { .archive a { grid-template-columns: 1fr auto; } .archive strong { grid-column: 1 / -1; grid-row: 2; } }

.viz[data-viz="bits"] .dots { row-gap: 9px; }
@media (max-width: 960px) { .log .tag b { margin-right: 10px; } }

/* Entry and archive details. */
.log .read { white-space: nowrap; }
.post .about { font-family: var(--sans); color: var(--muted); margin-top: 14px; max-width: 66ch; }
.post .about a { text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; }
.post section { margin-top: 36px; }
.post section h2 { font-size: 12px; font-weight: 400; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.archive { margin-top: 12px; }
.archive a { grid-template-columns: 22ch minmax(0, 1fr); }
header nav { display: flex; gap: 28px; }

footer a { text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; }
.post .tag b { margin-right: 0; }
.viz.days figcaption small { grid-column: 1 / -1; justify-self: start; margin-top: 8px; font-size: 12px; white-space: nowrap; }

.post .who { font-family: var(--sans); color: var(--muted); margin-top: 28px; max-width: 66ch; }
.post .who a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; white-space: nowrap; }

/* An entry: the idea first, then sections with their own figures and diagrams. */
.post .idea { font-family: var(--sans); font-size: clamp(19px, 1.7vw, 24px); line-height: 1.45; color: var(--fg); max-width: 40ch; margin-top: 18px; text-wrap: pretty; }
.post .about { font-size: 14px; }
.post .body h2 { font-family: var(--mono); font-size: 18px; font-weight: 500; color: var(--fg); margin-top: 2.2em; }
.post .body p:first-child { color: var(--muted); }
.post .body ul { margin: 1em 0 0; padding-left: 1.2em; font-family: var(--sans); font-size: 18px; line-height: 1.6; color: var(--muted); }
.post .body li + li { margin-top: .35em; }
.post .body .viz { margin: 1.4em 0 0; }
.diagram { margin: 1.4em 0 0; padding: 16px 18px; border-left: 1px solid var(--rule); font-family: var(--mono); font-size: 13px; line-height: 1.55; color: var(--muted); overflow-x: auto; white-space: pre; }
.viz .bars { display: grid; grid-template-columns: max-content max-content max-content; gap: 9px 14px; align-items: center; }
.viz .bars .bar { display: flex; gap: 3px; }
.viz .bars b { font-weight: 400; color: var(--fg); }
@media (max-width: 720px) { .viz .bars { grid-template-columns: 1fr max-content; } .viz .bars > span:first-child, .viz .bars > span:nth-child(3n+1) { grid-column: 1 / -1; margin-bottom: -4px; } .diagram { font-size: 11px; padding: 12px; } }

.archive em { grid-column: 2; font-style: normal; font-family: var(--sans); color: var(--muted); max-width: 70ch; }
@media (max-width: 720px) { .archive em { grid-column: 1 / -1; grid-row: 3; } }

.post .body > h2:first-child { margin-top: 0; }

.peak { white-space: nowrap; }

/* The entry's drawing: beside the title on wide screens, above it on narrow ones. */
.post { position: relative; }
.post .thumb { max-width: 440px; margin-bottom: 20px; }
.post .thumb svg { display: block; width: 100%; height: auto; }
@media (min-width: 1100px) {
  .post .thumb { position: absolute; right: var(--pad); top: clamp(28px, 5vw, 72px); width: min(440px, 34vw); margin: 0; }
  .post h1, .post .idea, .post .about { max-width: min(24ch, 52vw); }
  .post .idea { max-width: min(40ch, 52vw); } .post .about { max-width: min(66ch, 52vw); }
}

.sub a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 4px; }

.work h3 { font-family: var(--sans); font-size: 15px; font-weight: 400; color: var(--muted); margin: 26px 0 10px; }
.work h2 + h3 { margin-top: 0; }

.log .earlier { font-family: var(--sans); font-size: 15px; font-weight: 400; color: var(--muted); margin: 28px 0 0; }

/* Section jumps on an entry: a list under the context line on narrow screens, a rail that follows the reader on wide ones. */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.post .body h2 { scroll-margin-top: 24px; }
.post .cols { display: flex; flex-direction: column; }
.toc { order: -1; margin-bottom: 28px; padding: 14px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); max-width: 66ch; }
.toc p { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.toc ol { list-style: none; padding: 0; margin-top: 6px; }
.toc a { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; font-size: 13px; color: var(--dim); }
.toc a::before { content: ""; flex: none; width: 4px; height: 4px; border-radius: 50%; background: var(--rule); transform: translateY(-2px); }
.toc a:hover, .toc a.here { color: var(--fg); }
.toc a.here::before { background: var(--fg); width: 6px; height: 6px; margin: 0 -1px; }
@media (min-width: 1100px) {
  .post .cols { display: grid; grid-template-columns: minmax(0, 66ch) minmax(220px, 300px); justify-content: space-between; gap: 48px; align-items: start; }
  .toc { order: 0; position: sticky; top: 28px; margin: 0; padding: 0 0 0 18px; border: 0; border-left: 1px solid var(--rule); }
}

/* A real screenshot inside an entry, and a plain table. No frame or shadow: a thin rule, as diagrams have. */
.post .body .shot { margin: 1.6em 0 0; }
.post .body .shot img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); }
.post .body .shot figcaption { margin-top: 10px; font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--dim); }
.post .body ol { margin: 1em 0 0; padding-left: 1.4em; font-family: var(--sans); font-size: 18px; line-height: 1.6; color: var(--muted); }
.post .body ol li + li { margin-top: .8em; }
.post .body strong { font-weight: 500; color: var(--fg); }
.post .body .table { margin: 1.4em 0 0; overflow-x: auto; }
.post .body table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--muted); }
.post .body th, .post .body td { text-align: left; vertical-align: top; padding: 9px 14px 9px 0; border-bottom: 1px solid var(--rule); }
.post .body thead th { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--fg); }
.post .body tbody th { font-weight: 400; color: var(--fg); white-space: nowrap; }
@media (max-width: 720px) { .post .body table { font-size: 14px; } .post .body tbody th { white-space: normal; } }
