/* ---------------------------------------------------------------------------
 * site.css — the whole stylesheet for storopoli.com.
 *
 * Concept: "literary text, terminal chrome". Prose is set in Newsreader,
 * a contemporary editorial serif (self-hosted variable woff2, optical
 * sizing); everything machine-adjacent — nav, dates, tags, labels,
 * captions, footnote numbers, code — is monospaced. One color system
 * throughout: Flexoki paper/ink surfaces with the Flexoki accents for
 * both the site accent and the syntax-highlight palette.
 *
 * No JavaScript anywhere: the theme toggle is a checkbox + light-dark(),
 * the ToC is a native <details>, page transitions are CSS view
 * transitions where supported.
 * --------------------------------------------------------------------------- */

/* --- Fonts ------------------------------------------------------------------ */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-opsz-italic.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-ext-opsz-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/newsreader-latin-ext-opsz-italic.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Tokens ------------------------------------------------------------------
 * Warm paper/ink in both schemes (palette after Flexoki). The scheme follows
 * the system preference; the header checkbox (#theme-toggle) flips it with
 * no JavaScript. The checkbox state resets on navigation — the price of
 * zero JS.
 * --------------------------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --paper: light-dark(#fffcf0, #100f0f);
  --ink: light-dark(#100f0f, #cecdc3);
  --ink-2: light-dark(#6f6e69, #878580); /* secondary text */
  --ink-2-wash: light-dark(#575653, #9a9891); /* secondary text on --wash */
  --ink-3: light-dark(#b7b5ac, #575653); /* faint marks */
  --line: light-dark(#e6e4d9, #282726); /* hairlines */
  --wash: light-dark(#f2f0e5, #1c1b1a); /* subtle panels */
  --accent: light-dark(#bc5215, #da702c);
  --accent-wash: light-dark(#9d4310, #da702c); /* accent text on --wash */

  /* Code surfaces: Flexoki base-50 / base-950, same family as --wash */
  --code-bg: light-dark(#f2f0e5, #1c1b1a);
  --code-fg: light-dark(#100f0f, #cecdc3);

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino,
    Georgia, serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo,
    Consolas, monospace;

  accent-color: var(--accent);
}

@media (prefers-color-scheme: light) {
  html:has(#theme-toggle:checked) {
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: dark) {
  html:has(#theme-toggle:checked) {
    color-scheme: light;
  }
}

/* --- Base -------------------------------------------------------------------- */

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

html {
  font-size: 100%;
}

body {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2rem);
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 420;
  line-height: 1.65;
  font-optical-sizing: auto;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
}

::selection {
  background: color-mix(in oklab, var(--accent) 24%, transparent);
}

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

/* Anchor jumps (ToC, footnotes) must clear the floating header */
[id] {
  scroll-margin-top: 4.5rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* Cross-document crossfade between pages (progressive enhancement) */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* --- Prose ------------------------------------------------------------------- */

p {
  margin: 1.1em 0;
}

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  line-height: 1.18;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.95rem, 1.35rem + 2.2vw, 2.6rem);
  font-weight: 540;
  line-height: 1.16;
  letter-spacing: -0.016em;
  margin: 1rem 0 0.8rem;
}

h2 {
  font-size: 1.65rem;
  font-weight: 560;
  line-height: 1.2;
  letter-spacing: -0.008em;
  margin: 2.5rem 0 0.85rem;
}

h3 {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.24;
  margin: 2rem 0 0.65rem;
}

h4 {
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 560;
  line-height: 1.28;
  margin: 1.7rem 0 0.5rem;
}

h1 code,
h2 code,
h3 code {
  font-weight: 500;
}

/* Deep subsections become monospaced eyebrow labels */
h5,
h6 {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 1.8rem 0 0.6rem;
}

main a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

main a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

/* Subtle section anchor links (`#`) injected on h2–h4 headings with an id */
main a.heading-anchor {
  margin-left: 0.35em;
  font-family: var(--mono);
  font-style: normal;
  font-weight: 400;
  font-size: 0.78em;
  color: var(--ink-3);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

h2:hover a.heading-anchor,
h3:hover a.heading-anchor,
h4:hover a.heading-anchor,
main a.heading-anchor:focus-visible {
  opacity: 1;
}

main a.heading-anchor:hover {
  color: var(--accent);
  text-decoration: none;
}

@media (hover: none) {
  main a.heading-anchor {
    opacity: 0.55;
  }
}

strong {
  font-weight: 660;
}

ul,
ol {
  padding-left: 1.5rem;
  margin: 1.1em 0;
}

li {
  margin: 0.3em 0;
}

li::marker {
  color: var(--ink-3);
}

blockquote {
  margin: 1.7rem 0;
  padding: 0.15rem 0 0.15rem 1.25rem;
  border-left: 2px solid var(--ink-3);
  font-style: italic;
}

blockquote em {
  font-style: normal;
}

/* Editorial update/note callouts: blockquotes opening with a bold lead render
   upright in a --wash panel with an accent rule (no JS or Markdown changes) */
blockquote:has(> p:first-child > strong:first-child) {
  font-style: normal;
  font-size: 1.04rem;
  line-height: 1.58;
  background: var(--wash);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  padding: 0.85rem 1.15rem;
}

blockquote:has(> p:first-child > strong:first-child) p:first-child {
  margin-top: 0;
}

blockquote:has(> p:first-child > strong:first-child) p:last-child {
  margin-bottom: 0;
}

blockquote:has(> p:first-child > strong:first-child) em {
  font-style: italic;
}

blockquote:has(> p:first-child > strong:first-child) > p:first-child > strong:first-child {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent-wash);
}

blockquote:has(> p:first-child > strong:first-child) a:hover {
  color: var(--accent-wash);
}

/* Thematic break as a typewriter dinkus */
hr {
  border: 0;
  margin: 2.8rem 0;
  text-align: center;
}

hr::before {
  content: "* * *";
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.4em;
  color: var(--ink-3);
}

sup {
  line-height: 0;
}

/* --- Header / nav -------------------------------------------------------------- */

/* Floating nav: sticky on every screen size, translucent paper with a
   blur so content slides beneath it. Pure CSS, no JS. The mobile media
   query below compacts the bar so it stays slim when pinned. */
body > header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1.2rem;
  padding: 1.1rem 0 0.8rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.2rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* Reading progress on posts: an accent hairline along the header's
   bottom edge, driven by scroll position — CSS scroll-driven animation,
   no JS; browsers without support just don't draw it. */
@supports (animation-timeline: scroll()) {
  @keyframes reading-progress {
    from {
      transform: scaleX(0);
    }

    to {
      transform: scaleX(1);
    }
  }

  body > header.post-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(0);
    animation: reading-progress linear both;
    animation-timeline: scroll(root);
  }
}

input.theme-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

input.theme-toggle:focus-visible ~ nav label.theme-label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.logo a {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  font-weight: 540;
  color: inherit;
  text-decoration: none;
}

.logo a:hover {
  color: var(--accent);
}

body > header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.05rem;
}

body > header nav a {
  position: relative;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  color: var(--ink-2);
  text-decoration: none;
  padding: 0.2rem 0;
}

body > header nav a:hover {
  color: var(--accent);
}

body > header nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

body > header nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

label.theme-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  padding: 0.22rem 0.38rem 0.22rem 0.65rem;
  margin-left: 0.05rem;
  border-left: 1px solid var(--line);
  font-size: 0.98rem;
  line-height: 1;
  color: var(--ink-2);
  transition: color 0.15s ease;
}

label.theme-label:hover {
  color: var(--accent);
}

/* --- Footer ---------------------------------------------------------------------- */

body > footer {
  margin-top: 4.5rem;
  padding: 1rem 0 2.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-2);
}

body > footer a {
  color: inherit;
  text-decoration: none;
}

body > footer a:hover {
  color: var(--accent);
}

/* --- Post header (meta line under the title) -------------------------------------- */

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-2);
  margin: 0.4rem 0 2.2rem;
}

.post-meta > * + *::before {
  content: "·";
  color: var(--ink-3);
  margin: 0 0.6rem;
}

.post-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

a.tag {
  color: var(--accent);
  text-decoration: none;
}

a.tag::before {
  content: "#";
  opacity: 0.65;
}

a.tag:hover {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

/* Tag page title: the tag itself, oversized */
h1.tag-title {
  font-family: var(--mono);
  font-weight: 500;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
  letter-spacing: -0.01em;
  color: var(--accent);
}

h1.tag-title::before {
  content: "#";
  opacity: 0.5;
}

/* --- Table of contents (native <details>, no JS) ------------------------------------ */

details.toc {
  margin: 0 0 2.4rem;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 1rem;
}

details.toc summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.65rem 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2-wash);
}

details.toc summary::-webkit-details-marker {
  display: none;
}

details.toc summary::after {
  content: "+";
  font-size: 0.9rem;
}

details.toc[open] summary::after {
  content: "\2212"; /* minus sign */
}

details.toc summary:hover {
  color: var(--accent-wash);
}

details.toc nav {
  padding: 0.15rem 0 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
}

details.toc ol {
  list-style: none;
  padding-left: 0;
  margin: 0.45rem 0 0;
}

details.toc ol ol {
  margin: 0.25rem 0 0.25rem 0.2rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
}

details.toc li {
  margin: 0.35em 0;
}

details.toc a {
  color: var(--ink-2-wash);
  text-decoration: none;
}

details.toc a:hover {
  color: var(--accent-wash);
}

/* --- Home intro & post lists (index, archive, tags) ----------------------------------- */

.home-intro {
  margin: 0 0 2.1rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--line);
}

.home-intro p.lede {
  margin: 0 0 0.5rem;
  font-size: 1.32rem;
  font-weight: 440;
  line-height: 1.46;
  letter-spacing: -0.006em;
  color: var(--ink);
}

.home-intro p.sub {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.55;
  color: var(--ink-2);
}

.home-intro p.sub a {
  color: var(--accent);
  text-decoration: none;
}

.home-intro p.sub a:hover {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.tag-meta {
  margin: -0.2rem 0 1.8rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-2);
}

.tag-meta a {
  color: var(--accent);
  text-decoration: none;
}

.tag-meta a:hover {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

ul.post-list {
  list-style: none;
  padding: 0;
  margin: 0.6rem 0 1.8rem;
}

ul.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1.3rem;
  margin: 0;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

ul.post-list li:first-child {
  border-top: 1px solid var(--line);
}

ul.post-list.detailed li {
  display: grid;
  grid-template-columns: 6.4rem 1fr;
  column-gap: 1.25rem;
  align-items: baseline;
  padding: 0.9rem 0;
}

.post-entry {
  min-width: 0;
}

time.post-date {
  flex: none;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

a.post-link {
  display: inline-block;
  font-size: 1.12rem;
  font-weight: 540;
  line-height: 1.3;
  text-decoration: none;
  color: var(--ink);
}

a.post-link:hover {
  color: var(--accent);
  text-decoration: none;
}

p.post-desc {
  margin: 0.28rem 0 0.38rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-2);
}

.post-entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-2);
}

.post-entry-meta a.tag {
  color: var(--ink-2);
  text-decoration: none;
}

.post-entry-meta a.tag:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.post-entry-meta .read-time {
  color: var(--ink-2);
}

.archive-more {
  margin: 1.2rem 0 0;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.archive-more a {
  color: var(--accent);
  text-decoration: none;
}

.archive-more a:hover {
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

/* Section labels on listing pages ("Recent posts") */
h2.section-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 0.65rem;
}

/* Archive: compact tag index panel + year-grouped chronological rows */
.tag-index {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.95rem;
  margin: 1rem 0 2.2rem;
  padding: 0.85rem 1rem;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.5;
}

.tag-index a {
  color: var(--ink);
  text-decoration: none;
}

.tag-index a:hover {
  color: var(--accent-wash);
  text-decoration: none;
}

.tag-index a .hash {
  color: var(--accent-wash);
}

.tag-index a .cnt {
  color: var(--ink-2-wash);
  margin-left: 0.24rem;
  font-size: 0.68rem;
}

.year-group {
  margin: 1.8rem 0;
}

h2.year-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.3;
  color: var(--ink-2);
  margin: 0 0 0.4rem;
}

h2.year-heading .year-count {
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

ul.post-list.compact {
  margin: 0;
}

ul.post-list.compact li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  padding: 0.52rem 0;
}

ul.post-list.compact .row-main {
  display: flex;
  align-items: baseline;
  gap: 1.15rem;
  min-width: 0;
}

ul.post-list.compact a.post-link {
  font-size: 1.05rem;
  font-weight: 500;
}

ul.post-list.compact .row-tags {
  flex: none;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-2);
}

ul.post-list.compact .row-tags a.tag {
  color: var(--ink-2);
  text-decoration: none;
}

ul.post-list.compact .row-tags a.tag:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

/* --- Math (native MathML, typst 0.15) --------------------------------------------------- */

/* MathML is live text: it inherits `color`, so light/dark mode works with no
   repainting, and it scales with zoom/font-size. Inline math needs no styling
   (native baseline alignment). Block math is centered by the engine's default
   display-equation layout, and wide equations scroll horizontally instead of
   overflowing the column.

   The horizontal scroll lives on a wrapper (scripts/build.py wraps each block
   equation in <div class="math-block">), never on the <math> element itself:
   giving <math> an intrinsic width (fit-content) or overflow makes engines
   collapse it to min-content — every atom stacking vertically on a narrow
   screen — or right-align it (iOS Safari). Left untouched, <math> stays a
   full-width centered block, and the wrapper scrolls when it is too wide. */
.math-block {
  margin: 1.8rem 0;
  overflow-x: auto;
}

math[display="block"] {
  margin: 0;
}

/* --- Code --------------------------------------------------------------------------------- */

code {
  font-family: var(--mono);
  font-size: 0.82em;
}

/* inline code */
:not(pre) > code {
  background: var(--wash);
  border-radius: 4px;
  padding: 0.1em 0.32em;
}

