/* ══════════════════════════════════════════════════════════════
   MARGINALIA ESSAY — the whole design system for the essay body.
   Ported from blog-post-layout.html (the source of truth for every
   value). Two mechanical adaptations, values untouched:
   1. Every custom property is prefixed --me- because the site's
      editorial system already defines --measure and --space-* on
      :root with different values.
   2. Page-level rules are scoped to body.marginalia-essay so the
      out-of-scope site header/footer keep their own system.
   ══════════════════════════════════════════════════════════════ */

/* ── Self-hosted type (latin subsets). Preloads live in wp_head. ── */
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-roman.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-stretch: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-roman.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ══════════════════════════════════════════════════════════════
   1 · TOKENS
   ══════════════════════════════════════════════════════════════ */
:root {
  --me-font-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --me-font-body: "Newsreader", Georgia, "Times New Roman", serif;
  --me-font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Type scale. Body lands 17→18.4px; the title is deliberately
     dominant even at the small end of the range. */
  --me-step--1: clamp(0.8rem, 0.77rem + 0.12vw, 0.86rem);
  --me-step-0:  clamp(1.0625rem, 1.02rem + 0.2vw, 1.15rem);
  --me-step-1:  clamp(1.3rem, 1.2rem + 0.45vw, 1.6rem);
  --me-step-2:  clamp(1.85rem, 1.55rem + 1.1vw, 2.5rem);
  --me-step-3:  clamp(2.1rem, 1.65rem + 2.2vw, 3.4rem);
  --me-step-4:  clamp(3.4rem, 2.1rem + 5.6vw, 6.5rem);

  --me-lh: 1.7;

  /* 8-point spacing scale. Every vertical gap in the article is one
     of these — nothing is hand-tuned. */
  --me-space-1: 0.5rem;   /*  8 */
  --me-space-2: 1rem;     /* 16 */
  --me-space-3: 1.5rem;   /* 24 */
  --me-space-4: 2rem;     /* 32 */
  --me-space-5: 2.5rem;   /* 40 */
  --me-space-6: 3rem;     /* 48 */
  --me-space-8: 4rem;     /* 64 */
  --me-space-10: 5rem;    /* 80 */

  /* Measure + rails. Rails are on the RIGHT for sidenotes; the left
     gutter belongs to the contents rail. */
  --me-measure: 44rem;        /* 704px ≈ 72 characters at body size */
  --me-rail-inner: 3rem;      /* text → pop  : +6rem  = 50rem */
  --me-rail-outer: 9rem;      /* pop  → wide : +24rem = 68rem */
  --me-note-w: 10rem;         /* sidenote, floating into the right rails */
  --me-pad: clamp(1.25rem, 4vw, 2.5rem);

  --me-toc-w: 10rem;          /* contents rail */
  --me-toc-gap: 4.5rem;       /* 72px from the rail to the text column */
  --me-masthead-h: 0px;       /* remeasured by JS on load and resize */
  --me-toc-h: 3rem;

  --me-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Mobile densify: the mid-scale gaps shrink one step so paragraph
   spacing stays below one line-height (32px gaps read as section
   breaks at 17px type), quote padding stops squeezing the measure,
   and display blocks lose their desktop-scale air. */
@media (max-width: 46rem) {
  :root {
    --me-space-4: 1.5rem;
    --me-space-5: 2rem;
    --me-space-6: 2.5rem;
    --me-space-8: 3rem;
    --me-space-10: 3.5rem;
  }

  /* Mobile byline: author and the date·read-time unit share one line
     when they fit; the unit is nowrap so on very narrow screens it
     drops whole — never splitting at a separator. The author/date
     separator goes: the gap does its job, and it would dangle at a
     line end whenever the unit wraps. (Children are spans in template
     order: by, sep, date·read-time, tags.) */
  /* Author anchors left, the date·read-time unit anchors right — the
     classic one-line byline. A wrapped unit falls back to the left. */
  .essay-prose .byline {
    column-gap: var(--me-space-2);
    justify-content: space-between;
  }
  .essay-prose .byline > span:nth-child(2) { display: none; }
  .essay-prose .byline > span:nth-child(3) { white-space: nowrap; }
  .essay-prose .byline .tags {
    flex-basis: 100%;
    margin-inline-start: 0;
  }
  .essay-prose .byline .tags a { padding: 0.3rem 0.7rem; }
}

/* Light set: the default, and the explicit choice. */
:root,
:root[data-theme="light"] {
  --me-paper:      #f7f4ed;
  --me-paper-2:    #fffefb;
  --me-ink-strong: #1c1815;   /* headings */
  --me-ink:        #322d29;   /* body — 12.2:1, warm rather than black */
  --me-ink-2:      #5c564e;   /* 6.6:1 */
  --me-ink-3:      #726b5f;   /* 4.8:1 — floor for small text */
  --me-rule:       #e0d9cb;
  --me-accent:     #a63e26;   /* 5.7:1 */
  --me-accent-2:   #d9724f;
  --me-mark:       #f0e3cd;
  --me-shadow:     0 1px 2px rgb(25 23 19 / 0.05), 0 12px 28px -18px rgb(25 23 19 / 0.35);
}

/* Dark set: system preference by default… */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --me-paper:      #14130f;
    --me-paper-2:    #1d1b16;
    --me-ink-strong: #f2ede2;
    --me-ink:        #ddd6c9;   /* 12.9:1 */
    --me-ink-2:      #a8a094;
    --me-ink-3:      #8f8779;
    --me-rule:       #302c25;
    --me-accent:     #e0805e;
    --me-accent-2:   #b8543a;
    --me-mark:       #2f2618;
    --me-shadow:     0 1px 2px rgb(0 0 0 / 0.5), 0 14px 32px -20px rgb(0 0 0 / 0.9);
  }
}

