/* =============================================================================
   Subnetted — production design system
   Editorial serif, near-monochrome with one quiet accent, book-interior type.

   Base concept: "Quarto" (winning homepage), hardened for a multi-page static
   site on Cloudflare Pages. Grafts folded in where they strengthen the winner:
     - warmed near-monochrome palette (light + dark), AA discipline kept
     - strict baseline grid: every vertical step is a multiple of --baseline
     - monospace-as-signal for metadata (dates, read-times, tabular figures)
     - oldstyle/proportional figure feel in serif body via font-feature-settings
     - print-style table (italic caption hung below, heavier last-row rule)
     - centered fleuron section break + footer colophon
     - inline-SVG moon/sun theme toggle and footer RSS mark (hairline, mono)
     - labelled fenced-code title bar (filename / lang), hairline only
     - code COMMENT token re-tuned to clear AA (>=4.5:1) in BOTH themes
     - explicit <360px type step-down so the big serif title never crowds 320px
     - @media print: drop chrome, ink-on-white, avoid breaking code/callout

   Only external asset references in the site are /styles.css and /favicon.svg.
   ========================================================================== */

/* -----------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* --- Type families ---
     Serif for prose; a neutral system sans for chrome/UI; mono for code+meta. */
  --font-serif: "Charter", "Iowan Old Style", "Palatino Linotype",
                "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --font-ui:    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
                "Helvetica Neue", Arial, sans-serif;
  --font-mono:  ui-monospace, "SF Mono", "SFMono-Regular", "Cascadia Mono",
                "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* --- Modular scale, ratio ~1.2 (minor third), 1rem base --- */
  --step--2: 0.694rem;
  --step--1: 0.833rem;
  --step-0:  1rem;
  --step-1:  1.2rem;
  --step-2:  1.44rem;
  --step-3:  1.728rem;
  --step-4:  2.074rem;

  /* --- Measure & rhythm ---
     --baseline is the single rhythm unit. Every vertical margin, gap, and
     block line-height resolves to an integer multiple of it (Swiss grid). */
  --baseline: 0.45rem;          /* 9 * 0.45 = 4.05rem etc.; tuned for body LH */
  --measure: 68ch;              /* lands ~64-68 real chars in the serif body  */
  --line-body: 1.7;             /* ~3.06 * --baseline at 1rem; kept as ratio  */

  --hairline: 1px;
  --radius: 4px;
  --radius-lg: 5px;

  /* --- LIGHT THEME — true ink on warm paper (grafted warmer from "Warm Minimal").
     Body text & UI text verified comfortably AA (>=4.5:1) on --paper. --- */
  --paper:        #f7f3ec;   /* warm off-white */
  --paper-raised: #f1ece1;   /* asides, code chrome, hover wells */
  --ink:          #211e19;   /* warm near-black — body ink */
  --ink-soft:     #46423a;   /* deks, secondary prose */
  --ink-faint:    #6b6557;   /* meta, captions — AA on paper for small text */
  --rule:         #e2dccf;   /* hairlines */
  --rule-strong:  #cdc6b6;   /* heavier rules, control borders */
  --accent:       #3a5a8c;   /* quiet slate-blue — links/marks (AA on paper) */
  --accent-strong:#2b4673;   /* hover/pressed */
  --mark-bg:      #ece2c6;   /* low-chroma highlight */

  /* Code surface — low-chroma, readable not rainbow. Tokens AA on --code-bg. */
  --code-bg:      #f1ece0;
  --code-border:  #e0d9c9;
  --code-ink:     #2a2620;
  --tok-comment:  #6f6a5d;   /* re-tuned: ~5.0:1 on code-bg (was AA-large only) */
  --tok-keyword:  #5a4b86;
  --tok-string:   #46624f;
  --tok-number:   #875634;
  --tok-func:     #35578a;

  --sel-bg:       #e3d6b4;   /* selection */
}

/* --- Alternate accent token: terracotta (grafted from "Warm Minimal").
   Opt in per page or globally with <html data-accent="terracotta">. --- */
