/* ============================================================================
   tokens.css — colours, type scale, spacing.  The whole theme lives here.

   Black ink on white paper.  The page is always white: there is no dark mode,
   so a reader's system setting cannot turn it grey or black.  Nothing has a
   tinted background -- listings, inline code, callouts and tables are separated
   by rules and spacing alone.

   Fonts are declared in the [fonts] table of site.toml; the build emits them
   after this file, so what is below is only the fallback when no font is
   configured.
   ========================================================================== */

:root {
  color-scheme: only light;

  /* ink and paper */
  --bg:        #ffffff;
  --fg:        #000000;
  --fg-dim:    #3c3c39;
  --fg-faint:  #77776f;
  --rule:      #b6b6b0;
  --rule-soft: #dededa;
  --link:      #000000;
  --link-hover:#000000;

  /* callouts: the GitHub alert palette, used only on the bar and the title */
  --alert-note:      #0969da;
  --alert-tip:       #1a7f37;
  --alert-important: #8250df;
  --alert-warning:   #9a6700;
  --alert-caution:   #d1242f;

  /* Type is a build setting: [fonts] in site.toml emits the real stacks after
     this file.  What is here is only the bare fallback for a project that
     configures nothing, so swapping fonts never means editing CSS. */
  --font-body: serif;
  --font-algo: serif;
  --font-code: monospace;

  /* Code: a pale blue-grey slab, rounded, with a restrained palette --
     type names crimson, control words green, function names blue, numbers and
     operators grey, comments teal italic. */
  --code-bg:       #e7e9f1;
  --code-fg:       #1c1c1c;
  --code-comment:  #4b7b7e;
  --code-type:     #a0213f;
  --code-keyword:  #2b7a0b;
  --code-func:     #1f1fd6;
  --code-string:   #a31515;
  --code-number:   #6a6a6a;
  --code-operator: #6a6a6a;
  --code-radius:   10px;

  --fs: 18px;
  --lh: 1.72;

  /* 48rem ~ 43 CJK characters per line.  Both widths can be changed in the
     [layout] table of site.toml; page follows the measure unless set. */
  --measure: 48rem;
  --page:    calc(var(--measure) + 22.5rem);

  /* rhythm */
  --s1: 0.35rem;
  --s2: 0.7rem;
  --s3: 1.1rem;
  --s4: 1.9rem;
  --s5: 3rem;
}

/* generated from [fonts] in site.toml */
:root {
  --font-body: "Seaford", "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Palatino", "Source Serif Pro", serif;
  --font-code: "Courier", "Courier New", "Menlo", "Consolas", monospace;
  --font-algo: "Seaford", "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Palatino", serif;
}
@font-face { font-family: "Seaford"; src: url("/assets/fonts/SeafordRg.woff2?v=6d273c6a"); font-weight: 400; font-style: normal; font-display: optional; }
@font-face { font-family: "Seaford"; src: url("/assets/fonts/SeafordMed.woff2?v=de248fb6"); font-weight: 700; font-style: normal; font-display: optional; }
@font-face { font-family: "Seaford"; src: url("/assets/fonts/SeafordRgIt.woff2?v=12fcdb56"); font-weight: 400; font-style: italic; font-display: optional; }
@font-face { font-family: "Seaford"; src: url("/assets/fonts/SeafordMedIt.woff2?v=5f7c7883"); font-weight: 700; font-style: italic; font-display: optional; }

/* ============================================================================
   style.css — one stylesheet, read top to bottom.

   Rules of the house: monochrome, no shadows, no rounded cards, no colour that
   is not doing work.  Hierarchy comes from type size, spacing and 1px rules;
   links are underlined rather than tinted.

   Three type roles, each configurable in site.toml:
     --font-body   prose and headings
     --font-algo   algorithm listings (a paper face, even when body is not)
     --font-code   code blocks, inline code, the language label
   ========================================================================== */