/* …and an explicit data-theme outranks it. */
:root[data-theme="dark"] {
  --me-paper:      #14130f;
  --me-paper-2:    #1d1b16;
  --me-ink-strong: #f2ede2;
  --me-ink:        #ddd6c9;
  --me-ink-2:      #a8a094;
  --me-ink-3:      #8f8779;
  --me-rule:       #302c25;
  --me-accent:     #e0805e;
  --me-accent-2:   #b8543a;
  --me-mark:       #2f2618;
  --me-shadow:     0 1px 2px rgb(0 0 0 / 0.5), 0 14px 32px -20px rgb(0 0 0 / 0.9);
}

/* ══════════════════════════════════════════════════════════════
   2 · BASE — scoped to the essay body class
   ══════════════════════════════════════════════════════════════ */
html:has(body.marginalia-essay) {
  scroll-behavior: smooth;
  hanging-punctuation: first last;
}

body.marginalia-essay {
  background: var(--me-paper);
  color: var(--me-ink);
  font-family: var(--me-font-body);
  font-size: var(--me-step-0);
  line-height: var(--me-lh);
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s var(--me-ease), color 0.4s var(--me-ease);
}

body.marginalia-essay::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(60rem 40rem at 12% 8%,  color-mix(in oklab, var(--me-accent) 8%, transparent), transparent 70%),
    radial-gradient(50rem 36rem at 92% 82%, color-mix(in oklab, var(--me-accent-2) 7%, transparent), transparent 70%);
}
/* Skip links opt out: Oxygen's .oxy-skip-link hides via clip, which only
   applies to absolutely positioned elements — forcing position: relative
   here would unhide it. */
body.marginalia-essay > :not(.oxy-skip-link) { position: relative; z-index: 1; }

.marginalia-essay .essay-prose :is(h1, h2, h3) {
  font-weight: 400;
  color: var(--me-ink-strong);
  text-wrap: balance;
}
.marginalia-essay .essay-prose :is(p, li) { text-wrap: pretty; }
.marginalia-essay .essay-prose :is(img, svg) { max-width: 100%; display: block; }

body.marginalia-essay ::selection { background: var(--me-mark); color: var(--me-ink-strong); }

