/* ═════════════════════════════════════════════════════════════════════
   Passions Play — Vellum theme · style.css
   ─────────────────────────────────────────────────────────────────────
   Sections:
     0. Design tokens (merged from tokens.css)
     1. Minimal reset
     2. Document defaults
     3. Layout primitives
     4. Site chrome — header / nav / footer
     5. Page headers
     6. Long-form prose (.prose)         ← the main event
     7. Code blocks & Prism theme
     8. Components — post card, kbd, tag list
     9. Marginalia patterns
    10. Print
    11. Accessibility helpers
   ═════════════════════════════════════════════════════════════════════ */


/* ── 0. Design tokens ─────────────────────────────────────────────── */

:root {
  /* ─── Color · light mode (canonical) ──────────────────────────────── */
  --bg:         #f1ece0;   /* cream paper */
  --bg-elev:    #e6dfce;   /* slightly darker — cards, footers, callouts */
  --bg-code:    #26221b;   /* dark inkwell — code blocks in both modes */
  --text:       #2a2418;   /* warm ink */
  --muted:      #6b6253;   /* body de-emphasis, captions */
  --dim:        #9a9180;   /* metadata, secondary lines */
  --rule:       #d3cab5;   /* hairline separators */

  /* Amber — the line of attention. Links, current nav, drop caps, "read on". */
  --amber:      #b8741a;
  --amber-soft: #ebd9b5;   /* link underlines, inline code background */

  /* Moss — the supporting cast. Tags, captions, ✓ states, marginalia. */
  --moss:       #4a6b3a;
  --moss-soft:  #d8dec8;   /* aside backgrounds */

  /* Code (Prism token colors — see prism-theme block in style.css) */
  --code-fg:    #ece6d4;
  --code-bg:    var(--bg-code);
  --code-rule:  rgba(255,255,255,0.06);

  /* ─── Typography ──────────────────────────────────────────────────── */
  --font-serif: "Newsreader", "Iowan Old Style", "Charter", Georgia, serif;
  --font-sans:  "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono:  "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Modular scale · ratio 1.333 (perfect fourth) · base 17px */
  --fs-xs:    0.75rem;
  --fs-sm:    0.875rem;
  --fs-base:  1rem;
  --fs-lg:    1.125rem;
  --fs-xl:    1.333rem;
  --fs-2xl:   1.777rem;
  --fs-3xl:   2.369rem;
  --fs-4xl:   3.157rem;
  --fs-5xl:   4.209rem;

  /* Line heights */
  --lh-tight: 1.1;
  --lh-snug:  1.2;
  --lh-body:  1.7;
  --lh-code:  1.65;

  /* ─── Spacing (vertical rhythm) ───────────────────────────────────── */
  --space-1:    0.25rem;
  --space-2:    0.5rem;
  --space-3:    0.75rem;
  --space-4:    1rem;
  --space-5:    1.5rem;
  --space-6:    1.75rem;
  --space-7:    2rem;
  --space-8:    3rem;
  --space-9:    4rem;
  --space-10:   6rem;

  /* ─── Measure (reading width) ─────────────────────────────────────── */
  --measure:        72ch;
  --measure-tight:  60ch;
  --measure-wide:   90ch;

  /* Page gutter — fluid */
  --gutter: clamp(1rem, 5vw, 3.5rem);

  /* ─── Misc ────────────────────────────────────────────────────────── */
  --radius-sm:  2px;
  --radius-md:  3px;
  --kbd-shadow: 0 1px 0 var(--rule);

  /* Z-layers */
  --z-popover:  10;
  --z-nav:      20;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #1a1814;
    --bg-elev:    #221f1a;
    --text:       #ece6d4;
    --muted:      #9a9282;
    --dim:        #6a6354;
    --rule:       #2f2c25;
    --amber:      #d99a3e;
    --amber-soft: #2f2820;
    --moss:       #88a86b;
    --moss-soft:  #232820;
  }
}

[data-theme="dark"] {
  --bg:         #1a1814;
  --bg-elev:    #221f1a;
  --text:       #ece6d4;
  --muted:      #9a9282;
  --dim:        #6a6354;
  --rule:       #2f2c25;
  --amber:      #d99a3e;
  --amber-soft: #2f2820;
  --moss:       #88a86b;
  --moss-soft:  #232820;
}


/* ── 1. Minimal reset ─────────────────────────────────────────────── */

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

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

body { margin: 0; }

