/* =========================================================
   jonathanfrei.com — design system (single source of truth)
   Served as /assets/css/core.css on every page. Feature sheets ship
   only when needed (code, search, embeds, pagination — optional-css.html, #165).
   Keep everything under _includes/.
   ========================================================= */

/* ---------- Fonts (Fontsource / jsDelivr, latin variable) ---------- */
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/source-serif-4:vf@5.2.5/latin-wght-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: "Source Serif 4";
  font-style: italic;
  font-display: swap;
  font-weight: 200 900;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/source-serif-4:vf@5.2.5/latin-wght-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: "Source Code Pro";
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/source-code-pro:vf@5.2.5/latin-wght-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: "Source Code Pro";
  font-style: italic;
  font-display: swap;
  font-weight: 200 900;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/source-code-pro:vf@5.2.5/latin-wght-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;
}

/* ---------- Brand tokens (#145) — Editorial intelligence + technical edge ----------
   Signature: Paper + Ink + Jonathan Blue (#0077A8). Use blue sparingly (links,
   rules, labels). Editorial accents (seafoam, ochre, terracotta, lavender, sand)
   are content categories — not UI semantics. */
:root {
  /* Foundation */
  --brand-ink: #111C24;
  --brand-deep-ocean: #00334D;
  --brand-paper: #FAF9F6;
  --brand-white: #FFFFFF;
  --brand-warm-gray: #E8E6E1;
  /* Charcoal / stone darkened for WCAG AA on Paper (#FAF9F6) */
  --brand-charcoal: #2F3A42;
  --brand-stone: #4A5560;

  /* Signature blue scale */
  --brand-primary-100: #00334D; /* Deep Ocean */
  --brand-primary-80: #0077A8;  /* Signature Blue */
  --brand-primary-60: #3391BA;  /* Ocean Blue */
  --brand-primary-40: #66ABD0;  /* Sky Blue */
  --brand-primary-20: #D9EDF5;  /* Pale Blue */
  --brand-primary-10: #EEF7FA;  /* Ice */

  /* Editorial accents (content modes — not error/success) */
  --brand-seafoam: #00A896;
  --brand-ochre: #C58B2A;
  --brand-terracotta: #C85C4A;
  --brand-lavender: #7667A8;
  --brand-sand: #E9DCC8;

  /* UI semantics (separate from brand accents) */
  --color-success: #0b6e4f;
  --color-warning: #c58b2a;
  --color-error: #b00020;
  --color-info: #0077A8;

  /* Mapped surface tokens (site chrome + prose) */
  --color-bg: var(--brand-paper);
  --color-fg: var(--brand-ink);
  --color-muted: var(--brand-stone);
  --color-border: var(--brand-warm-gray);
  --color-accent: var(--brand-primary-80);
  --color-accent-hover: var(--brand-primary-100);
  --color-code-bg: var(--brand-primary-10);
  --color-header-bg: var(--brand-paper);
  --color-surface: var(--brand-white);

  --font-body: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-ui: "Source Code Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: var(--font-ui);

  --type-base: clamp(1.0625rem, 1rem + 0.35vw, 1.125rem);
  --type-sm: 0.875em;
  --type-lg: 1.25em;
  --type-xl: 1.5em;
  --type-2xl: 1.875em;
  --type-3xl: 2.25em;

  --leading-body: 1.4;
  --leading-tight: 1.3;
  --leading-heading: 1.25;

  --measure: 36em;
  --measure-wide: 48em;

  --rhythm: calc(var(--type-base) * var(--leading-body));
  --space-1: calc(var(--rhythm) * 0.25);
  --space-2: calc(var(--rhythm) * 0.5);
  --space-3: calc(var(--rhythm) * 0.75);
  --space-4: var(--rhythm);
  --space-5: calc(var(--rhythm) * 1.5);
  --space-6: calc(var(--rhythm) * 2);
  --space-8: calc(var(--rhythm) * 3);

  --radius: 0.25rem;

  /* Unit policy: em follows local type; rem anchors fixed UI geometry;
     px preserves device-level strokes and minimum targets; %, viewport,
     and container units remain fluid. Prefer tokens for shared values. */

  /* Syntax highlighter token colors (overridden in dark) */
  --cr-comment: #6b6b5e;
  --cr-string: #0b6e4f;
  --cr-keyword: #0077A8;
  --cr-function: #00334D;
  --cr-number: #c58b2a;
  --cr-name: #7667A8;
}

/* Dark: ink-on-black editorial notebook (#145)
   Remap brand foundation tokens so components using --brand-* stay readable. */
html[data-theme="dark"] {
  --brand-ink: #F4F3EF;
  --brand-deep-ocean: #8EC5E0; /* light ocean for headings on dark surfaces */
  --brand-paper: #0B1115;
  --brand-white: #18262E;
  --brand-warm-gray: #2A373E;
  --brand-charcoal: #C5CED3;
  --brand-stone: #A8B3B9;
  --brand-primary-100: #8EC5E0;
  --brand-primary-10: #152028; /* “ice” → dark surface tint, not pale blue */
  --brand-primary-20: #1A2A34;
  --brand-sand: #1E2A32;
  --brand-seafoam: #3DCFC0;
  --brand-ochre: #E0A84A;
  --brand-terracotta: #E89284;
  --brand-lavender: #B5A8E0;

  --color-bg: #0B1115;
  --color-fg: #F4F3EF;
  --color-muted: #A8B3B9;
  --color-border: #2A373E;
  --color-accent: #4AA8D4;
  --color-accent-hover: #7AD0EC;
  --color-code-bg: #121C22;
  --color-header-bg: #0B1115;
  --color-surface: #18262E;
  --cr-comment: #9a968c;
  --cr-string: #7dcea0;
  --cr-keyword: #66C0DD;
  --cr-function: #8ab4f8;
  --cr-number: #f0c674;
  --cr-name: #c9a0dc;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --brand-ink: #F4F3EF;
    --brand-deep-ocean: #8EC5E0;
    --brand-paper: #0B1115;
    --brand-white: #18262E;
    --brand-warm-gray: #2A373E;
    --brand-charcoal: #C5CED3;
    --brand-stone: #A8B3B9;
    --brand-primary-100: #8EC5E0;
    --brand-primary-10: #152028;
    --brand-primary-20: #1A2A34;
    --brand-sand: #1E2A32;
    --brand-seafoam: #3DCFC0;
    --brand-ochre: #E0A84A;
    --brand-terracotta: #E89284;
    --brand-lavender: #B5A8E0;

    --color-bg: #0B1115;
    --color-fg: #F4F3EF;
    --color-muted: #A8B3B9;
    --color-border: #2A373E;
    --color-accent: #4AA8D4;
    --color-accent-hover: #7AD0EC;
    --color-code-bg: #121C22;
    --color-header-bg: #0B1115;
    --color-surface: #18262E;
    --cr-comment: #9a968c;
    --cr-string: #7dcea0;
    --cr-keyword: #66C0DD;
    --cr-function: #8ab4f8;
    --cr-number: #f0c674;
    --cr-name: #c9a0dc;
  }
}

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

img,
video {
  max-width: 100%;
  height: auto;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Do not set overflow-x on html. iOS Safari then sizes the layout
     viewport to overflowing content (~980px) and every max-width
     media query sees a desktop canvas (#227, #231). */
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--type-base);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--color-fg);
  background-color: var(--color-bg);
  min-height: 100vh;
  min-width: 0;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: var(--leading-heading);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  text-wrap: balance;
  letter-spacing: -0.01em;
}

/* Heading permalinks (#160): H2/H3 icon left of text on hover; click heading or icon */
.prose :is(h2, h3) {
  position: relative;
}

.prose :is(h2, h3) > a.heading-anchor {
  color: inherit;
  text-decoration: none;
}

.prose :is(h2, h3) > a.heading-anchor:hover,
.prose :is(h2, h3) > a.heading-anchor:focus-visible {
  color: inherit;
  text-decoration: none;
}

