/* ----------------------------------------------------
   Blog post — clean single-column reading layout
   Shared by every post. Inherits tokens from styles.css
   ---------------------------------------------------- */

body.post-body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

/* ---------- Top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--rule);
  background: rgba(251, 250, 247, .9);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 940px;
  margin: 0 auto;
  padding: 14px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--sans);
  font-size: 13px;
}
.topbar a { text-decoration: none; color: var(--ink); }
.topbar a:hover { color: var(--accent); }
.topbar .brand { font-weight: 600; }
.topbar .crumb { color: var(--ink-faint); margin: 0 8px; }
.topbar nav { display: flex; gap: 18px; }
.topbar nav a { color: var(--ink-soft); }

/* ---------- Hero ---------- */
.post-hero {
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(44px, 7vw, 84px) var(--gutter) clamp(28px, 4vw, 40px);
}
.post-hero .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 22px;
}
.post-hero .eyebrow .pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 8px;
  margin-right: 8px;
}
.post-hero h1 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(31px, 4.8vw, 50px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
  text-wrap: balance;
}
.post-hero h1 em { font-style: italic; color: var(--accent); }
.post-hero .dek {
  font-family: var(--sans);
  font-size: clamp(18px, 2vw, 21px);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 30px;
}
.byline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 28px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule-faint);
  padding-top: 18px;
}
.byline .field-label {
  display: block;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}
.byline .field-value { color: var(--ink); }
.byline .field-value a { text-decoration: none; border-bottom: 1px solid var(--rule); }
.byline .field-value a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Cover image ---------- */
.post-cover {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 28px) var(--gutter) 0;
}
.post-cover img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
  background: var(--paper);
}
.post-cover .cap {
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-faint);
  margin: 10px 0 0;
}

/* ---------- Article: single column, figures break wider ---------- */
.article {
  max-width: 940px;
  margin: 0 auto;
  padding: clamp(36px, 5vw, 60px) var(--gutter) 72px;
}
.article > * {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}
.article > figure { max-width: 100%; }

.article p {
  font-size: 19px;
  line-height: 1.7;
  margin: 0 0 1.15em;
  text-wrap: pretty;
}
.article p .dropcap:first-letter {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 4.4em;
  line-height: .82;
  float: left;
  padding: 6px 10px 0 0;
  color: var(--accent);
}
.article strong { font-weight: 600; }
.article em { font-style: italic; }
.article a {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.article a:hover { color: var(--accent); }

.article h2 {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 60px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.article h2 .num {
  font-family: var(--mono);
  color: var(--accent);
  margin-right: 12px;
}
.article h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.3;
  margin: 34px 0 10px;
  letter-spacing: -0.015em;
}

.article ul, .article ol {
  font-size: 18px;
  line-height: 1.65;
  padding-left: 1.4em;
}
.article li { margin-bottom: .4em; }

/* TL;DR card */
.tldr {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 20px 24px;
  margin: 8px auto 34px;
}
.tldr .label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.tldr p { font-size: 17px; line-height: 1.6; margin: 0; }

/* Inline aside */
.note {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-soft);
  border-left: 2px solid var(--accent);
  background: var(--rule-faint);
  padding: 12px 16px;
  margin: 24px auto;
}

/* Pull quote */
.pull {
  font-family: var(--sans);
  font-style: italic;
  font-size: clamp(21px, 2.6vw, 26px);
  line-height: 1.4;
  color: var(--ink);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 26px 0;
  margin: 38px auto;
  text-wrap: balance;
}

/* ---------- Figures ---------- */
figure.figure {
  margin: 40px auto;
  background: var(--paper);
  border: 1px solid var(--rule);
}
figure.figure a { display: block; }
figure.figure img {
  width: 100%;
  height: auto;
  display: block;
  border-bottom: 1px solid var(--rule);
}
figure.figure figcaption {
  padding: 13px 18px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}