h1, h2, h3, h4, h5, h6, p, figure, blockquote, pre, dl, dd { margin: 0; }

ul, ol { margin: 0; padding: 0; list-style: none; }

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

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--amber); color: var(--bg); }


/* ── 2. Document defaults ─────────────────────────────────────────── */

html {
  font-size: 17px;             /* base — change here to scale the whole site */
  font-family: var(--font-serif);
  font-feature-settings: "kern", "liga", "calt", "onum";
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-optical-sizing: auto;   /* Newsreader & DM Sans both honor this */
}

@media (min-width: 1280px) {
  html { font-size: 18px; }    /* nudge up on big screens */
}

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


/* ── 3. Layout primitives ─────────────────────────────────────────── */

/* .container — centers content, applies the measure */
.container {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

/* .post-frame — the canonical post + index wrapper.
   Sits at --measure-wide (matching the site header's inner width) so its
   left edge aligns with the "Passions Play" wordmark. The prose column
   inside is capped to --measure (72ch) but flush-left within the frame —
   not centered — so reading width stays comfortable while the left rail
   stays vertically aligned across header, post-header, prose, and footer. */
.post-frame {
  width: 100%;
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.post-frame > .page-header,
.post-frame > .prose,
.post-frame > .post-footer {
  max-width: var(--measure);
  margin-inline: 0;
  padding-inline: 0;
}

/* The wide-marginalia variant (.prose--with-margin) gets the full frame
   width so the right rail has room to materialize at ≥1024px. */
.post-frame > .prose--with-margin {
  max-width: none;
}

/* .stack — vertical rhythm utility. Children get `--stack` gap above. */
.stack > * + * { margin-top: var(--stack, var(--space-4)); }

.stack-2 > * + * { margin-top: var(--space-2); }
.stack-4 > * + * { margin-top: var(--space-4); }
.stack-5 > * + * { margin-top: var(--space-5); }
.stack-7 > * + * { margin-top: var(--space-7); }

/* .cluster — horizontal flow, wraps */
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: baseline;
}


/* ── 4. Site chrome — header / nav / footer ───────────────────────── */

.site-header {
  border-bottom: 1px solid var(--rule);
  padding: var(--space-5) 0 var(--space-4);
}

.site-header__inner {
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-5);
}

.brand {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand em {
  color: var(--amber);
  font-style: italic;
}
.brand__volume {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-left: 0.5em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  gap: var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}

.site-nav a {
  color: var(--muted);
  font-weight: 500;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  transition: color 120ms ease, border-color 120ms ease;
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] {
  color: var(--amber);
  font-weight: 600;
  border-color: var(--amber);
}

.site-footer {
  margin-top: var(--space-10);
  border-top: 1px solid var(--rule);
  padding: var(--space-5) 0;
  background: var(--bg-elev);
}
.site-footer__inner {
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--dim);
  letter-spacing: 0.04em;
}
.site-footer em {
  color: var(--amber);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
}


/* ── 5. Page headers ──────────────────────────────────────────────── */

.page-header {
  padding-block: var(--space-8) var(--space-5);
}

.page-header__eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--moss);
  margin-bottom: var(--space-2);
}
.page-header__eyebrow .accent { color: var(--amber); }

.page-header__title {
  font-family: var(--font-serif);
  font-size: clamp(var(--fs-3xl), 6vw, var(--fs-5xl));
  font-weight: 400;
  line-height: var(--lh-tight);
  letter-spacing: -0.022em;
  color: var(--text);
  text-wrap: balance;
}
.page-header__title em {
  font-style: italic;
  color: var(--amber);
}

.page-header__lede {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--muted);
  max-width: var(--measure-tight);
  margin-top: var(--space-4);
  text-wrap: pretty;
}


/* ── 6. Long-form prose ────────────────────────────────────────────
   Everything under `.prose` follows the Vellum reading rules. Most of
   your post content will live inside this class. */

.prose {
  font-family: var(--font-serif);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--text);
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
  hyphens: auto;
}