.heading-anchor__icon {
  position: absolute;
  left: -0.95em;
  width: 0.9em;
  margin-left: 0;
  font-family: var(--font-mono);
  font-size: 0.75em;
  font-weight: 400;
  line-height: inherit;
  color: var(--color-muted);
  opacity: 0;
  transition: opacity 0.12s ease;
  text-decoration: none;
  user-select: none;
}

.prose :is(h2, h3):hover .heading-anchor__icon,
.prose :is(h2, h3):focus-within .heading-anchor__icon,
.heading-anchor:focus-visible .heading-anchor__icon {
  opacity: 1;
  color: var(--color-accent);
}

@media (hover: none) {
  /* Touch: keep icon discoverable without hover */
  .heading-anchor__icon {
    opacity: 0.35;
  }
}

h1 {
  font-size: var(--type-3xl);
  margin-top: 0;
  margin-bottom: var(--space-4);
}

h2 { font-size: var(--type-2xl); }
h3 { font-size: var(--type-xl); }
h4 { font-size: var(--type-lg); }

p, ul, ol, blockquote, pre, table, figure {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

ul, ol {
  padding-left: 1.4em;
}

li + li {
  margin-top: 0.35em;
}

blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: var(--space-4);
  border-left: 2px solid var(--color-accent);
  color: var(--color-muted);
  font-style: italic;
  font-weight: 300;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin-block: var(--space-6);
}

:focus {
  outline: none;
}

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

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

a:hover,
a:focus-visible {
  color: var(--color-accent-hover);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--measure);
  min-width: 0;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.site-main {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding-block: var(--space-8);
  /* Query container for .figure-wide breakout. 100cqi is the main
     column (no scrollbar), unlike 100vw (#223, #243). */
  container-type: inline-size;
}

/* ---------- Header ---------- */
.site-header {
  font-family: var(--font-ui);
  font-size: var(--type-sm);
  font-weight: 500;
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
  padding-block: var(--space-3);
}

.site-header .container {
  width: 100%;
  max-width: var(--measure-wide);
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
}

@media (min-width: 40em) {
  .site-header .container {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }
}

.site-logo {
  font-family: var(--font-body);
  font-size: var(--type-base);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--color-fg);
  text-decoration: none;
}