/* 1. reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
  scrollbar-gutter: stable;
}

/* Motion changes paint, never type weight or box geometry. Keep native focus
   visible; touch feedback replaces WebKit's large grey tap flash. */
a, button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
a, button {
  transition: color 140ms ease, text-decoration-color 140ms ease,
              opacity 140ms ease, background-color 140ms ease;
}
a:active, button:active { opacity: 0.65; }
input { transition: border-color 140ms ease, box-shadow 140ms ease; }

/* A delayed, indeterminate top edge: no overlay, fake percentage, or layout
   shift. Fast loads show nothing; slower loads keep the document readable. */
html::before {
  content: '';
  position: fixed;
  inset: 0 auto auto 0;
  width: 35%;
  height: 2px;
  background: var(--fg);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
}
html.page-loading::before {
  animation: page-progress 1.2s ease-in-out 180ms infinite;
}
@keyframes page-progress {
  0% { opacity: 1; transform: translateX(-100%); }
  100% { opacity: 1; transform: translateX(300%); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  a, button, input { transition: none; }
  html.page-loading::before { animation: none; opacity: 1; width: 100%; }
}
@media print { html::before { display: none; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }

/* 2. base type ------------------------------------------------------------ */
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.17em;
  text-decoration-color: currentColor;
}
a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.26;
  margin: 0;
  text-wrap: balance;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--s5) 0;
}

::selection { background: #d8d8d2; color: #000; }

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  background: var(--bg);
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--rule);
}

/* 3. frame ---------------------------------------------------------------- */
.masthead { margin-bottom: var(--s5); }
.masthead-inner,
.foot-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.masthead-inner {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  flex-wrap: wrap;
  padding-top: 1.6rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule-soft);
}

.brand {
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: var(--fg);
  text-decoration: none;
  margin-right: auto;
}
.brand:hover { color: var(--fg); text-decoration: none; }

.nav, .langs {
  display: flex;
  gap: 1.4rem;
  font-size: 0.92rem;
}
.nav a { color: var(--fg-dim); text-decoration: none; }
.nav a:hover { color: var(--fg); text-decoration: underline; }
.nav a[aria-current="page"] {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 0.4em;
  text-decoration-thickness: 1.5px;
}
.langs { font-size: 0.85rem; padding-left: 1.4rem; border-left: 1px solid var(--rule-soft); }
.langs a { color: var(--fg-dim); text-decoration: none; }
.langs a:hover { color: var(--fg); text-decoration: underline; }
.langs [aria-current="true"] { color: var(--fg-faint); }

.foot-space { height: 4rem; }
.foot {
  margin-top: var(--s5);
  padding: 0 0 3rem;
  font-size: 0.84rem;
  color: var(--fg-faint);
}
.foot-inner {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule-soft);
}

.sep { color: var(--fg-faint); }

/* 4. measure -------------------------------------------------------------- */
/* Header, footer and every page share one left edge; prose is held to the
   measure inside it instead of being centred on its own.  <main> is a size
   container so the build can ask, in the prose's own font units, whether the
   table of contents still fits beside it: keep it block-level and present
   (inline-size containment makes a shrink-to-fit main collapse). */
main { container-type: inline-size; }
.shell {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.shell > * { max-width: var(--measure); }

.page-title {
  font-size: 2rem;
  margin-bottom: var(--s2);
}
.page-sub {
  color: var(--fg-dim);
  font-size: 0.92rem;
  margin: 0 0 var(--s4);
}

/* 5. home ----------------------------------------------------------------- */
.intro { margin-bottom: var(--s5); }
.intro p { margin: 0 0 0.85em; max-width: var(--measure); }

.section-label,
.year-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--fg-faint);
  margin: var(--s4) 0 var(--s2);
}
.year + .year { margin-top: var(--s4); }
.year-label {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.3rem;
  margin-bottom: 0.55rem;
}

