/* The Archive-First Press — site stylesheet.
 *
 * Hand-written, dependency-free CSS for the published record. No Tailwind, no
 * build step, no scanning of source code: every class this styles is emitted by
 * press/src/manifest.ts, and nothing else. Grown from the original site.css
 * .article-body block (which replaced @tailwindcss/typography).
 *
 * Theming: all colors route through custom properties. Dark mode is a token
 * swap, applied by the `.dark` class (site theme toggle) or, when no explicit
 * .light/.dark class is set, by prefers-color-scheme.
 */

/* =========================================================================
   Tailwind-preflight parity. Every rule below was ported from a site running
   Tailwind's preflight, so it was authored assuming border-box sizing and a
   1.5 body line-height (set on body below). Without this the code-block
   gutter (44px + padding under content-box) overlaps the first character of
   every line, and bordered chrome runs 2px tall.
   ========================================================================= */

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

/* =========================================================================
   Design tokens. The article palette is gray-*; the page chrome (header, nav,
   dates) is zinc-*, exactly as the two lived on the legacy site.
   ========================================================================= */

:root {
  --paper: #ffffff;
  --chrome-fg: #09090b;
  --chrome-muted: #71717a;
  --fg: #374151;
  --heading: #111827;
  --link: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --rule: #e5e7eb;
  --marker-ol: #6b7280;
  --marker-ul: #d1d5db;
  --bq-fg: #111827;
  --bq-border: #e5e7eb;
  --pre-bg: #1f2937;
  --pre-fg: #e5e7eb;
  --card-bg: #fafafa;
  --card-border: #e5e7eb;
  --popover-bg: #ffffff;
  --popover-fg: #111827;
  --popover-border: #e5e7eb;
  --callout-bg: #f3f4f6;
  --callout-border: #d1d5db;
  --callout-blue-bg: #eff6ff;
  --callout-blue-label: #1d4ed8;
  --rq-bg: #f9fafb;
  --rq-glyph: #d1d5db;
  --kbd-shadow: rgb(17 24 39 / 10%);
  --inline-code-fg: #1f2937;
  --inline-code-bg: #f9fafb;
  --inline-code-bg-image: none;
  --inline-code-border: rgb(229 231 235 / 60%);
  /* The site has always been sans — the legacy @theme defined a serif token but
     never used it. Tailwind's default stack, spelled out. */
  --font-sans:
    ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",
    "Noto Color Emoji";
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
}

/* Dark tokens, twice: once for the explicit theme class (site toggle), once for
   system preference when no explicit class is present. Keep the two blocks
   identical. */
.dark {
  --paper: #09090b;
  --chrome-fg: #fafafa;
  --chrome-muted: #a1a1aa;
  --fg: #d1d5db;
  --heading: #ffffff;
  --link: #ffffff;
  --muted: #9ca3af;
  --faint: #6b7280;
  --rule: #374151;
  --marker-ol: #9ca3af;
  --marker-ul: #4b5563;
  --bq-fg: #f3f4f6;
  --bq-border: #374151;
  --pre-bg: rgb(0 0 0 / 50%);
  --pre-fg: #d1d5db;
  --card-bg: #18181b;
  --card-border: #33333a;
  --popover-bg: #18181b;
  --popover-fg: #f4f4f5;
  --popover-border: #3f3f46;
  --callout-bg: #1c1c20;
  --callout-border: #3f3f46;
  --callout-blue-bg: rgb(30 58 138 / 20%);
  --callout-blue-label: #93c5fd;
  --rq-bg: rgb(31 41 55 / 50%);
  --rq-glyph: #4b5563;
  --kbd-shadow: rgb(255 255 255 / 10%);
  --inline-code-fg: #e5e7eb;
  --inline-code-bg: rgb(31 41 55 / 30%);
  --inline-code-bg-image: linear-gradient(to right, rgb(30 58 138 / 20%), rgb(88 28 135 / 20%));
  --inline-code-border: rgb(55 65 81 / 50%);
}

@media (prefers-color-scheme: dark) {
  :root:not(.light):not(.dark) {
    --paper: #09090b;
    --chrome-fg: #fafafa;
    --chrome-muted: #a1a1aa;
    --fg: #d1d5db;
    --heading: #ffffff;
    --link: #ffffff;
    --muted: #9ca3af;
    --faint: #6b7280;
    --rule: #374151;
    --marker-ol: #9ca3af;
    --marker-ul: #4b5563;
    --bq-fg: #f3f4f6;
    --bq-border: #374151;
    --pre-bg: rgb(0 0 0 / 50%);
    --pre-fg: #d1d5db;
    --card-bg: #18181b;
    --card-border: #33333a;
    --popover-bg: #18181b;
    --popover-fg: #f4f4f5;
    --popover-border: #3f3f46;
    --callout-bg: #1c1c20;
    --callout-border: #3f3f46;
    --callout-blue-bg: rgb(30 58 138 / 20%);
    --callout-blue-label: #93c5fd;
    --rq-bg: rgb(31 41 55 / 50%);
    --rq-glyph: #4b5563;
    --kbd-shadow: rgb(255 255 255 / 10%);
    --inline-code-fg: #e5e7eb;
    --inline-code-bg: rgb(31 41 55 / 30%);
    --inline-code-bg-image: linear-gradient(to right, rgb(30 58 138 / 20%), rgb(88 28 135 / 20%));
    --inline-code-border: rgb(55 65 81 / 50%);
  }
}

/* =========================================================================
   Article body — base typography.
   :where() keeps child-selector specificity at (0,1,0) so page-level utilities
   can still override.
   ========================================================================= */

.article-body {
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.7777778;
  max-width: 65ch;
  color: var(--fg);
}

/* Headings */
.article-body :where(h1) {
  color: var(--heading);
  font-size: 2.6666667em;
  margin: 0 0 0.5em;
  line-height: 1;
  font-weight: 800;
}

.article-body :where(h2) {
  color: var(--heading);
  font-size: 1.6666667em;
  margin: 1.8666667em 0 1.0666667em;
  line-height: 1.3333333;
  font-weight: 700;
}

.article-body :where(h3) {
  color: var(--heading);
  font-size: 1.3333333em;
  margin: 1.6666667em 0 0.6666667em;
  line-height: 1.5;
  font-weight: 600;
}

.article-body :where(h4) {
  color: var(--heading);
  margin: 1.7777778em 0 0.4444444em;
  line-height: 1.5555556;
  font-weight: 600;
}

.article-body :where(h1 strong) {
  font-weight: 900;
  color: inherit;
}

.article-body :where(h2 strong) {
  font-weight: 800;
  color: inherit;
}

.article-body :where(h3 strong, h4 strong) {
  font-weight: 700;
  color: inherit;
}

.article-body :where(h2 + *, h3 + *, h4 + *) {
  margin-top: 0;
}

/* Heading self-links (emitted by linked-heading) */
.article-body :where(.heading-anchor) {
  margin-left: 0.35em;
  color: var(--faint);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.article-body :where(h1, h2, h3, h4, h5, h6):hover .heading-anchor,
.article-body :where(.heading-anchor):focus-visible {
  opacity: 1;
}

/* Paragraphs */
.article-body :where(p) {
  margin-top: 1.3333333em;
  margin-bottom: 1.3333333em;
}

/* Links */
.article-body :where(a) {
  color: var(--link);
  text-decoration: underline;
  font-weight: 500;
}

.article-body :where(a strong),
.article-body :where(a code) {
  color: inherit;
}

/* Bold */
.article-body :where(strong) {
  color: var(--heading);
  font-weight: 600;
}

.article-body :where(blockquote strong, thead th strong) {
  color: inherit;
}

/* Highlight */
.article-body :where(mark) {
  background: #fde047;
  color: #111827;
  padding: 0.05em 0.15em;
  border-radius: 2px;
}

/* Lists */
.article-body :where(ol) {
  list-style-type: decimal;
  margin: 1.3333333em 0;
  padding-inline-start: 1.5555556em;
}

.article-body :where(ul) {
  list-style-type: disc;
  margin: 1.3333333em 0;
  padding-inline-start: 1.5555556em;
}

.article-body :where(li) {
  margin: 0.6666667em 0;
  padding-inline-start: 0.4444444em;
}

.article-body :where(ol > li)::marker {
  font-weight: 400;
  color: var(--marker-ol);
}

.article-body :where(ul > li)::marker {
  color: var(--marker-ul);
}

.article-body :where(ul ul, ul ol, ol ul, ol ol) {
  margin: 0.8888889em 0;
}

/* Checklists */
.article-body :where(ul.checklist) {
  list-style: none;
  padding-inline-start: 0.4444444em;
}

.article-body :where(.checklist-item input[type="checkbox"]) {
  margin-right: 0.55em;
  vertical-align: 0.05em;
  accent-color: var(--heading);
}

/* Blockquotes */
.article-body :where(blockquote) {
  font-weight: 500;
  font-style: italic;
  color: var(--bq-fg);
  border-inline-start: 0.25rem solid var(--bq-border);
  margin: 1.6666667em 0;
  padding-inline-start: 1em;
  quotes: "\201C" "\201D" "\2018" "\2019";
}

.article-body :where(blockquote p:first-of-type)::before {
  content: open-quote;
}

.article-body :where(blockquote p:last-of-type)::after {
  content: close-quote;
}

/* Horizontal rules */
.article-body :where(hr) {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 3.1111111em 0;
}

.article-body :where(hr + *) {
  margin-top: 0;
}

.article-body :where(hr.page-break) {
  border-top-style: dashed;
}

/* =========================================================================
   Figures & media
   ========================================================================= */

.article-body :where(figure) {
  margin: 1.7777778em 0;
}

.article-body :where(figure > *) {
  margin: 0;
}

.article-body :where(figcaption) {
  color: #a3a3a3;
  font-size: 0.7777778em;
  line-height: 1.4285714;
  margin-top: 0.5714286em;
}

.article-body :where(figcaption p) {
  margin: 0;
}

.article-body :where(img, video) {
  margin: 0;
}

/* Block alignment for image/video figures (center is the default) */
.article-body :where(figure.image, figure.video) {
  margin-inline: auto;
}

.article-body :where(figure.image--left, figure.video--left) {
  margin-inline: 0 auto;
}

.article-body :where(figure.image--right, figure.video--right) {
  margin-inline: auto 0;
}

.article-body :where(img.inline-image) {
  display: inline-block;
  vertical-align: middle;
  max-width: 100%;
}

/* Greyscale line-art SVGs marked at upload (#theme-invert) invert on the dark
   theme so black ink stays legible. */
.dark .article-body img[src$="#theme-invert"] {
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not(.light):not(.dark) .article-body img[src$="#theme-invert"] {
    filter: invert(1);
  }
}

/* =========================================================================
   Inline code, kbd, code blocks
   ========================================================================= */

/* Inline code renders as the chip the legacy exportDOM hardcoded on its span:
   translucent grey over a faint blue-to-purple wash, bordered, pill-padded.
   (pre code below resets all of this inside code blocks.) */
.article-body :where(code) {
  color: var(--inline-code-fg);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8888889em;
  background-color: var(--inline-code-bg);
  background-image: var(--inline-code-bg-image);
  border: 1px solid var(--inline-code-border);
  border-radius: 0.25rem;
  padding: 0.125rem 0.5rem;
}

.article-body :where(h1 code, h2 code, h3 code, h4 code, blockquote code, thead th code) {
  color: inherit;
}

.article-body :where(kbd) {
  font-weight: 500;
  font-family: inherit;
  color: var(--heading);
  font-size: 0.8888889em;
  border-radius: 0.3125rem;
  padding: 0.2222222em 0.4444444em;
  box-shadow:
    0 0 0 1px var(--kbd-shadow),
    0 3px 0 var(--kbd-shadow);
}

/* Code blocks. The palette is fixed (VSCode Dark Modern) in both themes, as on
   the current site. The line-number gutter renders from data-gutter. */
.article-body :where(pre) {
  background-color: #1e1e1e;
  color: #f6f6f6;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  tab-size: 2;
  border-radius: 6px;
  margin: 8px 0;
  padding: 8px;
  position: relative;
  overflow-x: auto;
}

.article-body :where(pre[data-gutter]) {
  padding-left: 52px;
}

.article-body :where(pre[data-gutter])::before {
  content: attr(data-gutter);
  position: absolute;
  background-color: #252526;
  left: 0;
  top: 0;
  bottom: 0;
  width: 44px;
  border-right: 1px solid #404040;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  padding: 8px;
  color: #858585;
  white-space: pre;
  text-align: right;
}

.article-body :where(pre code) {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  white-space: pre;
}

/* Syntax tokens (emitted as tok-<prism-type>) — VSCode Dark Modern palette */
.tok-comment {
  color: #6a9955;
  font-style: italic;
}
.tok-punctuation,
.tok-operator {
  color: #d4d4d4;
}
.tok-property,
.tok-variable {
  color: #9cdcfe;
}
.tok-selector,
.tok-string,
.tok-char,
.tok-attr-value {
  color: #ce9178;
}
.tok-atrule,
.tok-keyword,
.tok-boolean,
.tok-tag {
  color: #569cd6;
}
.tok-function {
  color: #dcdcaa;
}
.tok-number {
  color: #b5cea8;
}
.tok-constant,
.tok-symbol {
  color: #4fc1ff;
}
.tok-class,
.tok-class-name,
.tok-namespace,
.tok-builtin {
  color: #4ec9b0;
}
.tok-attr-name {
  color: #9cdcfe;
}
.tok-important,
.tok-deleted {
  color: #f44747;
}
.tok-inserted {
  color: #6a9955;
}

/* =========================================================================
   Tables
   ========================================================================= */

.article-body :where(table) {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 0.8888889em;
  line-height: 1.5;
}

.article-body :where(th) {
  color: var(--heading);
  font-weight: 600;
  vertical-align: bottom;
  text-align: left;
  padding: 0 0.75em 0.75em;
  border-bottom: 1px solid var(--marker-ul);
}

.article-body :where(th:first-child) {
  padding-inline-start: 0;
}

.article-body :where(th:last-child) {
  padding-inline-end: 0;
}

.article-body :where(td) {
  padding: 0.25rem 0.75rem;
  border-bottom: 1px solid var(--rule);
}

/* Cell content is wrapped in a <p>; without this its article margins (1.333em
   top+bottom) balloon every row to ~3x its height. Live tables are compact. */
.article-body :where(td p, th p) {
  margin: 0;
}

.article-body :where(td:first-child) {
  padding-inline-start: 0;
}

.article-body :where(td:last-child) {
  padding-inline-end: 0;
}

.article-body :where(tr:last-child td) {
  border-bottom: 0;
}

/* =========================================================================
   Constructs
   ========================================================================= */

/* Callout — the live legacy look: blue-tinted box, blue uppercase label, a 4px
   inline-start rule, right-rounded corners, upright body. */
.article-body :where(aside.callout) {
  background: var(--callout-blue-bg);
  border-inline-start: 4px solid var(--callout-border);
  border-radius: 0 0.5rem 0.5rem 0;
  padding: 1em 1.5em;
  margin: 1.5em 0;
  font-size: 0.8888889em;
}

.article-body :where(.callout-label) {
  display: block;
  margin: 0 0 0.5em;
  font-weight: 600;
  font-size: 0.875em;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  color: var(--callout-blue-label);
}

.article-body :where(aside.callout p) {
  margin: 0;
}

.article-body :where(aside.callout > :last-child) {
  margin-bottom: 0;
}

/* Rich quote — the live legacy look: gray card (no border), decorative serif
   quote glyphs in the corners, italic body, "— author" + source-domain link. */
.article-body :where(figure.rich-quote) {
  position: relative;
  margin: 1.7777778em 0;
  padding: 1.5rem 3rem;
  background: var(--rq-bg);
  border: 0;
  border-radius: 0.5rem;
}

.article-body :where(figure.rich-quote)::before,
.article-body :where(figure.rich-quote)::after {
  position: absolute;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 3.75rem;
  line-height: 1;
  color: var(--rq-glyph);
  pointer-events: none;
  user-select: none;
}

.article-body :where(figure.rich-quote)::before {
  content: "\201C";
  left: 0.75rem;
  top: 0.75rem;
}

.article-body :where(figure.rich-quote)::after {
  content: "\201D";
  right: 0.75rem;
  bottom: 0.75rem;
}

.article-body :where(figure.rich-quote blockquote) {
  border: 0;
  margin: 0;
  padding: 0;
  font-style: italic;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.625;
  color: var(--bq-fg);
  quotes: none;
}

.article-body :where(figure.rich-quote blockquote p)::before,
.article-body :where(figure.rich-quote blockquote p)::after {
  content: none;
}

.article-body :where(figure.rich-quote blockquote p:first-child) {
  margin-top: 0;
}

.article-body :where(figure.rich-quote blockquote p:last-child) {
  margin-bottom: 0;
}

.article-body :where(figure.rich-quote figcaption) {
  display: flex;
  align-items: center;
  gap: 0.25em;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.article-body :where(figure.rich-quote cite) {
  font-style: normal;
  color: var(--muted);
}

.article-body :where(figure.rich-quote .rich-quote-source) {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-style: dotted;
}

/* Tooltip trigger + popup. Content also ships in an inert <template> and a
   title fallback, so this styling is enhancement, not a dependency. */
.article-body :where(.tooltip-trigger) {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.tooltip-popup {
  position: absolute;
  background: var(--popover-bg);
  border: 1px solid var(--popover-border);
  border-radius: 6px;
  padding: 16px;
  font-size: 16px;
  color: var(--popover-fg);
  min-width: 384px;
  max-width: min(672px, calc(100vw - 32px));
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

@media (max-width: 640px) {
  /* On mobile a large tooltip overflows the viewport with no way to scroll, so
     present it as a full-width bottom sheet. Overrides the JS-set absolute
     left/top positioning; pointer-events:auto lets the reader scroll it. */
  .tooltip-popup {
    position: fixed !important;
    inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px !important;
    min-width: 0;
    max-width: none;
    width: auto;
    max-height: 70vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    pointer-events: auto;
    font-size: 14px;
    padding: 12px;
  }
}

.tooltip-popup.show {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-popup-image-only {
  min-width: 0;
  width: fit-content;
  max-width: min(fit-content, calc(100vw - 32px));
}

.tooltip-popup :where(p:first-child) {
  margin-top: 0;
}

.tooltip-popup :where(p:last-child) {
  margin-bottom: 0;
}

/* Link preview card */
.article-body :where(a.link-preview) {
  display: block;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  font-weight: 400;
  margin: 1.7777778em 0;
  background: var(--card-bg);
}

.article-body :where(.link-preview-image) {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 0;
}

.article-body :where(.link-preview-body) {
  display: block;
  padding: 0.85em 1.1em;
}

.article-body :where(.link-preview-title) {
  display: block;
  font-weight: 600;
  color: var(--heading);
}

.article-body :where(.link-preview-desc) {
  display: block;
  font-size: 0.8888889em;
  color: var(--muted);
  margin-top: 0.25em;
}

.article-body :where(.link-preview-site) {
  display: block;
  font-size: 0.7777778em;
  color: var(--faint);
  margin-top: 0.45em;
  letter-spacing: 0.02em;
}

/* Web embed */
.article-body :where(figure.web-embed) {
  margin: 1.7777778em 0;
}

.article-body :where(figure.web-embed--bordered iframe) {
  border: 1px solid var(--card-border) !important;
  border-radius: 8px;
}

.article-body :where(a.web-embed-link) {
  display: block;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 0.85em 1.1em;
  margin: 1.7777778em 0;
  text-decoration: none;
  font-weight: 500;
  color: var(--heading);
}

.article-body :where(a.web-embed-link)::after {
  content: " ↗";
  color: var(--faint);
}

/* App download card */
.article-body :where(aside.app-download-card) {
  display: flex;
  gap: 1.25em;
  align-items: flex-start;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--card-bg);
  padding: 1.25em;
  margin: 1.7777778em 0;
}

.article-body :where(.app-card-icon) {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  flex-shrink: 0;
}

.article-body :where(.app-card-body p) {
  margin: 0 0 0.4em;
}

.article-body :where(.app-card-name) {
  font-size: 1.2222222em;
  font-weight: 700;
  color: var(--heading);
}

.article-body :where(.app-card-tagline) {
  color: var(--fg);
}

.article-body :where(.app-card-meta) {
  font-size: 0.7777778em;
  color: var(--faint);
}

.article-body :where(.app-card-brew) {
  margin: 0.75em 0;
  padding: 8px 12px;
  font-size: 0.7777778em;
}

.article-body :where(.app-card-actions) {
  margin-top: 0.75em;
  display: flex;
  gap: 1em;
  align-items: center;
  flex-wrap: wrap;
}

.article-body :where(a.app-card-download) {
  display: inline-block;
  background: var(--heading);
  color: var(--paper);
  text-decoration: none;
  padding: 0.5em 1.25em;
  border-radius: 9999px;
  font-weight: 500;
}

.article-body :where(a.app-card-repo) {
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 480px) {
  .article-body :where(aside.app-download-card) {
    flex-direction: column;
  }
}

/* Layout columns — stack on narrow screens (overrides the inline
   grid-template-columns, hence the !important) */
.article-body :where(.layout) {
  display: grid;
  gap: 1.5rem;
  margin: 1.7777778em 0;
}

@media (max-width: 640px) {
  .article-body .layout {
    grid-template-columns: 1fr !important;
  }
}

.article-body :where(.layout-item > p:first-child) {
  margin-top: 0;
}

.article-body :where(.layout-item > p:last-child) {
  margin-bottom: 0;
}

/* Collapsible */
/* Element-agnostic (.collapsible, not details.collapsible): published emits
   <details class="collapsible">, but the editor's Chrome path emits a
   <div class="collapsible" data-open> (the <details>+contentEditable
   workaround), and both must get the same styling. */
.article-body :where(.collapsible) {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.65em 1.1em;
  margin: 1.7777778em 0;
}

.article-body :where(.collapsible summary) {
  cursor: pointer;
  font-weight: 700;
  color: var(--heading);
}

/* The title renders as a block <p> inside <summary> (press wraps the nested
   editor's paragraph); left block it drops onto its own line below the native
   disclosure marker. Keep it inline so marker + title share one line. */
.article-body :where(.collapsible summary p) {
  display: inline;
  margin: 0;
}

.article-body :where(.collapsible[open] summary, .collapsible[data-open] summary) {
  margin-bottom: 0.5em;
}

.article-body :where(.collapsible-content > p:first-child) {
  margin-top: 0;
}

.article-body :where(.collapsible-content > p:last-child) {
  margin-bottom: 0;
}

/* First and last child margin removal */
.article-body > :where(:first-child) {
  margin-top: 0;
}

.article-body > :where(:last-child) {
  margin-bottom: 0;
}

/* =========================================================================
   Site chrome — header, nav, footer, cards, badges, menus.
   Ported from the Tailwind-utility chrome to semantic classes.
   ========================================================================= */

body {
  margin: 0;
  background: var(--paper);
  color: var(--chrome-fg);
  font-family: var(--font-sans);
  line-height: 1.5;
}

.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;
}

.site-wrap {
  margin: 0 0.5rem;
}

@media (min-width: 768px) {
  .site-wrap {
    margin: 0 3rem;
  }
}

.site-main {
  max-width: 56rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Header */
.site-header {
  display: flex;
  margin: 1rem 0 2.5rem;
  align-items: center;
}

.site-nav {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 1rem;
}

/* The legacy header h1 carries no classes — under preflight it renders as
   plain 1rem/400 body text. Deliberately understated. */
.site-title {
  font-size: 1rem;
  font-weight: 400;
  margin: 0;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.nav-links a {
  color: inherit;
  text-decoration: underline;
}

.nav-links a:hover {
  text-decoration: none;
}

.nav-posts {
  display: none;
}

@media (min-width: 768px) {
  .nav-posts {
    display: inline;
  }
}

.site-social {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: flex-end;
}

.icon-link {
  color: var(--fg);
  display: inline-flex;
}

.icon-link--rss {
  color: #fb923c;
}

.icon-link--rss:hover,
.rss-menu summary:hover {
  color: var(--heading);
}

.icon-link--mastodon:hover {
  color: #6364ff;
}

.icon-link--bluesky:hover {
  color: #0085ff;
}

.icon-link--github:hover {
  color: var(--heading);
}

/* Dropdown menus (RSS + theme) — native <details> */
.rss-menu,
.theme-menu {
  position: relative;
}

.rss-menu summary,
.theme-menu summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rss-menu summary::-webkit-details-marker,
.theme-menu summary::-webkit-details-marker {
  display: none;
}

.rss-menu summary {
  color: #fb923c;
}

.theme-menu summary {
  border-radius: 9999px;
  padding: 0.5rem;
  color: var(--fg);
}

.theme-menu summary:hover {
  background: var(--callout-bg);
}

.menu-panel {
  position: absolute;
  right: 0;
  margin-top: 0.5rem;
  width: 11rem;
  border: 1px solid var(--card-border);
  border-radius: 0.375rem;
  background: var(--popover-bg);
  color: var(--popover-fg);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  padding: 0.25rem;
  font-size: 0.875rem;
  z-index: 50;
}

.menu-panel a,
.menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-radius: 0.25rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.menu-panel a:hover,
.menu-panel button:hover {
  background: var(--callout-bg);
}

/* Theme toggle icons: sun in light, moon in dark */
.theme-icons {
  position: relative;
  display: inline-flex;
  width: 20px;
  height: 20px;
}

.theme-icons .icon-moon {
  position: absolute;
  inset: 0;
  display: none;
}

.dark .theme-icons .icon-sun {
  display: none;
}

.dark .theme-icons .icon-moon {
  display: inline;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light):not(.dark) .theme-icons .icon-sun {
    display: none;
  }
  :root:not(.light):not(.dark) .theme-icons .icon-moon {
    display: inline;
  }
}

/* Articles & cards */
.article,
.post-card {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2rem;
  margin: 0 auto;
  max-width: 48rem;
  width: 100%;
}

.post-card-title {
  font-size: 3rem;
  line-height: 1;
  margin: 0 0 1.5rem;
}

.post-card-title a {
  color: var(--heading);
  text-decoration: none;
  font-weight: 800;
}

.post-card-title a:hover {
  text-decoration: underline;
}

.post-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.post-meta time {
  font-size: 0.875rem;
  line-height: 1.4285714;
  color: var(--chrome-muted);
  margin-left: auto;
  white-space: nowrap;
}

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

.article-content {
  margin-top: 2rem;
}

.post-card-more {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

.post-card-more a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  line-height: 1.4285714;
  font-weight: 500;
  color: var(--link);
  text-decoration: none;
}

.post-card-more a:hover {
  background: var(--heading);
  color: var(--paper);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.archive-link-row {
  margin-top: 3rem;
  display: flex;
  justify-content: center;
}

.archive-link-row a {
  font-size: 0.875rem;
  line-height: 1.4285714;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
}

.archive-link-row a:hover {
  text-decoration: underline;
}

/* Tag badges */
.tag-badge-link {
  text-decoration: none;
  display: inline-flex;
}

.tag-badge {
  display: inline-flex;
  align-items: center;
  height: 1.75rem;
  padding: 0 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--card-border);
  background: var(--callout-bg);
  color: var(--fg);
  font-size: 0.875rem;
  line-height: 1.4285714;
  font-weight: 600;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.tag-badge:hover {
  background: var(--heading);
  color: var(--paper);
}

.tag-badge--colored {
  border: 1px solid;
}

.tag-badge--colored:hover {
  opacity: 0.8;
  background: inherit;
  color: inherit;
}

.tag-icon {
  margin-right: 0.25rem;
  width: 0.875rem;
  height: 0.875rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  line-height: 1;
  object-fit: contain;
}

/* Archive index */
.archive-index {
  margin: 0 auto;
  width: 100%;
  max-width: 48rem;
}

/* The legacy page used a plain <ul> whose article-body padding indents the
   rows under the year heading; flex on the li suppresses the markers. */
.archive-list {
  list-style: none;
  padding-inline-start: 1.5555556em;
}

.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding-inline-start: 0.4444444em;
}

.archive-list time {
  font-size: 0.875rem;
  line-height: 1.4285714;
  color: var(--chrome-muted);
  white-space: nowrap;
  margin-left: auto;
}

/* Changelog (post pages) */
.changelog {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
  color: var(--muted);
}

/* Live reactions (tapback), at the foot of a published post. The widget is a
   custom element hydrated by a third-party module; reserve space so its arrival
   doesn't shift the page, and keep the slot invisible until it upgrades. */
.post-reactions {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  min-height: 2.5rem;
}

.post-reactions tapback-bar:not(:defined) {
  visibility: hidden;
}

.changelog h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
}

.changelog ol {
  margin: 0;
  padding-left: 1.25rem;
  list-style-type: decimal;
}

.changelog li {
  margin: 0.25rem 0;
  padding-inline-start: 0;
}

.changelog time {
  font-weight: 500;
  color: var(--fg);
}

/* Footer */
.site-footer {
  display: flex;
  margin-top: 2.5rem;
  justify-content: center;
  align-items: center;
  padding-bottom: 2rem;
}

@media (min-width: 768px) {
  .site-footer {
    margin-bottom: 6rem;
  }
}

/* 404 */
.err-404 {
  text-align: center;
  margin: 0 auto;
}

.err-404 .err-circle {
  stroke: var(--heading);
  display: inline-block;
  max-width: 100%;
  height: auto;
}
