/* ═══════════════════════════════════════════════════════════════════════════
   Blog — the index at /blog and the article pages at /blog/<slug>.

   Loads AFTER surface.css and theme.css, so every colour here comes from the
   shared tokens (--ink / --line / --surface / --acc / --grad …) and both themes
   are handled without a single dark-mode override in this file. The one
   exception is `.bl-mock`, the simulated app screen, which is deliberately
   dark in both themes: it is a picture of a product surface, not page chrome.

   Article body classes are prefixed `bl-` and are produced by the SERVER's
   renderer (server/src/blog.ts). Renaming one here without renaming it there
   silently unstyles that block on every post.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Accents ───────────────────────────────────────────────────────────────
   Each post picks one. Used for the category chip and the hero wash, so an
   index of six posts reads as six things rather than one repeated card. */
.acc-indigo  { --pa:#6366f1; --pb:#8b8bf7 }
.acc-teal    { --pa:#14a8b8; --pb:#5ecfc6 }
.acc-violet  { --pa:#8b5cf6; --pb:#b58bf8 }
.acc-amber   { --pa:#d08a1a; --pb:#efb75c }
.acc-rose    { --pa:#e0568a; --pb:#f091b4 }
.acc-emerald { --pa:#12996b; --pb:#54c79b }

/* ── Index hero ────────────────────────────────────────────────────────────── */
.blog-hero { padding: 64px 0 26px; }
.blog-hero h1 { font-size: clamp(38px, 5.4vw, 62px); margin: 12px 0 16px; }
.blog-hero .lead { font-size: clamp(17px, 1.7vw, 20px); color: var(--ink2); max-width: 62ch; margin: 0; line-height: 1.55; }

/* ── Filter rail ───────────────────────────────────────────────────────────── */
.blog-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 22px 0 30px; }
.blog-chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink2);
  border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: border-color .16s, color .16s, background .16s;
}
.blog-chip:hover { border-color: var(--acc); color: var(--ink); }
.blog-chip[aria-pressed="true"] { background: var(--grad); border-color: transparent; color: #fff; }
.blog-search {
  margin-left: auto; position: relative; display: flex; align-items: center;
  min-width: 236px; flex: 0 1 300px;
}
.blog-search input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 10px 16px 10px 38px; font: inherit; font-size: 14.5px;
}
.blog-search svg { position: absolute; left: 14px; width: 15px; height: 15px; stroke: var(--mut); fill: none; pointer-events: none; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.blog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 22px; padding-bottom: 30px; }
.blog-card {
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  transition: transform .2s cubic-bezier(.2,.7,.3,1), box-shadow .2s, border-color .2s;
}
.blog-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--pa) 45%, var(--line)); }
.blog-card-art {
  aspect-ratio: 16 / 9; position: relative; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--pa) 22%, transparent), color-mix(in srgb, var(--pb) 14%, transparent));
}
.blog-card-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blog-card-body { padding: 20px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.blog-cat {
  display: inline-flex; align-self: flex-start; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase;
  color: var(--pa); margin-bottom: 11px;
}
.blog-cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pa); }
.blog-card h2 { font-size: 21px; line-height: 1.25; margin: 0 0 10px; }
.blog-card p { color: var(--ink2); font-size: 14.5px; line-height: 1.6; margin: 0 0 16px; }
.blog-meta { display: flex; gap: 9px; align-items: center; font-size: 12.5px; color: var(--mut); margin-top: auto; }
.blog-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .55; }

/* The lead post gets a two-column treatment so the index has a focal point. */
.blog-card.is-lead { grid-column: 1 / -1; flex-direction: row; }
.blog-card.is-lead .blog-card-art { aspect-ratio: auto; flex: 0 0 46%; }
.blog-card.is-lead .blog-card-body { padding: 34px 38px; justify-content: center; }
.blog-card.is-lead h2 { font-size: clamp(24px, 2.6vw, 33px); }
.blog-card.is-lead p { font-size: 16px; max-width: 54ch; }
.blog-flag {
  position: absolute; top: 14px; left: 14px; z-index: 1;
  background: rgba(10, 14, 26, .74); color: #fff; backdrop-filter: blur(8px);
  border-radius: 999px; padding: 5px 12px; font-size: 11px; font-weight: 750;
  letter-spacing: .08em; text-transform: uppercase;
}
.blog-empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 46px; text-align: center; color: var(--mut); }