.entries {
  list-style: none;
  margin: 0;
  padding: 0;
}
.entries li {
  display: grid;
  grid-template-columns: 6.2em 1fr;
  column-gap: 0.7em;
  align-items: baseline;
  padding: 0.22rem 0;
}
.entries time {
  font-size: 0.85rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.entries a { color: var(--fg); text-decoration: none; }
.entries a:hover { color: var(--fg); text-decoration: underline; }

.more { margin-top: var(--s4); font-size: 0.9rem; color: var(--fg-dim); }

/* 6. tag index ------------------------------------------------------------ */
/* Tags are a flowing row of outlined chips: name, then a small count.  The
   fill stays white; only the hairline darkens on hover. */
.shell > .taglist { max-width: none; }
.taglist {
  list-style: none;
  margin: 1.8em 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 0.6rem;
}
.tag-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55em;
  padding: 0.3em 0.95em 0.34em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--fg);
  text-decoration: none;
  line-height: 1.4;
  transition: border-color 0.12s;
}
.tag-chip:hover { border-color: var(--fg); text-decoration: none; }
.tag-chip .count {
  color: var(--fg-faint);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* 6b. search -------------------------------------------------------------- */
.shell > .search { max-width: 34rem; }
.search-input {
  width: 100%;
  padding: 0.55em 0.9em;
  font: inherit;
  color: var(--fg);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--code-radius, 10px);
}
.search-input:focus {
  outline: none;
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}
.search-input::placeholder { color: var(--fg-faint); }
.search-status {
  margin: 1rem 0 1.4rem;
  font-size: 0.88rem;
  color: var(--fg-faint);
}
.search-status { min-height: 1.6em; }
.search-status.is-loading::after {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.6em;
  border: 1px solid var(--rule);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: search-spin 800ms linear infinite;
}
@keyframes search-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .search-status.is-loading::after { animation: none; }
}
.shell > .search-results { max-width: none; }
.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}
.search-results li {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--rule-soft);
}
.search-results li:last-child { border-bottom: 1px solid var(--rule-soft); }
.search-results a { font-size: 1.05rem; text-decoration: none; }
.search-results a:hover { text-decoration: underline; }
.search-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  font-size: 0.8rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}
.search-tag::before { content: "#"; margin-right: 0.1em; opacity: 0.6; }
.search-tag { margin-right: 0.5rem; }
.search-snippet { font-size: 0.92rem; color: var(--fg-dim); line-height: 1.55; }

/* 7. article -------------------------------------------------------------- */
.post {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.post-main { min-width: 0; width: 100%; max-width: var(--measure); }

.post-head { margin-bottom: var(--s4); }
.post-head h1 {
  font-size: 2rem;
  line-height: 1.18;
  margin-bottom: 0.5rem;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.8rem;
  margin: 0.35rem 0 0;
  font-size: 0.87rem;
  color: var(--fg-faint);
}
.post-meta time { font-variant-numeric: tabular-nums; }
.taglink { color: var(--fg-dim); text-decoration: none; }
.taglink:hover { color: var(--fg); text-decoration: underline; }

.toc { display: none; }

@media (min-width: 70.5rem) {
  .post {
    /* The table of contents yields its width before the prose does. */
    grid-template-columns: minmax(0, var(--measure)) minmax(0, 16rem);
    column-gap: 2.5rem;
    justify-content: start;
  }
  .toc {
    display: block;
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding-left: 1rem;
    border-left: 1px solid var(--rule-soft);
    /* Clearly an index, not a second column: smaller than the prose it sits
       beside, but still at a comfortable reading size. */
    font-size: 0.875rem;
    line-height: 1.45;
  }
  .toc-title {
    margin: 0 0 0.75em;
    padding-bottom: 0.55em;
    border-bottom: 1px solid var(--rule-soft);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-faint);
  }
  .toc ol { list-style: none; margin: 0; padding: 0; }
  /* Entries are separated by space, not markers: the hairline left rule already
     says "aside", so a second device would only add noise. */
  .toc li { margin: 0.5em 0; }
  .toc a {
    color: var(--fg-dim);
    text-decoration: none;
  }
  .toc a:hover,
  .toc a:focus-visible {
    color: var(--fg);
    text-decoration: underline;
    text-underline-offset: 0.22em;
  }
  /* The third level keeps the reading size and moves inward instead, so depth
     is a change of position rather than a change of type. */
  .toc-l3 { margin: 0.42em 0 0.42em 1.15em; }
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  border-top: 1px solid var(--rule);
  margin-top: var(--s5);
  padding-top: var(--s3);
  font-size: 0.9rem;
}
.post-nav a {
  color: var(--fg);
  text-decoration: none;
  max-width: 48%;
}
.post-nav a:hover { text-decoration: underline; }
.post-nav span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.post-nav .next { text-align: right; margin-left: auto; }

