/* ═══════════════════════════════════════════════════════════════════
   Blog — long-form editorial layer on top of styles.css.
   Loaded only by /blog pages, so the landing page payload is unchanged.
   ═══════════════════════════════════════════════════════════════════ */

/* Section ids are a public contract: the ModelFit desktop app deep-links
   to them from its glossary tooltips. Never rename one — only add. */
[id] { scroll-margin-top: 5.5rem; }

/* ── index ────────────────────────────────────────────────────────── */
.blog-head { padding-top: 4rem; max-width: 46rem; }
.blog-head .lede { max-width: 54ch; }

.post-list { list-style: none; margin: 3rem 0 0; padding: 0; display: grid; gap: 1.25rem; }
.post-card {
  display: block; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.75rem 1.6rem;
  transition: border-color .16s, transform .16s;
}
.post-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.post-card h2 {
  font-family: var(--serif); font-size: 1.5rem; font-weight: 600;
  letter-spacing: -.018em; margin: .45rem 0 .55rem; line-height: 1.25;
}
.post-card p { margin: 0; color: var(--ink-soft); font-size: .97rem; max-width: 62ch; }
.post-meta {
  font-size: .8rem; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
}
.post-meta .dot { opacity: .5; }
.post-more { display: inline-block; margin-top: 1rem; font-size: .9rem; font-weight: 500; color: var(--indigo); }

/* ── article shell ────────────────────────────────────────────────── */
.article-head { padding-top: 3.5rem; max-width: 44rem; }
.article-head h1 { font-size: clamp(2.1rem, 4.2vw, 3.1rem); margin-top: .7rem; }
.article-head .lede { max-width: 56ch; font-size: 1.14rem; }
.article-meta { margin: 1.6rem 0 0; font-size: .84rem; color: var(--muted); }

.article-grid { display: grid; gap: 3rem; padding-top: 3rem; align-items: start; }
@media (min-width: 1024px) {
  .article-grid { grid-template-columns: minmax(0, 1fr) 15rem; gap: 4rem; }
}

/* ── contents rail ────────────────────────────────────────────────── */
.toc { font-size: .87rem; }
@media (min-width: 1024px) {
  .toc { position: sticky; top: 5.5rem; order: 2; max-height: calc(100vh - 8rem); overflow-y: auto; }
}
.toc h2 {
  font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--clay-deep); margin: 0 0 .9rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .42rem; counter-reset: toc; }
.toc a {
  text-decoration: none; color: var(--muted); display: block; line-height: 1.4;
  border-left: 2px solid transparent; padding-left: .75rem; transition: color .14s, border-color .14s;
}
.toc a:hover { color: var(--ink); border-left-color: var(--border-strong); }
.toc a.is-current { color: var(--ink); border-left-color: var(--clay); font-weight: 500; }

/* ── prose ────────────────────────────────────────────────────────── */
.prose { max-width: 40rem; min-width: 0; }
.prose section { padding-top: 2.9rem; }
.prose section:first-of-type { padding-top: 0; }
.prose h2 {
  font-family: var(--serif); font-size: clamp(1.55rem, 2.6vw, 1.95rem);
  font-weight: 600; letter-spacing: -.018em; line-height: 1.2; margin: 0 0 1rem;
}
.prose h3 {
  font-family: var(--serif); font-size: 1.2rem; font-weight: 600;
  letter-spacing: -.014em; margin: 2rem 0 .7rem;
}
.prose p { margin: 0 0 1.15rem; color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 600; }
/* :not(.btn) so buttons keep their own fill and label colour — a plain
   `.prose a` outranks `.btn-primary` and would paint indigo text on indigo. */
.prose a:not(.btn) { color: var(--indigo); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--indigo) 35%, transparent); }
.prose a:not(.btn):hover { border-bottom-color: var(--indigo); }
.prose ul, .prose ol { margin: 0 0 1.15rem; padding-left: 1.3rem; color: var(--ink-soft); }
.prose li { margin-bottom: .5rem; }
.prose li::marker { color: var(--clay); }
.prose code {
  font-family: var(--mono); font-size: .87em;
  background: var(--paper-2); border: 1px solid var(--border);
  border-radius: .35rem; padding: .1em .38em; color: var(--ink);
}
.prose pre {
  margin: 0 0 1.3rem; padding: 1rem 1.15rem; overflow-x: auto;
  background: var(--paper-2); border: 1px solid var(--border); border-radius: 10px;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: .84rem; line-height: 1.7; }

