/* ============================================================
   Site design system
   Dark throughout. Near-black base, teal→cyan→violet accents.
   ============================================================ */

:root {
  /* surfaces */
  --bg-0: #04060c;
  --bg-1: #080c16;
  --bg-2: #0d1322;
  --bg-3: #131b2f;

  /* ink */
  --ink: #f4f7fd;
  --ink-dim: #c0c9da;
  --ink-faint: #9aa7c4;

  /* accent family */
  --teal: #2dd4bf;
  --cyan: #22d3ee;
  --violet: #818cf8;
  --pink: #f472b6;
  --amber: #fbbf24;
  --accent: var(--teal);

  --grad: linear-gradient(100deg, var(--teal), var(--cyan) 50%, var(--violet));

  /* lines */
  --line: rgba(140, 160, 200, 0.12);
  --line-strong: rgba(140, 160, 200, 0.22);

  /* type */
  --font-display: 'Space Grotesk Variable', 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter Variable', 'Inter', system-ui, sans-serif;

  /* glow */
  --glow-teal: 0 0 24px rgba(45, 212, 191, 0.35);
  --glow-cyan: 0 0 24px rgba(34, 211, 238, 0.35);
  --glow-violet: 0 0 24px rgba(129, 140, 248, 0.35);

  --radius: 16px;
  --header-h: 56px;

  /* Themeable surface hooks — blog themes (data-blog-theme) override these to
     reskin the fixed chrome without touching component CSS. Defaults reproduce
     today's dark "observatory" look exactly, so an unset/observatory theme is
     byte-for-byte unchanged. */
  --header-bg: rgba(4, 6, 12, 0.72);
  --header-blur: blur(14px);
  --header-border: var(--line);
  --selection-bg: rgba(34, 211, 238, 0.3);
  --scrim-text-shadow:
    0 0 14px rgba(4, 6, 12, 0.9),
    0 2px 28px rgba(4, 6, 12, 0.85),
    0 0 60px rgba(34, 211, 238, 0.18);
  --masthead-ink: #ffffff;
  --masthead-shadow:
    0 2px 6px rgba(4, 6, 12, 0.95),
    0 6px 30px rgba(4, 6, 12, 0.9),
    0 0 50px rgba(34, 211, 238, 0.45),
    0 0 110px rgba(34, 211, 238, 0.25);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }

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

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #1d2840; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }

/* ---------- layout ---------- */
.container { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }
.section { padding-block: clamp(1.2rem, 3vw, 2.2rem); position: relative; }

/* ---------- typography ---------- */
.display {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.eyebrow {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cyan);
}

.lead { font-size: clamp(1.02rem, 1.6vw, 1.18rem); color: var(--ink-dim); max-width: 56ch; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.01em; }

.section-title { font-size: clamp(1.45rem, 3vw, 2.05rem); font-weight: 700; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.9rem 1.4rem; margin-bottom: 0.9rem; }
.section-head .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); min-width: 60px; }

/* crisp headlines over busy/animated backgrounds */
.scrim-text {
  text-shadow: var(--scrim-text-shadow);
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 100;
  height: var(--header-h);
  display: flex; align-items: center;
  background: var(--header-bg);
  backdrop-filter: var(--header-blur);
  -webkit-backdrop-filter: var(--header-blur);
  border-bottom: 1px solid var(--header-border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  color: var(--ink); /* single colour — no dot, no gradient */
  transition: opacity 0.2s;
}
.logo:hover { opacity: 0.85; }

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

/* Header theme dropdown — prominent "Choose theme" control (footer chooser still exists). */
.theme-menu { position: relative; flex: none; margin-left: 0.85rem; }
.theme-menu-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(140, 160, 200, 0.06); border: 1px solid var(--line);
  color: var(--ink-dim); font: 600 0.78rem var(--font-display); letter-spacing: 0.02em;
  padding: 0.42em 0.72em; border-radius: 99px; cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.theme-menu-btn:hover { color: var(--ink); border-color: var(--line-strong); background: rgba(140, 160, 200, 0.1); }
.theme-menu-btn svg:first-child { color: var(--accent); }
.theme-menu-caret { opacity: 0.65; transition: transform 0.2s; }
.theme-menu-btn[aria-expanded="true"] .theme-menu-caret { transform: rotate(180deg); }
.theme-menu-panel {
  position: absolute; right: 0; top: calc(100% + 0.5rem);
  display: flex; flex-direction: column; gap: 0.12rem; min-width: 158px; z-index: 200;
  background: rgba(8, 12, 22, 0.97); border: 1px solid var(--line); border-radius: 12px; padding: 0.35rem;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.theme-menu-panel[hidden] { display: none; }
.theme-menu-panel button {
  text-align: left; background: transparent; border: 0; color: var(--ink-dim);
  font: 500 0.86rem var(--font-display); padding: 0.5em 0.7em; border-radius: 8px; cursor: pointer;
}
.theme-menu-panel button:hover { background: rgba(140, 160, 200, 0.1); color: var(--ink); }
.theme-menu-panel button[aria-pressed="true"] { color: var(--bg-0); background: var(--grad); font-weight: 700; }
.site-nav a {
  font-family: var(--font-display);
  font-size: 0.92rem;
  color: var(--ink-dim);
  padding: 0.45em 0.85em;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s;
}
.site-nav a:hover { color: var(--ink); background: rgba(140, 160, 200, 0.08); }
.site-nav a[aria-current="page"] { color: var(--ink); position: relative; }
.site-nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0.85em; right: 0.85em; bottom: 0.18em;
  height: 2px; border-radius: 2px; background: var(--grad);
  box-shadow: var(--glow-cyan);
}

/* hamburger + mobile quick-row: hidden on desktop (full nav is inline) */
.nav-toggle {
  display: none;
  width: 42px; height: 42px; padding: 0; flex: 0 0 auto;
  align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line-strong); border-radius: 11px;
  color: var(--ink-dim); cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-toggle:hover { color: var(--ink); border-color: var(--ink-faint); }
.nav-toggle svg { width: 22px; height: 22px; stroke: currentColor; }
.nav-primary { display: none; }

@media (max-width: 640px) {
  /* Mobile: ONE quick-access row (primary items) under a logo+hamburger top row.
     The hamburger holds the full menu. Two header rows → bump --header-h. */
  :root { --header-h: 104px; }
  .site-header { height: auto; min-height: var(--header-h); }
  .site-header .container {
    flex-wrap: wrap; align-items: center; row-gap: 0.45rem;
    padding-top: 0.5rem; padding-bottom: 0.5rem;
  }
  .logo { order: 1; flex: 1 1 auto; text-align: left; }
  .nav-toggle { display: inline-flex; order: 3; }
  /* show the theme switcher in the top bar on mobile too (compact: palette icon + caret) */
  .theme-menu { display: block; order: 2; margin: 0 0.4rem 0 0; }
  .theme-menu-btn { padding: 0.42em 0.55em; }
  .theme-menu-label { display: none; }   /* icon + caret only on mobile */
  .theme-menu-panel { right: 0; min-width: 150px; }

  /* the single visible row of primary items */
  .nav-primary {
    order: 3; width: 100%;
    display: flex; flex-wrap: nowrap; justify-content: center; gap: 0.15rem;
  }
  .nav-primary a {
    font-family: var(--font-display); font-size: 0.86rem;
    color: var(--ink-dim); padding: 0.38em 0.6em; border-radius: 10px;
    white-space: nowrap; transition: color 0.2s, background 0.2s;
  }
  .nav-primary a:hover { color: var(--ink); background: rgba(140, 160, 200, 0.08); }
  .nav-primary a[aria-current="page"] { color: var(--ink); }

  /* full menu becomes the hamburger dropdown */
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0.1rem;
    margin: 0; padding: 0.5rem 1.1rem 0.9rem;
    background: rgba(5, 7, 13, 0.985);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    opacity: 0; pointer-events: none; transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
  .site-nav.open { opacity: 1; pointer-events: auto; transform: none; }
  .site-nav a { font-size: 0.98rem; padding: 0.62em 0.7em; }
  .site-nav a[aria-current="page"]::after { display: none; }
}

/* push content below fixed header */
main { padding-top: var(--header-h); }

/* ---------- reading progress ---------- */
.progress-bar {
  position: fixed; top: 0; left: 0; z-index: 110;
  height: 3px; width: 100%;
  background: var(--grad);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.5);
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.55em;
  font-family: var(--font-display); font-weight: 600; font-size: 0.95rem;
  padding: 0.75em 1.5em; border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.25s, background 0.25s, border-color 0.25s;
}
.btn-primary {
  background: var(--grad); color: #04121a;
  box-shadow: 0 4px 24px rgba(34, 211, 238, 0.28);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 34px rgba(34, 211, 238, 0.42); }
.btn-ghost {
  border: 1px solid rgba(140, 160, 200, 0.45); color: var(--ink);
  background: rgba(140, 160, 200, 0.16);
}
.btn-ghost:hover { border-color: var(--cyan); box-shadow: var(--glow-cyan); transform: translateY(-2px); }
.btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

/* ---------- cards ---------- */
.card {
  position: relative;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.card.ring:hover, .card[data-tilt]:hover {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), var(--glow-cyan);
}
[data-tilt] { transform-style: preserve-3d; will-change: transform; }

/* ---------- marquee ---------- */
.marquee {
  overflow: hidden; position: relative;
  border-block: 1px solid var(--line);
  background: rgba(8, 12, 22, 0.6);
  padding-block: 0.85rem;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track {
  display: flex; gap: 2.6rem; width: max-content;
  animation: marquee 38s linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-item {
  display: flex; align-items: center; gap: 2.6rem;
  font-family: var(--font-display); font-size: 0.86rem; letter-spacing: 0.08em;
  color: var(--ink-dim); white-space: nowrap; text-transform: uppercase;
}
.marquee-item .dot-sep { color: var(--cyan); text-shadow: var(--glow-cyan); font-size: 0.7rem; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; flex-wrap: wrap; width: auto; }
}

/* ---------- ambient orbs ---------- */
.orbs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.orb-a { width: 480px; height: 480px; background: rgba(45, 212, 191, 0.14); top: -120px; right: -100px; }
.orb-b { width: 420px; height: 420px; background: rgba(129, 140, 248, 0.13); bottom: -140px; left: -120px; }
.orb-c { width: 320px; height: 320px; background: rgba(34, 211, 238, 0.10); top: 40%; left: 55%; }

/* ---------- grid texture ---------- */
.grid-lines {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image:
    linear-gradient(rgba(140, 160, 200, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(140, 160, 200, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, #000 30%, transparent 75%);
}

/* ---------- post cards ---------- */
.post-card {
  display: block; position: relative;
  padding: 1.15rem 1.3rem 1.15rem 1.55rem;
  /* per-post colour: a low-opacity wash of the card's own accent over the dark
     base so the tile grid reads varied yet stays dark-cohesive and legible. Row
     layouts (index/newspaper/timeline/terminal/headlines) reset background to
     none, so the tint only shows on the tile layouts (Reader/Cards/Magazine). */
  background:
    linear-gradient(155deg, color-mix(in srgb, var(--card-accent, var(--teal)) 34%, transparent), transparent 74%),
    linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid color-mix(in srgb, var(--card-accent, var(--teal)) 44%, var(--line));
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.post-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--card-accent, var(--teal));
  box-shadow: 0 0 14px var(--card-accent, var(--teal));
  opacity: 0.85; transition: width 0.25s;
}
.post-card:hover {
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5), 0 0 30px rgba(34, 211, 238, 0.12);
  transform: translateY(-3px);
}
.post-card:hover::before { width: 5px; }
.post-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.85rem;
  font-family: var(--font-display); font-size: 0.78rem;
  color: var(--ink-faint); letter-spacing: 0.05em;
}
.post-card h3 { font-size: 1.12rem; margin-top: 0.3rem; color: var(--ink); }
.post-card p {
  margin-top: 0.35rem; color: var(--ink-dim); font-size: 0.9rem; max-width: 64ch;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tag-chip {
  font-family: var(--font-display); font-size: 0.7rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--cyan);
  border: 1px solid rgba(34, 211, 238, 0.3); border-radius: 99px;
  padding: 0.18em 0.7em;
  background: rgba(34, 211, 238, 0.06);
}
.badge-interactive {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-family: var(--font-display); font-size: 0.7rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.35); border-radius: 99px;
  padding: 0.18em 0.7em; background: rgba(251, 191, 36, 0.07);
}
.badge-interactive::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 8px var(--amber);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 50% { opacity: 0.35; } }

/* ---------- topic sidebar ---------- */
/* Full-height left pane: pinned under the fixed header, scrolls on its own so the
   content column scrolls with the page independently. Subtle right hairline +
   thin scrollbar. Mobile (≤880px) resets this to static below. */
.topic-rail {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100dvh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding-top: 1.2rem; padding-right: 0.9rem;
  border-right: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: var(--bg-3) transparent;
}
.topic-rail::-webkit-scrollbar { width: 6px; }
.topic-rail::-webkit-scrollbar-track { background: transparent; }
.topic-rail::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 3px; }
.topic-rail::-webkit-scrollbar-thumb:hover { background: #1d2840; }
.topic-rail .rail-title {
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 1rem;
}
.topic-list { list-style: none; display: grid; gap: 0.15rem; }
.topic-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  width: 100%; text-align: left;
  font-family: var(--font-display); font-size: 0.95rem;
  color: var(--ink-dim); padding: 0.5em 0.8em; border-radius: 10px;
  border: 1px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.topic-btn:hover { color: var(--ink); background: rgba(140, 160, 200, 0.07); }
.topic-btn .count {
  font-size: 0.72rem; color: var(--ink-faint);
  border: 1px solid var(--line-strong); border-radius: 99px;
  padding: 0.05em 0.55em; min-width: 1.9em; text-align: center;
  transition: inherit;
}
.topic-btn.active {
  color: var(--ink);
  background: color-mix(in srgb, var(--cyan) 9%, transparent);
  border-color: color-mix(in srgb, var(--cyan) 38%, transparent);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--cyan) 7%, transparent), 0 0 14px color-mix(in srgb, var(--cyan) 12%, transparent);
}
.topic-btn.active .count { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); }
.topic-sub { list-style: none; margin: 0.1rem 0 0.35rem 1rem; display: grid; gap: 0.1rem; }
.topic-sub .topic-btn { font-size: 0.86rem; padding: 0.38em 0.8em; }

/* Reading templates restyle ONLY the reading surface. The Topics rail lives
   inside <article data-template>, so a template's colour-var overrides would
   otherwise cascade into the rail and make it illegible on its dark backing
   (e.g. Parchment's warm ink on the dark rail). Re-assert the normal dark
   palette on the rail under the recolouring templates so it stays readable.
   EXCLUDES the default 'observatory' template: under it the rail should inherit
   the active BLOG THEME's palette (so a light blog theme gets a legible light
   rail, not this hardcoded dark ink). */
article[data-template]:not([data-template="observatory"]) .topic-rail {
  --ink: #f4f7fd;
  --ink-dim: #c0c9da;
  --ink-faint: #9aa7c4;
  --teal: #2dd4bf;
  --cyan: #22d3ee;
  --violet: #818cf8;
  --line: rgba(140, 160, 200, 0.12);
  --line-strong: rgba(140, 160, 200, 0.22);
  --bg-3: #131b2f;
  color: var(--ink-dim);
}

/* ---------- chips: shared topic chip (archive filter row + constellation sub-row) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.5em;
  min-height: 38px; padding: 0.4em 0.95em;
  border-radius: 99px; border: 1px solid var(--line-strong);
  background: rgba(140, 160, 200, 0.06);
  color: var(--ink-dim);
  font-family: var(--font-display); font-size: 0.9rem; font-weight: 600;
  white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.chip:hover { color: var(--ink); background: rgba(140, 160, 200, 0.1); }
.chip .count {
  font-size: 0.72rem; color: var(--ink-faint);
  border: 1px solid var(--line-strong); border-radius: 99px;
  padding: 0.05em 0.55em; min-width: 1.9em; text-align: center;
  transition: inherit;
}
.chip.active {
  color: var(--ink);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  border-color: color-mix(in srgb, var(--cyan) 40%, transparent);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--cyan) 6%, transparent), 0 0 14px color-mix(in srgb, var(--cyan) 10%, transparent);
}
.chip.active .count { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); }

/* ---------- topic nav as a native <details> accordion ----------
   Desktop: always-open sidebar (toggle chrome hidden). Mobile: a collapsed,
   tappable "Topics ▾" bar that expands in place. JS in Base.astro syncs the
   open state across the 880px breakpoint. */
.topic-acc > summary { list-style: none; cursor: pointer; }
.topic-acc > summary::-webkit-details-marker { display: none; }
.topic-acc .acc-caret { transition: transform 0.2s; font-size: 1.05em; color: var(--cyan); line-height: 1; }
.topic-acc[open] > summary .acc-caret { transform: rotate(180deg); }

@media (min-width: 881px) {
  /* desktop: outer "Topics" behaves like a plain sidebar header — no toggle affordance.
     (Inner per-topic groups stay clickable — they're deeper than the direct child.) */
  .topic-acc > summary { pointer-events: none; }
  .topic-acc .acc-caret { display: none; }
}

