/* ==========================================================================
   Ablations — humanist. Warm paper, calligraphic serif, terracotta accent.
   One superfamily (Alegreya / Alegreya Sans); mono reserved for code.
   ========================================================================== */

:root {
  --paper:      #f7f2e8;
  --paper-sunk: #f0e9db;
  --paper-lift: #fdfaf4;
  --ink:        #1d1913;
  --ink-2:      #514738;
  --ink-3:      #877b66;
  --rule:       rgba(29, 25, 19, 0.15);
  --rule-soft:  rgba(29, 25, 19, 0.08);
  --accent:     #b4462a;
  --accent-2:   #8a6a2f;
  --accent-soft: rgba(180, 70, 42, 0.11);
  --shadow:     0 1px 2px rgba(29, 25, 19, 0.05), 0 18px 34px -22px rgba(29, 25, 19, 0.3);

  --grain-opacity: 0.38;
  --grain-blend: multiply;

  --display: "Alegreya", "Iowan Old Style", Palatino, Georgia, serif;
  --body: "Alegreya", Palatino, Georgia, serif;
  --sans: "Alegreya Sans", "Gill Sans", Optima, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 39rem;
  --gutter: 14rem;
  --page: 72rem;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #14120e;
    --paper-sunk: #1b1913;
    --paper-lift: #201d16;
    --ink:        #efe7d7;
    --ink-2:      #bcb09a;
    --ink-3:      #8b8069;
    --rule:       rgba(239, 231, 215, 0.16);
    --rule-soft:  rgba(239, 231, 215, 0.08);
    --accent:     #f2784c;
    --accent-2:   #d9a95a;
    --accent-soft: rgba(242, 120, 76, 0.15);
    --shadow:     0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 40px -24px rgba(0, 0, 0, 0.85);
    --grain-opacity: 0.24;
    --grain-blend: overlay;
  }
}
:root[data-theme="dark"] {
  --paper:      #14120e;
  --paper-sunk: #1b1913;
  --paper-lift: #201d16;
  --ink:        #efe7d7;
  --ink-2:      #bcb09a;
  --ink-3:      #8b8069;
  --rule:       rgba(239, 231, 215, 0.16);
  --rule-soft:  rgba(239, 231, 215, 0.08);
  --accent:     #f2784c;
  --accent-2:   #d9a95a;
  --accent-soft: rgba(242, 120, 76, 0.15);
  --shadow:     0 1px 2px rgba(0, 0, 0, 0.4), 0 20px 40px -24px rgba(0, 0, 0, 0.85);
  --grain-opacity: 0.24;
  --grain-blend: overlay;
}

/* --------------------------------------------------------------- reset ---- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.2rem;
  line-height: 1.72;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; }

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

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 0.9rem;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* --------------------------------------------------------------- grain ---- */

.grain {
  position: fixed;
  inset: -20%;
  z-index: 90;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.5'/></svg>");
}

/* ------------------------------------------------------------ masthead ---- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem clamp(1.2rem, 5vw, 3.5rem);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--rule-soft);
}

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  text-decoration: none;
  margin-right: auto;
}
.wordmark-mark {
  width: 1.15rem;
  height: 1.15rem;
  align-self: center;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.9;
  stroke-linecap: round;
  transition: transform 0.5s var(--ease), opacity 0.3s;
}
.wordmark:hover .wordmark-mark { transform: rotate(-18deg); }
/* Lights off: the power glyph dims, because of course it does. */
:root[data-theme="dark"] .wordmark-mark { opacity: 0.65; }
.wordmark-text {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.005em;
}

/* The name of the site is wired to the switch. "on" and "off" are both in the
   markup; exactly one is ever displayed, and it is always the accent colour. */
.wm-on, .wm-off { color: var(--accent); }
.wm-off { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wm-on { display: none; }
  :root:not([data-theme="light"]) .wm-off { display: inline; }
}
:root[data-theme="dark"] .wm-on { display: none; }
:root[data-theme="dark"] .wm-off { display: inline; }

.nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.nav a {
  text-decoration: none;
  color: var(--ink-2);
  padding-bottom: 2px;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: color 0.25s, background-size 0.35s var(--ease);
}
.nav a:hover { color: var(--ink); background-size: 100% 1px; }