:root[data-accent="terracotta"] {
  --accent:        #8a4f2c;
  --accent-strong: #6f3f23;
}

/* --- DARK THEME values (explicit toggle override).
   Warmed near-black (grafted) so the serif reads as inverted ink-on-paper. --- */
[data-theme="dark"] {
  --paper:        #191613;   /* warm near-black */
  --paper-raised: #211d18;
  --ink:          #ece5d8;   /* soft warm off-white */
  --ink-soft:     #c7bfb1;
  --ink-faint:    #948b7c;   /* AA on dark paper for small text */
  --rule:         #2e2922;
  --rule-strong:  #3d372e;
  --accent:       #95b4e2;   /* lifted slate-blue — AA on dark paper */
  --accent-strong:#b1c8ec;
  --mark-bg:      #3a3322;

  --code-bg:      #201c17;
  --code-border:  #322c24;
  --code-ink:     #e0d9cb;
  --tok-comment:  #9b927f;   /* re-tuned: ~5.3:1 on dark code-bg */
  --tok-keyword:  #b9ace4;
  --tok-string:   #a7c9a3;
  --tok-number:   #dbb27a;
  --tok-func:     #98b7e8;

  --sel-bg:       #3f351f;
}

/* Terracotta alternate, dark tuning */
[data-theme="dark"][data-accent="terracotta"],
:root[data-accent="terracotta"][data-theme="dark"] {
  --accent:        #d59264;
  --accent-strong: #e6aa7e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #191613;
    --paper-raised: #211d18;
    --ink:          #ece5d8;
    --ink-soft:     #c7bfb1;
    --ink-faint:    #948b7c;
    --rule:         #2e2922;
    --rule-strong:  #3d372e;
    --accent:       #95b4e2;
    --accent-strong:#b1c8ec;
    --mark-bg:      #3a3322;

    --code-bg:      #201c17;
    --code-border:  #322c24;
    --code-ink:     #e0d9cb;
    --tok-comment:  #9b927f;
    --tok-keyword:  #b9ace4;
    --tok-string:   #a7c9a3;
    --tok-number:   #dbb27a;
    --tok-func:     #98b7e8;

    --sel-bg:       #3f351f;
  }
  :root:not([data-theme="light"])[data-accent="terracotta"] {
    --accent:        #d59264;
    --accent-strong: #e6aa7e;
  }
}

/* -----------------------------------------------------------------------------
   2. RESET-ISH & ROOT ELEMENTS
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: var(--step-0);
  line-height: var(--line-body);
  /* Oldstyle/proportional figures in body where the system serif supports it. */
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1, "pnum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  /* Background transition kept ONLY here and gated below for reduced motion. */
  transition: background-color 200ms ease, color 200ms ease;
}

/* Base font scaling: a touch larger on wider viewports for a relaxed measure. */
@media (min-width: 40rem) { body { font-size: 1.0625rem; } }
@media (min-width: 64rem) { body { font-size: 1.125rem; } }

::selection { background: var(--sel-bg); }

img, svg { vertical-align: middle; }
svg { fill: none; }

/* -----------------------------------------------------------------------------
   3. LAYOUT SHELL — single centered column, generous margins
   -------------------------------------------------------------------------- */
.shell {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.5rem;
}
@media (min-width: 40rem) { .shell { padding-inline: 2rem; } }

/* A slightly wider shell for chrome (masthead/footer) so nav can breathe while
   prose stays at measure. Opt in by adding .shell--wide. */
.shell--wide { max-width: calc(var(--measure) + 8rem); }

/* -----------------------------------------------------------------------------
   4. SKIP LINK & ACCESSIBILITY HELPERS
   -------------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--paper-raised);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { left: 1rem; top: 1rem; }

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

/* -----------------------------------------------------------------------------
   5. LINKS — clean underline-via-border, subtle transition (the only animation)
   -------------------------------------------------------------------------- */