/* the anchored section the app just jumped to */
.prose section:target > h2 { position: relative; }
.prose section:target > h2::before {
  content: ""; position: absolute; left: -1.1rem; top: .18em; bottom: .18em;
  width: 3px; border-radius: 2px; background: var(--clay);
}

/* ── section anchor link ──────────────────────────────────────────── */
.anchor {
  margin-left: .45rem; font-family: var(--sans); font-size: .8rem; font-weight: 400;
  color: var(--border-strong); text-decoration: none; opacity: 0;
  transition: opacity .14s, color .14s;
}
h2:hover .anchor, .anchor:focus { opacity: 1; }
.anchor:hover { color: var(--clay); }

/* ── figures: the memory bar and tables ───────────────────────────── */
.prose figure { margin: 1.6rem 0 1.7rem; }
.prose figcaption { font-size: .84rem; color: var(--muted); margin-top: .7rem; }

.tbl-wrap { overflow-x: auto; margin: 0 0 1.3rem; border: 1px solid var(--border); border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; font-size: .89rem; background: var(--surface); }
.prose th, .prose td { padding: .6rem .85rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.prose thead th {
  font-size: .72rem; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); background: var(--paper-2);
}
.prose tbody tr:last-child td { border-bottom: 0; }
.prose td.num { text-align: right; font-variant-numeric: tabular-nums; }
.prose tr.pick td { background: color-mix(in srgb, var(--clay) 6%, transparent); }
.prose tr.pick td:first-child { font-weight: 600; color: var(--ink); }

/* stacked memory bar */
.membar { display: flex; height: 2.6rem; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.membar span { display: grid; place-items: center; font-size: .78rem; font-weight: 600; color: #fff; }
.membar .w { background: var(--clay); }
.membar .k { background: var(--indigo); }
.membar .o { background: var(--ink-soft); }
.membar-key { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: .8rem; font-size: .82rem; color: var(--muted); }
.membar-key i { display: inline-block; width: .65rem; height: .65rem; border-radius: 3px; margin-right: .4rem; vertical-align: middle; }

/* ── callout ──────────────────────────────────────────────────────── */
.note {
  border-left: 2px solid var(--clay); background: var(--clay-soft);
  border-radius: 0 10px 10px 0; padding: 1.05rem 1.2rem; margin: 1.5rem 0;
}
.note p { margin: 0; font-size: .93rem; }
.note p + p { margin-top: .7rem; }
.note strong { color: var(--clay-deep); }

/* ── in-app callback ──────────────────────────────────────────────── */
.in-app {
  margin-top: 4.5rem; padding: 1.75rem 1.6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.in-app h2 { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; margin: 0 0 .6rem; }
.in-app p { margin: 0 0 1.1rem; color: var(--ink-soft); font-size: .95rem; }

/* ── glossary page ────────────────────────────────────────────────
   Reuses the article shell: .toc rail lists every term, .prose holds
   the definitions. Entries are short, so the post-sized section rhythm
   is tightened rather than inherited. Generated — see glossary/index.html. */
.prose.glossary section { padding-top: 1.9rem; }
.prose.glossary section:first-of-type { padding-top: 0; }
.prose.glossary h2 { font-size: 1.28rem; margin-bottom: .5rem; }
.prose.glossary p { margin-bottom: .4rem; }
.prose.glossary section + section { border-top: 1px solid var(--border); }
.term-more { font-size: .87rem; font-weight: 500; }
.prose.glossary .in-app { margin-top: 3.5rem; }

/* ── glossary search ──────────────────────────────────────────────
   Progressive enhancement: with JS off the input is inert and every
   term stays visible, which is why the filter hides rather than renders. */
.term-search { margin-top: 1.6rem; max-width: 26rem; }
.term-search input {
  width: 100%; font: inherit; font-size: .95rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .85rem;
  transition: border-color .14s;
}
.term-search input::placeholder { color: var(--muted); }
.term-search input:focus {
  outline: none; border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--clay-soft);
}
.term-count { margin: .55rem 0 0; font-size: .8rem; color: var(--muted); }
.term-empty { color: var(--muted); font-size: .95rem; }
.prose.glossary section[hidden] { display: none; }
.toc li[hidden] { display: none; }
/* The first visible section keeps the flush top, whichever one it is. */
.prose.glossary section:not([hidden]) ~ section:not([hidden]) { border-top: 1px solid var(--border); }
.prose.glossary section { border-top: 0; padding-top: 1.9rem; }