/* ---------------------------------------------------------- social icons -- */

.nav-icons {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-left: 0.2rem;
}
.nav-icons a {
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: color 0.2s, transform 0.3s var(--ease);
}
.nav-icons a:hover { color: var(--accent); transform: translateY(-1px); }
.nav-icons svg { width: 1.05rem; height: 1.05rem; }

/* ------------------------------------------------- the Tonon/Tonoff switch -- */

.tonon {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 999px;
}

.tonon-track {
  --knob-x: 0%;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 6.6rem;
  height: 1.95rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-sunk);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.09);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tonon-word {
  position: relative;
  z-index: 2;
  text-align: center;
  color: var(--ink-3);
  transition: color 0.3s;
}

.tonon-knob {
  position: absolute;
  z-index: 1;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc(50% - 2px);
  border-radius: 999px;
  background: var(--paper-lift);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transform: translateX(var(--knob-x));
  transition: transform 0.42s var(--ease), background 0.3s;
}
.tonon:hover .tonon-knob { border-color: var(--accent); }
.tonon:active .tonon-knob { transform: translateX(var(--knob-x)) scale(0.94); }

/* Lights on: the knob sits over TONON and that word lights up. */
.tonon-word-on { color: var(--accent); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tonon-track { --knob-x: 100%; }
  :root:not([data-theme="light"]) .tonon-word-on { color: var(--ink-3); }
  :root:not([data-theme="light"]) .tonon-word-off { color: var(--accent); }
}
:root[data-theme="dark"] .tonon-track { --knob-x: 100%; }
:root[data-theme="dark"] .tonon-word-on { color: var(--ink-3); }
:root[data-theme="dark"] .tonon-word-off { color: var(--accent); }

/* ---------------------------------------------------------------- main ---- */

main { padding: 0 clamp(1.2rem, 5vw, 3.5rem); }

.section-label {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-3);
  margin-bottom: 1.8rem;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.eyebrow {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- hero ---- */

.hero {
  max-width: var(--page);
  margin: clamp(2.5rem, 8vw, 5.5rem) auto clamp(3rem, 7vw, 5rem);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}

.hero-text > * { animation: rise 0.9s var(--ease) backwards; }
.hero-text > .eyebrow { animation-delay: 0.05s; }
.hero-text > .hero-title { animation-delay: 0.12s; }
.hero-text > .hero-tagline { animation-delay: 0.2s; }
.hero-text > .hero-body { animation-delay: 0.28s; }
.hero-text > .hero-byline { animation-delay: 0.34s; }
.hero-text > .hero-tags { animation-delay: 0.4s; }

.hero-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(3.6rem, 9.5vw, 7.5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 0.7rem;
}
.hero-period { color: var(--accent); }

.hero-tagline {
  font-style: italic;
  font-size: clamp(1.25rem, 2.3vw, 1.7rem);
  font-weight: 400;
  color: var(--ink-2);
  max-width: 28ch;
  line-height: 1.32;
}

.hero-body {
  margin-top: 1.5rem;
  max-width: 46ch;
  color: var(--ink-2);
  text-wrap: pretty;
}
.hero-body em { color: var(--ink); font-style: italic; }

.hero-byline {
  margin-top: 1.1rem;
  max-width: 54ch;
  text-wrap: pretty;
  font-family: var(--sans);
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink-3);
}
.hero-byline strong { color: var(--ink-2); font-weight: 700; }

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 2rem;
}

.tag {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.2rem 0.62rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  color: var(--ink-2);
  background: var(--paper-lift);
  transition: color 0.2s, border-color 0.2s, transform 0.3s var(--ease);
}
.tag:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.tag span { color: var(--ink-3); font-size: 0.76rem; }
.tag-sm { padding: 0.1rem 0.5rem; font-size: 0.78rem; }

/* ------------------------------------------------------------ portrait ---- */

.portrait {
  margin: 0 auto;
  max-width: 19rem;
  animation: rise 1s var(--ease) 0.3s backwards;
}

/* Two photos, stacked: awake with the lights on, asleep with them off. */
.portrait-frame {
  display: grid;
  border-radius: 50%;
  /* A ring rather than a frame — the GitHub avatar treatment. */
  box-shadow:
    0 0 0 1px var(--rule),
    0 0 0 0.55rem var(--paper-lift),
    0 0 0 calc(0.55rem + 1px) var(--rule),
    var(--shadow);
}
.portrait-img {
  grid-area: 1 / 1;
  width: 100%;
  /* Without this, the width/height attributes win and the circle turns oval. */
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  background: var(--paper-sunk);
  filter: saturate(0.95) contrast(1.02);
  transition: opacity 0.45s var(--ease);
}
.portrait-off, .cap-off { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .portrait-on,
  :root:not([data-theme="light"]) .cap-on { display: none; }
  :root:not([data-theme="light"]) .portrait-off { display: block; }
  :root:not([data-theme="light"]) .cap-off { display: inline; }
}
:root[data-theme="dark"] .portrait-on,
:root[data-theme="dark"] .cap-on { display: none; }
:root[data-theme="dark"] .portrait-off { display: block; }
:root[data-theme="dark"] .cap-off { display: inline; }

.portrait figcaption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  margin-top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  text-align: center;
  color: var(--ink-3);
}
.portrait figcaption b {
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

/* The switch lives with the photo on the home page. */
.tonon-hero { margin: 1.2rem auto 0; display: block; }
.page-home .masthead .tonon { display: none; }

/* ------------------------------------------------------------ featured ---- */

.featured, .archive-list, .empty {
  max-width: var(--page);
  margin: 0 auto clamp(3rem, 7vw, 5rem);
}

.section-blurb {
  max-width: 54ch;
  margin: -0.9rem 0 1.8rem;
  color: var(--ink-3);
  font-size: 1.08rem;
  text-wrap: pretty;
}

/* ------------------------------------------------------------- filters ---- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 1.6rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule-soft);
}

.filter-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.24rem 0.68rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink-2);
  background: var(--paper-lift);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.3s var(--ease);
}
.filter-chip span { font-size: 0.78rem; color: var(--ink-3); }
.filter-chip:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.filter-chip[aria-current="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
  font-weight: 700;
}
.filter-chip[aria-current="true"] span { color: color-mix(in srgb, var(--paper) 70%, transparent); }

.filter-chip-empty { opacity: 0.55; }

.filter-count {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-3);
  margin-left: auto;
}

/* ------------------------------------------------------------ featured ---- */

.feature-card {
  border-top: 2px solid var(--ink);
  padding-top: 1.5rem;
}
.feature-card > * { max-width: 52rem; }

/* The newest entry in the feed gets a little extra presence. */
.entries-lead > .entry:first-child .entry-title { font-size: 1.85rem; }
.entries-lead > .entry:first-child .entry-dek { font-size: 1.08rem; color: var(--ink-2); }
.entries-lead > .entry:first-child .entry-link { padding-top: 1.4rem; padding-bottom: 1.4rem; }
.feature-meta {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--ink-3);
}
.feature-meta .num { color: var(--accent); font-weight: 700; }
.feature-meta .dot { opacity: 0.5; }

.feature-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.1rem, 4.4vw, 3.2rem);
  line-height: 1.06;
  letter-spacing: -0.015em;
  margin: 0.6rem 0 0.8rem;
  text-wrap: balance;
}
.feature-title a {
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 2px;
  background-repeat: no-repeat;
  background-position: 0 94%;
  transition: background-size 0.5s var(--ease), color 0.3s;
}
.feature-title a:hover { color: var(--accent); background-size: 100% 2px; }

.feature-dek {
  max-width: 58ch;
  font-size: 1.2rem;
  color: var(--ink-2);
  text-wrap: pretty;
}
.feature-more { margin-top: 1.2rem; }

.readmore {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--accent);
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 0.15rem;
  transition: border-color 0.3s;
}
.readmore span { transition: transform 0.35s var(--ease); }
.readmore:hover { border-color: var(--accent); }
.readmore:hover span { transform: translateX(4px); }

/* --------------------------------------------------------- empty state ---- */

.empty-card {
  border-top: 2px solid var(--ink);
  padding-top: 1.5rem;
  max-width: 46rem;
}
.empty-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.empty-body {
  margin-top: 0.8rem;
  max-width: 52ch;
  color: var(--ink-2);
  text-wrap: pretty;
}
.empty-more { margin-top: 1.3rem; }

/* ------------------------------------------------------------- entries ---- */

.entries { list-style: none; padding: 0; margin: 0; }

.entry {
  border-bottom: 1px solid var(--rule-soft);
  opacity: 0;
  animation: rise 0.7s var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * 55ms + 0.15s);
}
.entry:first-child { border-top: 1px solid var(--rule-soft); }

.entry-link {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  align-items: baseline;
  padding: 1.05rem 0.6rem 1.05rem 0.2rem;
  text-decoration: none;
  transition: background 0.3s, padding-left 0.35s var(--ease);
}
.entry-link:hover {
  background: linear-gradient(90deg, var(--accent-soft), transparent 70%);
  padding-left: 0.7rem;
}
.entry-main { display: block; min-width: 0; }
.entry-head { display: flex; align-items: baseline; gap: 0; }

.entry-num {
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink-3);
  transition: color 0.25s;
}
.entry-link:hover .entry-num { color: var(--accent); }

.entry-title {
  flex: 0 1 auto;
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1.16;
  text-wrap: balance;
  transition: color 0.25s;
}
.entry-link:hover .entry-title { color: var(--accent); }

.entry-dek {
  display: block;
  margin-top: 0.25rem;
  max-width: 62ch;
  font-size: 1.04rem;
  color: var(--ink-3);
  line-height: 1.5;
  text-wrap: pretty;
}

/* A table-of-contents dot leader, painted just above the text baseline. */
.entry-leader {
  flex: 1 1 1.5rem;
  min-width: 1.5rem;
  align-self: stretch;
  position: relative;
}
.entry-leader::before {
  content: "";
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.44em;
  height: 1px;
  background-image: linear-gradient(90deg, var(--rule) 40%, transparent 40%);
  background-size: 5px 1px;
  background-repeat: repeat-x;
}