/* per-topic collapsible group (Writing sidebar): broad topic shows, subs reveal on click */
.topic-group > summary {
  list-style: none; cursor: pointer;
  justify-content: flex-start; gap: 0.45rem;
}
.topic-group > summary::-webkit-details-marker { display: none; }
.topic-group > summary .count { margin-left: auto; }
.topic-group .grp-caret {
  order: -1; flex: 0 0 auto; font-size: 0.62em; line-height: 1;
  color: var(--ink-faint); transition: transform 0.2s;
}
.topic-group[open] > summary .grp-caret { transform: rotate(180deg); }

@media (max-width: 880px) {
  .topic-rail {
    position: static; margin-bottom: 0.5rem; height: auto;
    overflow: visible; padding: 0; border-right: none;
  }
  /* flat sub-lists (post-page TopicRail) stay hidden on mobile; grouped ones
     (Writing sidebar) collapse via their own <details>, so don't blanket-hide those. */
  .topic-list > li > .topic-sub { display: none; }
  /* the summary becomes a tappable bar */
  .topic-acc > summary {
    display: flex; align-items: center; justify-content: space-between;
    margin: 0; padding: 0.72em 0.95em;
    border: 1px solid var(--line-strong); border-radius: 12px;
    background: rgba(140, 160, 200, 0.05);
    color: var(--ink); font-size: 0.92rem; letter-spacing: 0.03em;
    text-transform: none; /* override .rail-title uppercasing */
  }
  .topic-acc[open] > summary {
    margin-bottom: 0.6rem;
    border-color: rgba(34, 211, 238, 0.32);
    background: rgba(34, 211, 238, 0.06);
  }
}

