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

/* IBM Plex Mono is the only family. Latin subset, ~15K per file. */
@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;
}

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

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

:root {
  --bg:          #121416;
  --text:        #e4e0d8;
  --text-strong: #e4e0d8;
  --text-body:   #e4e0d8;
  --text-read:   #cfcbc3;
  --muted:       #a39f97;
  --dim:         #7b7872;
  --faint:       #55524d;
  --rule:        #1b1e21;
  --rule-strong: #2d3135;
  --accent:      #e4e0d8;
}

/* ============================================================ 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: 680px;
  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;
  flex-wrap: wrap;
  gap: 1ch 2ch;
  padding: 28px 0;
  font-size: 13px;
}

.nav-brand,
.nav-brand:hover { background: none; color: var(--text-strong); text-decoration: none; }
.nav-brand .logo { width: 1.1em; height: 1.1em; margin-right: 1ch; vertical-align: -0.2em; }
.nav-name { font-weight: 500; }

.nav-links { display: inline-flex; gap: 1ch; }
.nav-links a { color: var(--muted); }
.nav-links a.active { color: var(--text-strong); }
.nav-sep { color: var(--faint); }

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

a {
  color: inherit;
  text-decoration: underline 1px;
  text-decoration-color: var(--faint);
  text-underline-offset: 5px;
  transition: color 120ms ease, background-color 120ms ease;
}

a:hover {
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
}

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

.post-title {
  margin: 96px 0 0;
  font-size: 2.25rem; /* 36px */
  line-height: 1.25;
  font-weight: 300;
  letter-spacing: 0.01em;
  color: var(--text-strong);
}

.page-title {
  margin: 96px 0 40px;
  font-size: 1.75rem; /* 28px */
  line-height: 1.3;
  font-weight: 300;
  letter-spacing: 0.01em;
  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;
  font-size: 0.9375rem; /* 15px */
  line-height: 1.9;
  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 {
  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: 72ch;
  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;
  margin: 2.2em 0 0.8em;
  font-weight: 400;
  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: space alone separates sections, no rule. */
.prose h2 {
  font-size: 1.5rem; /* 24px */
  font-weight: 300;
  letter-spacing: 0.01em;
  margin: 2.6em 0 0.9em;
}

/* 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; }
.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,
.prose .zola-anchor:hover {
  background: none;
  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(228, 224, 216, 0.12); }
  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); }

.prose strong { font-weight: 600; color: var(--text-strong); }
.prose em { font-style: italic; }

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

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

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

.prose code {
  background: var(--rule-strong);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.92em;
}

.prose pre {
  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; gap: 44px; }

.row {
  display: grid;
  grid-template-columns: 4ch 1fr;
  column-gap: 2ch;
  align-items: baseline;
}

.row-num { color: var(--faint); font-variant-numeric: tabular-nums; }
.row-title { font-size: 1rem; color: var(--text-strong); justify-self: start; }

.row-meta {
  grid-column: 2;
  margin: 6px 0 0;
  max-width: 62ch;
  color: var(--dim);
}

.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: 128px;
  padding: 18px 0 36px;
  font-size: 11px;
  color: var(--dim);
}

.footer a { color: var(--dim); }

/* ============================================================== 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; }

.home-logo { margin-top: 52px; }
.home-logo + .home-intro { margin-top: 20px; }
.home-logo .logo-halftone { display: block; width: 120px; height: 120px; }

.notfound-art {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 64px 0 32px;
}

.notfound-links { margin-top: 20px; }

/* ================================================ 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 { column-gap: 1.5ch; }

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

}