.entry-date {
  flex: none;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.archive-more { margin-top: 2rem; }

/* --------------------------------------------------------- list pages ---- */

.page-head {
  max-width: var(--page);
  margin: clamp(2.5rem, 7vw, 4.5rem) auto 3rem;
}
.page-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
.page-intro {
  margin-top: 0.9rem;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.page-intro em { font-style: italic; color: var(--ink); }

.archive { max-width: var(--page); margin: 0 auto 5rem; }
.year { margin-bottom: 3rem; }
.year-label {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.7rem;
}

/* ---------------------------------------------------------------- post ---- */

.post {
  max-width: var(--measure);
  margin: clamp(2.5rem, 7vw, 4.5rem) auto clamp(3rem, 7vw, 5rem);
  position: relative;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 85;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
@supports (animation-timeline: scroll()) {
  .progress {
    animation: progress linear;
    animation-timeline: scroll(root block);
  }
}

.post-head { margin-bottom: 2.6rem; }
.post-kicker {
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.post-kicker a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s;
}
.post-kicker a:hover { border-color: var(--accent); }
.post-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.4rem, 5.4vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 0;
  text-wrap: balance;
}
.post-dek {
  margin-top: 0.9rem;
  font-size: 1.35rem;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}

.post-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1rem 1.5rem;
  margin-top: 1.9rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.post-meta dt {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 0.25rem;
}
.post-meta dd {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.94rem;
  color: var(--ink-2);
}
.post-meta-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.toc {
  margin: 0 0 2.4rem;
  padding: 1rem 1.3rem;
  background: var(--paper-sunk);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
}
.toc-label {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 0.4rem;
}
.toc ol { margin: 0; padding-left: 1.3rem; color: var(--ink-2); }
.toc li { margin-bottom: 0.15rem; }
.toc a { text-decoration: none; border-bottom: 1px solid transparent; }
.toc a:hover { color: var(--accent); border-color: var(--accent-soft); }

/* ----------------------------------------------------------- post body ---- */

.post-body {
  font-size: 1.22rem;
  line-height: 1.78;
  counter-reset: section;
}
.post-body > * + * { margin-top: 1.1em; }
.post-body p { text-wrap: pretty; }

.post-body > p:first-of-type::first-line {
  font-variant-caps: small-caps;
  letter-spacing: 0.03em;
}

.post-body h2, .post-body h3 {
  font-family: var(--display);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.012em;
  position: relative;
}
.post-body h2 {
  font-size: 2rem;
  margin-top: 2.5em;
  counter-increment: section;
}
.post-body h2::before {
  content: counter(section);
  position: absolute;
  left: -2.6rem;
  top: 0.3em;
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
}
.post-body h3 { font-size: 1.5rem; margin-top: 2em; }
.post-body h4 {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-top: 2em;
}

.anchor {
  margin-left: 0.5rem;
  font-family: var(--sans);
  font-size: 0.55em;
  color: var(--accent);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.25s;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }

.post-body a:not(.anchor):not(.tag) {
  color: inherit;
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 1px;
  background-repeat: no-repeat;
  background-position: 0 1.15em;
  transition: background-size 0.3s var(--ease), color 0.25s;
}
.post-body a:not(.anchor):not(.tag):hover { color: var(--accent); background-size: 100% 2px; }
.post-body a.external::after {
  content: "↗";
  font-family: var(--sans);
  font-size: 0.7em;
  vertical-align: 0.35em;
  margin-left: 0.15em;
  color: var(--ink-3);
}

.post-body strong { font-weight: 700; }
.post-body em { font-style: italic; }

.post-body ul, .post-body ol { padding-left: 1.4rem; }
.post-body li + li { margin-top: 0.35em; }
.post-body li::marker { color: var(--ink-3); }

.post-body blockquote {
  margin-left: 0;
  padding: 0.2rem 0 0.2rem 1.4rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
  font-size: 1.24rem;
  color: var(--ink-2);
}
.post-body blockquote p + p { margin-top: 0.7em; }

.post-body hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 3em 0;
  position: relative;
}
.post-body hr::after {
  content: "❊";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: 0 0.8rem;
  color: var(--ink-3);
  font-size: 1rem;
}

figure { margin: 2.3em 0; }
figure img { border: 1px solid var(--rule); border-radius: 3px; width: 100%; height: auto; }
figcaption {
  margin-top: 0.6rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* --------------------------------------------------------------- video ---- */

.video { margin: 2.4em 0; }
.video-embed {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.25s, transform 0.4s var(--ease);
  /* Designed placeholder: if the YouTube thumbnail is blocked or missing, this
     is what you see, and it should look intentional rather than broken. */
  background:
    radial-gradient(120% 120% at 20% 0%, var(--accent-soft), transparent 62%),
    linear-gradient(160deg, var(--paper-lift), var(--paper-sunk));
}
.video-embed img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  display: block;
  transition: filter 0.4s;
}

/* Only shown when there is no thumbnail to show. */
.video-label {
  position: absolute;
  left: 1.1rem;
  right: 1.1rem;
  bottom: 1rem;
  font-family: var(--sans);
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  color: var(--ink-2);
  display: none;
}
.video-embed:not(:has(img)) .video-label { display: block; }
.video-embed:hover { border-color: var(--accent); transform: translateY(-2px); }
.video-embed:hover img { filter: brightness(1.06); }

/* A play button, drawn rather than downloaded. */
.video-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.video-play::before {
  content: "";
  width: 4.2rem;
  height: 4.2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 92%, transparent);
  box-shadow: 0 6px 24px -6px rgba(0, 0, 0, 0.6);
  transition: transform 0.35s var(--ease), background 0.25s;
}
.video-play::after {
  content: "";
  position: absolute;
  border-style: solid;
  border-width: 0.72rem 0 0.72rem 1.18rem;
  border-color: transparent transparent transparent #fff;
  transform: translateX(0.16rem);
}
.video-embed:hover .video-play::before { transform: scale(1.09); }

.video-frame, .video-file {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #000;
  box-shadow: var(--shadow);
}
.video-link { white-space: nowrap; }
.post-body .video figcaption { margin-top: 0.7rem; }

/* --------------------------------------------------------------- audio ---- */

.audio { margin: 2.2em 0; }
.audio-embed {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.2rem;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
  background:
    radial-gradient(90% 140% at 0% 0%, var(--accent-soft), transparent 60%),
    var(--paper-lift);
  transition: border-color 0.25s, transform 0.35s var(--ease);
}
.audio-embed:hover { border-color: var(--accent); transform: translateY(-2px); }
.audio-play {
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--accent);
  display: grid;
  place-items: center;
  position: relative;
}
.audio-play::after {
  content: "";
  position: absolute;
  border-style: solid;
  border-width: 0.42rem 0 0.42rem 0.68rem;
  border-color: transparent transparent transparent #fff;
  transform: translateX(0.09rem);
}
.audio-label {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--ink-2);
}
.audio-frame {
  display: block;
  width: 100%;
  height: 152px;
  border: 0;
  border-radius: 12px;
}