.marginalia-essay :where(a, button, input):focus-visible {
  outline: 2px solid var(--me-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Bridge to the out-of-scope site chrome: the templates themselves are
   untouched; on essay pages their surfaces pick up the paper tokens so
   there is no white seam above the article. */
body.marginalia-essay .site-header,
body.marginalia-essay .site-footer {
  background-color: transparent;
  border-color: var(--me-rule);
}

.marginalia-essay .skip {
  /* Fixed, not absolute: the nearest positioned ancestor is <main>, which
     starts below the header, so an absolute skip link peeks into view. */
  position: fixed;
  left: var(--me-pad);
  top: 0;
  z-index: 100;
  transform: translateY(-150%);
  padding: 0.6rem 1rem;
  background: var(--me-ink-strong);
  color: var(--me-paper);
  font: 500 var(--me-step--1)/1 var(--me-font-mono);
  text-decoration: none;
  transition: transform 0.2s var(--me-ease);
}
.marginalia-essay .skip:focus { transform: translateY(0.5rem); }

/* ══════════════════════════════════════════════════════════════
   3 · READING PROGRESS — CSS scroll-driven, JS only as fallback
   ══════════════════════════════════════════════════════════════ */
.marginalia-essay .progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  height: 2px;
  background: color-mix(in oklab, var(--me-rule) 60%, transparent);
}
.marginalia-essay .progress__bar {
  height: 100%;
  background: var(--me-accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
@supports (animation-timeline: scroll()) {
  .marginalia-essay .progress__bar {
    animation: me-fill-progress linear both;
    animation-timeline: scroll(root block);
  }
  @keyframes me-fill-progress { to { transform: scaleX(1); } }
}

/* ══════════════════════════════════════════════════════════════
   4 · THE EDITORIAL GRID
   full → edge to edge · wide → 68rem · pop → 50rem · text → 44rem
   The left gutter is reserved for the contents rail, so the rails
   inside the grid carry sidenotes on the RIGHT.
   ══════════════════════════════════════════════════════════════ */
.essay-prose {
  display: grid;
  counter-reset: sidenote;
  grid-template-columns:
    [full-start] minmax(var(--me-pad), 1fr)
    [wide-start] minmax(0, var(--me-rail-outer))
    [pop-start]  minmax(0, var(--me-rail-inner))
    [text-start] min(100% - var(--me-pad) * 2, var(--me-measure))
    [text-end]   minmax(0, var(--me-rail-inner))
    [pop-end]    minmax(0, var(--me-rail-outer))
    [wide-end]   minmax(var(--me-pad), 1fr)
    [full-end];
}
/* WordPress integration: the site's editorial system registers its own
   flat `.essay-prose` selector, and Oxygen prints its generated CSS
   (post-N-defaults.css, whose `.bde-rich-text` sets a light-scheme grey
   via --bde-body-text-color) AFTER wp_head — load order cannot be won.
   The scope class lifts these to (0,2,0) so they beat every flat
   single-class rule regardless of where Oxygen's sheets land. */
.marginalia-essay .essay-prose {
  max-width: none;
  font-family: var(--me-font-body);
  font-size: var(--me-step-0);
  line-height: var(--me-lh);
  color: var(--me-ink);
}

.essay-prose > *                { grid-column: text; }
.essay-prose > .is-pop          { grid-column: pop; }
.essay-prose > .is-wide         { grid-column: wide; }
.essay-prose > .is-full         { grid-column: full; }
.essay-prose > .is-offset-right { grid-column: text-start / wide-end; }

/* Gutenberg reaches the bands through core controls: the editor's own
   Wide/Full alignments, plus the Wide-band and Bleed-right styles.
   Bleed-right is full width here; it earns its asymmetry only at rail
   widths (see the 76rem block). */
.essay-prose > .alignwide            { grid-column: pop; }
.essay-prose > .alignfull            { grid-column: full; }
.essay-prose > .is-style-wide-band   { grid-column: wide; }
.essay-prose > .is-style-bleed-right { grid-column: full; }

/* Half figures: half the text measure, held to one edge. Blocks are grid
   items here, so the other half is deliberately empty air — prose cannot
   wrap beside a sibling. (The editorial .prose context floats these same
   classes instead; that CSS lives in the Oxygen selectors, not here.)
   Below the one-column breakpoint a half image is too small to read, so
   both collapse to the full measure. */
.essay-prose > .is-style-half-left,
.essay-prose > .is-style-half-right {
  grid-column: text;
  width: calc(50% - 0.75rem);
}
.essay-prose > .is-style-half-left  { justify-self: start; }
.essay-prose > .is-style-half-right { justify-self: end; }
@media (max-width: 46rem) {
  .essay-prose > .is-style-half-left,
  .essay-prose > .is-style-half-right { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════
   5 · ARTICLE HEADER
   ══════════════════════════════════════════════════════════════ */
.entry-header {
  grid-column: wide;
  margin: 0;
  padding-block: clamp(3rem, 9vw, 7rem) var(--me-space-6);
}

.essay-prose .kicker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 var(--me-space-3);
  color: var(--me-accent);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.essay-prose .kicker::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--me-rule), transparent); }
.essay-prose .kicker a { color: inherit; text-decoration: none; background-image: none; }

.essay-prose .entry-title {
  margin: 0 0 var(--me-space-4);
  max-width: 16ch;
  font-family: var(--me-font-display);
  font-size: var(--me-step-4);
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.essay-prose .entry-title em { font-style: italic; color: var(--me-accent); }

.essay-prose .deck {
  max-width: 36rem;
  margin: 0 0 var(--me-space-6);
  font-size: var(--me-step-1);
  font-weight: 300;
  line-height: 1.45;
  color: var(--me-ink-2);
}

.essay-prose .byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--me-space-1) var(--me-space-3);
  margin: 0;
  padding-top: var(--me-space-2);
  border-top: 1px solid var(--me-rule);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  color: var(--me-ink-3);
}
/* The author is the byline's one first-class fact: full ink while the
   date, read time, and separators stay muted. */
.essay-prose .byline > span:first-child { color: var(--me-ink); }
.essay-prose .byline a {
  color: var(--me-ink);
  background-image: none;
  text-decoration: underline;
  text-decoration-color: var(--me-rule);
  text-underline-offset: 3px;
  padding-bottom: 0;
}
.essay-prose .byline a:hover { text-decoration-color: var(--me-accent); }
/* Middot separators: rule-color was tuned for the heavier slash and
   disappears at middot size, so they sit at the small-text floor. */
.essay-prose .byline .sep { color: var(--me-ink-3); }
.essay-prose .byline .tags { margin-inline-start: auto; display: flex; gap: var(--me-space-1); }
.essay-prose .byline .tags a {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--me-rule);
  border-radius: 999px;
  color: var(--me-ink-2);
  text-decoration: none;
  transition: border-color 0.2s var(--me-ease), color 0.2s var(--me-ease);
}
.essay-prose .byline .tags a:hover { border-color: var(--me-accent); color: var(--me-accent); }

