:root {
  /* ---- warm-paper substrate (unified with index.html) ---- */
  --bg: #F6F0E4;
  --paper: #FBF6EC;
  --paper-soft: #EFE7D6;
  --ink: #2A2018;
  --ink-2: #4A3E33;
  --muted: #75685A;
  --faint: #A99B86;
  --rule: #DED2BC;
  --accent: #B14E27;
  --accent-dark: #8E3A1B;
  --accent-soft: #F3E2D2;
  --green: #3E6B33;
  --green-soft: #E3EAD3;
  --blue: #33596E;
  --blue-soft: #DCE4E4;
  --shadow: 0 12px 32px rgba(74, 56, 35, 0.10);
  /* ---- new tokens ---- */
  --paper-deep: #E7DCC6;
  --rule-strong: #C8B89C;
  --brass: #B07B2C;
  --brass-soft: #F0E4C9;
  --shadow-card: inset 0 1px 0 #FFFDF8, 0 10px 26px rgba(74, 56, 35, 0.10);
  --shadow-hero: 0 22px 50px rgba(74, 56, 35, 0.16);
  --shadow-lift: 0 14px 30px rgba(74, 56, 35, 0.13);
  --focus-ring: 0 0 0 3px rgba(177, 78, 39, 0.25);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--grain);
  background-size: 240px 240px;
  opacity: 0.035;
  mix-blend-mode: multiply;
}
@media (forced-colors: active) {
  body::before { display: none; }
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-dark); }
::selection { background: var(--accent-soft); color: var(--ink); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}
.serif { font-family: Fraunces, Georgia, serif; }
.mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.shell { width: min(1100px, calc(100% - 48px)); margin: 0 auto; }

/* ---------- nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(246, 240, 228, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 2px 0 rgba(168, 148, 116, 0.10);
}
.nav-inner {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  font-family: Fraunces, Georgia, serif;
  font-weight: 900;
  font-size: 26px;
  color: var(--ink);
}
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: #FFFDF8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background-color .18s ease, border-color .18s ease;
}
.button:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #FFFDF8; }

/* ---------- article hero ---------- */
.article-hero {
  border-bottom: 1px solid var(--rule);
  padding: 64px 0 40px;
}
.kicker {
  margin: 0 0 18px;
  color: var(--accent);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.article-hero h1 {
  max-width: 980px;
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(40px, 5.6vw, 68px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
  color: var(--ink);
}
.dek {
  max-width: 720px;
  margin: 22px 0 0;
  color: var(--ink-2);
  font-size: 21px;
  line-height: 1.55;
}
/* ruled byline strip — the "record" device */
.byline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.04em;
}
.byline strong { color: var(--ink); }
.byline a:hover { color: var(--accent-dark); }
.byline span:last-of-type {
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11.5px;
}

/* ---------- hero photo: tipped-in plate ---------- */
.hero-photo {
  margin: 30px auto 0;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 34px;
}
.hero-photo .hero-photo-frame {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 6px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule), var(--shadow-hero);
  isolation: isolate;
  background: var(--paper-soft);
}
.hero-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transform-origin: center;
  filter: sepia(0.06) contrast(1.01);
  animation: heroKenBurns 30s ease-in-out infinite alternate;
  will-change: transform;
}
.hero-photo .hero-photo-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(42, 32, 24, 0.38) 0%, rgba(42, 32, 24, 0.04) 42%, rgba(42, 32, 24, 0) 100%);
  pointer-events: none;
  z-index: 1;
}
.hero-photo figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1.45;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
@keyframes heroKenBurns {
  0%   { transform: scale(1.02); }
  100% { transform: scale(1.06); }
}
/* Missing-image: warm letterpress plate (no glow, no alarm) */
.hero-photo.hero-photo-empty { border-bottom: 1px solid var(--rule); }
.hero-photo .hero-photo-placeholder {
  position: relative;
  min-height: 280px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  border: 6px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule), var(--shadow);
  background: linear-gradient(135deg, var(--paper) 0%, var(--paper-soft) 55%, var(--paper-deep) 100%);
}
.hero-photo .hero-photo-placeholder::before {
  content: "";
  position: absolute;
  left: 18px;
  bottom: 44px;
  width: 56px;
  height: 2px;
  background: var(--accent);
}
.hero-photo .hero-photo-placeholder .hp-tag {
  position: absolute;
  left: 18px;
  bottom: 16px;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.hero-photo .hero-photo-placeholder .hp-pulse {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(251, 246, 236, 0.8);
  animation: heroPulse 4s ease-in-out infinite;
}
@keyframes heroPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ---------- reading layout ---------- */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 700px) 300px;
  gap: 84px;
  padding: 48px 0 72px;
}