/* ------------------------------------------------------------- diagrams ---- */

.diagram { margin: 2.4em 0; }
.diagram svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
/* Hand-drawn diagrams inherit the page palette through these classes. */
.diagram .dg-stroke { stroke: var(--ink-2); fill: none; }
.diagram .dg-accent { stroke: var(--accent); fill: none; }
.diagram .dg-fill { fill: var(--paper-lift); stroke: var(--rule); }
.diagram .dg-text {
  fill: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
}
.diagram .dg-note { fill: var(--ink-3); font-family: var(--sans); font-size: 14px; }

/* ---------------------------------------------------------------- code ---- */

code, kbd, samp { font-family: var(--mono); }

.post-body :not(pre) > code {
  font-size: 0.8em;
  padding: 0.12em 0.34em;
  background: var(--paper-sunk);
  border: 1px solid var(--rule-soft);
  border-radius: 3px;
  white-space: nowrap;
}

pre {
  margin: 2em 0;
  padding: 1.1rem 1.2rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper-sunk) !important;
  font-size: 0.86rem;
  line-height: 1.62;
  tab-size: 2;
  scrollbar-width: thin;
}
pre code { display: block; width: fit-content; min-width: 100%; }

/* Shiki emits both themes as custom properties; pick one with no reflow. */
.shiki, .shiki span { color: var(--shiki-light); background: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shiki,
  :root:not([data-theme="light"]) .shiki span { color: var(--shiki-dark); }
}
:root[data-theme="dark"] .shiki,
:root[data-theme="dark"] .shiki span { color: var(--shiki-dark); }

/* --------------------------------------------------------------- table ---- */

.table-scroll { overflow-x: auto; margin: 2em 0; scrollbar-width: thin; }
.post-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 1.02rem;
  font-variant-numeric: tabular-nums;
}
.post-body thead th {
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  padding: 0 0.8rem 0.45rem;
  border-bottom: 1px solid var(--ink-3);
  text-align: left;
}
/* Sans labels want to be small; a formula in a header does not. */
.post-body th .katex { font-size: 1.35em; text-transform: none; }
.post-body tbody td {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--rule-soft);
}
.post-body tbody tr:hover { background: var(--accent-soft); }
.post-body td:first-child, .post-body th:first-child { padding-left: 0; }

/* ----------------------------------------------------------- sidenotes ---- */

.sn-ref {
  font-family: var(--sans);
  font-size: 0.62em;
  font-weight: 700;
  vertical-align: 0.5em;
  color: var(--accent);
  margin-left: 0.1em;
  cursor: pointer;
  padding: 0 0.1em;
  border-radius: 2px;
  transition: background 0.2s;
}
.sn-ref:hover { background: var(--accent-soft); }
.sn-toggle { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

.sidenote {
  display: none;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.sn-num {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  vertical-align: 0.45em;
  margin-right: 0.3em;
}
.sn-toggle:checked + .sidenote {
  display: block;
  margin: 1rem 0 1rem 1.2rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent-soft);
}

/* --------------------------------------------------------- post footer ---- */

.post-foot {
  margin-top: 3.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}

.cite summary {
  font-family: var(--sans);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.cite summary::-webkit-details-marker { display: none; }
.cite summary::before {
  content: "+";
  color: var(--accent);
  font-size: 1rem;
  transition: transform 0.3s var(--ease);
}
.cite[open] summary::before { transform: rotate(45deg); }
.cite summary:hover { color: var(--ink); }
.bibtex {
  margin: 1rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-2);
  background: var(--paper-sunk) !important;
}

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin-top: 2.4rem;
}
.pager-item {
  display: block;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-decoration: none;
  transition: border-color 0.25s, transform 0.35s var(--ease), background 0.25s;
}
a.pager-item:hover {
  border-color: var(--accent);
  background: var(--paper-lift);
  transform: translateY(-2px);
}
.pager-next { text-align: right; }
.pager-empty { border: 0; }
.pager-label {
  display: block;
  font-family: var(--sans);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-3);
  margin-bottom: 0.3rem;
}
.pager-title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.2;
}
a.pager-item:hover .pager-title { color: var(--accent); }