/* ---------- article ---------- */
.article-body {
  max-width: 68ch;
  font-size: 1.14rem;
  line-height: 1.78;
  color: #e9eef8;
  font-weight: 410;
}
.article-body > * + * { margin-top: 1.3em; }
.article-body h2 {
  font-size: 1.55rem; margin-top: 2.2em; color: var(--ink);
  padding-top: 1.2em; border-top: 1px solid var(--line);
}
.article-body h3 { font-size: 1.2rem; margin-top: 1.8em; color: var(--ink); }
.article-body a { color: var(--cyan); border-bottom: 1px solid rgba(34, 211, 238, 0.35); transition: border-color 0.2s, text-shadow 0.2s; }
.article-body a:hover { border-color: var(--cyan); text-shadow: 0 0 12px rgba(34, 211, 238, 0.5); }
.article-body strong { color: #ffffff; }
.article-body em { color: #cdd6e6; }
.article-body ul, .article-body ol { padding-left: 1.3em; }
.article-body li + li { margin-top: 0.45em; }
.article-body li::marker { color: var(--cyan); }
.article-body blockquote {
  border-left: 3px solid var(--violet); padding-left: 1.2em;
  color: var(--ink-dim); font-style: italic;
  box-shadow: inset 8px 0 24px -16px rgba(129, 140, 248, 0.4);
}
.article-body code {
  font-size: 0.88em; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.12em 0.4em;
}
.article-body pre { background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 1.1em 1.3em; overflow-x: auto; }
.article-body pre code { background: none; border: none; padding: 0; }
.article-body hr { border: none; height: 1px; background: var(--line-strong); }

/* ============================================================
   Parchment reading theme — the post opens as a warm light
   "sheet" centred on the dark site frame. Theme layer over the
   same block content; selected per-post via frontmatter `theme`.
   ============================================================ */
article[data-post-theme="parchment"] .article-grid {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}
article[data-post-theme="parchment"] .topic-rail { display: none; }
/* content column fills the single grid track; hero centres on the sheet above the body */
article[data-post-theme="parchment"] .article-col { width: 100%; }
article[data-post-theme="parchment"] .post-hero-inner { margin-inline: auto; }

article[data-post-theme="parchment"] .article-body {
  --parch-ink: #2f2618;
  --parch-soft: #5c4f3a;
  --parch-rule: #cdbb95;
  --parch-accent: #9a531f;
  width: 100%;
  max-width: 74ch;
  margin-inline: auto;
  box-sizing: border-box;
  background:
    radial-gradient(130% 90% at 50% -20%, #faf1da, transparent 60%),
    #f3e8cf;
  color: var(--parch-ink);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  font-size: 1.18rem;
  line-height: 1.8;
  font-weight: 400;
  padding: clamp(1.8rem, 4.5vw, 3.6rem) clamp(1.4rem, 5vw, 3.4rem);
  border: 1px solid #e6d6ac;
  border-radius: 7px;
  box-shadow:
    0 1px 0 #fff8e7 inset,
    0 34px 80px -34px rgba(0, 0, 0, 0.75),
    0 2px 12px rgba(0, 0, 0, 0.4);
}
/* illuminated drop-cap on the opening paragraph */
article[data-post-theme="parchment"] .article-body > p:first-of-type::first-letter {
  float: left; font-size: 3.5em; line-height: 0.66;
  padding: 0.04em 0.14em 0 0; color: var(--parch-accent); font-weight: 700;
}
article[data-post-theme="parchment"] .article-body h2,
article[data-post-theme="parchment"] .article-body h3 { color: var(--parch-ink); }
article[data-post-theme="parchment"] .article-body h2 { border-top-color: var(--parch-rule); }
article[data-post-theme="parchment"] .article-body a {
  color: var(--parch-accent); border-bottom-color: rgba(154, 83, 31, 0.4);
}
article[data-post-theme="parchment"] .article-body a:hover {
  border-bottom-color: var(--parch-accent); text-shadow: none;
}
article[data-post-theme="parchment"] .article-body strong { color: #1c150a; }
article[data-post-theme="parchment"] .article-body em { color: var(--parch-soft); }
article[data-post-theme="parchment"] .article-body li::marker { color: var(--parch-accent); }
article[data-post-theme="parchment"] .article-body blockquote {
  border-left-color: var(--parch-accent); color: var(--parch-soft); box-shadow: none;
}
article[data-post-theme="parchment"] .article-body code {
  background: #e8dabb; border-color: #d6c498; color: #463821;
}
article[data-post-theme="parchment"] .article-body hr { background: var(--parch-rule); }
article[data-post-theme="parchment"] .article-body figcaption { color: var(--parch-soft); }
/* pre/playground panels stay dark on purpose — a deliberate inset on the sheet */

/* ---------- rich media inside articles ---------- */
.article-body img {
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  margin-inline: auto;
}
.article-body figure { margin-block: 2rem; }
.article-body figcaption {
  margin-top: 0.7rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  text-align: center;
}
.article-body video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
/* A self-hosted video with a poster (still backdrop) holds a 16:9 box before play so
   the page doesn't jump while the poster loads; the figure spaces like other media. */
.article-body video[poster] { aspect-ratio: 16 / 9; object-fit: cover; background: var(--bg-1); }
.article-body figure.blk-video { margin-block: 2rem; }
.article-body iframe {
  width: 100%;
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: 12px;
  background: var(--bg-1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.article-body iframe[src*="youtube"], .article-body iframe[src*="vimeo"],
.article-body .embed-16x9 iframe { aspect-ratio: 16 / 9; height: auto; }
.embed-16x9 { margin-block: 2rem; }
/* full-bleed media breakout on wide screens */
.article-body .breakout { width: min(960px, 92vw); margin-inline: calc((70ch - min(960px, 92vw)) / 2); }
@media (max-width: 1000px) { .article-body .breakout { width: 100%; margin-inline: 0; } }

/* ---------- footnotes / citations (GFM, remark-gfm) ----------
   Inline reference: <sup><a data-footnote-ref> · End section: <section data-footnotes
   class="footnotes"> with an <ol> and ↩ back-links. Theme-var driven so it follows
   every site theme; parchment overrides below. */
.article-body sup a[data-footnote-ref] {
  color: var(--cyan);
  font-weight: 700;
  font-size: 0.72em;
  text-decoration: none;
  border-bottom: 0;
  padding: 0 0.12em;
  transition: text-shadow 0.2s, color 0.2s;
}
.article-body sup a[data-footnote-ref]:hover {
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(34, 211, 238, 0.55);
}
.article-body .footnotes,
.article-body [data-footnotes] {
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line-strong);
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ink-dim);
}
/* a visible "Footnotes" label even though the GFM <h2> is sr-only */
.article-body [data-footnotes]::before {
  content: "References";
  display: block;
  font-family: var(--font-display);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.9rem;
}
.article-body [data-footnotes] ol { padding-left: 1.4em; }
.article-body [data-footnotes] li { color: var(--ink-dim); }
.article-body [data-footnotes] li::marker { color: var(--cyan); }
.article-body [data-footnotes] li + li { margin-top: 0.55em; }
.article-body [data-footnotes] li p { margin: 0; }
.article-body a[data-footnote-backref] {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 0;
  margin-left: 0.35em;
  font-size: 0.95em;
}
.article-body a[data-footnote-backref]:hover { text-shadow: 0 0 10px rgba(34, 211, 238, 0.5); }

/* parchment reading theme — warm accent, warm rule */
article[data-post-theme="parchment"] .article-body sup a[data-footnote-ref],
article[data-post-theme="parchment"] .article-body a[data-footnote-backref] {
  color: var(--parch-accent);
}
article[data-post-theme="parchment"] .article-body sup a[data-footnote-ref]:hover,
article[data-post-theme="parchment"] .article-body a[data-footnote-backref]:hover { text-shadow: none; }
article[data-post-theme="parchment"] .article-body [data-footnotes] {
  border-top-color: var(--parch-rule);
  color: var(--parch-soft);
}
article[data-post-theme="parchment"] .article-body [data-footnotes]::before { color: var(--parch-soft); }
article[data-post-theme="parchment"] .article-body [data-footnotes] li { color: var(--parch-soft); }
article[data-post-theme="parchment"] .article-body [data-footnotes] li::marker { color: var(--parch-accent); }

/* side-floated media (The Helm composer: placement Left/Right) — figures plus the
   div wrappers the pipeline builds (.gallery via rehype-gallery, .embed-16x9)
   share the same float rules, so a placed gallery/embed floats like a figure */
.article-body figure.img-left,
.article-body figure.img-right,
.article-body .gallery.img-left,
.article-body .gallery.img-right,
.article-body .embed-16x9.img-left,
.article-body .embed-16x9.img-right { max-width: 46%; margin: 0.4rem 0 1rem; }
.article-body figure.img-left,
.article-body .gallery.img-left,
.article-body .embed-16x9.img-left { float: left; margin-right: 1.6rem; }
.article-body figure.img-right,
.article-body .gallery.img-right,
.article-body .embed-16x9.img-right { float: right; margin-left: 1.6rem; }
.article-body figure.img-left img,
.article-body figure.img-right img { width: 100%; height: auto; }
@media (max-width: 640px) {
  .article-body figure.img-left,
  .article-body figure.img-right,
  .article-body .gallery.img-left,
  .article-body .gallery.img-right,
  .article-body .embed-16x9.img-left,
  .article-body .embed-16x9.img-right { float: none; max-width: 100%; margin: 1rem 0; }
}

/* image size (The Helm composer: Small / Medium / Large). Large = column width (no class).
   Small/Medium centre the figure; on floats they narrow the float instead. */
.article-body figure.img-sm:not(.img-left):not(.img-right) { width: min(300px, 55%); margin-inline: auto; }
.article-body figure.img-md:not(.img-left):not(.img-right) { width: min(480px, 78%); margin-inline: auto; }
.article-body figure.img-left.img-sm,
.article-body figure.img-right.img-sm { max-width: 26%; }
.article-body figure.img-left.img-md,
.article-body figure.img-right.img-md { max-width: 36%; }
@media (max-width: 640px) {
  .article-body figure.img-sm:not(.img-left):not(.img-right),
  .article-body figure.img-md:not(.img-left):not(.img-right) { width: min(380px, 88%); }
}

/* ============================================================
   Drag-to-resize media (The Helm composer)
   A resizable block (image / figure / embed / video / playground /
   gallery) can carry an explicit width via the `--blk-w` CSS var
   plus a `data-align` (left / center / right). The var wins over
   the legacy Small/Medium/Large sizing when present. Theme-var
   only (no colours), so it works across every site theme.
   On narrow screens (≤640px) any width is forced to 100% so phones
   are never cramped. A width-less block is untouched (today's
   default), so existing posts don't regress.
   ============================================================ */
.article-body [style*="--blk-w"] {
  width: var(--blk-w);
  max-width: 100%;
  margin-inline: auto;          /* default: centred */
  float: none;
}
/* the inner media fills the sized wrapper */
.article-body [style*="--blk-w"] > img,
.article-body [style*="--blk-w"] > video,
.article-body [style*="--blk-w"] .embed-16x9,
.article-body [style*="--blk-w"] > iframe,
.article-body figure.fig[style*="--blk-w"] svg { width: 100%; max-width: 100%; height: auto; }
/* alignment: left / right push to the edge (no float — block-level, predictable);
   center is the default above. */
.article-body [style*="--blk-w"][data-align="left"]  { margin-inline: 0 auto; }
.article-body [style*="--blk-w"][data-align="right"] { margin-inline: auto 0; }
.article-body [style*="--blk-w"][data-align="center"]{ margin-inline: auto; }
/* gallery sized as a whole; a single-image gallery centres its lone image */
.article-body .gallery[style*="--blk-w"] { display: grid; }
.article-body .gallery.gallery--one[style*="--blk-w"] { display: block; }
/* the YouTube/Vimeo aspect-ratio box must follow its sized embed wrapper */
.article-body .embed-16x9[style*="--blk-w"] { margin-inline: auto; }
/* RESPONSIVE: phones get the full column regardless of the chosen width */
@media (max-width: 640px) {
  .article-body [style*="--blk-w"] { width: 100% !important; margin-inline: 0 !important; }
}

/* ============================================================
   Figures (The Helm figures engine: <figure class="fig ...">)
   Self-contained inline SVGs that colour themselves from the
   active theme's CSS vars (--ink / --ink-dim / --teal / --cyan
   / --violet) and inline their own fig-draw line-draw animation
   (with a prefers-reduced-motion guard). These styles are only
   the surrounding layout + optional base-image overlay — no
   hardcoded colours, so every site theme (dark or light) flips
   automatically.
   ============================================================ */
.article-body .fig {
  position: relative;
  margin-block: 2.2rem;
  text-align: center;
}
/* responsive SVG: the svg already carries theme-var colours */
.article-body .fig svg {
  width: 100%;
  height: auto;
  max-width: 640px;
  display: block;
  margin: 0 auto;
  overflow: visible;
}
/* placement modifiers */
.article-body .fig--wide svg { max-width: 100%; }
.article-body .fig--default svg { max-width: 640px; }
.article-body .fig--left,
.article-body .fig--right { margin-block: 0.6rem; }
@media (min-width: 720px) {
  .article-body .fig--left,
  .article-body .fig--right { max-width: 46%; }
  .article-body .fig--left { float: left; margin-right: 1.8rem; }
  .article-body .fig--right { float: right; margin-left: 1.8rem; }
  .article-body .fig--left svg,
  .article-body .fig--right svg { max-width: 100%; }
}
/* caption: muted, small, centred */
.article-body .fig figcaption {
  margin-top: 0.6rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  text-align: center;
}
/* Route-2 base-image layering: when a .fig contains BOTH an <img>
   and an <svg>, the img is the base (it sets the box size) and the
   svg overlays it. Only applies when both are present. */
.article-body .fig:has(img) { display: block; }
.article-body .fig img {
  display: block;
  width: 100%;
  height: auto;
  margin-inline: auto;
}
.article-body .fig img + svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
}

/* ---------- stickers (retro die-cut figures) ----------
   A sticker is a figure (kind:"sticker") with a colourful, self-contained inline
   SVG. The drop-shadow gives the playful kiss-cut "peel it off and slap it on"
   look; stickers tend to be small, so cap the default width tighter than figures.
   When slapped onto an image (.fig:has(img)) the svg overlays the photo. */
.article-body .fig--sticker svg {
  max-width: 360px;
  overflow: visible;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.45));
}
.article-body .fig--sticker.fig--wide svg { max-width: 100%; }
/* overlay sticker (on an image): keep the shadow but fill the base box */
.article-body .fig--sticker:has(img) svg { max-width: none; }

/* ---------- playgrounds (interactive embeds) ---------- */
.playground {
  margin-block: 2rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34, 211, 238, 0.07), transparent 60%),
    linear-gradient(165deg, var(--bg-2), var(--bg-0));
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: 0 14px 50px rgba(0, 0, 0, 0.55), inset 0 0 40px rgba(34, 211, 238, 0.04), 0 0 28px rgba(34, 211, 238, 0.08);
}
.playground svg { width: 100%; height: auto; }
.pg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.6rem; }
.playground label {
  display: block; font-family: var(--font-display); font-size: 0.78rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan); margin-bottom: 0.35em;
}
.pg-readout {
  font-family: var(--font-display); font-size: 0.92rem; color: var(--ink-dim);
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: rgba(8, 12, 22, 0.8); padding: 0.6em 1em;
}
.pg-readout b { color: var(--ink); font-weight: 600; }