/* Headings — modular scale + Vellum rhythm */
.prose h1 {
  font-size: clamp(var(--fs-3xl), 5vw, var(--fs-4xl));
  font-weight: 400;
  line-height: var(--lh-tight);
  letter-spacing: -0.022em;
  margin-top: var(--space-9);
  margin-bottom: var(--space-4);
  text-wrap: balance;
}
.prose h2 {
  font-size: var(--fs-2xl);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: -0.015em;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  text-wrap: balance;
}
.prose h3 {
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: -0.012em;
  margin-top: var(--space-7);
  margin-bottom: var(--space-2);
  text-wrap: balance;
}
.prose h4 {
  font-size: var(--fs-lg);
  font-weight: 600;
  font-style: italic;
  line-height: var(--lh-snug);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

/* The first heading after the post header shouldn't push extra space */
.prose > h1:first-child,
.prose > h2:first-child,
.prose > h3:first-child { margin-top: 0; }

/* Paragraph rhythm */
.prose p {
  margin-top: var(--space-4);
  text-wrap: pretty;
}
.prose p:first-child { margin-top: 0; }

/* Lede paragraph — opt-in via .lede on first paragraph (or .prose__lede) */
.prose .lede,
.prose > p:first-of-type.lede {
  font-size: var(--fs-lg);
  font-style: italic;
  line-height: 1.6;
  color: var(--text);
  margin-top: var(--space-7);
}

/* Drop cap — opt-in: <p class="dropcap">…</p> on a lede paragraph.
   Use once per essay, never twice. */
.prose .dropcap::first-letter {
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 500;
  font-size: 4.5em;
  line-height: 0.85;
  color: var(--amber);
  float: left;
  margin: 0.05em 0.08em -0.05em 0;
  letter-spacing: -0.04em;
}

/* Emphasis */
.prose em { font-style: italic; }
.prose strong { font-weight: 600; font-style: normal; }

/* Links — amber, with a soft underline that thickens on hover */
.prose a,
a.link {
  color: var(--amber);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--amber-soft);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  transition: text-decoration-color 120ms ease;
}
.prose a:hover,
a.link:hover { text-decoration-color: var(--amber); }
.prose a:focus-visible,
a.link:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Lists */
.prose ul,
.prose ol {
  margin-top: var(--space-4);
  padding-left: 1.5em;
}
.prose ul { list-style: none; }
.prose ul > li {
  position: relative;
  padding-left: 0.2em;
  margin-top: var(--space-2);
}
.prose ul > li::before {
  content: "·";
  color: var(--amber);
  font-weight: 700;
  position: absolute;
  left: -0.9em;
  font-size: 1.5em;
  line-height: 1;
  top: 0.05em;
}
.prose ol {
  list-style: none;
  counter-reset: ol;
}
.prose ol > li {
  counter-increment: ol;
  position: relative;
  padding-left: 0.2em;
  margin-top: var(--space-2);
}
.prose ol > li::before {
  content: counter(ol) ".";
  position: absolute;
  left: -1.6em;
  color: var(--moss);
  font-family: var(--font-mono);
  font-size: 0.86em;
  font-weight: 500;
  top: 0.18em;
}

/* Blockquote — pulled */
.prose blockquote {
  margin: var(--space-7) 0;
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--amber);
  font-style: italic;
  color: var(--text);
  font-size: var(--fs-lg);
  line-height: 1.5;
}
.prose blockquote p { margin-top: var(--space-3); }
.prose blockquote p:first-child { margin-top: 0; }
.prose blockquote cite {
  display: block;
  margin-top: var(--space-3);
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-sm);
  color: var(--moss);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.prose blockquote cite::before { content: "— "; }

/* Horizontal rule — asterism instead of a line */
.prose hr {
  border: none;
  text-align: center;
  margin: var(--space-8) 0;
  height: 1em;
  position: relative;
}
.prose hr::before {
  content: "* * *";
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  color: var(--dim);
  letter-spacing: 1em;
  /* The letter-spacing pushes everything right; balance with a left margin */
  margin-left: 1em;
}

/* Figures + captions */
.prose figure {
  margin: var(--space-7) 0;
}
.prose figure img { border-radius: var(--radius-md); }
.prose figcaption {
  margin-top: var(--space-3);
  padding-left: var(--space-3);
  border-left: 2px solid var(--moss);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.5;
}
.prose figcaption::before {
  content: "fig. ";
  color: var(--moss);
  font-weight: 600;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  margin-right: 0.3em;
  text-transform: uppercase;
}

/* Tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-6) 0;
  font-size: var(--fs-sm);
  font-family: var(--font-sans);
}
.prose th,
.prose td {
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  text-align: left;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
.prose th {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moss);
  border-bottom-color: var(--moss);
}


/* ── 7. Code blocks & Prism theme ─────────────────────────────────── */

/* Inline code — amber on amber-soft */
.prose code:not(pre code),
code.inline {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--amber);
  background: var(--amber-soft);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  font-weight: 400;
}