/* ------------------------------------------------------------ comments ---- */
/* The box itself is an iframe styled by giscus-{light,dark}.css; everything
   here is the frame around it, set to the same measure as the post. */

.comments {
  max-width: var(--measure);
  margin: 0 auto clamp(3rem, 7vw, 5rem);
}
.comments-note {
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-3);
  margin: 0.9rem 0 1.8rem;
  max-width: 32rem;
}
.comments-note a { color: var(--ink-2); text-decoration-color: var(--rule); }
.comments-note a:hover { color: var(--accent); }

/* Hold the space the frame will take, so the footer does not jump when giscus
   finishes loading. */
.giscus { min-height: 14rem; }
.giscus noscript {
  display: block;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-3);
}

/* ----------------------------------------------------------------- math --- */

.math-inline {
  display: inline-block;
  white-space: nowrap;
  text-indent: 0;
}
.math-block {
  margin: 1.7em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4rem 0;
  scrollbar-width: thin;
}
.katex { font-size: 1.02em; }
.katex-display { margin: 0; }
.tex-error { color: var(--accent); }

/* --------------------------------------------------------------- 404 ------ */

.notfound {
  max-width: 34rem;
  margin: clamp(4rem, 14vh, 9rem) auto;
}
.notfound .hero-title { font-size: clamp(3rem, 8.5vw, 5.5rem); margin: 0.4rem 0 1.4rem; }
.notfound em { color: var(--accent); font-style: italic; }
.notfound p { margin-bottom: 1.4rem; }

/* -------------------------------------------------------------- footer ---- */

.footer {
  max-width: var(--page);
  margin: 6rem auto 0;
  padding: 0 clamp(1.2rem, 5vw, 3.5rem) 3rem;
}
.footer-rule { height: 1px; background: var(--rule); margin-bottom: 1.5rem; }
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  justify-content: space-between;
  align-items: flex-start;
}
.footer-name {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 500;
}
.footer-meta {
  margin-top: 0.2rem;
  max-width: 36ch;
  font-family: var(--sans);
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--ink-3);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.3rem;
  list-style: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
}
.footer-links a {
  text-decoration: none;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}
.footer-links a:hover { color: var(--accent); border-color: var(--accent); }
.colophon {
  margin-top: 2.2rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  color: var(--ink-3);
}

/* ------------------------------------------------------------ keyframes --- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes progress { to { transform: scaleX(1); } }

/* ------------------------------------------------------------ responsive -- */

/* Wide: sidenotes move into the right margin. */
@media (min-width: 78rem) {
  .post { max-width: calc(var(--measure) + var(--gutter) + 3rem); }
  .post > *, .post-body > * { max-width: var(--measure); }
  .post-body { max-width: none; }
  .post-body > * { max-width: var(--measure); }

  .sn-ref { cursor: default; }
  .sidenote,
  .sn-toggle:checked + .sidenote {
    display: block;
    float: right;
    clear: right;
    width: var(--gutter);
    margin: 0.35rem calc(-1 * (var(--gutter) + 3rem)) 1.2rem 0;
    padding: 0;
    border: 0;
    position: relative;
  }
  .sn-ref:hover ~ .sidenote { color: var(--ink); }
  .sn-ref:hover ~ .sidenote .sn-num { background: var(--accent-soft); }
}

@media (max-width: 64rem) {
  .hero { grid-template-columns: 1fr; gap: 3rem; justify-items: start; }
  .portrait { order: -1; max-width: 13rem; margin: 0; }
  .portrait figcaption { align-items: flex-start; text-align: left; margin-top: 1.4rem; }
}