.site-logo:hover,
.site-logo:focus-visible {
  color: var(--color-accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.site-nav a {
  /* Charcoal-level contrast on paper (not light stone) */
  color: var(--brand-charcoal, #2F3A42);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.45em 0.35em;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-transform: uppercase;

}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.site-nav a[aria-current="page"] {
  color: var(--color-fg);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.2em;
}

/* ---------- Footer ---------- */
.site-footer {
  font-family: var(--font-ui);
  font-size: var(--type-sm);
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-5);
  color: var(--brand-charcoal, #2F3A42);
}

.site-footer .container {
  max-width: var(--measure-wide);
}

.site-footer a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--color-accent-hover);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}

.footer-copy,
.footer-links {
  margin: 0;
  line-height: 1.35;
}

.footer-copy {
  min-width: 0;
}

.footer-end {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-shrink: 0;
}

.footer-links {
  white-space: nowrap;
}

.footer-links-sep {
  margin-inline: 0.25em;
  opacity: 0.7;
}

.footer-note {
  margin: var(--space-4) 0 0;
  font-size: var(--type-sm);
  color: var(--brand-charcoal, #2F3A42);
  opacity: 0.92;
}

html[data-theme="dark"] .site-nav a,
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .footer-note,
html[data-theme="dark"] .theme-toggle {
  color: var(--color-muted);
}

html[data-theme="dark"] .site-nav a:hover,
html[data-theme="dark"] .site-nav a:focus-visible {
  color: var(--color-accent);
}

html[data-theme="dark"] .site-nav a[aria-current="page"] {
  color: var(--color-fg);
}

html[data-theme="dark"] .site-footer a {
  color: var(--color-accent);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .site-nav a,
  html:not([data-theme="light"]) .site-footer,
  html:not([data-theme="light"]) .footer-note,
  html:not([data-theme="light"]) .theme-toggle {
    color: var(--color-muted);
  }

  html:not([data-theme="light"]) .site-nav a:hover,
  html:not([data-theme="light"]) .site-nav a:focus-visible {
    color: var(--color-accent);
  }

  html:not([data-theme="light"]) .site-nav a[aria-current="page"] {
    color: var(--color-fg);
  }

  html:not([data-theme="light"]) .site-footer a {
    color: var(--color-accent);
  }
}

@media (max-width: 28em) {
  .footer-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .footer-end {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
}

/* Theme toggle */
.theme-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  color: var(--brand-charcoal, #2F3A42);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  color: var(--color-fg);
  border-color: var(--color-border);
  background: color-mix(in srgb, var(--color-fg) 6%, transparent);
  outline: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-toggle__icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
}

html[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

html[data-theme="light"] .theme-toggle__icon--sun,
html:not([data-theme]) .theme-toggle__icon--sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-toggle__icon--moon {
    display: none;
  }
  html:not([data-theme="light"]) .theme-toggle__icon--sun {
    display: block;
  }
}

/* ---------- Prose ---------- */
.prose {
  max-width: var(--measure);
  min-width: 0;
  hyphens: auto;
}

.prose .lede {
  font-size: var(--type-lg);
  font-weight: 400;
  line-height: 1.45;
}

.prose > :first-child {
  margin-top: 0;
}

.prose img,
.prose figure {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* Standalone article images fill the measure (#203). Small figure
   specimens (e.g. the typography favicon) stay intrinsic-sized.
   .figure-wide keeps intrinsic size and may break out of the measure (#223). */
.prose p:has(> img:only-child):not(.figure-wide) img,
.prose p:has(> a:only-child > img:only-child):not(.figure-wide) img {
  display: block;
  width: 100%;
}

.prose p:has(> a:only-child > img:only-child) > a {
  display: block;
}

.prose figcaption {
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  color: var(--color-muted);
  margin-top: var(--space-2);
  text-align: center;
  letter-spacing: 0.02em;
}

.prose pre,
.prose code {
  font-family: var(--font-mono);
  font-size: var(--type-sm);
}

.prose pre {
  background: var(--color-code-bg);
  padding: var(--space-4);
  overflow-x: hidden;
  border-radius: var(--radius);
  line-height: 1.45;
  hyphens: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.prose code {
  background: var(--color-code-bg);
  padding: 0.12em 0.35em;
  border-radius: calc(var(--radius) * 0.6);
}

.prose pre code {
  background: transparent;
  font-size: inherit;
  padding: 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-sm);
  font-family: var(--font-ui);
}

.prose th,
.prose td {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}

/* Drop caps on the opening paragraph (after H1). initial-letter: 2 sizes the
   letter so its cap-height meets the first line and its baseline
   meets the second line. */
.prose--drop-cap .post-body > p:first-of-type::first-letter {
  -webkit-initial-letter: 2;
  initial-letter: 2;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--color-fg);
  margin-inline-end: 0.1em;
}

.prose--drop-cap .post-body > p:first-of-type {
  hyphens: none;
}

/* Fallback when initial-letter is missing. Size from one line-height
   plus Source Serif 4's cap-height (~0.657em) so the letter still
   spans two lines as closely as float allows. */
@supports not ((initial-letter: 2) or (-webkit-initial-letter: 2)) {
  .prose--drop-cap .post-body > p:first-of-type::first-letter {
    float: left;
    font-size: calc((1em * var(--leading-body) + 0.657em) / 0.657);
    line-height: 0.657;
    padding-top: calc((1em * var(--leading-body) - 1em) / 2);
    padding-right: 0.1em;
    margin-inline-end: 0;
  }
}

/* ---------- Prose editorial marks (#223) ---------- */
/* Kramdown: {: .aside} / {: .pull-quote} / {: .caption} / {: .figure-wide} */

/* Host paragraph first in the DOM (reading order). On small screens the
   aside stays boxed underneath. On wide screens a hanging grid puts it
   in the left margin without overlapping the measure. */
.aside-pair {
  --aside-outer-space: 11.5rem;
  --aside-gap: 1.35rem;

  display: flex;
  flex-direction: column;
}

.prose p.aside,
.prose aside.aside,
.aside-pair > .aside {
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 0.82em;
  line-height: 1.45;
  color: var(--color-fg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-4);
}

.prose p.aside a,
.prose aside.aside a,
.aside-pair > .aside a {
  color: var(--color-accent);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.prose p.aside a:hover,
.prose p.aside a:focus-visible,
.prose aside.aside a:hover,
.prose aside.aside a:focus-visible,
.aside-pair > .aside a:hover,
.aside-pair > .aside a:focus-visible {
  color: var(--color-accent-hover);
}

.prose p.aside strong,
.prose aside.aside strong,
.aside-pair > .aside strong {
  font-weight: 700;
  color: var(--brand-deep-ocean, var(--color-fg));
}

.prose .aside-pair > .aside img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

/* Hang only when the aside space and gap fit beside the 36em measure. At 60em
   the box sat off the left edge and widened the page (#226, #231).
   Only paired asides hang; an unpaired .aside stays boxed instead of
   sitting on a heading (#232). The hang selectors must beat
   `.prose p.aside` or the box/padding/margin win and the sidenote
   overlaps the paragraph. */
@media (min-width: 84em) {
  .aside-pair {
    display: grid;
    grid-template-columns: var(--measure) minmax(0, 1fr);
    column-gap: var(--aside-gap);
    align-items: start;
    position: relative;
    width: calc(100% + 2 * var(--aside-outer-space));
  }

  .aside-pair > :not(.aside) {
    grid-column: 1;
    grid-row: 1;
  }

  .prose .aside-pair > .aside,
  .prose .aside-pair > p.aside {
    grid-column: 2;
    grid-row: 1;
    position: absolute;
    top: 0.15em;
    right: 0;
    left: 0;
    float: none;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
  }
}

.prose .pull-quote {
  font-family: var(--font-body);
  font-size: 1.15em;
  font-weight: 700;
  font-style: italic;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--color-fg);
  padding: var(--space-3) 0 var(--space-3) var(--space-5);
  margin-block: var(--space-5);
}

.prose blockquote.pull-quote {
  --pull-quote-bleed: 8rem;

  border: 0;
  border-left: 4px solid var(--brand-ochre);
  color: var(--color-fg);
}

.prose blockquote.pull-quote > p {
  margin-bottom: var(--space-3);
}

.prose blockquote.pull-quote > p:last-child {
  margin-bottom: 0;
}

/* A final emphasized line is the quote attribution. */
.prose blockquote.pull-quote > p:last-child > em:only-child {
  display: block;
  font-family: var(--font-body);
  font-size: var(--type-sm);
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0.02em;
  color: var(--color-muted);
}

@media (min-width: 56em) {
    .prose blockquote.pull-quote {
        width: calc(100% + 2 * var(--pull-quote-bleed));
        max-width: calc(100vw - 2 * var(--space-4));
        margin-inline: calc(-1 * var(--pull-quote-bleed));
    }
}

.prose .caption {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 0.75em;
  line-height: 1.5;
  color: var(--color-fg);
  margin-top: calc(-1 * var(--space-4));
  margin-bottom: var(--space-4);
}

.prose .caption strong {
  font-family: var(--font-mono);
  font-weight: 700;
  font-style: normal;
  color: var(--color-fg);
  text-transform: uppercase;
  margin-right: 0.5em;
}

.prose .caption em,
.prose .caption i {
  font-family: var(--font-mono);
  font-weight: 200;
  font-style: normal;
  color: var(--color-muted);
  margin-left: 0.5em;
}

.prose .caption a {
  color: var(--color-accent);
  font-weight: inherit;
  text-decoration: none;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.prose .caption a:hover,
.prose .caption a:focus-visible {
  color: var(--color-accent-hover);
  text-decoration-style: solid;
}

/*
  Wide figures break out of the measure to .site-main. Do not use
  100vw (scrollbar; Safari layout viewport) and do not restyle the
  page when :has(.figure-wide) — that indented every .prose child on
  /blog and /archive (#243). Only the figure changes width.

  Fallback cancels .container padding. 100cqi is the main column.
  The img stays intrinsic-sized: full bleed when it is wide enough,
  never stretched. On small screens the img fills the bleed slot.
*/
.prose .figure-wide,
.prose p.figure-wide,
.prose figure.figure-wide {
  margin-block: var(--space-5) var(--space-4);
  text-align: center;
  width: calc(100% + 2 * var(--space-4));
  max-width: none;
  margin-inline: calc(-1 * var(--space-4));
}

@supports (width: 1cqi) {
  .prose .figure-wide,
  .prose p.figure-wide,
  .prose figure.figure-wide {
    width: 100cqi;
    max-width: 100cqi;
    margin-inline: calc(50% - 50cqi);
  }
}

.prose .figure-wide img,
.prose img.figure-wide {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

/* ---------- Post list & meta ---------- */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list > li {
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.post-list > li:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.post-list > li > a {
  font-family: var(--font-body);
  font-size: var(--type-lg);
  font-weight: 400;
  text-decoration: none;
  color: var(--color-fg);
  letter-spacing: -0.01em;
}

.post-list > li > a:hover,
.post-list > li > a:focus-visible {
  color: var(--color-accent);
  text-decoration: underline;
}

.post-list .excerpt {
  margin: var(--space-2) 0 0;
}

/* ---------- Link posts (#37) ---------- */
.link-entry__title {
  font-size: var(--type-lg);
  font-weight: 400;
  margin: 0;
}

.link-entry__title a {
  color: var(--color-fg);
  text-decoration: none;
}

.link-entry__title a:hover,
.link-entry__title a:focus-visible {
  color: var(--color-accent);
  text-decoration: underline;
}

.link-entry__meta { margin: 0 0 var(--space-3); }
.link-entry__body,
.link-post__body {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

.link-entry__body img,
.link-post__body img {
  max-width: 100%;
  height: auto;
}
.link-entry__body > :first-child,
.link-post__body > :first-child { margin-top: 0; }
.link-post__meta { margin: 0 0 var(--space-6); }
.links-year + .links-year { margin-top: var(--space-8); }
.link-archive-months { margin-bottom: var(--space-6); }

.link-glyphs {
  float: left;
  margin: 0.15em 0.45em 0 0;
  line-height: inherit;
}
.link-glyph {
  font-family: var(--font-mono);
  color: var(--color-accent);
  text-decoration: none;
  margin-right: 0.15em;
}
.link-glyph:hover,
.link-glyph:focus-visible {
  text-decoration: underline;
}

.stream-post__title {
  font-size: var(--type-lg);
  font-weight: 400;
  margin: 0;
}
.stream-post__title a {
  color: var(--color-fg);
  text-decoration: none;
}
.stream-post__title a:hover,
.stream-post__title a:focus-visible {
  color: var(--color-accent);
  text-decoration: underline;
}
.stream-post__meta { margin: var(--space-2) 0 0; }
.stream-post > .post-tags { margin-top: var(--space-3); }
.stream-post__excerpt { margin-top: var(--space-4); }
.read-more {
  margin: var(--space-3) 0 0;
  font-family: var(--font-ui);
  font-size: var(--type-sm);
}

.post-meta a,
a.post-meta__date {
  color: inherit;
  text-decoration: none;
}
.post-meta a:hover,
.post-meta a:focus-visible,
a.post-meta__date:hover,
a.post-meta__date:focus-visible {
  color: var(--color-accent);
}

.link-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--color-fg);
  text-decoration: none;
  background: var(--color-bg);
}

.link-card:hover,
.link-card:focus-visible {
  border-color: var(--color-accent);
  text-decoration: none;
}

.link-card__image { display: block; width: 100%; max-height: 16rem; object-fit: cover; }
.link-card__body { display: grid; gap: var(--space-1); padding: var(--space-3); }
.link-card__host { color: var(--color-muted); font-family: var(--font-mono); font-size: var(--type-sm); letter-spacing: 0.06em; text-transform: uppercase; }
.link-card__title { font-size: var(--type-md); font-weight: 600; }
.link-card__description { color: var(--color-muted); font-size: var(--type-sm); }

/* Post meta: published · Updated · N min read (#75) */
.post-meta__sep {
  margin: 0 0.15em;
}

.post-meta__updated,
.post-meta__reading {
  white-space: nowrap;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  color: var(--color-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.post-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.post-header h1 {
  margin-top: 0;
  margin-bottom: var(--space-3);
}

.prose .eyebrow {
  margin: 0 0 var(--space-2);
  font-family: var(--font-ui);
  font-size: var(--type-sm);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-ochre);
}

.prose .deck {
  margin: 0 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--type-lg);
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-muted);
}

.post-header .post-meta {
  margin: 0;
}

/* Archive / tag / category page titles without full post-header chrome */
.page-title {
  margin-bottom: var(--space-6);
}

.page-title h1 {
  margin-top: 0;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: var(--space-3) 0 0;
  font-family: var(--font-mono);
}

.tags li {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  margin: 0;
  padding: 0;
}

.tags li + li {
  margin-top: 0;
}

.tags li .post-meta {
  margin-left: 0.15em;
}

.tag {
  display: inline-block;
  font-size: var(--type-sm);
  background: var(--color-code-bg);
  padding: 0.35em 0.65em;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 1.75rem;
  line-height: 1.3;
}

.tag:hover,
.tag:focus-visible {
  color: var(--color-accent);
  text-decoration: none;
}

/* Singleton tags: same chip, not a link (#140) */
.tag--solo,
span.tag {
  cursor: default;
  opacity: 0.72;
  border: 1px dashed var(--color-border);
  background: transparent;
}

.tag--solo:hover,
.tag--solo:focus,
span.tag:hover {
  color: var(--color-muted);
}

.post-tags {
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  margin-top: var(--space-6);
}

.post-tags__list,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag-row {
  display: inline-flex;
  vertical-align: middle;
}

.post-tags__list li {
  margin: 0;
  padding: 0;
}

.post-tags__list li + li {
  margin-top: 0;
}

/* Post footer actions */
.post-comment-link,
.post-nav {
  font-family: var(--font-ui);
  font-size: var(--type-sm);
  margin-top: var(--space-8);
}

.post-comment-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.35em;
  row-gap: 0.25em;
  line-height: 1.35;
}

.post-comment-link a {
  white-space: nowrap;
}

.post-actions-sep {
  opacity: 0.7;
  user-select: none;
}

/* Home */
.home-intro {
  margin-bottom: var(--space-8);
}

.home-intro h1 {
  font-size: var(--type-2xl);
  margin-bottom: var(--space-4);
}

.section-title {
  font-family: var(--font-mono);
  font-size: var(--type-sm);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--space-4);
  margin-top: 0;
}

/* Accessibility */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-ui);
  padding: var(--space-2) var(--space-4);
  z-index: 100;
  border: 2px solid var(--color-accent);
}

.skip-link:focus {
  top: var(--space-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Monthly archive list (dense block on /archive) */
.archive-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0;
  font-family: var(--font-ui);
  font-size: var(--type-sm);
}

.archive-list li {
  display: inline-block;
  margin: 0;
  padding: 0;
  border: 0;
}

.archive-list a {
  text-decoration: none;
  color: var(--color-fg);
}

.archive-list a:hover,
.archive-list a:focus-visible {
  color: var(--color-accent);
  text-decoration: underline;
}

/* Small screens */
@media (max-width: 40em) {
  .site-main {
    padding-block: var(--space-6);
  }

  /* Full-bleed standalone images (#202). .figure-wide has its own
     breakout (cqi / padding-cancel) and is excluded here so this
     rule cannot override it. */
  .prose p:has(> img:only-child):not(.figure-wide),
  .prose p:has(> a:only-child > img:only-child):not(.figure-wide) {
    width: calc(100% + (2 * var(--space-4)));
    max-width: none;
    margin-inline: calc(-1 * var(--space-4));
  }

  .prose p:has(> img:only-child) img,
  .prose p:has(> a:only-child > img:only-child) img {
    border-radius: 0;
  }

  .prose .figure-wide img,
  .prose img.figure-wide {
    width: 100%;
  }
}