/* ── Featured image: same 68rem band as the headline, fixed ratio ── */
.essay-prose .hero { margin: 0 0 var(--me-space-6); }
/* Inner figure exists only to pair the caption (see hero markup); it
   must not pick up the article figure margins. */
.essay-prose .hero__figure { margin: 0; }
.hero__frame {
  aspect-ratio: 2 / 1;
  overflow: hidden;
  background: color-mix(in oklab, var(--me-accent) 8%, var(--me-paper));
  border: 1px solid var(--me-rule);
}
.hero__frame > * { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 46rem) { .hero__frame { aspect-ratio: 3 / 2; } }

/* ══════════════════════════════════════════════════════════════
   6 · PROSE
   ══════════════════════════════════════════════════════════════ */
.essay-prose h2 {
  margin: var(--me-space-8) 0 var(--me-space-3);
  scroll-margin-top: calc(var(--me-masthead-h) + var(--me-toc-h) + var(--me-space-3));
  font-family: var(--me-font-display);
  font-size: var(--me-step-2);
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.essay-prose h2::before {
  content: attr(data-num);
  display: block;
  margin-bottom: var(--me-space-1);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  letter-spacing: 0.2em;
  color: var(--me-accent);
}

.essay-prose h3 {
  margin: var(--me-space-6) 0 var(--me-space-2);
  font-size: var(--me-step-1);
  font-style: italic;
}

.essay-prose p  { margin: 0 0 var(--me-space-4); }
.essay-prose ul,
.essay-prose ol { margin: 0 0 var(--me-space-4); padding-inline-start: 1.4em; }
.essay-prose li { margin-block: var(--me-space-2); padding-inline-start: 0.25em; }
.essay-prose li::marker { color: var(--me-accent); font-size: 0.85em; }
.essay-prose mark { background: var(--me-mark); color: inherit; padding: 0.05em 0.15em; }

.essay-prose :is(p, li) a {
  color: inherit;
  text-decoration: none;
  padding-bottom: 1px;
  background-image: linear-gradient(var(--me-accent), var(--me-accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  transition: background-size 0.3s var(--me-ease), color 0.3s var(--me-ease);
}
.essay-prose :is(p, li) a:hover {
  color: var(--me-accent);
  background-size: 100% 100%;
  background-image: linear-gradient(
    color-mix(in oklab, var(--me-accent) 14%, transparent),
    color-mix(in oklab, var(--me-accent) 14%, transparent));
}

/* Drop cap: core's has-drop-cap control, styled here. */
.essay-prose .has-drop-cap::first-letter {
  float: left;
  margin: 0.05em 0.08em 0 0;
  font-family: var(--me-font-display);
  font-size: 4.1em;
  line-height: 0.78;
  color: var(--me-accent);
}
@supports (initial-letter: 3) or (-webkit-initial-letter: 3) {
  .essay-prose .has-drop-cap::first-letter {
    -webkit-initial-letter: 3;
    initial-letter: 3;
    float: none;
    font-size: inherit;
    margin: 0 0.12em 0 0;
  }
}

/* ── Block quote: a resting point, not a marginal note ─────── */
.essay-prose blockquote {
  margin: var(--me-space-6) 0;
  padding: var(--me-space-4) var(--me-space-4) var(--me-space-4) var(--me-space-5);
  border-inline-start: 4px solid var(--me-accent);
  background: color-mix(in oklab, var(--me-accent) 4%, transparent);
  font-size: 1.15em;
  font-style: italic;
  line-height: 1.5;
  color: var(--me-ink-strong);
}
.essay-prose blockquote p { margin: 0; }
.essay-prose blockquote cite {
  display: block;
  margin-top: var(--me-space-3);
  text-align: right;
  font: 400 var(--me-step--1)/1.5 var(--me-font-mono);
  color: var(--me-ink-3);
  border-bottom: 1px solid transparent;
  transition: color 0.25s var(--me-ease), border-color 0.25s var(--me-ease);
}
.essay-prose blockquote cite::before { content: "— "; }
.essay-prose blockquote:hover cite { color: var(--me-ink-2); border-bottom-color: var(--me-rule); }

/* ── Pull quote: a chapter break. Centred in `pop` so it clears
      the contents rail on the left. core/pullquote maps here. ── */
.essay-prose .pullquote,
.essay-prose .wp-block-pullquote {
  grid-column: pop;
  margin: var(--me-space-10) 0;
  padding-block: var(--me-space-6);
  border-block: 1px solid var(--me-rule);
  text-align: center;
  font-family: var(--me-font-display);
  font-size: var(--me-step-3);
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--me-ink-strong);
}
.essay-prose :is(.pullquote, .wp-block-pullquote) em { font-style: italic; color: var(--me-accent); }
.essay-prose .wp-block-pullquote blockquote {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  font-style: normal;
  line-height: inherit;
  color: inherit;
}
.essay-prose .wp-block-pullquote p { margin: 0; font-size: inherit; }
.essay-prose .wp-block-pullquote cite {
  display: block;
  margin-top: var(--me-space-3);
  text-align: center;
  font: 400 var(--me-step--1)/1.5 var(--me-font-mono);
  color: var(--me-ink-3);
}

/* ── Callout: a third texture, for the scroll rhythm ────────── */
.essay-prose .callout {
  margin: var(--me-space-6) 0;
  padding: var(--me-space-4);
  border: 1px solid var(--me-rule);
  background: var(--me-paper-2);
  box-shadow: var(--me-shadow);
}
.essay-prose .callout__label {
  margin: 0 0 var(--me-space-1);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--me-accent);
}
.essay-prose .callout p:last-child { margin-bottom: 0; }

/* ── Set-piece patterns: banner, CTA buttons, reading list ──── */
/* Banner: the pullquote's frame at whisper volume — one mono line
   between rules for disclosures, corrections, context. */
.essay-prose .banner {
  margin: var(--me-space-6) 0;
  padding: var(--me-space-2) 0;
  border-block: 1px solid var(--me-rule);
}
.essay-prose .banner p {
  margin: 0;
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  line-height: 1.6;
  color: var(--me-ink-2);
}
.essay-prose .banner__label {
  margin-right: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--me-accent);
}