/* ── Article hero ──────────────────────────────────────────────────────────── */
.post-hero { padding: 46px 0 0; position: relative; }
.post-hero::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 380px; z-index: -1;
  background: radial-gradient(760px 340px at 24% 0%, color-mix(in srgb, var(--pa) 15%, transparent), transparent 68%);
}
.post-back { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--mut); margin-bottom: 22px; }
.post-back:hover { color: var(--acc-d); }
.post-hero h1 { font-size: clamp(32px, 4.4vw, 54px); margin: 12px 0 18px; max-width: 20ch; }
.post-hero .lead { font-size: clamp(17px, 1.8vw, 20.5px); color: var(--ink2); max-width: 66ch; line-height: 1.55; margin: 0 0 26px; }
.post-byline { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; padding-bottom: 30px; }
.post-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pa), var(--pb)); color: #fff; font-weight: 800; font-size: 15px;
}
.post-byline b { display: block; font-size: 14.5px; }
.post-byline small { display: block; font-size: 12.5px; color: var(--mut); }
.post-cover { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 8px; }
.post-cover img { width: 100%; height: auto; display: block; aspect-ratio: 16 / 8; object-fit: cover; }

/* ── Article layout: contents rail + body ──────────────────────────────────── */
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr) 244px; gap: 56px; align-items: start; padding: 42px 0 20px; }
/* The contents rail is a <nav>, and surface.css styles the ELEMENT `nav` for the
   site header (`display:flex; height:70px`). Without this reset the heading and
   the list lay out side by side in a 70px-tall strip. */
.post-toc { display: block; height: auto; position: sticky; top: 96px; font-size: 13.5px; }
.post-toc h2 { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--mut); margin: 0 0 12px; }
.post-toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.post-toc li a { display: block; padding: 6px 0 6px 15px; margin-left: -2px; color: var(--ink2); border-left: 2px solid transparent; line-height: 1.4; }
.post-toc li a:hover { color: var(--ink); }
.post-toc li a[aria-current="true"] { color: var(--acc-d); border-left-color: var(--acc); font-weight: 650; }
.post-toc li.lvl3 a { padding-left: 27px; font-size: 12.8px; }
.post-share { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.post-share button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: 6px 0;
  color: var(--ink2); font: inherit; font-size: 13.5px; cursor: pointer;
}
.post-share button:hover { color: var(--acc-d); }