.playground input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: linear-gradient(90deg, var(--teal), var(--cyan), var(--violet));
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.35);
  outline-offset: 6px;
}
.playground input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--cyan);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.8);
  cursor: grab;
}
.playground input[type="range"]::-webkit-slider-thumb:active { cursor: grabbing; }
.playground input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); border: 2px solid var(--cyan);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.8);
  cursor: grab;
}

/* ---------- timeline (About) ---------- */
.timeline { position: relative; display: grid; gap: 1.8rem; padding-left: 1.8rem; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px;
  background: linear-gradient(180deg, var(--teal), var(--violet));
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.3);
  border-radius: 2px;
}
.timeline-item { position: relative; }
.timeline-item::before {
  content: ""; position: absolute; left: calc(-1.8rem + 1px); top: 8px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-0); border: 2px solid var(--cyan);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.7);
}
.timeline-item .tl-period {
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--cyan);
}
.timeline-item h3 { font-size: 1.15rem; margin-top: 0.3rem; }
.timeline-item .tl-place { color: var(--ink-dim); font-size: 0.92rem; margin-top: 0.15rem; font-family: var(--font-display); }
.timeline-item .tl-detail { color: var(--ink-dim); font-size: 0.95rem; margin-top: 0.55rem; max-width: 68ch; }

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat-card {
  text-align: center; padding: 1.4rem 1rem;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line); border-radius: var(--radius);
}
.stat-card .stat-value {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2rem, 4vw, 2.7rem); line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(34, 211, 238, 0.3));
}
.stat-card .stat-label { margin-top: 0.5rem; font-size: 0.82rem; color: var(--ink-dim); }

/* ---------- CV list blocks ---------- */
.cv-list { list-style: none; display: grid; gap: 0.9rem; }
.cv-item {
  display: grid; grid-template-columns: 86px 1fr; gap: 1.1rem;
  padding: 0.95rem 1.1rem;
  background: linear-gradient(160deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--line); border-radius: 12px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.cv-item:hover { border-color: rgba(129, 140, 248, 0.4); box-shadow: 0 0 22px rgba(129, 140, 248, 0.1); }
.cv-item .cv-year {
  font-family: var(--font-display); font-size: 0.8rem; letter-spacing: 0.08em;
  color: var(--cyan); padding-top: 0.15em; white-space: nowrap;
}
.cv-item .cv-title { font-weight: 600; color: var(--ink); font-size: 0.98rem; font-family: var(--font-display); }
.cv-item .cv-body { color: var(--ink-dim); font-size: 0.88rem; margin-top: 0.2rem; }
.cv-item a { color: var(--cyan); font-size: 0.82rem; }
.cv-item a:hover { text-shadow: 0 0 10px rgba(34, 211, 238, 0.6); }
@media (max-width: 560px) { .cv-item { grid-template-columns: 1fr; gap: 0.2rem; } }

/* ---------- forms ---------- */
.field label {
  display: block; font-family: var(--font-display); font-size: 0.85rem;
  color: var(--ink-dim); margin-bottom: 0.4em;
}
.field input, .field textarea {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line-strong);
  border-radius: 12px; color: var(--ink); padding: 0.8em 1em;
  font-family: var(--font-body); font-size: 0.95rem;
  transition: border-color 0.25s, box-shadow 0.25s; resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15), var(--glow-cyan);
}

/* ---------- socials ---------- */
.socials { display: flex; gap: 0.7rem; }
.socials a {
  display: grid; place-items: center; width: 46px; height: 46px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}
.socials a svg { width: 20px; height: 20px; fill: var(--ink-dim); transition: fill 0.25s; }
.socials a:hover { border-color: var(--cyan); box-shadow: var(--glow-cyan); transform: translateY(-2px); }
.socials a:hover svg { fill: var(--cyan); }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2.4rem;
  margin-top: 4rem;
}
.site-footer .container {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem;
  align-items: center; justify-content: space-between;
  font-size: 0.85rem; color: var(--ink-faint);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; }
.site-footer a { color: var(--ink-dim); transition: color 0.2s; }
.site-footer a:hover { color: var(--cyan); }
.footer-socials { display: flex; gap: 0.6rem; align-items: center; }
.footer-socials a {
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink-dim);
}
.footer-socials a:hover { color: var(--cyan); border-color: rgba(34, 211, 238, 0.4); box-shadow: var(--glow-cyan); }

/* ---------- reveal initial states are set by JS (gsap) so content
              never hides when JS is unavailable ---------- */

/* ---------- gallery grid + lightbox ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 1.8rem 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: zoom-in; display: block; }
.gx-lightbox { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center;
  background: rgba(2, 4, 8, 0.92); backdrop-filter: blur(4px); cursor: zoom-out; }
.gx-lightbox.open { display: flex; }
.gx-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 20px 80px rgba(0,0,0,.7); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Switchable site themes (environments)
   Default = "Observatory" (the :root tokens above).
   Vista = a deep-ocean environment — still dark, per the house rule.
   Selected via <html data-site-theme="…"> (footer chooser, localStorage).
   ============================================================ */
:root[data-site-theme="vista"] {
  --bg-0: #02060f;
  --bg-1: #04101d;
  --bg-2: #07202f;
  --bg-3: #0b3043;
  --ink: #eaf6ff;
  --ink-dim: #b6d2e2;
  --ink-faint: #7ea7be;
  --teal: #2ee6c8;
  --cyan: #38d0ff;
  --violet: #6aa9ff;
  --accent: var(--cyan);
  --grad: linear-gradient(100deg, var(--teal), var(--cyan) 50%, var(--violet));
  --line: rgba(120, 180, 220, 0.14);
  --line-strong: rgba(120, 180, 220, 0.26);
  --glow-teal: 0 0 26px rgba(46, 230, 200, 0.4);
  --glow-cyan: 0 0 26px rgba(56, 208, 255, 0.42);
  --glow-violet: 0 0 26px rgba(106, 169, 255, 0.4);
}