/* THE core upgrade: prose moves from Georgia to Fraunces on cream */
.prose {
  font-family: Fraunces, Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 440;
  font-size: 20px;
  line-height: 1.74;
  color: var(--ink);
  text-wrap: pretty;
}
.prose p { margin: 0 0 1.5em; }
/* Drop cap: the one ember flourish that says "feature" */
.prose > p:first-of-type::first-letter {
  float: left;
  font-family: Fraunces, Georgia, serif;
  font-weight: 900;
  font-size: 4.4em;
  line-height: 0.78;
  padding: 8px 14px 0 0;
  color: var(--accent);
}
.prose h2 {
  margin: 2.2em 0 0.6em;
  font-family: Fraunces, Georgia, serif;
  font-size: 30px;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -0.005em;
}
.prose h2::before {
  content: "";
  display: block;
  width: 28px;
  height: 3px;
  margin-bottom: 14px;
  background: var(--accent);
}
.prose ul { margin: 0 0 1.5em; padding-left: 1.2em; }
.prose li { margin: 0 0 0.5em; }
.prose li::marker { color: var(--accent); }
.prose a {
  color: var(--accent-dark);
  border-bottom: 0;
  text-decoration: underline;
  text-decoration-color: rgba(142, 58, 27, 0.4);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color .15s ease;
}
.prose a:hover { text-decoration-color: var(--accent); }

/* ---- journal blocks: code, terminal output, pull quotes ---- */
.prose pre {
  margin: 0 0 1.6em;
  padding: 18px 20px;
  background: var(--paper-deep);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  overflow-x: auto;
  box-shadow: var(--shadow-card);
}
.prose pre code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  white-space: pre;
  background: none;
  padding: 0;
  border: 0;
}
.prose code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: var(--paper-soft);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.1em 0.36em;
  color: var(--ink-2);
}
.prose blockquote {
  margin: 0 0 1.6em;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--accent);
  font-family: Fraunces, Georgia, serif;
  font-size: 1.12em;
  font-style: italic;
  color: var(--ink-2);
}
/* A code block or heading must never sit under a drop cap. */
.prose > pre:first-child,
.prose > h2:first-child { margin-top: 0; }

/* Automated-desk disclosure under the byline */
.automated-note {
  margin: 14px 0 0;
  max-width: 60ch;
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  border-left: 2px solid var(--rule-strong);
  padding-left: 12px;
}
.automated-note a { color: var(--ink-2); text-decoration-color: var(--rule-strong); }
.automated-note a:hover { color: var(--accent-dark); }

/* Journal posts have no sidebar aside — let the prose column centre itself. */
.article-layout-solo { grid-template-columns: minmax(0, 720px); justify-content: center; }

/* Pull-quote (revived from dead CSS): no box, just rule + serif air */
.take {
  border-left: 3px solid var(--accent);
  background: transparent;
  border-radius: 0;
  padding: 6px 0 6px 26px;
  margin: 44px 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.4;
  color: var(--ink);
}

/* "The Briefing": three spec-boxes become one ruled ledger panel */
.publish-blocks {
  display: grid;
  gap: 0;
  margin: 44px 0 36px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
}
.publish-block {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 20px 24px;
}
.publish-block + .publish-block { border-top: 1px solid var(--rule); }
.publish-block h2 {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
}
.publish-block p {
  margin: 0;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.65;
}

/* ---------- side rail: "Signal" ---------- */
.side-note {
  position: sticky;
  top: 88px;
  align-self: start;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--brass);
  border-radius: 12px;
  background: var(--paper-soft);
  padding: 22px;
}
.side-note h2 {
  margin: 12px 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 23px;
  font-weight: 650;
  line-height: 1.12;
}
.side-note p,
.side-note li {
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
}
.side-note ul { margin: 12px 0 0; padding-left: 18px; }

/* tags: warm filing labels (matches homepage) */
.tag {
  display: inline-flex;
  width: fit-content;
  border-radius: 4px;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: var(--blue-soft); color: var(--blue); }

/* ---------- sources: footnote apparatus ---------- */
.sources {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 2px solid var(--rule-strong);
  font-family: Inter, system-ui, sans-serif;
}
.sources h2 {
  margin: 0 0 16px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.sources ul {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: src;
}
.sources li {
  position: relative;
  counter-increment: src;
  padding-left: 40px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 12px;
}
.sources li::before {
  content: counter(src, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sources li a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-color: rgba(142, 58, 27, 0.35);
  text-underline-offset: 3px;
}
.sources li a:hover { text-decoration-color: var(--accent); }
.source-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- read next ---------- */
.read-next {
  padding: 40px 0 8px;
  border-top: 2px solid var(--rule-strong);
}
.read-next > h2 {
  margin: 0 0 18px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.read-next-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.read-next-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow-card);
  padding: 20px 20px 16px;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.read-next-card:hover {
  border-color: var(--rule-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
}
.read-next-card h3 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.22;
  color: var(--ink);
}
.read-next-card:hover h3 { color: var(--accent-dark); }
.read-next-meta {
  margin-top: auto;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- footer: sepia colophon band ---------- */
.footer {
  margin-top: 56px;
  border-top: 2px solid var(--ink);
  background: var(--paper-deep);
  padding: 30px 0 44px;
  color: var(--muted);
  font-size: 12px;
}
.footer .shell {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

/* ---------- inline subscribe: the warmest block on the page ---------- */
.article-subscribe { padding: 44px 0 8px; }
.article-subscribe-inner {
  padding: 32px 32px 30px;
  border: 1px solid var(--rule-strong);
  border-radius: 18px;
  background: var(--accent-soft);
  box-shadow: var(--shadow-card);
}
.asub-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dark);
}
.article-subscribe h2 {
  margin: 0 0 8px;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(23px, 3.2vw, 30px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.asub-sub {
  margin: 0 0 18px;
  max-width: 58ch;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.55;
}
.asub-form { max-width: 460px; }
.asub-alt { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.asub-alt a { color: var(--accent-dark); font-weight: 600; }
.asub-vh { position: absolute; left: -999px; }
.asub-hp { position: absolute; left: -9999px; }

/* subscribe form primitives (matches homepage) */
.subscribe-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.subscribe-form input[type="email"] {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: #FFFDF8;
  padding: 0 13px;
  font-size: 14px;
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
}
.subscribe-form input[type="email"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.subscribe-form .button { min-height: 42px; }
.subscribe-status {
  grid-column: 1 / -1;
  margin: 0.6rem 0 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 13.5px;
  color: var(--ink-2);
  min-height: 1em;
}
.subscribe-status.is-success { color: var(--green); }
.subscribe-status.is-error { color: var(--accent-dark); }

/* ---------- shared reveal motion ---------- */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .42s cubic-bezier(.2, .7, .2, 1), transform .42s cubic-bezier(.2, .7, .2, 1);
}
.reveal.is-visible { opacity: 1; transform: none; }
.reveal[data-r="1"] { transition-delay: .06s; }
.reveal[data-r="2"] { transition-delay: .12s; }
.reveal[data-r="3"] { transition-delay: .18s; }
.reveal[data-r="4"] { transition-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .hero-photo img { animation: none; transform: none; }
  .hero-photo .hp-pulse { animation: none; }
}

@media (max-width: 860px) {
  .shell { width: min(100% - 28px, 1100px); }
  /* Keep the section links reachable on phones: brand on row 1, links + subscribe on row 2. */
  .nav-inner { flex-wrap: wrap; row-gap: 10px; min-height: 0; padding: 11px 0; }
  .brand { font-size: 22px; }
  .nav-links { width: 100%; gap: 16px; flex-wrap: wrap; }
  .nav-links a { font-size: 12px; }
  .nav-links .button { margin-left: auto; min-height: 34px; padding: 0 13px; }
  /* minmax(0,1fr) lets the column shrink below a code block's min-content width,
     so a long <pre> line scrolls inside its own box instead of stretching the page. */
  .article-layout, .article-layout-solo { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .side-note { position: static; }
  .article-hero { padding: 44px 0 32px; }
  .article-hero h1 { font-size: clamp(34px, 10.5vw, 56px); line-height: 1.07; }
  .dek { font-size: 19px; }
  .publish-block { padding: 16px 18px; }
  .prose { font-size: 19px; min-width: 0; }
  .prose > p:first-of-type::first-letter { font-size: 3.8em; }
  .hero-photo img { aspect-ratio: 4 / 3; }
  .hero-photo .hero-photo-placeholder { aspect-ratio: 4 / 3; min-height: 220px; }
  .read-next-grid { grid-template-columns: 1fr; }
  .article-subscribe-inner { padding: 24px 20px; }
  .subscribe-form { grid-template-columns: 1fr; }
  .footer .shell { flex-direction: column; }
}

/* In-body diagrams (figure blocks, hand-authored inline SVG) */
.article-figure { margin: 2.4em auto; text-align: center; }
.article-figure svg,
.article-figure img { display: block; width: 100%; height: auto; max-width: 660px; margin: 0 auto; border-radius: 6px; }
.article-figure figcaption {
  margin: 12px auto 0;
  max-width: 58ch;
  color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  line-height: 1.55;
  text-align: center;
}