a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 0.06em;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  transition: border-color 160ms ease, color 160ms ease;
}
a:hover {
  color: var(--accent-strong);
  border-bottom-color: var(--accent-strong);
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
  border-bottom-color: transparent;
}

/* Fallback for browsers without color-mix(): a plain hairline accent underline. */
@supports not (color: color-mix(in srgb, red, blue)) {
  a { border-bottom-color: var(--rule-strong); }
}

/* -----------------------------------------------------------------------------
   6. REDUCED MOTION — honor the preference globally
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* =============================================================================
   7. MASTHEAD
   ========================================================================== */
.masthead { border-bottom: 1px solid var(--rule); }
.masthead__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-top: 2rem;     /* ~4.5 * baseline */
  padding-bottom: 1.35rem; /* ~3 * baseline */
}

.brand { display: flex; flex-direction: column; gap: 0.225rem; }

.wordmark {
  font-family: var(--font-serif);
  font-size: var(--step-2);
  line-height: 1.1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink);
  border-bottom: none;
}
.wordmark:hover { color: var(--ink); }
.wordmark:focus-visible { outline-offset: 4px; }

.tagline {
  font-style: italic;
  color: var(--ink-faint);
  font-size: var(--step-0);
  line-height: 1.35;
  letter-spacing: 0.01em;
  max-width: 46ch;
}

/* Primary nav + theme toggle */
.nav {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  font-family: var(--font-ui);
}
.nav a {
  color: var(--ink-soft);
  border-bottom: 1px solid transparent;
  font-size: var(--step-0);
  letter-spacing: 0.01em;
}
.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* --- Theme toggle: inline-SVG moon/sun (grafted from "Warm Minimal").
   Self-evident, crisp at small sizes, no text label required. --- */
.theme-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink-soft);
  font: inherit;
  line-height: 1;
  padding: 0.5em;
  border-radius: var(--radius);
  cursor: pointer;
  align-self: center;
  transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
  background: var(--paper-raised);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle .icon {
  width: 1.05em;
  height: 1.05em;
  display: block;
  stroke: currentColor;
}
/* Default (light or unresolved): show the moon = "switch to dark". */
.theme-toggle .t-sun  { display: none; }
.theme-toggle .t-moon { display: block; }
/* When dark is active, show the sun = "switch to light". */
[data-theme="dark"] .theme-toggle .t-sun  { display: block; }
[data-theme="dark"] .theme-toggle .t-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .t-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .t-moon { display: none; }
}

/* =============================================================================
   8. MAIN
   ========================================================================== */
main { padding-block: 2.7rem 0.9rem; } /* ~6 * baseline top */

/* Intro / lede block under the masthead on the home page */
.intro { margin-bottom: 2.7rem; }
.intro p {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
  max-width: 60ch;
  text-wrap: pretty;
}

/* --- Centered fleuron rule — a print-style section break (grafted).
   Decorative-but-restrained; hidden from assistive tech via aria-hidden. --- */
.fleuron {
  border: 0;
  text-align: center;
  margin: 2.7rem 0;
  overflow: visible;
  height: 0;
}
.fleuron::before {
  content: "\276F";            /* ❯ — heavy right-angle bracket; mono "signal" */
  display: inline-block;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: var(--step-0);
  line-height: 1;
  transform: translateY(-0.55em);
  letter-spacing: 0.1em;
}
/* A softer botanical variant, if a warmer break is wanted: add .fleuron--leaf */
.fleuron--leaf::before {
  content: "\2767";            /* ❧ rotated floral heart */
  font-family: var(--font-serif);
  font-size: var(--step-1);
}

/* Section labels — small caps-ish, mono for "engineer" precision */
.section-label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-style: normal;
  font-weight: 600;
  margin: 0 0 1.35rem;
}

/* -----------------------------------------------------------------------------
   9. POST LIST — recent writing index
   -------------------------------------------------------------------------- */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: post;
}
.post-list > li {
  padding: 1.35rem 0;          /* 3 * baseline */
  border-top: 1px solid var(--rule);
}
.post-list > li:first-child { border-top: 0; padding-top: 0; }