/* 8. prose ---------------------------------------------------------------- */
.author-profile { display: flex; align-items: center; gap: 1.5rem; margin: 1.5rem 0 2rem; }
.author-avatar { width: 112px; height: 112px; border-radius: 50%; object-fit: cover; flex: none; }
.author-profile p { margin: 0.35em 0; }
.author-name { font-size: 1.25rem; font-weight: 400; }
@media (max-width: 40rem) { .author-profile { flex-direction: column; align-items: flex-start; } }
.prose { font-size: 1.125rem; }
.prose > *:first-child { margin-top: 0; }

.prose p { margin: 0.9em 0; text-wrap: pretty; }
.prose h2 {
  font-size: 1.5rem;
  margin: 2.1em 0 0.55em;
}
.prose h3 {
  font-size: 1.28rem;
  margin: 1.7em 0 0.45em;
}
.prose h4 {
  font-size: 1.16rem;
  margin: 1.5em 0 0.4em;
}
/* Below h4 the scale has no room left, so h5/h6 are run-in headings: they keep
   the reading size and separate themselves with weight and spacing instead.
   Without this they would fall back to the browser's 0.83em/0.67em -- smaller
   than the prose they introduce. */
.prose h5,
.prose h6 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 1.4em 0 0.3em;
}
.prose ul, .prose ol { margin: 0.85em 0; padding-left: 1.5em; }
.prose li { margin: 0.26em 0; }
.prose li > ul, .prose li > ol { margin: 0.22em 0; }

.prose blockquote {
  margin: 1.4em 0;
  padding: 0.1em 0 0.1em 1em;
  border-left: 2px solid var(--rule);
  color: var(--fg-dim);
}
.prose blockquote p { margin: 0.55em 0; }

.prose code {
  font-family: var(--font-code);
  font-size: 0.84em;
  padding: 0.08em 0.35em;
  background: var(--code-bg);
  border-radius: 4px;
  overflow-wrap: break-word;
  font-variant-ligatures: none;
}
.prose pre code { padding: 0; background: none; border-radius: 0; font-size: inherit; }

.prose img { display: block; margin: 1.6em auto; }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--fg-dim);
}
.prose table th,
.prose table td {
  text-align: left;
  padding: 0.32em 0.9em 0.32em 0;
  vertical-align: top;
}
.prose table thead th {
  border-bottom: 1px solid var(--fg-dim);
  font-weight: 700;
}
.prose table tbody tr { border-bottom: 1px solid var(--rule-soft); }
.prose table tbody tr:last-child { border-bottom: 1px solid var(--fg-dim); }

.prose .footnotes {
  margin-top: var(--s5);
  padding-top: var(--s2);
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--fg-dim);
}

/* 8b. comments ------------------------------------------------------------ */
/* Opt-in: the section only exists when [comments] is configured.  It sits in
   the reading column, after the prev/next links, so it shares their left edge
   and width instead of opening a separate full-width band. */