/* Buttons exist in prose only inside CTA panels: mono, bordered, no
   fill — the accent arrives on hover, never as a pill. Specificity
   (0,2,0) beats core's .wp-element-button defaults. */
.essay-prose .wp-block-button__link {
  display: inline-block;
  padding: 0.65rem 1.4rem;
  border: 1px solid var(--me-ink);
  border-radius: 0;
  background: none;
  color: var(--me-ink);
  font: 500 var(--me-step--1)/1 var(--me-font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  transition: border-color 0.2s var(--me-ease), color 0.2s var(--me-ease);
}
.essay-prose .wp-block-button__link:hover {
  border-color: var(--me-accent);
  color: var(--me-accent);
}

/* Reading list inside a callout: links carry the ink, markers muted. */
.essay-prose .callout ul { margin: 0; padding-left: 1.1em; }
.essay-prose .callout li { margin: 0 0 var(--me-space-1); }
.essay-prose .callout li::marker { color: var(--me-ink-3); }

/* Native gallery: core's flex layout does the work; the article
   figure margin must not leak onto the nested figures. */
.essay-prose .wp-block-gallery figure { margin: 0; }

/* ── Sidenotes: lettered, floating into the RIGHT rails ────── */
.sn-ref {
  counter-increment: sidenote;
  display: inline-block;
  font-family: var(--me-font-mono);
  font-size: 0.6em;
  font-weight: 500;
  vertical-align: super;
  line-height: 0;
  letter-spacing: 0.05em;
  color: var(--me-accent);
  padding-inline: 0.15em 0.05em;
  transition: transform 0.2s var(--me-ease);
}
.sn-ref::after { content: counter(sidenote, upper-alpha); }
.sn-ref:hover { transform: translateY(-2px) scale(1.2); }

.marginnote {
  display: block;
  font-size: 0.82em;
  line-height: 1.5;
  color: var(--me-ink-2);
  text-wrap: pretty;
}
.marginnote::before {
  content: counter(sidenote, upper-alpha);
  display: block;
  font-family: var(--me-font-display);
  font-size: 1.45rem;
  line-height: 1;
  color: var(--me-accent);
}
.marginnote em { font-style: italic; }

/* ── Figures ───────────────────────────────────────────────── */
.essay-prose figure { margin: var(--me-space-6) 0; }
.essay-prose figure svg { width: 100%; }
.essay-prose figure img { width: 100%; height: auto; background: var(--me-paper-2); }
.essay-prose figure .frame {
  padding: var(--me-space-3);
  background: var(--me-paper-2);
  border: 1px solid var(--me-rule);
}
.essay-prose figcaption {
  max-width: 34rem;
  margin-top: var(--me-space-2);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  line-height: 1.55;
  color: var(--me-ink-3);
}
.essay-prose figcaption b { color: var(--me-accent); font-weight: 500; }

.essay-prose pre,
.essay-prose .wp-block-code {
  margin: var(--me-space-6) 0;
  padding: var(--me-space-3);
  overflow-x: auto;
  background: var(--me-paper-2);
  border: 1px solid var(--me-rule);
  border-inline-start: 4px solid var(--me-accent);
  font-family: var(--me-font-mono);
  font-size: 0.8em;
  line-height: 1.7;
  tab-size: 2;
}
.essay-prose code { font-family: var(--me-font-mono); font-size: 0.86em; }
.essay-prose :not(pre) > code { padding: 0.1em 0.35em; background: var(--me-mark); border-radius: 3px; }

.essay-prose hr { margin: var(--me-space-10) 0; border: 0; text-align: center; background: none; }
.essay-prose hr::before { content: "❦"; color: var(--me-ink-3); font-size: 1.1rem; }

/* ── Footnotes: core/footnotes, styled — no parallel system ── */
.essay-prose .footnotes,
.essay-prose .wp-block-footnotes {
  margin: var(--me-space-10) 0 0;
  padding-top: var(--me-space-3);
  border-top: 1px solid var(--me-rule);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  line-height: 1.65;
  color: var(--me-ink-2);
}
.essay-prose .wp-block-footnotes { padding-inline-start: 1.3rem; }
.essay-prose .wp-block-footnotes li { margin-block: var(--me-space-1); }
.essay-prose .footnotes h2 {
  margin: 0 0 var(--me-space-2);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--me-ink-3);
}
.essay-prose .footnotes h2::before { content: none; }
.essay-prose .footnotes ol { padding-inline-start: 1.3rem; }
.essay-prose sup.fn a {
  display: inline-block;
  font-size: 0.68em;
  vertical-align: super;
  line-height: 0;
  padding: 0 0.15em;
  color: var(--me-accent);
  background-image: none;
  transition: transform 0.2s var(--me-ease);
}
.essay-prose sup.fn { line-height: 0; }
.essay-prose sup.fn a:hover { transform: translateY(-2px) scale(1.2); }