/* Optional mono index numerals 01/02/03 (grafted from "Quiet Swiss Sans").
   Enable by adding .post-list--numbered to the <ol>. */
.post-list--numbered > li { counter-increment: post; position: relative; }
.post-list--numbered .post-item { display: block; }
.post-list--numbered .post-item__num {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  margin-bottom: 0.225rem;
}
.post-list--numbered .post-item__num::before {
  content: counter(post, decimal-leading-zero);
}

/* Metadata line — set in MONO with tabular figures (grafted) so dates and
   read-times align and read as "engineer". */
.post-item__meta {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.45rem;
}
.post-item__meta time { font-feature-settings: "onum" 0; } /* lining in mono */
.post-item__meta .dot { margin: 0 0.5em; color: var(--rule-strong); }

/* Optional category pill, mono + hairline (grafted from Concept 4) */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: 0.06em;
  text-transform: lowercase;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.05em 0.45em;
  vertical-align: baseline;
}

.post-item__title {
  font-size: var(--step-2);
  line-height: 1.2;
  margin: 0 0 0.45rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-wrap: balance;
}
.post-item__title a {
  color: var(--ink);
  border-bottom: 1px solid transparent;
}
.post-item__title a:hover { color: var(--ink); border-bottom-color: var(--accent); }

.post-item__dek {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.5;
  max-width: 60ch;
  text-wrap: pretty;
}

/* =============================================================================
   10. ARTICLE — the typographic showcase (post page + home excerpt)
   ========================================================================== */
.article { margin-top: 0.9rem; }
.article__header,
.excerpt__header { margin-bottom: 1.8rem; }

/* Post title (h1) */
.article__title,
.excerpt__title {
  font-size: var(--step-4);
  line-height: 1.12;
  letter-spacing: -0.012em;
  font-weight: 600;
  margin: 0 0 0.6rem;
  text-wrap: balance;
  color: var(--ink);
}

/* Dek / standfirst */
.article__dek,
.excerpt__dek {
  font-size: var(--step-1);
  line-height: 1.45;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 0.9rem;
  max-width: 58ch;
  text-wrap: pretty;
}

/* Byline / meta — mono, tabular (grafted) */
.article__byline,
.excerpt__byline {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  margin: 0;
}
.article__byline .dot,
.excerpt__byline .dot { margin: 0 0.5em; color: var(--rule-strong); }
.article__byline time,
.excerpt__byline time { font-feature-settings: "onum" 0; }

/* -----------------------------------------------------------------------------
   11. PROSE — the long-form body
   -------------------------------------------------------------------------- */
.prose > * { margin-block: 0 1.35rem; }   /* 3 * baseline trailing rhythm */
.prose > *:last-child { margin-bottom: 0; }

.prose p {
  max-width: var(--measure);
  text-wrap: pretty;
  hyphens: auto;
}

/* Lead paragraph: a hair larger; restrained emphasis on the first letter. */
.prose > p:first-of-type { font-size: 1.06em; }
.prose > p:first-of-type::first-letter { font-weight: 600; }

/* Headings */
.prose h2 {
  font-size: var(--step-3);
  line-height: 1.2;
  letter-spacing: -0.008em;
  font-weight: 600;
  margin-top: 2.25rem;   /* 5 * baseline */
  margin-bottom: 0.9rem; /* 2 * baseline */
  text-wrap: balance;
}
.prose h3 {
  font-size: var(--step-1);
  line-height: 1.3;
  font-weight: 600;
  margin-top: 1.8rem;    /* 4 * baseline */
  margin-bottom: 0.675rem;
  color: var(--ink);
  text-wrap: balance;
}

.prose strong { font-weight: 600; }
.prose em { font-style: italic; }

/* Lists — em-dash markers on unordered for an editorial feel */
.prose ul, .prose ol {
  max-width: var(--measure);
  padding-left: 1.4rem;
  margin-block: 0 1.35rem;
}
.prose li { margin-bottom: 0.45rem; }
.prose li::marker { color: var(--ink-faint); }
.prose ul li::marker { content: "\2014\00a0\00a0"; } /* "—  " */
.prose li > ul, .prose li > ol { margin-top: 0.45rem; margin-bottom: 0; }

/* Blockquote — hung accent rule, print style */
.prose blockquote {
  margin: 1.8rem 0;
  padding: 0.2rem 0 0.2rem 1.5rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
  max-width: 60ch;
}
.prose blockquote p { margin-bottom: 0.675rem; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose blockquote cite {
  display: block;
  margin-top: 0.45rem;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}
.prose blockquote cite::before { content: "\2014\00a0"; } /* "— " */

/* Inline code */
.prose code,
code.inline {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  color: var(--code-ink);
  font-feature-settings: normal;
  overflow-wrap: break-word;
}

/* =============================================================================
   12. FENCED CODE BLOCKS — with optional hairline title bar (grafted)
   ========================================================================== */

/* When a block needs a filename/lang label, wrap <pre> in <figure class="code">
   with a <figcaption class="code__title">. The bar is hairline only. */
.code {
  margin: 1.8rem 0;
}
.code__title {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  background: var(--paper-raised);
  border: 1px solid var(--code-border);
  border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 0.4rem 1.15rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.code__title .code__lang {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-size: var(--step--2);
}
/* When inside .code, square the top of the <pre> so it meets the title bar. */
.code > pre,
.code .prose-pre {
  margin: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* The <pre> itself (works standalone or inside .code / .prose) */
.prose pre,
pre.code-block {
  font-family: var(--font-mono);
  font-size: 0.84em;
  line-height: 1.6;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  margin: 1.8rem 0;
  overflow-x: auto;
  color: var(--code-ink);
  -webkit-overflow-scrolling: touch;
  font-feature-settings: normal;
  tab-size: 2;
}
.prose pre code,
pre.code-block code {
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Syntax tokens — low-chroma; comment re-tuned to clear AA in BOTH themes. */
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-keyword { color: var(--tok-keyword); }
.tok-string  { color: var(--tok-string); }
.tok-number  { color: var(--tok-number); }
.tok-func    { color: var(--tok-func); }

/* =============================================================================
   13. TABLES — book-interior: rules not boxes; italic caption hung below (graft)
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  margin: 1.8rem 0;
  -webkit-overflow-scrolling: touch;
}
.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.94em;
  font-variant-numeric: tabular-nums lining-nums;
}
.prose caption {
  caption-side: bottom;        /* hung beneath the table */
  text-align: left;
  font-size: var(--step--1);
  color: var(--ink-faint);
  font-style: italic;
  padding-top: 0.6rem;
}
.prose th, .prose td {
  text-align: left;
  padding: 0.55rem 0.9rem 0.55rem 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}
.prose thead th {
  border-bottom: 1.5px solid var(--rule-strong);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}
/* Heavier closing rule on the last row reads as "book interior". */
.prose tbody tr:last-child td { border-bottom: 1.5px solid var(--rule-strong); }
.prose td.num, .prose th.num {
  text-align: right;
  padding-right: 0.9rem;
  font-variant-numeric: tabular-nums lining-nums;
}

/* -----------------------------------------------------------------------------
   14. HORIZONTAL RULE (in-prose), MARK, ASIDE/CALLOUT
   -------------------------------------------------------------------------- */
.prose hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 1.8rem auto;
  width: 100%;
}

mark {
  background: var(--mark-bg);
  color: inherit;
  padding: 0.02em 0.2em;
  border-radius: 2px;
}

/* Aside / callout — quiet, no shadow, hairline + tint + hung accent edge */
.callout {
  margin: 1.8rem 0;
  padding: 0.9rem 1.2rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.97em;
  color: var(--ink-soft);
}
.callout p { margin: 0; max-width: 58ch; }
.callout p + p { margin-top: 0.675rem; }
.callout__label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-faint);
  margin-bottom: 0.45rem;
  font-style: normal;
}
/* Optional warning/note variants stay within the palette (no new hues). */
.callout--note  { border-left-color: var(--accent); }
.callout--quiet { border-left-color: var(--rule-strong); }

