/* ================================================================
   BLOG — nicolasbiondi.com  (Vercel-style redesign, 2026-10)
   ----------------------------------------------------------------
   Light, flat, quiet: #fafafa page, #fff cards, hairline #ebebeb,
   ink #171717, muted #666. Geist + Geist Mono, self-hosted (OFL,
   files copied by scripts/blog/build.mjs into /assets/fonts/).
   Headings are tight (-0.04 … -0.055em) at weight 500/600.

   Page anatomy
     listing pages  .bg-wrap > .bg-title + .bg-bar + .bg-grid + .bg-foot
     post pages     .pv > .pv-head + .pv-cover + .pv-layout
                    (.post-body 680px + sticky .pv-rail ≥1100px)
   The home page does NOT load this file: its blog section is styled
   by landing.css (same .bg-card markup, its own skin).
   ================================================================ */

/* ---- Fonts ------------------------------------------------------ */
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/fonts/geist-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/geist-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('/assets/fonts/geist-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist';
  font-style: normal; font-weight: 700; font-display: swap;
  src: url('/assets/fonts/geist-sans-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/assets/fonts/geist-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('/assets/fonts/geist-mono-latin-500-normal.woff2') format('woff2');
}

/* ---- Tokens / base ---------------------------------------------- */
:root {
  --bg: #fafafa;
  --ink: #171717;
  --muted: #666666;
  --line: #ebebeb;
  --card: #ffffff;
  --accent: #0068d6;           /* AA on white for body links */
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body.blog {
  background: var(--bg);
  color: var(--ink);
  font-family: Geist, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.blog a { color: inherit; text-decoration: none; }
body.blog [hidden] { display: none !important; }

body.blog :focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---- Header / footer chrome ------------------------------------ */
.blog-header { border-bottom: 1px solid var(--line); background: var(--bg); }

.blog-nav {
  display: flex;
  align-items: center;
  gap: 0.75em;
  max-width: 1392px;
  margin: 0 auto;
  padding: 14px 24px;
  font-size: 14px;
}
.blog-nav-home { font-weight: 600; letter-spacing: -0.01em; }
.blog-nav-home:hover, .blog-nav-blog:hover { color: var(--muted); }
.blog-nav-sep { color: #c9c9c9; }
.blog-nav-blog { color: var(--muted); }

.blog-nav .lang-switch {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-size: 13px;
}
.lang-switch a { color: var(--muted); min-height: 24px; display: inline-flex; align-items: center; }
.lang-switch a:hover { color: var(--ink); }
.lang-switch .lang-current { color: var(--ink); font-weight: 600; }
.lang-switch .lang-sep { color: #c9c9c9; }

.blog-footer {
  max-width: 1392px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.blog-footer a { color: var(--muted); }
.blog-footer a:hover { color: var(--ink); }

/* ---- Listing pages: title + pills/search/RSS bar ---------------- */
.bg-wrap {
  max-width: 1392px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.bg-title {
  font-size: clamp(40px, 5vw, 48px);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1.1;
  margin: 52px 0 28px;
}

.bg-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.bg-pills { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.bg-pill {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
}
.bg-pill:hover { background: #f0f0f0; }
.bg-pill.is-on { background: var(--line); font-weight: 500; }

.bg-search { margin-left: auto; }
.bg-search-input {
  width: 200px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s ease;
}
.bg-search-input::placeholder { color: #999; }
.bg-search-input:focus { outline: none; border-color: #c6c6c6; }

.bg-rss {
  width: 34px; height: 34px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.bg-rss:hover { color: var(--ink); border-color: #c6c6c6; }

.bg-subline { color: var(--muted); font-size: 15px; margin: -24px 0 32px; }

/* ---- Card grid --------------------------------------------------- */
.bg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

/* Flat, Vercel-style: white block on the #fafafa page, no border, no
   radius; the hairline ring + soft shadow only appear on hover. */
.bg-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  transition: box-shadow .2s ease;
}
.bg-card:hover { box-shadow: 0 0 0 1px var(--line), 0 8px 30px rgba(0, 0, 0, 0.06); }

.bg-card-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.bg-card-in {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 22px 24px 24px;
}

/* Listing pages get Vercel's tall card rhythm: subtitle + author sit
   at the bottom, whatever the title length (related cards on post
   pages stay compact). */
.bg-wrap .bg-grid > .bg-card { min-height: 420px; }
.bg-wrap .bg-card-sub { margin-top: auto; }

.bg-card-meta { font-size: 14px; color: var(--ink); display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.bg-card-meta span { color: var(--muted); }

.blog-new-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0a7d33;
  background: #e8f7ee;
  border-radius: 999px;
  padding: 2px 8px;
}

.bg-card-title {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-weight: 500;
  margin: 14px 0 10px;
  text-wrap: balance;
}

.bg-card-sub {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
}

.bg-card-by {
  margin-top: auto;
  padding-top: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.bg-card-by img { width: 20px; height: 20px; border-radius: 50%; }

/* Section icon before the card title: grey and faint, full colour on hover. */
.bg-card-title { display: flex; align-items: center; gap: .45em; }
.bg-card-px { flex: none; line-height: 0; }
.bg-card-px svg { width: .8em; height: auto; filter: grayscale(1); opacity: .4; transition: filter .3s ease, opacity .3s ease; }
.bg-card:hover .bg-card-px svg,
.bg-card:focus-visible .bg-card-px svg { filter: none; opacity: 1; }

/* Featured card: first on the page, spans 2 columns, image left 55% */
.bg-card--feat { grid-column: span 2; flex-direction: row; }
.bg-card--feat .bg-card-img {
  width: 55%;
  aspect-ratio: auto;
}
.bg-card--feat .bg-card-in { width: 45%; }
.bg-card--feat .bg-card-title { font-size: 36px; }

/* Featured card: fill the text column (description, tags, reading time,
   explicit "read" call to action) instead of leaving it half empty. */
.bg-card--feat .bg-card-in { padding: 2em 2.2em; }
.bg-card--feat .bg-card-sub { font-size: 1.05em; color: var(--ink); opacity: .82; }
.bg-card--feat .bg-card-desc { margin: .9em 0 0; font-size: .92em; line-height: 1.6; color: var(--ink-muted, var(--muted)); }
.bg-card--feat .bg-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 1.1em 0 0; }
.bg-card--feat .bg-card-tags span { font-size: .74em; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; background: rgba(3, 105, 161, .07); color: var(--ink-accent, var(--accent)); }
.bg-card .bg-card-by { flex-wrap: wrap; }
.bg-card .bg-card-rt { color: var(--ink-muted, var(--muted)); }
.bg-card .bg-card-go { margin-left: auto; display: inline-flex; align-items: center; gap: .45em; font-weight: 600; color: var(--ink-accent, var(--accent)); }
.bg-card .bg-card-arrow { display: inline-block; transition: transform .3s ease; }
.bg-card:hover .bg-card-arrow { transform: translateX(3px); }

.blog-empty, .blog-tabs-empty { color: var(--muted); font-size: 15px; grid-column: 1 / -1; }
.blog-tabs-empty { margin: 8px 0 0; }
.blog-tabs-empty a { color: var(--accent); }

/* "Show more" (revealed by blog-ui.js only when there are hidden cards) */
.bg-more { text-align: center; margin: 48px 0 0; }
.bg-more-btn {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.bg-more-btn:hover { border-color: #c6c6c6; }

/* ---- Footer block: compact archive + tags ------------------------ */
.bg-foot {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px;
  border-top: 1px solid var(--line);
  margin-top: 88px;
  padding-top: 32px;
}
.bg-foot-title {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.bg-foot-year { font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 8px; }
.bg-foot-y { font-weight: 600; }
.bg-foot-year span, .bg-foot-tag span { color: var(--muted); font-weight: 400; }
.bg-foot-month { color: var(--muted); }
.bg-foot-month:hover, .bg-foot-y:hover { color: var(--ink); }
.bg-foot-month.is-on, .bg-foot-y.is-on { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.bg-foot-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.bg-foot-tag {
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
}
.bg-foot-tag:hover { border-color: #c6c6c6; }
.bg-foot-tag.is-on { background: var(--line); }

/* ---- Post page ---------------------------------------------------- */
.pv { max-width: 1392px; margin: 0 auto; padding: 0 24px 96px; }

.pv-head { max-width: 680px; margin: 56px auto 0; }

.pv-crumb { font-size: 14px; color: var(--muted); display: flex; gap: 8px; }
.pv-crumb a:hover { color: var(--ink); }

.pv-title {
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-weight: 500;
  margin: 20px 0 12px;
  text-wrap: balance;
}

.pv-sub {
  font-size: 20px;
  line-height: 1.45;
  letter-spacing: -0.02em;
  color: var(--muted);
  max-width: 680px;
  margin: 0 0 24px;
  text-wrap: pretty;
}

.pv-author {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin: 0 0 8px;
}
.pv-author img { width: 24px; height: 24px; border-radius: 50%; }
.pv-author a:hover { color: var(--muted); }
.pv-series { color: var(--muted); margin-left: 8px; }
.pv-series strong { font-weight: 500; color: var(--ink); }

.pv-cover { max-width: 1100px; margin: 36px auto 48px; }
.pv-cover img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
}

/* Body column + sticky right rail. The rail only exists ≥1100px:
   the body column stays centered on the page at every width and the
   rail hangs in the right gutter next to it. */
.pv-layout { position: relative; max-width: 680px; margin: 0 auto; }

/* The rail needs 680 (column) + 56 (gap) + 240 (rail) on top of the
   page padding — below ~1320px it would hang past the viewport edge
   (QA: scrollWidth 1186@1100), so it only exists from 1320px up. */
.pv-rail { display: none; }
@media (min-width: 1320px) {
  .pv-rail {
    display: block;
    position: absolute;
    left: calc(100% + 56px);
    top: 4px;
    bottom: 0;
    width: 240px;
  }
  .pv-rail-sticky { position: sticky; top: 28px; }
}

.pv-rail { font-size: 14px; color: var(--muted); }
.pv-rail-meta { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.pv-rail-meta time { color: var(--ink); }

.pv-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.pv-copy:hover { color: var(--ink); border-color: #c6c6c6; }
.pv-copy.is-copied { color: #0a7d33; border-color: #bfe6cd; }

.pv-toc { margin-top: 28px; }
.pv-toc-title { font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.pv-toc a {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  padding: 4px 0 4px 12px;
  border-left: 1px solid var(--line);
}
.pv-toc a:hover { color: var(--ink); }
.pv-toc a.is-active { color: var(--ink); border-left-color: var(--ink); }

/* ---- Post body typography ---------------------------------------- */
.post-body { font-size: 18px; line-height: 1.65; }

.post-body p { margin: 0 0 22px; }

.post-body a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: #c6c6c6;
  text-underline-offset: 3px;
  transition: text-decoration-color .15s ease;
}
.post-body a:hover { text-decoration-color: var(--ink); }

.post-body h2 {
  font-size: 32px;
  letter-spacing: -0.04em;
  font-weight: 500;
  line-height: 1.2;
  margin: 48px 0 16px;
  scroll-margin-top: 28px;
}
.post-body h3 {
  font-size: 22px;
  letter-spacing: -0.03em;
  font-weight: 500;
  margin: 36px 0 12px;
}

.post-body ul, .post-body ol { margin: 0 0 22px; padding-left: 1.4em; }
.post-body li { margin: 0.35em 0; }
.post-body li::marker { color: var(--muted); }

.post-body strong { font-weight: 600; }

.post-body blockquote {
  border-left: 2px solid var(--line);
  padding: 0.1em 0 0.1em 1.2em;
  color: var(--muted);
  margin: 0 0 22px;
}
.post-body blockquote p:last-child { margin-bottom: 0; }

.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }

.post-body img { max-width: 100%; height: auto; border-radius: 8px; }

/* Callouts (TL;DR / Analogy) keep working for every post. */
.post-body .callout {
  border: 1px solid var(--line);
  border-left: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  padding: 18px 22px;
  font-size: 16.5px;
}
.post-body .callout--analogy { border-left-color: #8f8f8f; }
.post-body .callout strong { font-weight: 600; }

/* Code — Geist Mono */
.post-body code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: #f0f0f0;
  border-radius: 4px;
  padding: 0.12em 0.38em;
}
.post-body pre {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.6;
}
.post-body pre code { background: none; padding: 0; font-size: inherit; }

/* Tables: scroll container with the right-edge fade hint. */
.table-wrap { margin: 0 0 22px; }
.table-scroll { overflow-x: auto; }
.post-body table { border-collapse: collapse; width: 100%; font-size: 15px; }
.post-body th, .post-body td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.post-body th {
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* ---- Wide elements: diagrams break out of the 680 column
   SYMMETRICALLY (Vercel-style white framed box, up to 1000px total),
   staying centred on the text column like the cover above. Without
   the rail (<1320px) the breakout grows with the free space up to
   ±160px; with the rail visible it stays within the 56px gap left of
   the rail (±40px) so they never collide. */
:root { --breakout: 0px; }
@media (min-width: 768px) {
  :root { --breakout: clamp(0px, calc((100vw - 752px) / 2), 160px); }
}
@media (min-width: 1320px) {
  :root { --breakout: 40px; }
}

.post-body .diagram {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  margin: 32px 0;
  margin-inline: calc(-1 * var(--breakout));
  width: calc(100% + 2 * var(--breakout));
}
.post-body .diagram svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram-scroll { overflow-x: auto; }
/* Natural diagram width (set inline as --dw by the build) caps the
   svg so small diagrams don't stretch. */
.post-body .diagram svg { width: min(100%, calc(var(--dw, 700) * 1px)); }

.post-body figcaption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 12px;
}

/* Memes: memes.css caps .meme at 680px and centers it with
   margin:auto — exactly the text column, no nudge needed. */

/* Scroll-fade hint (diagrams/tables wider than their scroller) */
.scroll-fade { position: relative; }
.scroll-fade.has-overflow::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 44px;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255,255,255,0), #ffffff);
}

/* Tags under the article */
.pv-tags { margin-top: 36px; display: flex; flex-wrap: wrap; gap: 8px; }
.blog-tag {
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
}
.blog-tag:hover { border-color: #c6c6c6; }

/* Related cards at the end */
.pv-related { max-width: 1100px; margin: 72px auto 0; }
.pv-related-title { font-size: 15px; color: var(--muted); margin-bottom: 18px; }
.pv-related-title a { color: var(--ink); font-weight: 500; }
.pv-related-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.pv-related .bg-grid--related .bg-card-title { font-size: 22px; }

/* ---- Responsive --------------------------------------------------- */
@media (max-width: 1024px) {
  .bg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bg-card--feat { grid-column: span 2; }
  .bg-card--feat .bg-card-title { font-size: 30px; }
  .bg-card-title { font-size: 24px; }
}

@media (max-width: 640px) {
  .bg-grid { grid-template-columns: minmax(0, 1fr); }
  .bg-card--feat { grid-column: auto; flex-direction: column; }
  .bg-card--feat .bg-card-img { width: 100%; aspect-ratio: 16 / 9; }
  .bg-card--feat .bg-card-in { width: 100%; }
  .bg-title { margin-top: 36px; }
  .bg-wrap .bg-grid > .bg-card { min-height: 0; }
  .bg-bar { gap: 10px; }
  .bg-search { margin-left: 0; flex: 1 1 100%; order: 3; }
  .bg-search-input { width: 100%; }
  .bg-rss { order: 2; margin-left: auto; }
  .bg-pills { order: 1; width: calc(100% - 50px); overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .bg-pills::-webkit-scrollbar { display: none; }
  .bg-card--feat .bg-card-title { font-size: 26px; }

  .pv-head { margin-top: 32px; }
  .pv-title { font-size: 40px; }
  .pv-sub { font-size: 18px; }
  .pv-cover { margin: 28px auto 32px; }
  .pv-cover img { border-radius: 10px; }
  .post-body { font-size: 17px; }
  .post-body h2 { font-size: 26px; }
  .post-body .diagram { padding: 18px; }
}
