/* ==========================================================================
   Theme: warm monochrome editorial, adapted from the NOCTRA reference.
   Cream/bone on near-black (dark, primary) — inverted to dark-on-cream (light).
   NO colour accent: the design is strictly warm monochrome. Structure comes
   from fine hairlines, boxed/bracketed controls and generous space.
   Signature motifs: the animated 3D pixel-computer wordmark, ✶ section
   labels, [↗] arrow-in-a-box "open" affordances, cream/dark fill buttons,
   bordered mosaic cells with duotone (grayscale+sepia) covers.

   Type: JetBrains Mono (ALL chrome — nav, meta, labels, footer, code; UPPER
   tracked), Redaction 35 (big display titles), Newsreader (clean serif —
   cell titles, prose headings), Paprika (wordmark), Geologica (post reading
   body only — the user's pick). All self-hosted, strict CSP.
   ========================================================================== */

/* ---- Self-hosted fonts (latin subset) ---- */

@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/newsreader-italic-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Geologica";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/geologica-latin.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin.woff2") format("woff2");
}

/* Paprika (SIL OFL) — the wordmark voice; used NOWHERE else. */
@font-face {
  font-family: "Paprika";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/paprika.woff2") format("woff2");
}

/* Redaction 35 (SIL OFL) — degraded/rough "artifacty" serif, echoing NOCTRA.
   OTF (no woff2 tooling here); the display voice for big titles only.
   Newsreader is the clean fallback. */
@font-face {
  font-family: "Redaction 35";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/redaction35.otf") format("opentype");
}

@font-face {
  font-family: "Redaction 35";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/redaction35-italic.otf") format("opentype");
}

/* ---- Design tokens ------------------------------------------------------
   Dark is primary. Both themes are warm monochrome (cream ↔ near-black).
   The dark block appears twice (manual toggle + system preference) — keep
   both identical.
--------------------------------------------------------------------------- */