.comments {
  margin-top: var(--s5);
  padding-top: var(--s3);
  border-top: 1px solid var(--rule);
}
.comments-title {
  font-size: 1.28rem;
  margin: 0 0 0.35em;
}
.comments-note {
  margin: 0 0 var(--s4);
  font-size: 0.88rem;
  color: var(--fg-faint);
}
.comments-mount { min-height: 3rem; }
.comments-status {
  margin: 0.8em 0;
  font-size: 0.9rem;
  color: var(--fg-dim);
}
.comments-status a { color: var(--fg); }

/* 9. code blocks ---------------------------------------------------------- */
/* A pale blue-grey rounded slab and a coloured, restrained palette.  No
   language label -- the reader can see what it is.  The copy button is the
   only chrome and appears on hover. */
.code-block {
  position: relative;
  margin: 1.5em 0;
  background: var(--code-bg);
  border-radius: var(--code-radius);
}
.code-head {
  position: absolute;
  top: 0.45rem;
  right: 0.7rem;
  display: flex;
  gap: 0.9em;
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--fg-faint);
}
.code-lang { font-style: italic; }
.code-copy {
  border: 0;
  background: var(--code-bg);
  padding: 0.25rem 0.35rem;
  min-inline-size: 7em;
  min-block-size: 2rem;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--fg-faint);
  cursor: pointer;
  opacity: 0;
}
.code-block:hover .code-copy,
.code-copy:focus-visible,
.code-copy[data-copy-busy] { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .code-copy { opacity: 1; min-block-size: 44px; }
}
.code-copy:hover { color: var(--fg); text-decoration: underline; }
.code-body {
  margin: 0;
  padding: 0.95rem 1.2rem;
  overflow-x: auto;
  background: none;
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--code-fg);
  font-variant-ligatures: none;
  tab-size: 4;
}

/* Pygments classes -> the palette.  Type names crimson, control words green,
   function names blue, numbers and operators grey, comments teal italic. */
.tok-kt, .tok-kd, .tok-nc, .tok-nn, .tok-ne { color: var(--code-type); }
.tok-k, .tok-kc, .tok-kn, .tok-kp, .tok-kr, .tok-ow, .tok-nb, .tok-bp { color: var(--code-keyword); }
.tok-k, .tok-kc, .tok-kd, .tok-kn, .tok-kp, .tok-kr, .tok-kt, .tok-ow { font-weight: 700; }
.tok-nf, .tok-fm, .tok-nd, .tok-na { color: var(--code-func); }
.tok-s, .tok-sa, .tok-sb, .tok-sc, .tok-sd, .tok-se, .tok-sh,
.tok-si, .tok-sr, .tok-ss, .tok-s1, .tok-s2, .tok-dl { color: var(--code-string); }
.tok-m, .tok-mb, .tok-mf, .tok-mh, .tok-mi, .tok-mo, .tok-il { color: var(--code-number); }
.tok-o, .tok-p { color: var(--code-operator); }
.tok-c, .tok-c1, .tok-cm, .tok-cp, .tok-cs, .tok-ch {
  color: var(--code-comment);
  font-style: italic;
}
/* Pygments marks anything its lexer did not recognise as an error token.  In a
   listing that is usually a grammar mismatch (an objdump listing read as GNU
   asm, say), not a mistake worth pointing a line at, so keep the text plain
   instead of underlining half the bytes. */
.tok-err { color: inherit; }

/* 10. algorithms ---------------------------------------------------------- */
/* The `algorithm` package: top rule, caption rule, bottom rule, nothing else. */
.algo {
  margin: 2.1em 0;
  border-top: 1px solid var(--fg);
  border-bottom: 1px solid var(--fg);
}
.algo-cap {
  padding: 0.3rem 0 0.36rem;
  border-bottom: 1px solid var(--fg);
  font-family: var(--font-algo);
  font-size: 0.93rem;
}
.fig-tag { font-weight: 700; margin-right: 0.65em; }
.algo-title { color: var(--fg-dim); }