@media (max-width: 44rem) {
  body { font-size: 1.12rem; }
  .masthead { gap: 0.7rem; padding: 0.85rem 1.1rem; }
  .nav { gap: 0.85rem; font-size: 0.8rem; }
  .nav-icons { gap: 0.6rem; margin-left: 0; }
  .nav-icons svg { width: 0.95rem; height: 0.95rem; }
  .wordmark-text { font-size: 1.2rem; }
  .wordmark-mark { width: 1rem; height: 1rem; }
  .tonon-track { width: 5.3rem; height: 1.7rem; font-size: 0.6rem; letter-spacing: 0.03em; }

  .entry-link { grid-template-columns: 2.4rem minmax(0, 1fr); padding: 0.95rem 0.2rem; }
  .entry-head { gap: 0.8rem; }
  .entry-leader { display: none; }
  .entry-title { font-size: 1.3rem; }
  .entry-date { font-size: 0.8rem; }

  .post-body { font-size: 1.14rem; }
  .post-body h2::before { position: static; display: inline; margin-right: 0.6rem; }
  .post-meta { grid-template-columns: 1fr 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; }
  .footer { margin-top: 4rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
  .entry, .hero-text > * { opacity: 1; }
}

/* ---------------------------------------------------------------- print --- */

@media print {
  .grain, .masthead, .theme-toggle, .progress, .pager, .toc { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .post { max-width: none; }
  .sidenote { display: block; font-size: 9pt; border-left: 1px solid #999; padding-left: 8pt; margin: 8pt 0 8pt 12pt; }
  a { text-decoration: underline; }
  pre { border: 1px solid #ccc; background: #fafafa !important; }
}

/* The playable project opens this post before the making-of text. */
.game-launch{margin:0 0 3rem;grid-column:1 / -1;border:1px solid var(--rule, #85766340);background:#102422;color:#eee6d1}.game-poster{position:relative;display:block;text-decoration:none!important;overflow:hidden}.game-poster img{display:block;width:100%;height:auto;aspect-ratio:16/9;object-fit:cover}.game-start{position:absolute;right:6%;bottom:12%;display:flex;align-items:center;gap:36px;padding:17px 24px;background:#eaddb9;color:#143027;font-family:'Alegreya Sans',sans-serif;font-weight:700;font-size:19px;box-shadow:0 6px 35px #0005}.game-poster:hover .game-start{background:#fff0c9}.game-poster:focus-visible{outline:3px solid #cba96a;outline-offset:5px}.game-start>span{font-size:25px}.game-launch-caption{padding:18px 24px;display:flex;flex-direction:column;gap:4px;font-family:'Alegreya Sans',sans-serif}.game-launch-caption strong{font-size:22px}.game-launch-caption span{font-size:15px;color:#bfcab6}.game-launch-caption small{font-size:13px;color:#a2b39f;margin-top:5px}
@media(max-width:600px){.game-start{font-size:16px;padding:12px 16px;right:5%;bottom:10%;gap:18px}.game-launch-caption{padding:14px 18px}.game-launch-caption strong{font-size:20px}}

/* Each comparison keeps its source beside the adaptation, then stacks on phones. */
.spoiler-notice{border-left:3px solid var(--accent);padding:.8rem 1.1rem;background:var(--accent-soft);margin:3rem 0 1.5rem}
.puzzle-study{border-top:1px solid var(--rule);margin:2rem 0;padding-top:1rem;scroll-margin-top:5rem}
.puzzle-study h4{font-size:1.3rem;margin:0 0 1rem}.puzzle-study h5{font-family:'Alegreya Sans',sans-serif;font-size:.88rem;font-weight:700;margin:0 0 .5rem;color:var(--muted)}
.puzzle-compare{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1.5rem}.puzzle-compare p{font-size:1.05rem;line-height:1.65;margin:0}
.puzzle-compare .comparison-shot{margin:.75rem 0 1rem}
.comparison-shot a{display:block;border-radius:3px;overflow:hidden}
.comparison-shot a:focus-visible{outline:3px solid var(--ink);outline-offset:4px}
.comparison-shot img{display:block;width:100%;height:auto;aspect-ratio:16/10;object-fit:contain;background:#e9e6de}
.comparison-shot figcaption{font-size:.88rem;line-height:1.45;min-height:3em}
.study-images{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;margin:2rem 0}.study-images figure{margin:0}.study-images img{width:100%;height:auto}.study-images figcaption{font-size:.9rem;line-height:1.5}
@media(max-width:600px){.puzzle-compare,.study-images{grid-template-columns:1fr;gap:1rem}.puzzle-compare>div+div{border-left:2px solid var(--rule);padding-left:1rem}}