:root {
  --font-serif: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
  --font-display: "Redaction 35", "Newsreader", ui-serif, Georgia, serif;
  --font-word: "Paprika", "JetBrains Mono", ui-monospace, monospace;
  --font-body: "Geologica", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* ✶ six-point star and ↗ arrow, as theme-tinted masks (background = ink). */
  --star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1 13.7 9.06 21.53 6.5 15.4 12 21.53 17.5 13.7 14.94 12 23 10.3 14.94 2.47 17.5 8.6 12 2.47 6.5 10.3 9.06Z' fill='%23000'/%3E%3C/svg%3E");
  --arrow-ne: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 18 18 6M9.5 6H18v8.5' fill='none' stroke='%23000' stroke-width='2.1'/%3E%3C/svg%3E");
  /* 3D pixel computer, TWO aligned masks on a 13×12 grid: the FRONT layer
     (outlined CRT face + stepped stand, full ink) and the DEPTH layer (top
     plane + right side plane, painted dimmer for pixel-art shading). */
  --computer-front: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 12' shape-rendering='crispEdges'%3E%3Cpath d='M0 2h11v1H0zM0 9h11v1H0zM0 3h1v6H0zM10 3h1v6h-1zM4 10h3v1H4zM2 11h7v1H2z' fill='%23000'/%3E%3C/svg%3E");
  --computer-depth: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 13 12' shape-rendering='crispEdges'%3E%3Cpath d='M2 0h10v1H2zM1 1h10v1H1zM11 1h1v9h-1zM12 0h1v9h-1z' fill='%23000'/%3E%3C/svg%3E");
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* Light — warm cream / bone paper, dark warm ink. */
  color-scheme: light;
  --bg: #e8dfce;
  --bg-2: #ded3bf;
  --grain-o: 0.05;
  --grain-blend: multiply;
  --ink: #1a1610;
  --ink-2: #6a6355;
  --ink-3: #9a9280;
  --line: rgba(26, 22, 16, 0.22);
  --line-2: rgba(26, 22, 16, 0.1);
  --fill: #1a1610;
  --fill-ink: #e8dfce;
  --sel: rgba(26, 22, 16, 0.16);
  --cover-filter: grayscale(1) sepia(0.34) contrast(1.09) brightness(0.84);
  --thumb-lift: brightness(1);

  --tok-com: #9a9280;
  --tok-kw: #1a1610;
  --tok-str: #7a6b4c;
  --tok-num: #8a6a45;
  --tok-fn: #52504a;
  --tok-type: #6b5a3c;

  --header-h: 4.25rem;
  --frame: 76rem;   /* wide, framed "newspaper" content width */
  --measure: 42rem; /* comfortable prose reading measure */
  --gutter: clamp(1.3rem, 3.5vw, 3rem);
  /* ONE display scale for every Redaction-35 title (hero, list, post). */
  --size-display: clamp(2.25rem, 1.3rem + 3.3vw, 3.5rem);
  /* Index-cell inner padding (shared so the caption bar can full-bleed). */
  --cell-pad: clamp(0.95rem, 0.8rem + 0.5vw, 1.3rem);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14120f;
  --bg-2: #1c1a15;
  --grain-o: 0.055;
  --grain-blend: overlay;
  --ink: #ece4d3;
  --ink-2: #948d7d;
  --ink-3: #625c50;
  --line: rgba(236, 228, 211, 0.17);
  --line-2: rgba(236, 228, 211, 0.08);
  --fill: #ece4d3;
  --fill-ink: #14120f;
  --sel: rgba(236, 228, 211, 0.22);
  --cover-filter: grayscale(1) sepia(0.42) contrast(1.04) brightness(0.9);
  --thumb-lift: brightness(1.35) contrast(0.94);

  --tok-com: #625c50;
  --tok-kw: #ece4d3;
  --tok-str: #c2ac86;
  --tok-num: #cbb083;
  --tok-fn: #b9b2a0;
  --tok-type: #d8c39a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14120f;
    --bg-2: #1c1a15;
    --grain-o: 0.055;
    --grain-blend: overlay;
    --ink: #ece4d3;
    --ink-2: #948d7d;
    --ink-3: #625c50;
    --line: rgba(236, 228, 211, 0.17);
    --line-2: rgba(236, 228, 211, 0.08);
    --fill: #ece4d3;
    --fill-ink: #14120f;
    --sel: rgba(236, 228, 211, 0.22);
    --cover-filter: grayscale(1) sepia(0.42) contrast(1.04) brightness(0.9);
  --thumb-lift: brightness(1.35) contrast(0.94);

    --tok-com: #625c50;
    --tok-kw: #ece4d3;
    --tok-str: #c2ac86;
    --tok-num: #cbb083;
    --tok-fn: #b9b2a0;
    --tok-type: #d8c39a;
  }
}

/* ---- Base ---- */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.4rem);
  scrollbar-color: var(--ink-3) transparent;
}

/* Lenis smooth-scroll compat (scroll.js skips Lenis under reduced motion,
   leaving the native smooth behaviour above). */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fine film grain over the whole page — the duotone/print texture. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--grain);
  opacity: var(--grain-o);
  mix-blend-mode: var(--grain-blend);
  pointer-events: none;
}

.wrap {
  max-width: var(--frame);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Vertical page rules — a fixed frame drawn down the whole viewport, so the
   content reads as a ruled "newspaper" page. Hidden on small screens. */
.page-frame {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, var(--frame));
  border-inline: 1px solid var(--line-2);
  pointer-events: none;
  z-index: 0;
}

/* Reading pages (posts, about) are a centred column — drop the wide frame. */
body.is-page .page-frame {
  display: none;
}

.site-main {
  flex: 1 0 auto;
  padding-top: calc(var(--header-h) + clamp(3rem, 7vh, 5.5rem));
  padding-bottom: clamp(3rem, 6vh, 5rem);
}

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

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

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* ---- Shared bits ---- */

/* [↗] arrow in a bordered box — the "open / read" affordance. */
.arrow-box {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--line);
  color: var(--ink);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.arrow-box::before {
  content: "";
  width: 46%;
  height: 46%;
  background: currentColor;
  -webkit-mask: var(--arrow-ne) center / contain no-repeat;
  mask: var(--arrow-ne) center / contain no-repeat;
  transition: transform 0.25s ease;
}

/* The ↗ leans toward its corner when the cell is hovered. */
.entry:hover .arrow-box::before {
  transform: translate(9%, -9%);
}

/* Solid fill button (cream on dark / dark on cream), mono uppercase. */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.85em 1.6em;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--fill-ink);
  background: var(--fill);
  border: 1px solid var(--fill);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Hover = the fill state flips (solid → outline, ghost → filled). */
.button:hover {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.button--ghost {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.button--ghost:hover {
  background: var(--fill);
  color: var(--fill-ink);
  border-color: var(--fill);
}

.button-arrow {
  font-size: 1.15em;
  line-height: 0;
}

/* ---- Accessibility ---- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--fill);
  color: var(--fill-ink);
  padding: 0.7em 1.2em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.skip-link:focus {
  left: 0;
}

/* ---- Masthead: slim bar — ✶ wordmark left, mono nav + toggle right ---- */

.masthead {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;
}

.mast-bar {
  position: relative;
  min-height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line-2);
  transition: border-color 0.3s ease;
}

.masthead.is-condensed .mast-bar {
  border-bottom-color: var(--line);
}

/* Reading-progress hairline (posts). */
.mast-bar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 0;
  z-index: 2;
  background: var(--ink);
  transition: width 0.1s linear;
}

body.is-post .mast-bar::after {
  width: calc(var(--progress, 0) * 100%);
}

.mast-inner {
  display: flex;
  align-items: center;
  gap: 0.5rem 2.25rem;
  max-width: var(--frame);
  min-height: var(--header-h);
  margin-inline: auto;
  padding: 0.4rem var(--gutter);
}

/* Wordmark = the ANIMATED 3D pixel computer + the site title in Paprika
   (the user's pick, by name). Un-boxed; everything is --ink / currentColor
   so the whole lockup follows the theme. (Killed lockups — don't
   relitigate: boxed square, glass chip, solid fill, Silkscreen, Workbench,
   Sixtyfour, Rubik Broken Fax, the ✶+Redaction-italic detour, a FLAT
   laptop, and a dither-shaded CRT — the depth plane must be a separate
   DIMMER layer, not dither.) */
.mast-title {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  color: var(--ink);
  font-family: var(--font-word);
  font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: color 0.2s ease;
}

.mast-title:hover {
  color: var(--ink-2);
}

/* The 3D pixel computer: ::before = dim DEPTH planes (top + side), ::after =
   full-ink FRONT face, .mast-screen = two typing text-lines on the screen.
   All currentColor, so it re-inks with the theme and the hover dim. */
.mast-mark {
  position: relative;
  flex: none;
  width: 1.35em;
  height: 1.25em;
}

.mast-mark::before,
.mast-mark::after {
  content: "";
  position: absolute;
  inset: 0;
}

.mast-mark::before {
  background: color-mix(in srgb, currentColor 42%, transparent);
  -webkit-mask: var(--computer-depth) center / 100% 100% no-repeat;
  mask: var(--computer-depth) center / 100% 100% no-repeat;
}

.mast-mark::after {
  background: currentColor;
  -webkit-mask: var(--computer-front) center / 100% 100% no-repeat;
  mask: var(--computer-front) center / 100% 100% no-repeat;
}

/* The screen types two mono lines, holds, clears, and starts over — stepped
   so it stays pixel-true. Under reduced motion the animation is globally
   killed and the base width leaves the lines statically drawn. */
.mast-screen {
  position: absolute;
  left: 15.4%;
  top: 33.4%;
  width: 53.8%;
  height: 8.3%;
  background: currentColor;
  box-shadow: 0 0.21em 0 0 currentColor;
  animation: mark-type 5.2s step-end infinite;
}

@keyframes mark-type {
  0% { width: 0; }
  7% { width: 15.4%; }
  14% { width: 30.8%; }
  21% { width: 46.2%; }
  28% { width: 53.8%; }
  74% { width: 53.8%; }
  80% { width: 0; }
  100% { width: 0; }
}

/* Nav + toggle sit together on the RIGHT (user's ask). */
.site-nav {
  margin-left: auto;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.25rem 1.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item a {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-2);
  transition: color 0.2s ease;
}

.nav-item a:hover,
.nav-item a:focus-visible {
  color: var(--ink);
}

.nav-item a[aria-current="page"] {
  color: var(--ink);
}

/* A hairline slides in from the left on hover; it stays put under the
   current page's link. */
.nav-item a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.45em;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.nav-item a:hover::after,
.nav-item a[aria-current="page"]::after {
  transform: scaleX(1);
}

/* ---- Theme toggle: a mono bordered box (always visible with JS) ---- */

.theme-toggle {
  flex: none;
  width: 2.3rem;
  height: 2.3rem;
  display: none;
  place-items: center;
  font-size: 0.9rem;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

:root.js .theme-toggle {
  display: grid;
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.toggle-glyph {
  display: block;
  line-height: 1;
  transition: transform 0.5s cubic-bezier(0.3, 1.1, 0.4, 1);
}

:root[data-theme="dark"] .toggle-glyph {
  transform: rotate(180deg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toggle-glyph {
    transform: rotate(180deg);
  }
}

/* ---- Kickers & section labels (mono uppercase) ---- */

.kicker {
  margin: 0 0 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.kicker:empty {
  display: none;
}

.kicker a {
  color: var(--ink);
  text-decoration: none;
}

.kicker a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.kicker-sep {
  margin: 0 0.5em;
  color: var(--ink-3);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin: 0 0 1.8rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.section-label::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  background: currentColor;
  -webkit-mask: var(--star) center / contain no-repeat;
  mask: var(--star) center / contain no-repeat;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---- Home hero ---- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  align-items: end;
  align-content: end;
  gap: 1.6rem var(--gutter);
  min-height: clamp(16rem, 40vh, 24rem);
  padding: clamp(1.5rem, 4vh, 3rem) 0 clamp(3rem, 7vh, 5rem);
  border-bottom: 1px solid var(--line);
}

.hero-lead {
  grid-column: 1;
  font-family: var(--font-display);
  font-size: var(--size-display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.004em;
  color: var(--ink);
}

.hero-lead p {
  margin: 0 0 0.2em;
}

.hero-lead em {
  font-style: italic;
}

.hero-aside {
  grid-column: 2;
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 0.4rem;
}

.hero-aside .kicker {
  margin: 0;
}

.hero-note {
  margin: 0;
  max-width: 26ch;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

/* ---- Post index: a grid of bordered cells (the "subtle squares") ---- */

.post-feed {
  margin-top: clamp(3rem, 7vh, 5.5rem);
}

/* NOCTRA mosaic: small base unit, dense auto-flow so cells backfill any gap
   the wide cells open — the grid re-arranges ("heals") on its own at every
   width. The newest post and every 7th entry become DOUBLE-WIDE feature
   cells; everything else stays a compact module (no desc, no tags). Rows
   stay flush because the cover thumb flex-grows to absorb height slack. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  grid-auto-flow: dense;
  gap: clamp(0.8rem, 1.6vw, 1.4rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cards > .entry:first-child,
.cards > .entry:nth-child(6n) {
  grid-column: span 2;
}

.cards > .entry:first-child .entry-thumb,
.cards > .entry:nth-child(6n) .entry-thumb {
  aspect-ratio: 16 / 9;
}

.cards > .entry:first-child .entry-title,
.cards > .entry:nth-child(6n) .entry-title {
  font-size: clamp(1.4rem, 1.15rem + 0.8vw, 1.9rem);
}

.cards > .entry:first-child .entry-desc,
.cards > .entry:nth-child(6n) .entry-desc {
  display: block;
  max-width: 58ch;
}

.cards > .entry:first-child .entry-tag,
.cards > .entry:nth-child(6n) .entry-tag {
  display: inline;
}

.entry {
  border: 1px solid var(--line);
  transition: border-color 0.25s ease, background 0.25s ease;
}

.entry:hover {
  border-color: var(--ink-3);
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.entry-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

/* The thumb is the cell's elastic part: aspect-ratio sets its resting height,
   flex-grow lets it stretch when a mosaic row runs taller — that slack is
   what keeps every row edge flush. The img is absolutely-positioned cover
   fill so it simply shows more picture as the thumb grows. */
.entry-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  flex: 1 0 auto;
  overflow: hidden;
  border-bottom: 1px solid var(--line-2);
}

.entry-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: var(--cover-filter) var(--thumb-lift);
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.6s ease;
}

.entry:hover .entry-thumb img {
  transform: scale(1.05);
  filter: grayscale(1) sepia(0.12) contrast(1.02) brightness(1.08) var(--thumb-lift);
}

.entry-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem var(--cell-pad) 1rem;
}

/* Coverless cell: let the text block take the slack instead of a thumb —
   and since there is room, surface the description too. */
.entry-meta + .entry-body {
  flex: 1 0 auto;
}

.entry-meta + .entry-body .entry-desc {
  display: block;
}

/* Meta = the ruled caption bar CAPPING the cell (NOCTRA card order):
   [01] + date (+ tags on features) cluster left, the [↗] holds the right
   corner as the open affordance. */
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.8rem;
  padding: 0.5rem 0.55rem 0.5rem var(--cell-pad);
  border-bottom: 1px solid var(--line-2);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.entry-meta .arrow-box {
  width: 1.8rem;
  height: 1.8rem;
  margin-left: auto;
}

.entry-tag {
  display: none;
  color: inherit;
}

.entry-idx::before {
  content: "[";
}

.entry-idx::after {
  content: "]";
}

.entry-title {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.entry-desc {
  display: none;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.72;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.entry:hover .arrow-box {
  background: var(--fill);
  color: var(--fill-ink);
  border-color: var(--fill);
}

.more-link {
  margin: 2.75rem 0 0;
}

/* ---- List page header ---- */

.list-header {
  padding-bottom: 2.5rem;
  margin-bottom: clamp(2rem, 5vh, 3rem);
  border-bottom: 1px solid var(--line);
}

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.4rem 3rem;
}

.list-head-aside {
  max-width: 34ch;
  padding-bottom: 0.4rem;
}

.list-head-aside .prose,
.list-lede {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.list-sort {
  display: inline-block;
  margin: 1rem 0 0;
  padding: 0.55em 0.9em;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* Archive span stamp, e.g. "JUL 2026" or "MAR 2024 — JUL 2026". */
.list-range {
  margin: 0.9rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.list-sort::before {
  content: "↓ ";
}

.list-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--size-display);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.005em;
  color: var(--ink);
}

.list-header .prose {
  margin-top: 1.2rem;
}

/* ---- Single post / page: a centred reading column ---- */

.post {
  max-width: 45rem;
  margin-inline: auto;
}

.post-head {
  padding: 0.5rem 0 2.25rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--line);
}

.post-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--size-display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.004em;
  color: var(--ink);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
  margin: 1.4rem 0 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.tag-row a {
  color: var(--ink-3);
  text-decoration: none;
  transition: color 0.2s ease;
}

.tag-row a:hover {
  color: var(--ink);
}

/* Cover → a duotone hero with the title FUSED over it: the image melts into
   the page through a bottom gradient to --bg, and the title sits in that
   fusion zone (a bg-coloured glow keeps it legible over any cover). */
.post-hero {
  position: relative;
  margin: 0 0 1.75rem;
  min-height: clamp(17rem, 42vh, 28rem);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  border: 1px solid var(--line);
}

.post-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 36%;
  z-index: 0;
  filter: var(--cover-filter);
}

.post-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, var(--bg) 0%, var(--bg) 26%, color-mix(in srgb, var(--bg) 50%, transparent) 48%, transparent 76%);
}

/* corner registration ticks on the hero */
.post-hero::before {
  content: "";
  position: absolute;
  inset: 0.7rem;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(var(--ink) 0 0) left top / 8px 1px no-repeat,
    linear-gradient(var(--ink) 0 0) left top / 1px 8px no-repeat,
    linear-gradient(var(--ink) 0 0) right top / 8px 1px no-repeat,
    linear-gradient(var(--ink) 0 0) right top / 1px 8px no-repeat,
    linear-gradient(var(--ink) 0 0) left bottom / 8px 1px no-repeat,
    linear-gradient(var(--ink) 0 0) left bottom / 1px 8px no-repeat,
    linear-gradient(var(--ink) 0 0) right bottom / 8px 1px no-repeat,
    linear-gradient(var(--ink) 0 0) right bottom / 1px 8px no-repeat;
  opacity: 0.5;
}

.post-hero-inner {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0 1.6rem 1.5rem;
}

/* Date · reading time on top, tags on their own line below (so a long tag list
   never clashes with the date) — BELOW the picture, ruled off from prose. */
.post-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
  padding-bottom: 2rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--line);
}