.algo-body {
  position: relative;
  counter-reset: algo-line;
  padding: 0.6rem 0;
  font-family: var(--font-algo);
  font-size: 0.95rem;
  line-height: 1.68;
  overflow-x: auto;
}
.algo-row {
  counter-increment: algo-line;
  padding-left: calc(2.7rem + var(--depth, 0) * 1.45rem);
  padding-right: 0.2rem;
  min-height: 1.68em;
}
.algo-row::before {
  content: counter(algo-line);
  position: absolute;
  left: 0;
  width: 1.9rem;
  text-align: right;
  font-family: var(--font-algo);
  font-size: 1em;
  line-height: 1.68;
  color: var(--fg-faint);
}
.algo-blank { counter-increment: none; }
.algo-blank::before { content: none; }

.algo .kw { font-weight: 700; }
.algo .cmt { color: var(--fg-faint); font-style: italic; }

/* 11. figures ------------------------------------------------------------- */
.diagram {
  margin: 2em 0;
  text-align: center;
}
.diagram svg { display: inline-block; max-width: 100%; height: auto; }
.diagram figcaption,
.subfigures figcaption {
  margin-top: 0.55rem;
  font-family: var(--font-body);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--fg-dim);
  text-align: center;
}

.dg-node { fill: var(--bg); stroke: var(--fg); stroke-width: 1.1; }
.dg-plain { fill: none; stroke: none; }
.dg-label {
  font-family: var(--font-body);
  font-size: 13px;
  fill: var(--fg);
  text-anchor: middle;
  dominant-baseline: central;
}
.dg-edge { fill: none; stroke: var(--fg); stroke-width: 1.1; }
.dg-head { fill: var(--fg); }
.dg-dashed { stroke-dasharray: 4 3; }
.dg-edge-label {
  font-family: var(--font-body);
  font-size: 11.5px;
  font-style: italic;
  fill: var(--fg-dim);
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.subfigures { margin: 2em 0; }
.subfig-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: var(--s3);
}
.subfig { margin: 0; }
.subfig img {
  display: block;
  width: 100%;
  border: 1px solid var(--rule);
}
.subfig figcaption {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--fg-dim);
  text-align: center;
}

/* 11b. side-by-side ------------------------------------------------------- */
/* `::: cols` / `::: col`: a plain grid.  In a slide the same markup becomes a
   two-panel layout, so a talk can put text beside its figure. */
.cols {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: var(--s4, 2em);
  margin: 1.5em 0;
  align-items: start;
}
.cols .col > :first-child { margin-top: 0; }
.cols .col > :last-child { margin-bottom: 0; }
.col-center { text-align: center; }
.col-center img { margin-inline: auto; }
@media (max-width: 640px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
}

/* 11c. images from content/ ----------------------------------------------- */
/* An image written as ![alt](figure.svg) sits beside the Markdown it belongs
   to, and is published unchanged under /content/. */
.prose img { max-width: 100%; border-radius: 2px; }
.prose p > img:only-child { margin: 1.6em auto; }

/* 12. callouts ------------------------------------------------------------ */
/* GitHub alerts: a rounded box with a coloured outline and title icon; the
   fill stays white, so the page stays white.  One set of rules serves both spellings
   (`> [!NOTE]` and `::: note`). */
.callout {
  --alert: var(--fg-dim);
  --alert-icon: none;
  margin: 1.5em 0;
  padding: 0.8em 1.15em;
  border: 1.5px solid var(--alert);
  border-radius: var(--code-radius, 10px);
  background: #fff;
}
.callout-title,
.prose .callout-title {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 0.35em;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--alert);
}
.callout-title::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  background: currentColor;
  -webkit-mask: var(--alert-icon) center / contain no-repeat;
  mask: var(--alert-icon) center / contain no-repeat;
}
.callout-body > *:first-child { margin-top: 0; }
.callout-body > *:last-child { margin-bottom: 0; }