[data-theme="dark"] .prose code:not(pre code),
[data-theme="dark"] code.inline {
  background: var(--amber-soft);
  /* In dark mode amber-soft is already a deep brown — keep amber readable on it */
}

/* Block-level code — dark inkwell in both modes */
.prose pre,
pre.code-block {
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 0.875rem;       /* slightly smaller than body */
  line-height: var(--lh-code);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-6) 0;
  border-radius: var(--radius-md);
  overflow-x: auto;
  /* Break the measure — code blocks can be wider than prose */
  max-width: none;
}

.prose pre code {
  font: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

/* Optional file-path header — wrap your <pre> in a .code-figure with a label */
.code-figure {
  margin: var(--space-6) 0;
}
.code-figure__label {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--moss);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.code-figure__label .file {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.code-figure pre { margin-top: 0; }
.code-figure figcaption {
  margin-top: var(--space-2);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--muted);
  padding-left: 0;
  border: none;
}
.code-figure figcaption::before { content: none; }

/* Prism token theme — matches Vellum's syntax palette.
   These selectors target the standard prism class names. */

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata { color: #7a7160; font-style: italic; }

.token.punctuation { color: #c5beb0; }

.token.namespace { opacity: 0.7; }

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol { color: #d4a3c8; }     /* pink */

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted { color: #a4b87a; }   /* moss-green */

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string { color: #c5beb0; }

.token.atrule,
.token.attr-value,
.token.keyword { color: #d99a3e; }    /* amber */

.token.function,
.token.class-name { color: #94c3c0; } /* teal */

.token.regex,
.token.important,
.token.variable { color: #cba85a; }   /* golden */

.token.important,
.token.bold { font-weight: 700; }
.token.italic { font-style: italic; }

.token.entity { cursor: help; }

.token.deleted { color: #d97757; }


/* ── 8. Components ────────────────────────────────────────────────── */

/* Post metadata bar — for the top of a post */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: baseline;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
  margin-top: var(--space-4);
}
.post-meta__sep {
  color: var(--dim);
}
.post-meta__tags {
  display: inline-flex;
  gap: var(--space-3);
}
.post-meta__tag {
  color: var(--moss);
  font-weight: 600;
}
.post-meta__tag::before { content: "#"; }

/* Eyebrow above a post title */
.post-eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--moss);
  font-weight: 700;
}
.post-eyebrow .accent { color: var(--amber); }

/* Tags pill list (used in post index) */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.tag-list__item {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--moss);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tag-list__item::before { content: "#"; }

/* Keyboard glyph */
kbd, .kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.05em 0.4em;
  box-shadow: var(--kbd-shadow);
}

/* Post card — used on the index */
.post-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: var(--space-5);
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.post-card__number {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--amber);
  font-weight: 500;
  letter-spacing: 0.04em;
}
.post-card__date {
  display: block;
  margin-top: var(--space-2);
  color: var(--muted);
  font-family: var(--font-sans);
  font-weight: 400;
  letter-spacing: 0.02em;
}
.post-card__title {
  font-family: var(--font-serif);
  font-size: var(--fs-xl);
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: -0.015em;
  color: var(--text);
  text-wrap: balance;
}
.post-card a:hover .post-card__title { color: var(--amber); }
.post-card__summary {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-sm);
  color: var(--muted);
  margin-top: var(--space-2);
  line-height: 1.55;
  max-width: 60ch;
}

/* "Continue reading" affordance */
.read-on {
  display: inline-block;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--amber);
  font-size: var(--fs-base);
  font-weight: 500;
  margin-top: var(--space-5);
}
.read-on::after {
  content: "  →";
  font-style: normal;
  transition: margin-left 120ms ease;
}
.read-on:hover::after { margin-left: 0.2em; }


/* ── 9. Marginalia patterns ───────────────────────────────────────────
   Three are CSS-only. The popover variant needs ~30 lines of JS in
   your layout; this file styles it but doesn't wire it. */

/* (a) Inline boxed asides — <aside class="aside aside--note"> */
.prose .aside {
  margin: var(--space-5) 0;
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--moss);
  background: var(--moss-soft);
  font-family: var(--font-serif);
  font-style: italic;
}
.prose .aside p { margin-top: var(--space-2); }
.prose .aside p:first-child { margin-top: 0; }
.prose .aside__label {
  display: block;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--moss);
  margin-bottom: var(--space-2);
}
.prose .aside--warn { border-left-color: var(--amber); background: var(--amber-soft); }
.prose .aside--warn .aside__label { color: var(--amber); }


/* (b) Footnote reference + footnotes section
   When using markdown-it-footnote, the rendered structure is:
     <sup class="footnote-ref"><a href="#fn1" id="fnref1">[1]</a></sup>
     <section class="footnotes"><ol class="footnotes-list">...</ol></section>
*/
.prose sup.footnote-ref a,
.prose a.footnote-ref {
  color: var(--moss);
  font-family: var(--font-mono);
  font-size: 0.65em;
  font-weight: 500;
  text-decoration: none;
  border: none;
  padding: 0 0.1em;
  vertical-align: super;
  line-height: 0;
}
.prose sup.footnote-ref a:hover,
.prose a.footnote-ref:hover { color: var(--amber); }

.prose .footnotes {
  margin-top: var(--space-9);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
}
.prose .footnotes::before {
  content: "Notes";
  display: block;
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--dim);
  margin-bottom: var(--space-4);
}
.prose .footnotes ol { padding-left: 0; }
.prose .footnotes li {
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--muted);
  margin-top: var(--space-3);
}
.prose .footnotes li::before {
  color: var(--moss);
  font-family: var(--font-mono);
  font-weight: 500;
}
.prose .footnote-backref {
  color: var(--dim);
  text-decoration: none;
  margin-left: 0.3em;
}
.prose .footnote-backref:hover { color: var(--moss); }