/* ── Article prose ─────────────────────────────────────────────────────────── */
.post-body { max-width: 74ch; font-size: 17.5px; line-height: 1.72; color: var(--ink2); }
.post-body > :first-child { margin-top: 0; }
.post-body h2.bl-h { font-size: clamp(25px, 2.7vw, 32px); color: var(--ink); margin: 52px 0 16px; scroll-margin-top: 92px; }
.post-body h3 { font-size: 20.5px; color: var(--ink); margin: 34px 0 10px; scroll-margin-top: 92px; }
.post-body p { margin: 0 0 20px; }
.post-body strong { color: var(--ink); font-weight: 700; }
.post-body a { color: var(--acc-d); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; text-decoration-color: color-mix(in srgb, var(--acc) 40%, transparent); }
.post-body a:hover { text-decoration-color: currentColor; }
.post-body code {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; font-size: .87em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.post-body .bl-ul, .post-body .bl-ol { margin: 0 0 22px; padding-left: 26px; }
.post-body .bl-ul li, .post-body .bl-ol li { margin: 9px 0; padding-left: 4px; }
.post-body .bl-ul li::marker { color: var(--acc); }
.post-body .bl-ol li::marker { color: var(--acc); font-weight: 700; }
.post-body .bl-hr { border: 0; border-top: 1px solid var(--line); margin: 46px 0; }

/* Walkthrough steps — the spine of every how-to post. */
.post-body .bl-steps { list-style: none; counter-reset: blstep; margin: 30px 0; padding: 0; }
.post-body .bl-step {
  counter-increment: blstep; position: relative;
  padding: 0 0 30px 42px; border-left: 2px solid var(--line);
}
.post-body .bl-step:last-child { border-left-color: transparent; padding-bottom: 4px; }
.post-body .bl-step::before {
  content: counter(blstep); position: absolute; left: -17px; top: -3px;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-size: 14px; font-weight: 800;
  box-shadow: 0 0 0 5px var(--bg);
}
.post-body .bl-step h3 { margin: 2px 0 8px; font-size: 19.5px; }
.post-body .bl-step p { margin: 0 0 4px; }
.post-body .bl-step .bl-mock { margin-top: 16px; }

/* Callouts */
.post-body .bl-callout {
  border: 1px solid var(--line); border-left: 3px solid var(--acc);
  background: var(--surface2, var(--bg2)); border-radius: 13px;
  padding: 18px 22px; margin: 30px 0;
}
.post-body .bl-callout.is-tip { border-left-color: #14a8b8; }
.post-body .bl-callout.is-warn { border-left-color: #d08a1a; }
.post-body .bl-callout.is-success { border-left-color: var(--good); }
.post-body .bl-callout-k {
  display: block; font-size: 11.5px; font-weight: 750; letter-spacing: .09em;
  text-transform: uppercase; color: var(--mut); margin-bottom: 7px;
}
.post-body .bl-callout p { margin: 0; font-size: 16.5px; }

.post-body .bl-quote { margin: 38px 0; padding: 0 0 0 26px; border-left: 3px solid var(--acc); }
.post-body .bl-quote p { font-size: clamp(20px, 2.2vw, 26px); line-height: 1.4; color: var(--ink); font-weight: 600; letter-spacing: -.01em; margin: 0; }
.post-body .bl-quote cite { display: block; font-style: normal; font-size: 13.5px; color: var(--mut); margin-top: 12px; }

/* Figures: photographs and hand-authored SVG diagrams. */
.post-body .bl-figure { margin: 34px 0; }
.post-body .bl-figure img { width: 100%; height: auto; display: block; border-radius: 13px; border: 1px solid var(--line); }
.post-body .bl-figure figcaption { font-size: 13.5px; color: var(--mut); text-align: center; margin-top: 12px; line-height: 1.5; }
.post-body .bl-diagram {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 26px 24px 20px; color: var(--ink);
}
.post-body .bl-diagram svg { width: 100%; height: auto; display: block; }
.post-body .bl-diagram figcaption { margin-top: 18px; }

/* Stat row */
.post-body .bl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 14px; margin: 32px 0; }
.post-body .bl-stat { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); padding: 18px 14px; text-align: center; }
.post-body .bl-stat b { display: block; font-size: clamp(22px, 2.5vw, 29px); letter-spacing: -.02em; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.post-body .bl-stat span { display: block; font-size: 12.8px; color: var(--mut); margin-top: 6px; line-height: 1.35; }

/* Tables */
.post-body .bl-tablewrap { overflow-x: auto; margin: 30px 0; border: 1px solid var(--line); border-radius: 13px; }
.post-body .bl-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.post-body .bl-table caption { caption-side: top; text-align: left; padding: 15px 18px 0; font-size: 13.5px; color: var(--mut); }
.post-body .bl-table th, .post-body .bl-table td { padding: 13px 18px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.post-body .bl-table th { font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); background: var(--bg2); }
.post-body .bl-table tr:last-child td { border-bottom: 0; }

/* FAQ — same <details class="faq"> markup the SEO generator lifts from. */
.post-body .bl-faqs { margin: 32px 0; }
.post-body .faq { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); padding: 4px 20px; margin-bottom: 11px; }
.post-body .faq summary { cursor: pointer; padding: 15px 0; font-weight: 650; color: var(--ink); font-size: 16.5px; list-style: none; display: flex; align-items: center; gap: 12px; }
.post-body .faq summary::-webkit-details-marker { display: none; }
.post-body .faq summary::after { content: "+"; margin-left: auto; font-size: 21px; font-weight: 400; color: var(--mut); line-height: 1; }
.post-body .faq[open] summary::after { content: "−"; }
.post-body .faq > div { padding: 0 0 16px; font-size: 16px; }
.post-body .faq > div p { margin: 0; }

/* Code */
.post-body .bl-code { margin: 28px 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: var(--bg2); }
.post-body .bl-code figcaption { padding: 11px 18px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--mut); text-align: left; margin: 0; }
.post-body .bl-code pre { margin: 0; padding: 18px; overflow-x: auto; }
.post-body .bl-code code { background: none; border: 0; padding: 0; font-size: 14px; line-height: 1.6; }

/* Closing call to action */
.post-body .bl-cta {
  margin: 44px 0 10px; padding: 32px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--pa) 34%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--pa) 11%, transparent), color-mix(in srgb, var(--pb) 7%, transparent));
}
.post-body .bl-cta h3 { margin: 0 0 8px; font-size: 23px; color: var(--ink); }
.post-body .bl-cta p { margin: 0 0 20px; }

/* ── The simulated app screen ──────────────────────────────────────────────
   Intentionally dark in BOTH themes: it depicts a product surface, and a
   picture that re-tints with the page reads as page furniture rather than as
   a screen. Colours are literal for that reason, not token-derived. */
.bl-mock {
  margin: 26px 0; border-radius: 14px; overflow: hidden;
  background: #0d1220; border: 1px solid #232c46;
  box-shadow: 0 22px 50px -26px rgba(9, 12, 28, .8);
}
.bl-mockwrap { margin: 34px 0; }
.bl-mock-bar { display: flex; align-items: center; gap: 11px; padding: 11px 15px; border-bottom: 1px solid #1e2740; background: #10162a; }
.bl-dots { display: flex; gap: 6px; }
.bl-dots i { width: 9px; height: 9px; border-radius: 50%; background: #2c3654; }
.bl-mock-title { font-size: 12.5px; color: #8794b8; font-weight: 600; }
.bl-mock-body { padding: 17px 18px; font-size: 15px; line-height: 1.6; color: #ccd5ee; }
.bl-mock-who { display: block; font-size: 10.5px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: #6b78a0; margin-bottom: 5px; }
.bl-mock-you { background: linear-gradient(135deg, rgba(99,102,241,.2), rgba(32,184,216,.12)); border: 1px solid #2b3560; border-radius: 11px; padding: 13px 15px; margin-bottom: 15px; }
.bl-mock-you p { margin: 0; color: #e6ecff; }
.bl-mock-ai { padding: 0 2px; }
.bl-mock-ai p { margin: 0 0 9px; }
.bl-mock-ai p:last-child { margin-bottom: 0; }
.bl-mock strong { color: #fff; font-weight: 650; }
.bl-mock code { background: rgba(255,255,255,.09); border: 0; border-radius: 5px; padding: 1px 6px; font-size: .87em; color: #a8ffe9; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.bl-mock-run { list-style: none; margin: 14px 0 0; padding: 0; font-size: 14px; }
.bl-mock-run li { display: flex; gap: 11px; align-items: flex-start; padding: 7px 0; color: #b3bfdf; border-top: 1px solid #1a2238; }
.bl-mock-run li:first-child { border-top: 0; }
.bl-tick { flex: none; width: 15px; height: 15px; margin-top: 4px; border-radius: 50%; background: rgba(78, 201, 154, .18); border: 1px solid rgba(78, 201, 154, .6); position: relative; }
.bl-tick::after { content: ""; position: absolute; left: 4px; top: 2px; width: 4px; height: 7px; border: solid #4ec99a; border-width: 0 1.6px 1.6px 0; transform: rotate(42deg); }
.bl-mock-foot { padding: 11px 18px; border-top: 1px solid #1e2740; font-size: 12.5px; color: #6b78a0; background: #0b1020; }

/* ── Article footer: share, tags, related ──────────────────────────────────── */
.post-tags { display: flex; gap: 9px; flex-wrap: wrap; margin: 40px 0 0; }
.post-tag { border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--mut); background: var(--surface); }
.post-related { border-top: 1px solid var(--line); margin-top: 56px; padding: 44px 0 70px; }
.post-related h2 { font-size: 26px; margin: 0 0 24px; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 1040px) {
  .post-layout { grid-template-columns: 1fr; gap: 0; }
  .post-toc { display: none; }
}
@media (max-width: 860px) {
  .blog-card.is-lead { flex-direction: column; }
  .blog-card.is-lead .blog-card-art { flex: none; aspect-ratio: 16 / 9; }
  .blog-card.is-lead .blog-card-body { padding: 24px 22px 26px; }
  .blog-search { margin-left: 0; flex-basis: 100%; }
  .post-body { font-size: 16.5px; }
  /* The date/reading-time pair is pushed right by margin-left:auto on wide
     screens; at this width that leaves it flush against the edge, so give it
     its own line instead. */
  .post-byline .blog-meta { margin-left: 0; flex-basis: 100%; }
  .post-body .bl-step { padding-left: 30px; }
  .post-body .bl-step::before { width: 27px; height: 27px; left: -14px; font-size: 12.5px; }
  .post-body .bl-cta { padding: 24px; }
}