.callout-note {
  --alert: var(--alert-note);
  --alert-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z'/></svg>");
}
.callout-tip {
  --alert: var(--alert-tip);
  --alert-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 0 1-1.484.211c-.04-.282-.163-.547-.37-.847a8.456 8.456 0 0 0-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.751.751 0 0 1-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75ZM5.75 12h4.5a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1 0-1.5ZM6 15.25a.75.75 0 0 1 .75-.75h2.5a.75.75 0 0 1 0 1.5h-2.5a.75.75 0 0 1-.75-.75Z'/></svg>");
}
.callout-important {
  --alert: var(--alert-important);
  --alert-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z'/></svg>");
}
.callout-warning {
  --alert: var(--alert-warning);
  --alert-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M6.457 1.047c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0 1 14.082 15H1.918a1.75 1.75 0 0 1-1.543-2.575Zm1.763.707a.25.25 0 0 0-.44 0L1.698 13.132a.25.25 0 0 0 .22.368h12.164a.25.25 0 0 0 .22-.368Zm.53 3.996v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 11a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z'/></svg>");
}
.callout-caution {
  --alert: var(--alert-caution);
  --alert-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M4.47.22A.749.749 0 0 1 5 0h6c.199 0 .389.079.53.22l4.25 4.25c.141.14.22.331.22.53v6a.749.749 0 0 1-.22.53l-4.25 4.25A.749.749 0 0 1 11 16H5a.749.749 0 0 1-.53-.22L.22 11.53A.749.749 0 0 1 0 11V5c0-.199.079-.389.22-.53Zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5ZM8 4a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 8 4Zm0 8a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z'/></svg>");
}

/* 13. math and references ------------------------------------------------- */
.math-block {
  margin: 1.5em 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}
math {
  font-family: var(--font-math, math);
  font-size: 1.02em;
  font-weight: 400;
}
/* Seaford's bold is deliberately avoided for prose; code keeps its own face. */
.prose strong, .reveal strong, .reveal b,
.prose th, .reveal th, .callout-title, .fig-tag, .algo .kw {
  font-weight: 400;
}
.math-error { font-family: var(--font-code); font-size: 0.85em; }

.xref { text-decoration-thickness: 1px; }
.xref-missing {
  font-family: var(--font-code);
  font-size: 0.82em;
  border-bottom: 1px dashed var(--fg);
}

/* 14. small screens ------------------------------------------------------- */
@media (max-width: 40rem) {
  body { font-size: 17px; }
  .post-head h1 { font-size: 1.75rem; }
  .entries li { grid-template-columns: 5.4em 1fr; }
  .entries time { font-size: 0.78rem; }
  .masthead-inner { gap: var(--s2); }
  .nav, .langs { gap: 0.85rem; }
  .taglist { gap: 0.55rem 0.5rem; }
  .code-body { font-size: 0.76rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* 15. print --------------------------------------------------------------- */
@media print {
  :root { --fs: 11pt; --lh: 1.55; }
  body { background: #fff; color: #000; }
  .masthead, .foot, .toc, .post-nav, .code-copy, .skip, .langs { display: none; }
  .post, .shell { max-width: none; padding: 0; }
  .post-main { max-width: none; }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " <" attr(href) ">"; font-size: 0.85em; }
  .algo, .code-block, .diagram, figure, pre, table { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  .code-block { border-left-color: #000; }
  .callout { border-left-color: #666; }
}

/* keep the table of contents out until the frame fits the measure */
@container (max-width: calc(48rem + 21.5rem - 0.0625rem)) {
  .post { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
/* fallback when a custom base.html has no <main> container;
   media-query rem is the 16px initial size, so a smaller root
   font hides the contents early and a larger one too late. */
@media (max-width: calc(48rem + 21.5rem - 0.0625rem)) {
  .post { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