/* footer theme chooser */
.theme-chooser { display: inline-flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.theme-chooser .tc-label { font: 600 0.68rem var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }
.theme-chooser button { font: 600 0.78rem var(--font-display); color: var(--ink-dim); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 0.25em 0.8em; cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.theme-chooser button:hover { color: var(--ink); border-color: var(--line-strong); }
.theme-chooser button[aria-pressed="true"] { color: #04211c; background: var(--grad); border-color: transparent; }

/* ── Blueprint theme — cyanotype drafting table (switchable) ─────────────── */
:root[data-site-theme="blueprint"] {
  --bg-0: #071a33;
  --bg-1: #0a2347;
  --bg-2: #0e2c57;
  --bg-3: #123769;
  --ink: #eaf2ff;
  --ink-dim: #bcd2f0;
  --ink-faint: #84a6d6;
  --teal: #7fdbff;
  --cyan: #a9d6ff;
  --violet: #cfe3ff;
  --accent: #a9d6ff;
  --grad: linear-gradient(100deg, #7fdbff, #a9d6ff 50%, #dbeafe);
  --line: rgba(150, 190, 240, 0.18);
  --line-strong: rgba(150, 190, 240, 0.34);
  --glow-teal: 0 0 24px rgba(127, 219, 255, 0.35);
  --glow-cyan: 0 0 24px rgba(169, 214, 255, 0.4);
  --glow-violet: 0 0 24px rgba(207, 227, 255, 0.32);
  /* technical/drafting type for headings & labels */
  --font-display: ui-monospace, 'SF Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
}
/* faint blueprint grid paper behind everything */
:root[data-site-theme="blueprint"] body {
  background-color: #071a33;
  background-image:
    linear-gradient(rgba(150, 190, 240, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 190, 240, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
}

/* ── Atlas theme — anatomical engraving (switchable; recolours the 3D explore too) ── */
:root[data-site-theme="atlas"] {
  --bg-0: #0b0a08;
  --bg-1: #12100c;
  --bg-2: #191510;
  --bg-3: #221c15;
  --ink: #f2ead6;
  --ink-dim: #d8caa8;
  --ink-faint: #a7986f;
  --teal: #c9a36b;
  --cyan: #d8c39a;
  --violet: #b5654d;
  --pink: #c96a6a;
  --amber: #d8c39a;
  --accent: #9e3b3b;
  --grad: linear-gradient(100deg, #d8c39a, #c9a36b 50%, #9e3b3b);
  --line: rgba(180, 160, 120, 0.16);
  --line-strong: rgba(180, 160, 120, 0.30);
  --glow-teal: 0 0 22px rgba(201, 163, 107, 0.3);
  --glow-cyan: 0 0 22px rgba(216, 195, 154, 0.32);
  --glow-violet: 0 0 22px rgba(158, 59, 59, 0.34);
  /* engraved-plate serif for headings & labels */
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Georgia', serif;
}

/* ── LIGHT themes — light backgrounds, dark ink (override the dark defaults) ── */
:root[data-site-theme="daybreak"] {
  color-scheme: light;
  --bg-0: #c3dcf3; --bg-1: #e7f2fc; --bg-2: #f6fbfe; --bg-3: #d3e4f4;
  --ink: #0f1d36; --ink-dim: #293a58; --ink-faint: #475a7c;
  --teal: #1f6f9e; --cyan: #2f88c0; --violet: #5a7bbf; --pink: #c47650; --amber: #e0a838;
  --accent: #1a5f8a;
  --grad: linear-gradient(100deg, #e0a838, #2f88c0 55%, #5a7bbf);
  --line: rgba(30, 70, 120, 0.24); --line-strong: rgba(30, 70, 120, 0.4);
  --glow-teal: 0 6px 22px rgba(30, 70, 120, 0.12);
  --glow-cyan: 0 6px 22px rgba(30, 70, 120, 0.12);
  --glow-violet: 0 6px 22px rgba(30, 70, 120, 0.12);
}
:root[data-site-theme="dune"] {
  color-scheme: light;
  --bg-0: #e3cfa8; --bg-1: #f2e7d2; --bg-2: #faf4e8; --bg-3: #d7c099;
  --ink: #2f2110; --ink-dim: #54401f; --ink-faint: #74603c;
  --teal: #8a5a2c; --cyan: #a8702f; --violet: #9a5a5a; --pink: #a8513c; --amber: #b87a2c;
  --accent: #9a4a32;
  --grad: linear-gradient(100deg, #c98a3c, #b5654d 55%, #a86a6a);
  --line: rgba(90, 60, 30, 0.28); --line-strong: rgba(90, 60, 30, 0.44);
  --glow-teal: 0 6px 22px rgba(90, 60, 30, 0.14);
  --glow-cyan: 0 6px 22px rgba(90, 60, 30, 0.14);
  --glow-violet: 0 6px 22px rgba(90, 60, 30, 0.14);
}
:root[data-site-theme="rivendell"] {
  color-scheme: light;
  --bg-0: #ddd0ad; --bg-1: #eee5cf; --bg-2: #f6f0e1; --bg-3: #d2c4a0;
  --ink: #262112; --ink-dim: #443a22; --ink-faint: #645737;
  --teal: #3f6b4a; --cyan: #54702f; --violet: #7a5d28; --pink: #8a4a3c; --amber: #8a6a2c;
  --accent: #3a6b3a;
  --grad: linear-gradient(100deg, #9a7b3c, #3f6b4a 55%, #5a7b3c);
  --line: rgba(80, 64, 36, 0.3); --line-strong: rgba(80, 64, 36, 0.44);
  --glow-teal: 0 6px 22px rgba(80, 64, 36, 0.14);
  --glow-cyan: 0 6px 22px rgba(80, 64, 36, 0.14);
  --glow-violet: 0 6px 22px rgba(80, 64, 36, 0.14);
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Georgia', serif;
}

/* light-theme surface fixes: the header bg + headline scrim are hardcoded for dark */
:root[data-site-theme="daybreak"] .site-header,
:root[data-site-theme="dune"] .site-header,
:root[data-site-theme="rivendell"] .site-header {
  background: rgba(255, 255, 255, 0.62);
  border-bottom-color: var(--line);
}
:root[data-site-theme="daybreak"] .scrim-text,
:root[data-site-theme="dune"] .scrim-text,
:root[data-site-theme="rivendell"] .scrim-text {
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.95), 0 2px 22px rgba(255, 255, 255, 0.85), 0 0 50px rgba(255, 255, 255, 0.55);
}
/* light themes: the header "Choose theme" dropdown panel is dark by default — make it light */
:is([data-site-theme="daybreak"], [data-site-theme="dune"], [data-site-theme="rivendell"]) .theme-menu-panel {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--line-strong);
  box-shadow: 0 18px 44px rgba(60, 70, 90, 0.22);
}

/* ============================================================
   READING TEMPLATES
   Six reading-surface treatments applied via `data-template` on the
   post <article> (src/pages/blog/[slug].astro). They restyle ONLY the
   reading surface — the post hero, article body and rail backdrop — by
   re-declaring the design tokens (and a few element rules) on the
   <article>. Because the fixed nav <header> lives OUTSIDE <article>, it
   keeps the site `:root` / site-theme tokens and STAYS DARK regardless.
   These overrides also win over any site theme inside the surface
   (article-scoped tokens are nearer ancestors of the body than :root).

   • observatory — default dark house style (no overrides needed).
   • parchment   — warm off-white, dark ink, serif, book-like measure.
   • manuscript  — dark, narrow measure, large serif, literary essay.
   • newsprint   — light grey, dark text, tight serif, editorial density.
   • slate       — cooler/cleaner dark, minimal ornament, sans.
   • focus       — stripped chrome (no rail), centred column, large type.
   ============================================================ */

/* ---- observatory (default) ---- */
/* Intentionally no rules: this IS the base dark house style. Listed here so
   the switcher's six keys are all represented in the stylesheet. */

/* =================== shared light-surface scaffolding ===================
   parchment + newsprint are light. Give the post a light panel behind the
   hero (which otherwise floats over the dark page bg), soften the decorative
   orbs/grid-lines, fix the white hero-title scrim, and lighten the rail rule. */
article[data-template="parchment"],
article[data-template="newsprint"] {
  color-scheme: light;
}
article[data-template="parchment"] .article-col,
article[data-template="newsprint"] .article-col {
  background: var(--bg-1);
  border-radius: 14px;
  padding-inline: clamp(0.6rem, 2.2vw, 1.6rem);
  box-shadow: 0 24px 70px -36px rgba(0, 0, 0, 0.5);
}
article[data-template="parchment"] .post-hero .orb,
article[data-template="newsprint"] .post-hero .orb { opacity: 0.12 !important; }
article[data-template="parchment"] .post-hero .grid-lines,
article[data-template="newsprint"] .post-hero .grid-lines { opacity: 0.25; }
/* white headline glow → light-surface scrim so the title stays crisp */
article[data-template="parchment"] .post-hero .scrim-text,
article[data-template="newsprint"] .post-hero .scrim-text {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
article[data-template="parchment"] .topic-rail,
article[data-template="newsprint"] .topic-rail { border-right-color: var(--line); }

/* =========================== PARCHMENT ===========================
   Warm off-white sheet, dark ink, serif body, generous measure + leading. */
article[data-template="parchment"] {
  --bg-0: #f3ead6;
  --bg-1: #f7efdc;
  --bg-2: #efe3c8;
  --bg-3: #e7d9b8;
  --ink: #2c2415;
  --ink-dim: #5a4d36;
  --ink-faint: #837154;
  --teal: #8a5a2c;
  --cyan: #9a531f;
  --violet: #6f5a2c;
  --accent: #9a531f;
  --line: rgba(120, 95, 50, 0.20);
  --line-strong: rgba(120, 95, 50, 0.34);
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
}
article[data-template="parchment"] .article-body {
  max-width: 72ch;
  color: var(--ink);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  font-size: 1.22rem;
  line-height: 1.85;
  font-weight: 400;
}
article[data-template="parchment"] .article-body h2,
article[data-template="parchment"] .article-body h3 { color: var(--ink); }
article[data-template="parchment"] .article-body h2 { border-top-color: var(--line-strong); }
article[data-template="parchment"] .article-body strong { color: #1c150a; }
article[data-template="parchment"] .article-body em { color: var(--ink-dim); }
article[data-template="parchment"] .article-body a { color: var(--cyan); border-bottom-color: rgba(154, 83, 31, 0.4); }
article[data-template="parchment"] .article-body a:hover { border-bottom-color: var(--cyan); text-shadow: none; }
article[data-template="parchment"] .article-body blockquote {
  border-left-color: var(--cyan); color: var(--ink-dim); box-shadow: none; font-style: italic;
}
article[data-template="parchment"] .article-body code {
  background: #e8dabb; border-color: #d6c498; color: #463821;
}
article[data-template="parchment"] .article-body pre {
  background: #2a2418; border-color: #1d1810;
}
article[data-template="parchment"] .article-body pre code { color: #f0e6d2; }

/* Light reading templates (parchment/newsprint) keep INTERACTIVE PLAYGROUNDS dark —
   each is a self-contained dark widget. Without this, the cream surface's dark-ink
   text vars (--ink-dim etc.) bleed into the playground's own dark sub-boxes
   (e.g. .pg-readout's "skill acquired" pill) → dark-on-dark, illegible. Re-assert the
   normal dark palette on the playground subtree so it renders as it does site-wide. */
article[data-template="parchment"] .playground,
article[data-template="newsprint"] .playground {
  --bg-0: #04060c; --bg-1: #080c16; --bg-2: #0d1322; --bg-3: #131b2f;
  --ink: #f4f7fd; --ink-dim: #c0c9da; --ink-faint: #9aa7c4;
  --teal: #2dd4bf; --cyan: #22d3ee; --violet: #818cf8;
  --line: rgba(140, 160, 200, 0.12); --line-strong: rgba(140, 160, 200, 0.22);
  color: var(--ink-dim);
}
article[data-template="parchment"] .article-body figcaption { color: var(--ink-faint); }
article[data-template="parchment"] .article-body img { border-color: var(--line-strong); box-shadow: 0 12px 36px rgba(80, 60, 30, 0.22); }
article[data-template="parchment"] .post-hero-meta,
article[data-template="parchment"] .back-link { color: var(--ink-dim); }

/* =========================== MANUSCRIPT ===========================
   DARK WARM sepia/ink surface, gold/amber accent, LARGE serif headings +
   body, NARROW measure, drop-cap + a subtle rule on the opening paragraph.
   A bound book by candlelight — must NOT read like observatory. */
article[data-template="manuscript"] {
  --bg-0: #130d07;
  --bg-1: #1a120a;
  --bg-2: #211710;
  --bg-3: #2c2014;
  --ink: #f0e4cf;
  --ink-dim: #cdbb98;
  --ink-faint: #9c8763;
  --teal: #d8b46a;
  --cyan: #e6c97e;
  --violet: #c9a25a;
  --accent: #d8b46a;
  --line: rgba(216, 180, 106, 0.18);
  --line-strong: rgba(216, 180, 106, 0.32);
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
}
/* paint the whole reading column the warm ink, framed in faint gold */
article[data-template="manuscript"] .article-col {
  background: radial-gradient(120% 80% at 50% -10%, #1d140b, transparent 60%), var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding-inline: clamp(0.8rem, 2.6vw, 2rem);
}
article[data-template="manuscript"] .article-body {
  max-width: 58ch;
  margin-inline: auto;
  color: var(--ink);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
  font-size: 1.34rem;
  line-height: 1.92;
  font-weight: 400;
}
/* gilt drop-cap + hairline rule under the opening paragraph */
article[data-template="manuscript"] .article-body > p:first-of-type::first-letter {
  float: left; font-size: 3.6em; line-height: 0.62;
  padding: 0.04em 0.12em 0 0; color: var(--teal); font-weight: 700;
  font-family: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
}
article[data-template="manuscript"] .article-body > p:first-of-type {
  padding-bottom: 1.1em; border-bottom: 1px solid var(--line); margin-bottom: 0.2em;
}
article[data-template="manuscript"] .post-title-row h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); letter-spacing: -0.01em; }
article[data-template="manuscript"] .article-body h2,
article[data-template="manuscript"] .article-body h3 { color: var(--ink); }
article[data-template="manuscript"] .article-body h2 { font-size: 1.95rem; border-top-color: var(--line-strong); }
article[data-template="manuscript"] .article-body h3 { font-size: 1.45rem; }
article[data-template="manuscript"] .article-body strong { color: #fbeecd; }
article[data-template="manuscript"] .article-body em { color: var(--ink-dim); }
article[data-template="manuscript"] .article-body a { color: var(--cyan); border-bottom-color: rgba(216, 180, 106, 0.45); }
article[data-template="manuscript"] .article-body a:hover { border-bottom-color: var(--cyan); text-shadow: 0 0 10px rgba(216, 180, 106, 0.4); }
article[data-template="manuscript"] .article-body li::marker { color: var(--teal); }
article[data-template="manuscript"] .article-body blockquote {
  border-left-color: var(--teal); color: var(--ink-dim); font-style: italic; font-size: 1.2rem;
  box-shadow: inset 8px 0 24px -16px rgba(216, 180, 106, 0.45);
}
article[data-template="manuscript"] .article-body code {
  font-size: 0.8em; background: #2a1f12; border-color: #3a2c19; color: #ecd9ad;
}
article[data-template="manuscript"] .article-body pre { background: #1c1409; border-color: #2c2014; font-size: 0.82em; }
article[data-template="manuscript"] .article-body pre code { color: #ecd9ad; }
/* warm down the decorative hero orbs so they read amber, not teal */
article[data-template="manuscript"] .post-hero .orb-b { background: radial-gradient(circle, rgba(216, 180, 106, 0.18), transparent 70%) !important; }

/* =========================== NEWSPRINT ===========================
   Light grey, dark text, tight serif, editorial density. */
article[data-template="newsprint"] {
  --bg-0: #e8e7e3;
  --bg-1: #ecebe7;
  --bg-2: #e0dfda;
  --bg-3: #d7d6d0;
  --ink: #1b1b1a;
  --ink-dim: #46453f;
  --ink-faint: #6d6c64;
  --teal: #7a2c1f;
  --cyan: #9a2f1a;
  --violet: #5a3a6a;
  --accent: #9a2f1a;
  --line: rgba(40, 40, 36, 0.18);
  --line-strong: rgba(40, 40, 36, 0.32);
  --font-display: Georgia, 'Times New Roman', 'Iowan Old Style', serif;
}
article[data-template="newsprint"] .article-body {
  max-width: 64ch;
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', 'Iowan Old Style', serif;
  font-size: 1.03rem;
  line-height: 1.52;
  font-weight: 400;
  letter-spacing: -0.005em;
}
article[data-template="newsprint"] .article-body > * + * { margin-top: 0.9em; }
/* tight, dense paragraphs — no extra leading between like a column of newsprint */
article[data-template="newsprint"] .article-body p { text-align: justify; hyphens: auto; }
article[data-template="newsprint"] .article-body h2,
article[data-template="newsprint"] .article-body h3 { color: var(--ink); font-weight: 700; }
/* thick rule above h2 — section break in a paper */
article[data-template="newsprint"] .article-body h2 {
  font-size: 1.5rem; margin-top: 1.6em; padding-top: 0.8em;
  border-top: 3px double var(--line-strong); letter-spacing: -0.01em;
}
article[data-template="newsprint"] .article-body h3 { font-size: 1.16rem; margin-top: 1.3em; }
article[data-template="newsprint"] .article-body strong { color: #000; }
article[data-template="newsprint"] .article-body em { color: var(--ink-dim); }
article[data-template="newsprint"] .article-body a { color: var(--cyan); border-bottom-color: rgba(154, 47, 26, 0.4); }
article[data-template="newsprint"] .article-body a:hover { border-bottom-color: var(--cyan); text-shadow: none; }
article[data-template="newsprint"] .article-body blockquote {
  border-left-color: var(--cyan); color: var(--ink-dim); box-shadow: none;
}
article[data-template="newsprint"] .article-body code {
  background: #dcdbd5; border-color: #c8c7c0; color: #2a2a26;
}
article[data-template="newsprint"] .article-body pre { background: #26261f; border-color: #1a1a14; }
article[data-template="newsprint"] .article-body pre code { color: #eceadf; }
article[data-template="newsprint"] .article-body figcaption { color: var(--ink-faint); }
article[data-template="newsprint"] .article-body img { border-color: var(--line-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
article[data-template="newsprint"] .post-hero-meta,
article[data-template="newsprint"] .back-link { color: var(--ink-dim); }

/* =========================== SLATE ===========================
   MEDIUM blue-grey surface (distinctly LIGHTER/greyer than near-black),
   clean sans, cool slate-blue accent, minimal ornament. */
article[data-template="slate"] {
  --bg-0: #1b2430;
  --bg-1: #1f2937;
  --bg-2: #27323f;
  --bg-3: #313d4c;
  --ink: #eef2f7;
  --ink-dim: #c2ccd9;
  --ink-faint: #8b97a8;
  --teal: #7fa6c9;
  --cyan: #93b7d6;
  --violet: #9fb2cc;
  --accent: #7fa6c9;
  --line: rgba(160, 180, 205, 0.16);
  --line-strong: rgba(160, 180, 205, 0.26);
  --font-display: 'Space Grotesk Variable', 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter Variable', 'Inter', system-ui, sans-serif;
}
/* paint the reading column the medium slate so it lifts clearly off the dark page */
article[data-template="slate"] .article-col {
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding-inline: clamp(0.8rem, 2.6vw, 2rem);
  box-shadow: 0 24px 70px -40px rgba(0, 0, 0, 0.7);
}
article[data-template="slate"] .article-body {
  max-width: 70ch;
  font-family: var(--font-body);
  font-size: 1.1rem;
  line-height: 1.75;
  color: var(--ink-dim);
}
article[data-template="slate"] .article-body h2,
article[data-template="slate"] .article-body h3 { color: var(--ink); font-weight: 600; }
article[data-template="slate"] .article-body strong { color: #ffffff; }
article[data-template="slate"] .article-body em { color: var(--ink); }
article[data-template="slate"] .article-body li::marker { color: var(--teal); }
/* minimal ornament: drop the decorative hero orbs + grid, lighten link glow */
article[data-template="slate"] .post-hero .orbs,
article[data-template="slate"] .post-hero .grid-lines { display: none; }
article[data-template="slate"] .article-body a { color: var(--cyan); border-bottom-color: rgba(127, 166, 201, 0.4); }
article[data-template="slate"] .article-body a:hover { text-shadow: none; border-bottom-color: var(--cyan); }
article[data-template="slate"] .article-body blockquote {
  border-left-color: var(--teal); color: var(--ink-dim); box-shadow: none; font-style: normal;
}
article[data-template="slate"] .article-body code {
  background: #2b3744; border-color: #3a4756; color: #d6e0ec;
}
article[data-template="slate"] .article-body pre { background: #161e28; border-color: #2b3744; }
article[data-template="slate"] .article-body h2 { border-top-color: var(--line); }

/* =========================== FOCUS ===========================
   Stripped chrome — hide the Topics rail + extras, centred single column,
   LARGE type, generous leading. Dark. */
article[data-template="focus"] .article-grid {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}
article[data-template="focus"] .topic-rail { display: none; }
article[data-template="focus"] .article-col { width: 100%; max-width: 760px; }
article[data-template="focus"] .post-hero-inner { margin-inline: auto; }
/* strip hero ornament for a calm, distraction-free read */
article[data-template="focus"] .post-hero .orbs,
article[data-template="focus"] .post-hero .grid-lines { display: none; }
article[data-template="focus"] .article-body {
  max-width: 38rem;
  margin-inline: auto;
  font-size: 1.42rem;
  line-height: 2.0;
}
article[data-template="focus"] .article-col { max-width: 760px; }
article[data-template="focus"] .post-title-row h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.08; }
article[data-template="focus"] .article-body h2 { font-size: 1.85rem; }
article[data-template="focus"] .article-body h3 { font-size: 1.4rem; }
/* stripped chrome: hide tags, read-time, series flag + glyph for a pure read */
article[data-template="focus"] .post-hero-meta .tag-chip,
article[data-template="focus"] .post-hero-meta .badge-interactive,
article[data-template="focus"] .post-title-row .glyph-badge,
article[data-template="focus"] .series-flag { display: none; }
article[data-template="focus"] .article-body a:hover { text-shadow: none; }

/* ---- legacy interaction guard ----
   A handful of posts use the older per-post `theme: parchment` (data-post-theme)
   which renders a centred warm "sheet". That still works under the DEFAULT
   `observatory` template. But if a reader picks a different template on such a
   post, the new template must own the surface — so neutralise the legacy sheet's
   layout + body skin whenever an explicit non-observatory template is active.
   (Higher specificity than the legacy `article[data-post-theme] .article-body`
   rules; resets to inherit so the chosen template's tokens take over.) */
article[data-post-theme="parchment"]:not([data-template="observatory"]) .article-grid {
  grid-template-columns: 230px minmax(0, 1fr);
  justify-items: stretch;
}
article[data-post-theme="parchment"][data-template="focus"] .article-grid {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}
article[data-post-theme="parchment"]:not([data-template="observatory"]) .topic-rail { display: block; }
article[data-post-theme="parchment"][data-template="focus"] .topic-rail { display: none; }
article[data-post-theme="parchment"]:not([data-template="observatory"]) .article-body {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  max-width: 68ch;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.14rem;
  line-height: 1.78;
}
/* the chosen template re-skins the body itself; re-assert each one's essentials
   over the broad reset above (serif templates need their family + measure back). */
article[data-post-theme="parchment"][data-template="parchment"] .article-body,
article[data-post-theme="parchment"][data-template="newsprint"] .article-body,
article[data-post-theme="parchment"][data-template="manuscript"] .article-body {
  color: var(--ink);
  font-family: var(--font-display);
}
article[data-post-theme="parchment"][data-template="manuscript"] .article-body {
  max-width: 58ch; margin-inline: auto; font-size: 1.34rem; line-height: 1.92;
}
article[data-post-theme="parchment"][data-template="slate"] .article-body { color: var(--ink-dim); }
/* drop-cap reset applies to every non-observatory template EXCEPT manuscript,
   which keeps its gilt drop-cap. */
article[data-post-theme="parchment"]:not([data-template="observatory"]):not([data-template="manuscript"]) .article-body > p:first-of-type::first-letter {
  float: none; font-size: inherit; line-height: inherit; padding: 0; color: inherit; font-weight: inherit;
}
article[data-post-theme="parchment"][data-template="manuscript"] .article-body > p:first-of-type {
  padding-bottom: 1.1em; border-bottom: 1px solid var(--line); margin-bottom: 0.2em;
}

/* ============================================================
   Darkroom — faceted filter bar, CSS-columns masonry grid, and
   PhotoSwipe dark theme. Dark house style throughout.
   ============================================================ */

/* ---------- filter bar ---------- */
.darkroom-filter {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem;
  margin: 0 0 1.4rem;
}
.dr-facet {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
}
.dr-facet-label {
  font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint); margin-right: 0.15rem;
}
/* Darkroom chips run a touch smaller than the archive's. */
.darkroom-filter .chip { min-height: 32px; padding: 0.3em 0.8em; font-size: 0.82rem; }
/* the active accent comes from the shared `.chip.active` rule; `.is-active`
   mirrors it so either hook lights the chip teal. */
.darkroom-filter .chip.is-active {
  color: var(--ink);
  background: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: inset 0 0 18px rgba(34, 211, 238, 0.06), 0 0 14px rgba(34, 211, 238, 0.1);
}
.dr-facet-meta { margin-left: auto; gap: 0.7rem; }
.dr-count {
  font-family: var(--font-display); font-size: 0.82rem; color: var(--ink-faint);
  white-space: nowrap;
}

/* ---------- masonry grid (pure CSS columns — no layout-thrash with lazy imgs) ---------- */
.darkroom-grid {
  column-count: 2;
  column-gap: 0.85rem;
}
@media (min-width: 620px)  { .darkroom-grid { column-count: 3; column-gap: 1rem; } }
@media (min-width: 1000px) { .darkroom-grid { column-count: 4; } }
@media (min-width: 1440px) { .darkroom-grid { column-count: 5; } }

.dr-shot {
  break-inside: avoid;
  display: block;
  margin-bottom: 0.85rem;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg-1);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.dr-shot:hover {
  transform: translateY(-3px);
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45), 0 0 18px rgba(34, 211, 238, 0.12);
}
.dr-shot img { width: 100%; height: auto; display: block; }
.is-hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .dr-shot { transition: border-color 0.25s ease; }
  .dr-shot:hover { transform: none; }
}

/* ---------- PhotoSwipe v5 — dark theme on-brand ---------- */
.pswp {
  --pswp-bg: #04060c;
  --pswp-placeholder-bg: #080c16;
  --pswp-icon-color: var(--ink);
  --pswp-icon-color-secondary: #04060c;
  --pswp-icon-stroke-color: rgba(4, 6, 12, 0.7);
}
/* caption strip: light ink on a translucent near-black bar, pinned bottom-left */
.pswp .dr-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.9rem;
  padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(4, 6, 12, 0.9), rgba(4, 6, 12, 0));
  font-family: var(--font-display);
  pointer-events: none; /* let the lightbox handle clicks except on the link */
}
.pswp .dr-caption:empty { display: none; }
/* The caption text takes its own row so the "from this post →" link always sits
   clearly below it (never running together with the caption text). */
.pswp .pswp-cap-text { flex: 1 1 100%; color: var(--ink); font-size: 0.92rem; }
.pswp .pswp-cap-link {
  display: inline-block;
  pointer-events: auto;
  color: var(--cyan); font-size: 0.84rem; font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid rgba(34, 211, 238, 0.4);
  transition: color 0.2s, border-color 0.2s;
}
/* When a caption precedes it, add breathing room above the link. */
.pswp .pswp-cap-text + .pswp-cap-link { margin-top: 0.15rem; }
.pswp .pswp-cap-link:hover { color: var(--ink); border-color: var(--cyan); }