/* ══════════════════════════════════════════════════════════════
   7 · CONTENTS — top strip by default, left rail when there is room
   The slot always reserves --me-toc-h, so pinning never shifts layout.

   NOTE ON SPECIFICITY — the contents markup sits inside .essay-prose, so the
   article's own element rules (.essay-prose p, .essay-prose ol, .essay-prose :is(p,li) a)
   would otherwise reach it and hand every entry a body-link underline
   and a list indent. Every selector below is prefixed with .essay-prose so it
   outranks them. Same for the rail block further down.
   ══════════════════════════════════════════════════════════════ */
.essay-prose .toc-slot {
  position: relative;
  height: var(--me-toc-h);
  margin-bottom: var(--me-space-6);
}
.toc-rail {
  position: absolute;
  inset: 0;
  border-block: 1px solid var(--me-rule);
  transition: background-color 0.25s var(--me-ease), box-shadow 0.25s var(--me-ease);
}
.toc-rail[data-pinned="true"] {
  position: fixed;
  top: var(--me-masthead-h);
  left: 0;
  right: 0;
  height: var(--me-toc-h);
  z-index: 30;
  border-top-color: transparent;
  background: color-mix(in oklab, var(--me-paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  box-shadow: 0 10px 20px -18px rgb(0 0 0 / 0.5);
}

.toc-rail__inner {
  display: flex;
  align-items: center;
  height: 100%;
  max-width: 68rem;
  margin-inline: auto;
  padding-inline: var(--me-pad);
}
.essay-prose .toc { display: flex; align-items: center; gap: var(--me-space-3); height: 100%; min-width: 0; }
.essay-prose .toc__label {
  flex: none;
  margin: 0;
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--me-ink-3);
}
.essay-prose .toc__list {
  display: flex;
  align-items: stretch;
  gap: clamp(1rem, 2.5vw, 2rem);
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  /* End padding: the last item stops short of whatever sits after the
     list (the back-to-top divider) instead of running into it. */
  padding-inline-end: var(--me-space-2);
}
.essay-prose .toc__list::-webkit-scrollbar { display: none; }

/* Edge fades are a scroll affordance, so they only appear on the side
   that actually hides more content — a static fade would keep the last
   item unreadable at the end of the strip. data-fade is set by
   essay.js from the strip's scroll position. */
.essay-prose .toc__list[data-fade="right"] {
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1.5rem), transparent 100%);
          mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 1.5rem), transparent 100%);
}
.essay-prose .toc__list[data-fade="left"] {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 1.5rem, #000 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 1.5rem, #000 100%);
}
.essay-prose .toc__list[data-fade="both"] {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 1.5rem, #000 calc(100% - 1.5rem), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 1.5rem, #000 calc(100% - 1.5rem), transparent 100%);
}

.essay-prose .toc__list li { position: relative; display: flex; margin: 0; padding: 0; counter-increment: toc; }
/* Section completion: one element, two colours, driven by --me-p.
   Strip layout only — removed in the rail (see the media query). */
.essay-prose .toc__list li::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(
    to right,
    var(--me-accent) 0 calc(var(--me-p, 0) * 100%),
    color-mix(in oklab, var(--me-rule) 70%, transparent) 0);
  transition: background 0.15s linear;
}
.essay-prose .toc__list a,
.essay-prose .toc__list a:hover {
  background-image: none;      /* opt out of the body-link hairline */
  padding-bottom: 0;
}
.essay-prose .toc__list a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5ch;
  white-space: nowrap;
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  color: var(--me-ink-2);
  text-decoration: none;
  transition: color 0.2s var(--me-ease);
}
.essay-prose .toc__list a::before { content: counter(toc, decimal-leading-zero); color: var(--me-ink-3); opacity: 0.55; }
.essay-prose .toc__list a:hover { color: var(--me-ink-strong); }
.essay-prose .toc__list a[aria-current="location"],
.essay-prose .toc__list a[aria-current="location"]:hover { color: var(--me-accent); }
.essay-prose .toc__list a[aria-current="location"]::before { color: var(--me-accent); opacity: 1; }