.post-meta .kicker,
.post-meta .tag-row {
  margin: 0;
}

.post-meta .tag-row {
  gap: 0.5rem 0.6rem;
}

.post-meta .tag-row a {
  display: inline-block;
  padding: 0.32em 0.75em;
  border: 1px solid var(--line-2);
  color: var(--ink-2);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.post-meta .tag-row a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* The fused title — sits over the cover/melt zone, legible via a bg glow. */
.post-title--fused {
  color: var(--ink);
  text-shadow:
    0 2px 22px var(--bg),
    0 0 6px color-mix(in srgb, var(--bg) 78%, transparent),
    0 1px 2px color-mix(in srgb, var(--bg) 60%, transparent);
}

.post-content {
  max-width: 100%;
  margin-top: 0;
}

/* Newer / older travel between posts: a ruled two-cell row (renders only
   when a neighbour exists). */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  margin-top: 4rem;
}

.post-nav-cell {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.1rem 1.3rem 1.2rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s ease;
}

.post-nav-cell:hover {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.post-nav-cell--older {
  grid-column: 2;
  border-left: 1px solid var(--line);
  text-align: right;
  align-items: flex-end;
}

.post-nav-label {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.post-nav-title {
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
}

.post-end {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.post-nav + .post-end {
  margin-top: 2.5rem;
}

.post-end-rule {
  display: none;
}

/* ---- Prose (reading body = Geologica; serif headings; mono h4 label) ---- */

.prose {
  max-width: var(--measure);
  font-family: var(--font-body);
  font-size: 1.15rem;
  line-height: 1.75;
  color: var(--ink);
}

/* The article/page reading column fills its centred `.post` wrapper. */
.post-content.prose {
  max-width: 100%;
}

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

.prose p {
  margin: 0 0 1.3em;
  overflow-wrap: break-word;
}

.prose a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-3);
  transition: text-decoration-color 0.2s ease;
}

.prose a:hover {
  text-decoration-color: var(--ink);
}

.prose h2 {
  margin: 2.4em 0 0.7em;
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-size: 1.9rem;
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.prose h3 {
  margin: 2em 0 0.6em;
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
}

.prose h4 {
  margin: 2em 0 0.6em;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.prose strong {
  font-weight: 680;
  color: var(--ink);
}

.prose ul,
.prose ol {
  margin: 0 0 1.3em;
  padding-left: 1.3em;
}

.prose li {
  margin: 0.4em 0;
}

.prose li::marker {
  color: var(--ink-3);
}

.prose blockquote {
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.5em;
  border-left: 2px solid var(--line);
  font-family: var(--font-serif);
  font-optical-sizing: auto;
  font-style: italic;
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--ink-2);
}

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

.prose code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  background: var(--bg-2);
  padding: 0.13em 0.38em;
}

.prose pre {
  margin: 0;
  padding: 1.15rem 1.3rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
  border: 1px solid var(--line);
  background: var(--bg-2);
  overflow-x: auto;
  scrollbar-width: thin;
}

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

.prose .highlight {
  margin: 1.8em 0;
}

.prose img {
  display: block;
  margin: 2em auto;
  border: 1px solid var(--line);
  filter: var(--cover-filter);
}

.prose figcaption {
  margin-top: 0.8em;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-2);
}