pre {
  background-color: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.9rem 1.1rem;
  margin: 1.7rem 0;
  overflow-x: auto;
  line-height: 1.55;
}

pre > code {
  font-size: 0.84rem;
}

/* Language-tagged code blocks wrapped by scripts/build.py so the language
   label stays pinned in a non-scrolling top hairline bar */
.code-block {
  background-color: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 1.7rem 0;
  overflow: hidden;
}

.code-lang {
  padding: 0.35rem 1.1rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2-wash);
}

.code-block pre {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0.85rem 1.1rem;
  margin: 0;
}

/* Syntax palette roles, rendered in Flexoki accents (600–800 in light,
   300–400 in dark, chosen so every token meets WCAG AA ≥4.5:1 on
   --code-bg). Typst's built-in default raw theme classifies the tokens
   at build time; scripts/build.py rewrites its inline colors into
   these classes so the palette can follow the color scheme. */
.tok-gray { color: light-dark(#575653, #878580); }
.tok-red { color: light-dark(#af3029, #e8705f); }
.tok-green { color: light-dark(#536907, #879a39); }
.tok-yellow { color: light-dark(#664d01, #d0a215); }
.tok-blue { color: light-dark(#205ea6, #66a0c8); }
.tok-purple { color: light-dark(#5e409d, #8b7ec8); }
.tok-aqua { color: light-dark(#1c6c66, #3aa99f); }
.tok-magenta { color: light-dark(#a02f6f, #ce5d97); }

/* --- Endnotes (typst footnotes) -------------------------------------------------------------- */

a[role="doc-noteref"] {
  font-family: var(--mono);
  font-size: 0.78em;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding-inline: 0.06em;
}

section[role="doc-endnotes"] {
  margin-top: 3.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  font-size: 0.97rem;
}

section[role="doc-endnotes"]::before {
  content: "Footnotes";
  display: block;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 0.8rem;
}

section[role="doc-endnotes"] ol {
  padding-left: 1.5rem;
}

section[role="doc-endnotes"] li {
  margin-bottom: 0.6rem;
}

section[role="doc-endnotes"] li::marker {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--ink-2);
}

section[role="doc-endnotes"] li:target {
  background: var(--wash);
  box-shadow: 0 0 0 6px var(--wash);
  border-radius: 2px;
}

section[role="doc-endnotes"] li:target a[role="doc-backlink"],
section[role="doc-endnotes"] li:target a:hover {
  color: var(--accent-wash);
}

section[role="doc-endnotes"] li p {
  display: inline;
  margin: 0;
}

a[role="doc-backlink"] {
  font-family: var(--mono);
  color: var(--accent);
  text-decoration: none;
  margin-right: 0.35em;
}

/* --- Bibliography ------------------------------------------------------------------------------- */

section[role="doc-bibliography"] {
  margin-top: 3.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
}

section[role="doc-bibliography"] h2 {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 0.8rem;
}

section[role="doc-bibliography"] ul {
  list-style: none;
  padding-left: 0;
}

section[role="doc-bibliography"] li {
  margin-bottom: 0.7rem;
  font-size: 0.97rem;
}

section[role="doc-bibliography"] .prefix a {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--accent);
  text-decoration: none;
}

section[role="doc-bibliography"] li:target {
  background: var(--wash);
  box-shadow: 0 0 0 6px var(--wash);
  border-radius: 2px;
}

section[role="doc-bibliography"] li:target .prefix a,
section[role="doc-bibliography"] li:target a:hover {
  color: var(--accent-wash);
}

/* --- Tables ---------------------------------------------------------------------------------------- */

.table-wrap {
  margin: 2rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

main table {
  border-collapse: collapse;
  margin: 2rem auto;
  width: 100%;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.table-wrap table {
  margin: 0 auto;
}

th {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  text-align: center;
  color: var(--ink-2);
  padding: 0.5rem 0.75rem;
  border-top: 1.5px solid var(--ink-3);
  border-bottom: 1px solid var(--ink-3);
  white-space: nowrap;
}

td {
  padding: 0.45rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

tbody tr:hover {
  background: var(--wash);
}

tbody tr:hover a:hover {
  color: var(--accent-wash);
}

tbody tr:last-child td {
  border-bottom: 1.5px solid var(--ink-3);
}

/* --- Figures, images, embeds -------------------------------------------------------------------------- */

figure {
  margin: 2rem 0;
}

figure > a {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
}

figure img {
  max-height: 28rem;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
}

/* Soften dark-mode glare on raster photos only; leave dark-mode-native Flexoki SVGs untouched */
@media (prefers-color-scheme: dark) {
  html:not(:has(#theme-toggle:checked)) figure img:not([src$=".svg" i]) {
    filter: brightness(0.92) contrast(1.03);
  }
}

@media (prefers-color-scheme: light) {
  html:has(#theme-toggle:checked) figure img:not([src$=".svg" i]) {
    filter: brightness(0.92) contrast(1.03);
  }
}

figcaption {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ink-2);
  text-align: center;
  max-width: 54ch;
  margin: 0.65rem auto 0;
}

.profile-image {
  float: right;
  width: 200px;
  height: auto;
  margin: 0.4rem 0 1rem 1.5rem;
  border-radius: 6px;
}

.embed-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  max-width: 100%;
  margin: 2rem 0;
  border-radius: 6px;
}

.embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --- Post navigation (Prev / Next) ---------------------------------------------------------------------- */

nav.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 3.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}

.post-nav-prev,
.post-nav-next {
  max-width: 48%;
}

.post-nav-next {
  margin-left: auto;
  text-align: right;
}

nav.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  text-decoration: none;
  color: inherit;
}

nav.post-nav a:hover {
  color: inherit;
  text-decoration: none;
}

nav.post-nav a:hover .post-nav-title {
  color: var(--accent);
}

.post-nav-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.post-nav-title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.3;
  transition: color 0.15s ease;
}

/* --- Entrance ------------------------------------------------------------------------------------------ */

@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
  }

  main > :not(article):nth-child(1),
  main > article > :nth-child(1) {
    animation: rise 0.45s ease-out backwards;
  }

  main > :not(article):nth-child(2),
  main > article > :nth-child(2) {
    animation: rise 0.45s ease-out 0.07s backwards;
  }

  main > :not(article):nth-child(3),
  main > article > :nth-child(n + 3) {
    animation: rise 0.45s ease-out 0.14s backwards;
  }
}

/* --- Mobile ---------------------------------------------------------------------------------------------- */

@media (max-width: 640px) {
  body {
    font-size: 1.15rem;
  }

  /* Compact pinned bar: slim paddings and type so the floating header
     stays out of the way on small screens */
  body > header {
    justify-content: center;
    text-align: center;
    padding: 0.55rem 0 0.5rem;
    gap: 0.1rem 1rem;
    margin-bottom: 1.8rem;
  }

  .logo a {
    font-size: 1rem;
  }

  body > header nav {
    justify-content: center;
    gap: 0.2rem 0.75rem;
  }

  body > header nav a {
    font-size: 0.72rem;
  }

  label.theme-label {
    font-size: 0.9rem;
    padding: 0.18rem 0.28rem 0.18rem 0.55rem;
  }

  p {
    hyphens: auto;
  }

  .profile-image {
    float: none;
    margin: 1rem auto;
  }

  ul.post-list li {
    flex-direction: column;
    gap: 0.1rem;
  }

  ul.post-list.detailed li {
    grid-template-columns: 1fr;
    gap: 0.18rem;
  }

  ul.post-list.compact li {
    flex-direction: column;
    gap: 0.18rem;
  }

  ul.post-list.compact .row-main {
    flex-direction: column;
    gap: 0.1rem;
  }

  nav.post-nav {
    flex-direction: column;
    gap: 1.1rem;
  }

  .post-nav-prev,
  .post-nav-next {
    max-width: none;
  }

  .post-nav-next {
    margin-left: 0;
    text-align: left;
  }

  body > footer {
    text-align: center;
  }
}

/* --- Print ---------------------------------------------------------------------------------------------------- */

@media print {
  body > header {
    position: static;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body > header.post-header::after,
  body > header nav,
  input.theme-toggle,
  label.theme-label,
  body > footer,
  nav.post-nav,
  a.heading-anchor {
    display: none;
  }

  body {
    max-width: none;
  }

  details.toc {
    display: none;
  }

  pre,
  blockquote,
  figure,
  .code-block,
  .table-wrap {
    break-inside: avoid;
  }

  h2,
  h3,
  h4 {
    break-after: avoid;
  }
}