.essay-prose .rail-meta { display: none; }

/* Back to top: affixed at the strip's right edge, outside the scrolling
   list, so it stays reachable regardless of list scroll. Only shown
   once the strip is pinned — at the top of the page it has nowhere
   to go. In rail mode the rail-meta button takes over (see 76rem). */
.essay-prose .toc-top {
  display: none;
  flex: none;
  align-items: center;
  /* The arrow gravitates to the screen edge it acts on; the divider
     keeps its distance on the left. */
  justify-content: flex-end;
  width: 3rem;
  height: 100%;
  margin-inline-start: auto;
  padding: 0;
  border: 0;
  border-inline-start: 1px solid var(--me-rule);
  background: none;
  color: var(--me-ink-2);
  cursor: pointer;
  transition: color 0.2s var(--me-ease);
}
.toc-rail[data-pinned="true"] .toc-top { display: flex; }
.essay-prose .toc-top:hover { color: var(--me-accent); }
.essay-prose .toc-top svg { display: block; }

@media (max-width: 34rem) { .essay-prose .toc__label { display: none; } }

/* ── ≥76rem: the left gutter can hold the rail.
   Right edge of the rail sits --me-toc-gap (72px) from the text column
   and 24px clear of `pop`, so figures and the pull quote never
   collide with it. Same nav element, same scrollspy. ── */
@media (min-width: 76rem) {
  :root { --me-toc-h: 0px; }

  .essay-prose .toc-slot { margin-bottom: var(--me-space-6); }

  .toc-rail,
  .toc-rail[data-pinned="true"] {
    position: fixed;
    top: 50%;
    left: max(1.25rem, calc((100vw - 68rem) / 2 - 2.5rem));
    right: auto;
    width: var(--me-toc-w);
    height: auto;
    transform: translateY(-50%);
    border: 0;
    background: none;
    backdrop-filter: none;
    box-shadow: none;
  }
  .toc-rail {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s var(--me-ease), visibility 0.35s;
  }
  .toc-rail[data-pinned="true"] { opacity: 1; visibility: visible; }

  .toc-rail__inner {
    display: block;
    height: auto;
    max-width: none;
    margin: 0;
    padding: 0 0 0 var(--me-space-2);
    border-inline-start: 1px solid var(--me-rule);
  }

  /* The rail owns the left gutter, and it reaches 7.5rem into the wide
     band — so while it can be on screen, bands wider than pop cap at
     pop (24px clear of the rail by construction). Two exemptions: the
     hero (the rail is never pinned that early), and the rich-text
     wrapper — a transparent grid container that must keep spanning the
     viewport so its children's bands (including bleed-right's full-end)
     resolve against the real page edge; those children cap themselves. */
  .essay-prose > :is(.is-full, .alignfull, .is-style-wide-band, .is-wide:not(.hero)):not(.is-style-bleed-right):not(.bde-rich-text) {
    grid-column: pop;
  }

  /* "Bleed right": flush with the prose on the left — well clear of the
     rail — and off the page on the right. The author's opt-in for the
     drama the symmetric cap removes; keep it away from paragraphs
     carrying sidenotes (the right rails are the sidenote channel). */
  .essay-prose > .is-style-bleed-right {
    grid-column: text-start / full-end;
  }
  .essay-prose .toc { display: block; height: auto; }
  .essay-prose .toc__label { display: block; margin-bottom: var(--me-space-2); }

  .essay-prose .toc__list,
  .essay-prose .toc__list[data-fade] {
    display: block;
    height: auto;
    overflow: visible;
    -webkit-mask-image: none;
            mask-image: none;
  }
  .essay-prose .toc__list li { display: block; margin-bottom: var(--me-space-2); }
  /* No completion bars in the rail — stacked underlines fight the type.
     The vertical marker alone carries the current section. */
  .essay-prose .toc__list li::after { content: none; }
  .essay-prose .toc__list a {
    display: block;
    white-space: normal;
    font-size: 0.78rem;
    line-height: 1.35;
  }
  .essay-prose .toc__list a::before { margin-inline-end: 0.5ch; }
  .essay-prose .toc__list a[aria-current="location"]::after {
    content: "";
    position: absolute;
    left: calc(-1 * var(--me-space-2) - 1px);
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--me-accent);
  }

  /* The rail earns its space: navigation on top, reading data below */
  .essay-prose .rail-meta {
    display: block;
    margin-top: var(--me-space-4);
    padding-top: var(--me-space-2);
    border-top: 1px solid var(--me-rule);
    font-family: var(--me-font-mono);
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--me-ink-3);
  }
  .essay-prose .rail-meta dl { margin: 0; }
  .essay-prose .rail-meta dt {
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.66rem;
    opacity: 0.75;
  }
  .essay-prose .rail-meta dd { margin: 0 0 var(--me-space-2); color: var(--me-ink-2); }
  .essay-prose .rail-meta button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--me-ink-3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.2s var(--me-ease);
  }
  .essay-prose .rail-meta button:hover { color: var(--me-accent); }
  .essay-prose .rail-meta .js-back-to-top {
    display: block;
    margin-top: var(--me-space-1);
  }

  /* The rail's meta block carries Back to top here; the strip affix
     retires with the strip. */
  .essay-prose .toc-top,
  .toc-rail[data-pinned="true"] .toc-top { display: none; }

  /* Sidenotes float into the right rails */
  .marginnote {
    float: right;
    clear: right;
    width: var(--me-note-w);
    margin: 0.5rem calc(-1 * (var(--me-note-w) + var(--me-space-4))) var(--me-space-3) 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--me-rule);
    transition: color 0.25s var(--me-ease), border-color 0.25s var(--me-ease);
  }
  .marginnote::before { margin-bottom: 0.3rem; }
  .sn-ref:hover + .marginnote { color: var(--me-ink-strong); border-top-color: var(--me-accent); }
}