figure.figure figcaption .num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 8px;
}

/* Photos (cat post) */
.article > figure.photo {
  max-width: 480px;
  margin: 38px auto;
  border: 1px solid var(--rule);
  background: var(--paper);
}
.article > figure.photo img {
  width: 100%;
  height: auto;
  display: block;
  border-bottom: 1px solid var(--rule);
}
.article > figure.photo figcaption {
  padding: 11px 16px;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 38px auto;
}
.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  display: block;
  border: 1px solid var(--rule);
}
.photo-grid-cap {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-faint);
  margin: 12px auto 0;
  text-align: center;
}
@media (max-width: 560px) {
  .photo-grid { grid-template-columns: 1fr; }
  .photo-grid img { aspect-ratio: 4 / 3; }
}

/* ---------- Interactive widget ---------- */
.widget {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 22px 24px;
  margin: 32px auto;
}
.widget header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-family: var(--sans);
}
.widget header h4 {
  margin: 0;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}
.widget header .tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 7px;
}
.widget .canvas-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.widget .panel {
  border: 1px solid var(--rule);
  background: #000;
  aspect-ratio: 1 / 1;
  position: relative;
}
.widget .panel canvas {
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
}
.widget .panel .panel-label {
  position: absolute; bottom: 6px; left: 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  padding: 2px 6px;
}
.widget .controls {
  display: grid;
  grid-template-columns: 96px 1fr 56px;
  align-items: center;
  gap: 12px;
  font-family: var(--sans);
  font-size: 13px;
  margin-bottom: 8px;
}
.widget .controls label { color: var(--ink-soft); }
.widget .controls .value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.widget input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  height: 2px;
  background: var(--rule);
  outline: none;
}
.widget input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px;
  background: var(--accent);
  border: 0; border-radius: 50%;
  cursor: pointer;
}
.widget input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--accent);
  border: 0; border-radius: 50%;
  cursor: pointer;
}
.widget .widget-note {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.55;
  margin: 14px 0 0;
}

/* Comparison strip */
.compare-strip { margin: 32px auto; }
.compare-strip .strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.compare-strip .strip > div {
  aspect-ratio: 1 / 1;
  background: #000;
  position: relative;
  border: 1px solid var(--rule);
}
.compare-strip .strip canvas {
  width: 100%; height: 100%;
  display: block;
  image-rendering: pixelated;
}
.compare-strip .strip .caption {
  position: absolute; bottom: 4px; left: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, .55);
  padding: 2px 6px;
}
.compare-strip .strip-note {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.55;
  margin: 0;
}

/* ---------- Math ---------- */
.eq-block {
  margin: 26px auto;
  text-align: center;
  font-size: 18px;
  position: relative;
  padding: 6px 56px 6px 6px;
  overflow-x: auto;
}
.eq-block .eq-tag {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-faint);
}
.article .katex { font-size: 1em !important; }

/* Algorithm box */
.algo {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 18px 22px;
  margin: 28px auto;
  white-space: pre;
  overflow-x: auto;
}
.algo .algo-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  white-space: normal;
}
.algo .kw { color: var(--accent); }
.algo .cm { color: var(--ink-faint); }

/* Citation block */
.cite-block {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 16px 18px;
  margin: 16px auto;
  white-space: pre;
  overflow-x: auto;
  color: var(--ink-soft);
}

/* References */
.refs {
  list-style: none;
  padding: 0;
  margin: 22px auto 0;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
  counter-reset: ref;
}
.refs li {
  counter-increment: ref;
  padding-left: 28px;
  position: relative;
  margin-bottom: 10px;
}
.refs li::before {
  content: "[" counter(ref) "]";
  position: absolute;
  left: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}

/* ---------- Footer ---------- */
.post-footer {
  max-width: 940px;
  margin: 0 auto;
  padding: 40px var(--gutter) 64px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-soft);
}
.post-footer a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); }
.post-footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }
