/* ============================================================ fonts ===== */

/* IBM Plex Mono - the monospace identity: nav, labels, titles, code,
   section headings. Static 400/500/600 (latin subset, ~15K each). */
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/IBMPlexMono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/IBMPlexMono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("/fonts/IBMPlexMono-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

/* iA Writer Quattro - long-form reading body. Derived from IBM Plex Mono and
   opened into a proportional text face, so it pairs with the mono above while
   reading far better for essays. Static roman/italic at 400 and 700. */
@font-face {
  font-family: "iA Writer Quattro";
  src: url("/fonts/iAWriterQuattroS-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "iA Writer Quattro";
  src: url("/fonts/iAWriterQuattroS-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "iA Writer Quattro";
  src: url("/fonts/iAWriterQuattroS-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "iA Writer Quattro";
  src: url("/fonts/iAWriterQuattroS-BoldItalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

/* =========================================================== tokens ===== */

:root {
  --bg:          #0c0c0f;
  --text:        #ffffff;
  --text-strong: #ffffff;
  --text-body:   #fbfbfc;
  --text-read:   #d4d4d8;
  --muted:       #ededf0;
  --dim:         #8a8a93;
  --faint:       #5c5c66;
  --rule:        #18181b;
  --rule-strong: #1f1f23;
  --accent:      #6700ff;
  --prompt:      #10b981;
}

/* ============================================================ reset ===== */

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

/* Sizes are in rem so a reader who bumps their browser font for a long
   article actually gets larger text. 1rem = 16px at the default. */
html { -webkit-text-size-adjust: 100%; font-size: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 400;
  font-size: 0.8125rem; /* 13px */
  line-height: 1.6;
  font-variant-ligatures: none;
  text-rendering: auto;
}

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

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

/* =========================================================== layout ===== */

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content { flex: 1 0 auto; }

/* ============================================================== nav ===== */

.nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2ch;
  padding: 20px 0;
  border-bottom: 1px solid var(--rule-strong);
  font-size: 13px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms ease;
}

.nav-brand {
  color: var(--text-strong) !important;
  font-weight: 500;
}

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

.nav-links a:hover { color: var(--text-strong); }

.nav-links a.active {
  color: var(--text-strong);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

.nav-sep { color: var(--faint); }

/* ============================================================ links ===== */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 4px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

a:hover {
  color: var(--text-strong);
  text-decoration-color: var(--accent);
}

/* =========================================================== titles ===== */

.post-title {
  margin: 56px 0 0;
  font-size: 1.75rem; /* 28px */
  line-height: 1.28;
  font-weight: 500;
  color: var(--text-strong);
}

.page-title {
  margin: 56px 0 32px;
  font-size: 22px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--text-strong);
}

.post-meta {
  margin: 12px 0 0;
  font-size: 0.75rem; /* 12px */
  color: var(--dim);
}

/* ============================================================ prose ===== */

.prose {
  max-width: 62ch;
  margin-top: 40px;
  /* Reading body is the proportional Quattro; mono is re-asserted on
     headings and code below so the technical rhythm stays. */
  font-family: "iA Writer Quattro", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.9375rem; /* 15px */
  line-height: 1.7;
  color: var(--text-body);
}

/* Line quality in a fixed monospace measure: balance the ragged right
   edge, kill orphans, and stop long tokens from breaking the column. */
.prose p {
  /* No auto-hyphenation: a proportional reading body reads cleaner with a
     plain ragged edge. text-wrap: pretty still balances the rag and kills
     orphans; overflow-wrap only steps in for unbreakable tokens (URLs). */
  text-wrap: pretty;
  hyphens: manual;
  overflow-wrap: break-word;
}

/* Long posts: shorter measure, larger type, softer body color than other
   prose pages so a full screenful of text does not glare or run too wide.
   Headings/strong keep var(--text-strong) for rhythm and contrast. */
.post .prose {
  max-width: 70ch;
  font-size: 1rem; /* 16px - Quattro reads a touch larger than the mono */
  line-height: 1.7;
  color: var(--text-read);
}

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

.prose p { margin: 0 0 1.5em; }

.prose h2,
.prose h3,
.prose h4 {
  position: relative;
  /* Headings stay monospace: a hard typographic cut between the brutal
     section markers and the proportional reading body. */
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  margin: 2.2em 0 0.8em;
  font-weight: 500;
  color: var(--text-strong);
  line-height: 1.35;
  /* room so an anchor jump doesn't land flush against the viewport top */
  scroll-margin-top: 2rem;
}

/* h2 = chapter break: hairline + generous top gap turns a long post into
   scannable sections; 600/larger firms up the hierarchy. */
.prose h2 {
  font-size: 1.2rem; /* ~19px */
  font-weight: 600;
  margin: 1.8em 0 0.9em;
  padding-top: 1em;
  border-top: 1px solid var(--rule-strong);
}

/* No doubled divider when an h2 directly follows an explicit <hr> or opens
   the post. */
.prose hr + h2,
.prose > h2:first-child {
  margin-top: 0.8em;
  padding-top: 0;
  border-top: 0;
}
.prose h3 { font-size: 0.96875rem; } /* 15.5px */
.prose h4 { font-size: 0.90625rem; color: var(--text); } /* 14.5px */

/* Headings are #permalinks (insert_anchor_links = "heading"). Quiet by
   default; a faint "#" appears on hover/focus, so the page never looks
   link-cluttered but every section is deep-linkable. */
.prose .zola-anchor {
  color: inherit;
  text-decoration: none;
}

.prose .zola-anchor::before {
  content: "#";
  position: absolute;
  left: -2ch;
  color: var(--faint);
  opacity: 0;
  transition: opacity 150ms ease;
}

.prose :is(h2, h3, h4):hover .zola-anchor::before,
.prose .zola-anchor:focus-visible::before { opacity: 1; }

/* Following a section link briefly flags the target; the static accent "#"
   remains as the indicator when motion is reduced (see reduced-motion block). */
.prose :is(h2, h3, h4):target::before { opacity: 1; color: var(--accent); }

.prose :is(h2, h3, h4):target {
  animation: target-flash 1.6s ease-out 1;
  border-radius: 3px;
}

@keyframes target-flash {
  from { background: rgba(103, 0, 255, 0.16); }
  to   { background: transparent; }
}

/* back-to-top, mirrors the quiet section-label rhythm */
.to-top {
  margin-top: 48px;
  font-size: 0.6875rem; /* 11px */
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.to-top a { color: var(--dim); text-decoration: none; }
.to-top a:hover { color: var(--accent); }

/* Quattro is a two-weight family (400/700); strong uses the real Bold. */
.prose strong { font-weight: 700; color: var(--text-strong); }
.prose em { font-style: italic; }

.prose a {
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 4px;
}

.prose ul,
.prose ol { margin: 0 0 1.5em; padding-left: 2.2ch; }
.prose li { margin: 0.3em 0; }

.prose hr {
  margin: 2.8em 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.prose blockquote {
  margin: 1.5em 0;
  padding-left: 2ch;
  border-left: 2px solid var(--rule-strong);
  color: var(--muted);
}

.prose code {
  /* Code stays mono even inside the proportional reading body. */
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--rule-strong);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.92em;
}

.prose pre {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  margin: 1.5em 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: var(--rule);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  font-size: 0.8125rem; /* 13px */
  line-height: 1.6;
  color: var(--text-body);
}

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

/* ===================================================== section labels === */

.section-label,
.year-marker {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0;
}

.previous { margin-top: 64px; }
.section-label { margin-bottom: 20px; }

.year-group { margin-top: 48px; }
.year-marker {
  font-size: 22px;
  padding-top: 22px;
  margin-bottom: 16px;
}

/* ======================================================== post rows ===== */

.rows { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: 11ch 1fr;
  gap: 2ch;
  padding: 7px 0;
  text-decoration: none;
  color: var(--text);
}

.row-date { color: var(--dim); }
.row-title { color: var(--text); transition: color 150ms ease; }
.row:hover .row-title { color: var(--text-strong); }
.row:hover .row-date { color: var(--muted); }

.more { margin-top: 28px; font-size: 13px; }

/* ====================================================== key/value kv ===== */

.kv {
  display: grid;
  gap: 0.4em 2ch;
  margin: 1.4em 0 2.4em;
  font-size: 14.5px;
  line-height: 1.7;
  max-width: 62ch;
}

.kv > span:nth-child(odd) { color: var(--dim); }
.kv > span:nth-child(even) { color: var(--text-body); }

.kv-feeds { grid-template-columns: 8ch 1fr; }
.kv-uses  { grid-template-columns: 12ch 1fr; }

/* manpage (uses) */
.manpage { max-width: 62ch; }

.man-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 2.4em 0 0.9em;
}

.now-updated {
  margin-top: 2.4em;
  font-size: 12px;
  color: var(--dim);
}

/* ==================================================== post siblings ===== */

.post-siblings {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  margin-top: 64px;
  font-size: 13px;
}

.sib-next { margin-left: auto; text-align: right; }

/* ============================================================== 404 ===== */

.notfound { margin-bottom: 64px; }
.notfound .muted { color: var(--muted); margin: 0 0 28px; }

.muted { color: var(--muted); }

/* =========================================================== footer ===== */

.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2ch;
  flex-wrap: wrap;
  margin-top: 80px;
  padding: 18px 0 28px;
  border-top: 1px solid var(--rule-strong);
  font-size: 11px;
  color: var(--dim);
}

.footer a { color: var(--dim); text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* ============================================================= links ===== */

.lk {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 4px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.lk:hover {
  color: var(--text-strong);
  text-decoration-color: var(--accent);
}

/* ============================================================== uses ===== */

.uses-label {
  margin: 32px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.uses-rows {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4em 3ch;
  margin-left: 3ch;
  max-width: 62ch;
  font-size: 13px;
  line-height: 1.6;
}

.uses-rows .uses-k { color: var(--dim); }
.uses-rows .uses-v { color: var(--text); }

.uses-updated {
  margin-top: 36px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--faint);
}

/* =========================================================== home intro = */

.home-intro {
  margin: 52px 0 0;
  max-width: 62ch;
  font-size: 13px;
  line-height: 1.7;
  color: var(--dim);
}

.home-intro + .page-title { margin-top: 28px; }

/* ================================================ reading progress ===== */

/* No-JS scroll-progress bar via CSS scroll-driven animation. Browsers
   without animation-timeline (Firefox/Safari) just never paint it, since
   the base transform stays scaleX(0) - a clean progressive no-op. */
.reading-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 50;
}

@supports (animation-timeline: scroll()) {
  .reading-progress {
    animation: reading-progress linear both;
    animation-timeline: scroll(root block);
  }

  @keyframes reading-progress {
    to { transform: scaleX(1); }
  }
}

/* =========================================================== mobile ===== */

@media (max-width: 700px) {
  .wrap { padding: 0 20px; }

  .post-title { margin-top: 40px; font-size: 24px; }
  .page-title { margin-top: 40px; }

  .row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 9px 0;
  }

  .kv-feeds,
  .kv-uses { grid-template-columns: 1fr; gap: 1px 0; }
  .kv > span:nth-child(odd) { padding-top: 0.6em; }
  .kv > span:nth-child(even) { padding-bottom: 0.2em; }

  .uses-rows {
    grid-template-columns: 1fr;
    gap: 1px 0;
    margin-left: 0;
  }
  .uses-rows .uses-k { padding-top: 0.6em; }

  .footer {
    flex-direction: column;
    gap: 4px;
  }
}

/* =================================================== reduced motion ===== */

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

  /* The scroll-driven bar would otherwise snap to full width and sit there;
     drop it entirely. The static accent "#" on :target still flags the
     section, so navigation stays usable without any motion. */
  .reading-progress { display: none; }
}