@media (max-width: 75.999rem) {
  .marginnote {
    margin: var(--me-space-4) 0;
    padding: 0.1rem 0 0.1rem var(--me-space-2);
    border-inline-start: 2px solid var(--me-accent);
  }
  .marginnote::before { font-size: 1.15rem; margin-bottom: 0.1rem; }
}

/* ══════════════════════════════════════════════════════════════
   8 · AFTER THE ARTICLE
   ══════════════════════════════════════════════════════════════ */
.essay-prose .author {
  grid-column: wide;
  display: flex;
  gap: var(--me-space-3);
  align-items: flex-start;
  margin: var(--me-space-10) 0 0;
  padding: var(--me-space-4);
  background: var(--me-paper-2);
  border: 1px solid var(--me-rule);
  box-shadow: var(--me-shadow);
}
.essay-prose .author__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.75rem;
  height: 3.75rem;
  border-radius: 50%;
  background: color-mix(in oklab, var(--me-accent) 16%, var(--me-paper));
  color: var(--me-accent);
  font-family: var(--me-font-display);
  font-size: 1.6rem;
  line-height: 1;
}
/* Display serif at its full size; essay.js shrinks it just enough to
   hold one line when the credentialed name would wrap (no-JS falls
   back to normal wrapping). */
.essay-prose .author__name {
  margin: 0 0 var(--me-space-1);
  font-family: var(--me-font-display);
  font-size: var(--me-step-1);
  line-height: 1.2;
}
.essay-prose .author__name::before { content: none; }
/* Photo variant: the disc becomes a frame; the initials styling on the
   base class stays as the no-photo fallback. */
.essay-prose .author__avatar--photo {
  padding: 0;
  overflow: hidden;
  background: none;
}
.essay-prose .author__avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}
.essay-prose .author p {
  margin: 0 0 var(--me-space-2);
  font-family: var(--me-font-mono);
  font-size: var(--me-step--1);
  line-height: 1.6;
  color: var(--me-ink-2);
}
.essay-prose .author p:last-child { margin-bottom: 0; }
.essay-prose .author p a {
  color: var(--me-accent);
  background-image: none;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--me-accent) 40%, transparent);
  text-underline-offset: 3px;
  padding-bottom: 0;
}
.essay-prose .author p a:hover { text-decoration-color: currentColor; }

/* ══════════════════════════════════════════════════════════════
   9 · MOTION — one orchestrated load, then quiet
   ══════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: no-preference) {
  .marginalia-essay .reveal > * { animation: me-rise 0.85s var(--me-ease) backwards; }
  .marginalia-essay .reveal > :nth-child(1) { animation-delay: 0.05s; }
  .marginalia-essay .reveal > :nth-child(2) { animation-delay: 0.15s; }
  .marginalia-essay .reveal > :nth-child(3) { animation-delay: 0.25s; }
  .marginalia-essay .reveal > :nth-child(4) { animation-delay: 0.35s; }
  @keyframes me-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
  }

  /* Section numbers arrive with their heading — no JS, no observer */
  @supports (animation-timeline: view()) {
    .essay-prose h2::before {
      animation: me-num-in linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
    @keyframes me-num-in {
      from { opacity: 0; transform: translateY(8px); }
      to   { opacity: 1; transform: none; }
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  html:has(body.marginalia-essay) { scroll-behavior: auto; }
  .marginalia-essay *, .marginalia-essay *::before, .marginalia-essay *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════
   10 · PRINT
   ══════════════════════════════════════════════════════════════ */
@media print {
  .marginalia-essay :is(.site-header, .site-footer, .progress, .toc-slot, .hero, .skip) { display: none !important; }
  body.marginalia-essay { background: #fff; color: #000; font-size: 11pt; }
  body.marginalia-essay::before { display: none; }
  .essay-prose { display: block; max-width: 40em; }
  .marginnote { float: none; width: auto; margin: 1em 0; border-top: 0; border-left: 1pt solid #999; padding-left: 1em; }
  .essay-prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; word-break: break-all; }
  .essay-prose :is(h2, h3) { break-after: avoid; }
  .essay-prose :is(figure, pre, blockquote, .callout, .author) { break-inside: avoid; }
}