.prose hr {
  border: 0;
  height: 1px;
  margin: 3em 0;
  background: var(--line);
}

.prose table {
  display: block;
  width: 100%;
  margin: 2em 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border-collapse: collapse;
  overflow-x: auto;
}

.prose th {
  padding: 0.6em 0.9em;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink-2);
  border-bottom: 1px solid var(--ink-3);
}

.prose td {
  padding: 0.6em 0.9em;
  border-bottom: 1px solid var(--line);
}

.footnotes {
  margin-top: 3em;
  font-size: 0.9rem;
  color: var(--ink-2);
}

/* ---- Syntax highlighting (warm monochrome / sepia) ---- */

.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1,
.chroma .cs, .chroma .cp, .chroma .cpf, .chroma .cd { color: var(--tok-com); font-style: italic; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn,
.chroma .kp, .chroma .kr { color: var(--tok-kw); font-weight: 600; }
.chroma .kt { color: var(--tok-type); }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl,
.chroma .sd, .chroma .s2, .chroma .se, .chroma .sh, .chroma .si,
.chroma .sx, .chroma .sr, .chroma .s1, .chroma .ss { color: var(--tok-str); }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh,
.chroma .mi, .chroma .il, .chroma .mo { color: var(--tok-num); }
.chroma .nf, .chroma .fm { color: var(--tok-fn); }
.chroma .nc, .chroma .nn, .chroma .nt, .chroma .na { color: var(--tok-type); }
.chroma .o, .chroma .ow, .chroma .p { color: var(--ink-2); }
.chroma .err { color: inherit; }

/* ---- Footer ---- */

.site-footer {
  flex: none;
  margin-top: clamp(3.5rem, 8vh, 6rem);
  border-top: 1px solid var(--line);
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.9rem 2.1rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.site-footer a {
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.site-footer a:hover {
  color: var(--ink);
}

.site-footer-right {
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

/* [RSS] speaks the bracket voice; ↑ TOP is a boxed control (smooth-scroll
   anchor — no JS needed). */
.site-footer .rss::before {
  content: "[";
}

.site-footer .rss::after {
  content: "]";
}

.top-link {
  display: inline-block;
  padding: 0.5em 0.9em;
  border: 1px solid var(--line);
}

.top-link:hover {
  background: var(--fill);
  color: var(--fill-ink);
  border-color: var(--fill);
}

/* ---- 404 ---- */

.notfound {
  padding: 5rem 0;
  text-align: center;
}

.notfound-code {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(5rem, 22vw, 9rem);
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
  opacity: 0.18;
}

.notfound-title {
  margin: 0.5rem 0 1.5rem;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  color: var(--ink);
}

/* ---- Entrance: a quiet rise ---- */

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.reveal {
  animation: rise 0.6s cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.post-content > * {
  animation: rise 0.5s cubic-bezier(0.22, 0.7, 0.3, 1) both;
  animation-delay: 0.35s;
}

.post-content > *:nth-child(1) { animation-delay: 0.06s; }
.post-content > *:nth-child(2) { animation-delay: 0.11s; }
.post-content > *:nth-child(3) { animation-delay: 0.16s; }
.post-content > *:nth-child(4) { animation-delay: 0.21s; }
.post-content > *:nth-child(5) { animation-delay: 0.26s; }
.post-content > *:nth-child(6) { animation-delay: 0.3s; }

.entry {
  animation: rise 0.55s cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.entry:nth-child(1) { animation-delay: 0.04s; }
.entry:nth-child(2) { animation-delay: 0.09s; }
.entry:nth-child(3) { animation-delay: 0.14s; }
.entry:nth-child(4) { animation-delay: 0.19s; }
.entry:nth-child(5) { animation-delay: 0.24s; }
.entry:nth-child(6) { animation-delay: 0.28s; }
.entry:nth-child(7) { animation-delay: 0.32s; }
.entry:nth-child(8) { animation-delay: 0.36s; }

/* ---- Responsive ---- */

/* Hide the ruled page-frame once the viewport is narrower than the frame
   (otherwise the rules would just hug the screen edges). */
@media (max-width: 76rem) {
  .page-frame {
    display: none;
  }
}

/* Stack the newspaper hero into one column — and box it into a MODULE, with
   the aside ruled off as a sub-cell (NOCTRA's mobile modularity). */
@media (max-width: 780px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 1.2rem;
    min-height: 0;
    border: 1px solid var(--line);
    padding: 1.5rem 1.2rem 1.4rem;
  }

  .hero-aside {
    grid-column: 1;
    align-self: start;
    border-top: 1px solid var(--line-2);
    padding-top: 1.1rem;
    padding-bottom: 0;
  }

  .hero-note {
    max-width: none;
  }

  .section-label {
    border-block: 1px solid var(--line-2);
    padding-block: 0.7rem;
    margin-bottom: 1.2rem;
  }
}

/* Mobile header: two rows — wordmark + toggle, then the nav. */
/* Mobile: keep the header a SINGLE row (wordmark left, nav + toggle right) —
   just shrink the pieces so it fits, rather than dropping the nav to a row. */
@media (max-width: 600px) {
  .mast-inner {
    gap: 0.35rem 0.7rem;
    padding-inline: 1rem;
  }

  .mast-title {
    font-size: 1.05rem;
  }

  .site-nav ul {
    gap: 0.15rem 0.7rem;
  }

  .nav-item a {
    font-size: 0.62rem;
    letter-spacing: 0.09em;
  }

  .theme-toggle {
    width: 2.1rem;
    height: 2.1rem;
  }

  .post-hero {
    min-height: clamp(13rem, 44vh, 20rem);
  }

  .site-main {
    padding-top: calc(var(--header-h) + 1.5rem);
    padding-bottom: 2rem;
  }

  .hero {
    padding: 1.25rem 1.1rem 1.3rem;
  }

  .post-feed {
    margin-top: 1.75rem;
  }

  .list-header {
    padding-bottom: 1.6rem;
    margin-bottom: 1.5rem;
  }

  /* NOCTRA phone mosaic: two compact modules per row; features span both.
     Phone features re-phase to 1, 6, 11… (5n+1 — always 4 compacts between)
     so the 2-col grid packs with NO index reordering; the desktop 6n
     features demote back to compact here. */
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .cards > .entry:nth-child(6n) {
    grid-column: auto;
  }

  .cards > .entry:nth-child(6n) .entry-thumb {
    aspect-ratio: 4 / 3;
  }

  .cards > .entry:nth-child(6n) .entry-title {
    font-size: 1rem;
  }

  .cards > .entry:nth-child(6n) .entry-desc,
  .cards > .entry:nth-child(6n) .entry-tag,
  .cards > .entry:nth-child(6n) .entry-meta time {
    display: none;
  }

  .cards > .entry:nth-child(5n+1) {
    grid-column: span 2;
  }

  .cards > .entry:nth-child(5n+1) .entry-thumb {
    aspect-ratio: 16 / 9;
  }

  .cards > .entry:nth-child(5n+1) .entry-title {
    font-size: clamp(1.4rem, 1.15rem + 0.8vw, 1.9rem);
  }

  .cards > .entry:nth-child(5n+1) .entry-desc {
    display: block;
  }

  .cards > .entry:nth-child(5n+1) .entry-tag,
  .cards > .entry:nth-child(5n+1) .entry-meta time {
    display: inline;
  }

  .entry-meta {
    gap: 0.3rem 0.55rem;
    padding-left: 0.7rem;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
  }

  /* Phone compact cells shed the date (NOCTRA's small modules keep only the
     index + the [↗]); the wide feature cells (5n+1 on phones) keep it. */
  .entry-meta time {
    display: none;
  }

  .cards > .entry:nth-child(5n+1) .entry-meta time {
    display: inline;
  }

  .entry-meta .arrow-box {
    width: 1.6rem;
    height: 1.6rem;
  }

  .entry-title {
    font-size: 1rem;
  }

  .entry-body {
    gap: 0.4rem;
    padding: 0.7rem 0.7rem 0.85rem;
  }

  .post-meta {
    padding-bottom: 1.5rem;
    margin-bottom: 1.75rem;
  }

  .site-footer {
    margin-top: 2.5rem;
  }
}

/* ---- Reduced motion ---- */

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

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