/* (c) Right-rail marginalia — uses CSS Grid on .prose--with-margin
   Up to ~900px the right rail collapses and notes go inline (as asides).
   Wrap notes as: <aside class="margin-note" data-n="1">…</aside>
   References inline as: <sup class="margin-ref" data-n="1">1</sup>
*/
.prose--with-margin {
  max-width: var(--measure-wide);
}

.prose--with-margin .margin-ref {
  color: var(--moss);
  font-family: var(--font-mono);
  font-size: 0.65em;
  font-weight: 500;
  margin-left: 0.1em;
  vertical-align: super;
  line-height: 0;
}

@media (min-width: 1024px) {
  .prose--with-margin {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: var(--space-6);
    align-items: start;
  }
  /* Lift the margin notes out of the prose flow into column 2 */
  .prose--with-margin .margin-note {
    grid-column: 2;
    font-family: var(--font-sans);
    font-style: italic;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
    padding-left: var(--space-3);
    border-left: 1px solid var(--rule);
    margin-top: 0;
  }
  .prose--with-margin .margin-note::before {
    content: attr(data-n) " · ";
    font-family: var(--font-mono);
    font-style: normal;
    font-weight: 500;
    color: var(--moss);
    margin-right: 0.2em;
  }
  /* Make sure everything else flows in column 1 */
  .prose--with-margin > *:not(.margin-note) { grid-column: 1; }
}

/* Below 1024px: render margin-notes as inline asides */
@media (max-width: 1023px) {
  .prose--with-margin .margin-note {
    display: block;
    margin: var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    border-left: 2px solid var(--moss);
    background: var(--moss-soft);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: var(--fs-sm);
    color: var(--muted);
  }
  .prose--with-margin .margin-note::before {
    content: "Note " attr(data-n);
    display: block;
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--moss);
    margin-bottom: var(--space-2);
    font-style: normal;
  }
}


/* ── 10. Print ────────────────────────────────────────────────────── */

@media print {
  html { font-size: 11pt; }
  body { background: white; color: black; }
  .site-nav, .site-footer { display: none; }
  .prose { max-width: none; }
  .prose pre {
    background: #fafafa;
    color: black;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
  .prose a { color: inherit; text-decoration: underline; }
  /* Show URLs after links — useful for print bibliography */
  .prose a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #666;
  }
}


/* ── 11. Accessibility helpers ────────────────────────────────────── */

/* Screen-reader only */
.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;
}

/* Skip link */
.skip-to-content {
  position: absolute;
  left: -9999px;
}
.skip-to-content:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  padding: 0.5rem 1rem;
  background: var(--amber);
  color: var(--bg);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-sm);
  z-index: 100;
  border-radius: var(--radius-md);
}

/* Reduce motion — already minimal but kill the read-on arrow shift */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}


/* ── Gallery shortcode ────────────────────────────────────────────── */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-block: var(--space-5);
}

.gallery figure { margin: 0; }

.gallery img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
}

.gallery figcaption {
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-top: var(--space-2);
  text-align: center;
}