/* "Continue reading" affordance on the home excerpt */
.read-more {
  margin-top: 1.8rem;
  font-size: var(--step-0);
}
.read-more a { font-style: italic; }
.read-more a::after { content: "\00a0\2192"; font-style: normal; } /* " →" */

/* =============================================================================
   15. FOOTER — RSS link, copyright, dry colophon (grafted)
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 3.6rem;          /* 8 * baseline */
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem 1.5rem;
  padding-block: 1.8rem 2.25rem;
  font-family: var(--font-ui);
  font-size: var(--step--1);
  color: var(--ink-faint);
}
.site-footer a {
  color: var(--ink-soft);
  border-bottom-color: transparent;
}
.site-footer a:hover { color: var(--ink); border-bottom-color: var(--accent); }

/* RSS link with inline-SVG mark (grafted) — hairline, monochrome. */
.site-footer .rss {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.site-footer .rss .icon { width: 0.9em; height: 0.9em; stroke: currentColor; }

.site-footer__meta {
  font-style: italic;
  max-width: 52ch;
}
/* Dry colophon line — voice-on-brand, sits under or beside the meta. */
.site-footer__colophon {
  flex-basis: 100%;
  font-style: normal;
  color: var(--ink-faint);
  font-size: var(--step--2);
  letter-spacing: 0.01em;
  margin-top: 0.2rem;
}

/* =============================================================================
   16. RESPONSIVE TYPE STEP-DOWN — guarantee comfort at 320px (grafted)
   Below ~360px, shrink the largest serif titles so they never crowd the column.
   ========================================================================== */
@media (max-width: 22.5rem) {
  :root {
    --step-4: 1.78rem;   /* article/excerpt title */
    --step-3: 1.5rem;    /* h2 / featured */
    --step-2: 1.3rem;    /* post-item title, wordmark */
  }
  .masthead__inner { padding-top: 1.6rem; }
  .shell { padding-inline: 1.15rem; }
  .nav { gap: 0.9rem; }
}

/* On the narrowest screens, let the nav wrap under the brand gracefully. */
@media (max-width: 30rem) {
  .masthead__inner { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; }
}

/* =============================================================================
   17. PRINT — long-form essay friendly (grafted from Concept 4)
   Drop chrome, ink-on-white, avoid breaking code/callouts/tables across pages.
   ========================================================================== */
@media print {
  :root {
    --paper: #ffffff;
    --paper-raised: #ffffff;
    --ink: #000000;
    --ink-soft: #1a1a1a;
    --ink-faint: #444444;
    --rule: #cccccc;
    --rule-strong: #999999;
    --accent: #000000;
    --accent-strong: #000000;
    --code-bg: #f5f5f5;
    --code-border: #cccccc;
    --code-ink: #000000;
  }
  body { font-size: 11pt; line-height: 1.5; background: #fff; color: #000; }

  .theme-toggle,
  .skip-link,
  .fleuron { display: none !important; }

  .masthead, .site-footer { border-color: #999; }

  a { color: #000; border-bottom: 0; }
  /* Expose post URLs in print, but not for in-page or nav anchors. */
  .prose a[href^="http"]::after,
  .prose a[href^="/"]::after {
    content: " (" attr(href) ")";
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: #444;
  }

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

  .prose h2, .prose h3 { break-after: avoid; page-break-after: avoid; }

  .shell { max-width: none; }
}

/* =============================================================================
   18. FORCED-COLORS / HIGH-CONTRAST — keep focus + borders meaningful
   ========================================================================== */
@media (forced-colors: active) {
  a:focus-visible,
  .theme-toggle:focus-visible { outline: 2px solid CanvasText; }
  .callout, .prose pre, .code__title { border-color: CanvasText; }
}
