/* Blog index, tag and article pages (views/blog/*.ejs). Shared components live in site.css. */

/* ---------- shared bits ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 22px; font: 500 0.78rem/1.4 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.crumbs a { color: var(--signal); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }

.blog-topic {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--muted); text-decoration: none;
  font: 400 0.8rem/1 var(--font-mono); transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.blog-topic:hover { color: var(--text); border-color: var(--line-3); }
.blog-topic[aria-current="page"] { color: var(--signal-ink); background: var(--signal); border-color: var(--signal); }
.blog-topic__n { color: var(--faint); font-size: 0.72rem; }
.blog-topic[aria-current="page"] .blog-topic__n { color: inherit; opacity: 0.7; }

/* ---------- index hero ---------- */
.blog-hero { padding-bottom: 40px; }
.blog-hero .h1 { max-width: 15ch; }
.blog-hero__meta { margin-top: 28px; --gap: 18px; }
.blog-rss { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; font: 500 0.8rem/1 var(--font-mono); }
.blog-rss svg { color: var(--scanner); }
.blog-rss:hover { color: var(--text); }

.blog-index { padding-block: 8px 96px; }
.blog-topics { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 32px; margin-bottom: 36px; border-bottom: 1px solid var(--line); }

/* ---------- featured post ---------- */
.post-feature { margin-bottom: 18px; }
.post-feature__link {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); text-decoration: none; color: inherit;
  border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden;
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}
.post-feature__link:hover { border-color: var(--line-3); }
.post-feature__link:hover .post-card__more { color: var(--signal); }
.post-feature__body { padding: clamp(26px, 4vw, 44px); display: grid; align-content: start; gap: 16px; }
.post-feature__title { font: 800 clamp(1.7rem, 3.2vw, 2.5rem)/1.05 var(--font-display); letter-spacing: -0.028em; margin: 0; text-wrap: balance; }
.post-feature__excerpt { color: var(--muted); margin: 0; font-size: 1.04rem; max-width: 46em; }
.post-feature__art {
  position: relative; min-height: 240px; border-left: 1px solid var(--line);
  background:
    radial-gradient(circle at 70% 30%, rgba(200, 245, 66, 0.16), transparent 55%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg-2);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 10px; padding: 32px;
}
.post-feature__tag {
  font: 500 0.78rem/1 var(--font-mono); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line-2);
  background: rgba(10, 11, 10, 0.75); color: var(--text); margin-left: calc(var(--i, 0) * 22px);
}
.post-feature__tag:nth-child(1) { color: var(--signal); border-color: rgba(200, 245, 66, 0.35); }
.post-feature__tag:nth-child(2) { color: var(--ai); }
.post-feature__tag:nth-child(3) { color: var(--crawler); }
.post-feature__tag:nth-child(4) { color: var(--scanner); }

/* ---------- post cards ---------- */
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.post-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 26px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface); transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.post-card:hover { border-color: var(--line-3); background: var(--surface-2); }
.post-card:focus-within { border-color: var(--signal); }
.post-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; font-size: 0.76rem; color: var(--faint); letter-spacing: 0.02em; }
.post-card__new { color: var(--signal-ink); background: var(--signal); border-radius: 5px; padding: 3px 7px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.68rem; }
.post-card__title { font: 700 1.24rem/1.2 var(--font-display); letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
.post-card__title a { color: var(--text); text-decoration: none; }
.post-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* whole card clickable */
.post-card__title a:focus-visible { outline: none; }
.post-card__excerpt { color: var(--muted); margin: 0; font-size: 0.95rem; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.post-card__tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: auto 0 0; padding: 6px 0 0; }
.post-card__tags li { font: 400 0.72rem/1 var(--font-mono); color: var(--faint); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; }
.post-card__more { font: 500 0.82rem/1 var(--font-mono); color: var(--text); transition: color 0.2s; }

.blog-empty { display: grid; justify-items: start; gap: 12px; max-width: 560px; }
.blog-empty svg { color: var(--signal); }
.blog-empty p { margin: 0; }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-top: 40px; }
.pager > :last-child { justify-self: end; }

/* ---------- CTA band ---------- */
.blog-cta-band { border-top: 1px solid var(--line); }
.blog-cta, .post-cta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px;
  padding: clamp(24px, 4vw, 40px); border-radius: var(--radius-lg); border: 1px solid rgba(200, 245, 66, 0.3);
  background: radial-gradient(circle at 100% 0%, rgba(200, 245, 66, 0.1), transparent 55%), var(--surface);
}
.blog-cta .kicker, .post-cta .kicker { margin-bottom: 10px; }
.blog-cta p, .post-cta p { margin: 0; }
.blog-cta .h3, .post-cta .h3 { margin-bottom: 8px; }
.blog-cta > div:first-child, .post-cta__copy { max-width: 560px; }

/* ---------- article ---------- */
.read-progress { position: fixed; inset: 0 0 auto; height: 2px; z-index: 120; pointer-events: none; }
.read-progress span { display: block; height: 100%; width: 100%; background: var(--signal); transform-origin: 0 50%; transform: scaleX(0); }
html:not(.js) .read-progress { display: none; }

.post-hero { padding-bottom: 44px; }
.post-hero__title { max-width: 22ch; font-size: clamp(2.1rem, 4.4vw, 3.5rem); line-height: 1.04; }
.post-hero .lede { max-width: 40em; }
.post-meta { display: flex; flex-wrap: wrap; gap: 0; margin: 32px 0 0; border: 1px solid var(--line-2); border-radius: var(--radius); width: max-content; max-width: 100%; background: rgba(19, 22, 19, 0.7); }
.post-meta > div { padding: 12px 18px; border-left: 1px solid var(--line); }
.post-meta > div:first-child { border-left: 0; }
.post-meta dt { font: 500 0.68rem/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; }
.post-meta dd { margin: 0; font-size: 0.88rem; color: var(--text); }

.post-layout {
  display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 72px; align-items: start;
  padding-block: 40px 88px; border-top: 1px solid var(--line);
}
.post-layout--no-toc { grid-template-columns: minmax(0, 1fr); }
.post-layout--no-toc .post-body { margin-inline: 0; } /* share the hero's left edge */
.post-body { max-width: 740px; min-width: 0; }

.post-toc { position: sticky; top: calc(var(--nav-h) + 24px); max-height: calc(100vh - var(--nav-h) - 48px); overflow-y: auto; padding-top: 8px; scrollbar-width: thin; }
.post-toc__summary { display: none; }
.post-toc .toc { position: static; }
.post-toc .toc a { font-size: 0.86rem; line-height: 1.35; }
.post-toc .toc a[aria-current="true"] { background: linear-gradient(90deg, var(--signal-soft), transparent 80%); }

/* long-form typography on top of .prose */
.post-prose { font-size: 1.07rem; line-height: 1.78; color: #c2c9c1; }
.post-prose > p:first-child { font-size: 1.16rem; color: var(--text); }
.post-prose h2 { font-size: clamp(1.55rem, 2.6vw, 1.95rem); margin-top: 2.1em; padding-top: 0.2em; }
.post-prose h3 { font-size: 1.22rem; margin-top: 1.9em; }
/* html already has scroll-padding-top for the fixed nav; headings only add a little air
   (and, on narrow screens, room for the sticky "On this page" bar). */
.post-prose h2, .post-prose h3, .post-prose h4 { scroll-margin-top: 8px; }
.post-prose h4 { font: 600 1rem/1.4 var(--font-body); color: var(--text); margin: 1.6em 0 0.4em; }
.post-prose a { text-decoration-color: rgba(200, 245, 66, 0.5); }
.post-prose ol > li::marker { font-family: var(--font-mono); font-size: 0.9em; }
.post-prose li > ul, .post-prose li > ol { margin: 0.35em 0 0; }
.post-prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.post-prose blockquote { margin: 1.4em 0; padding: 4px 0 4px 20px; border-left: 2px solid var(--signal); color: var(--text); }
.post-prose blockquote p { margin: 0.4em 0; }
.post-prose img { border-radius: var(--radius-sm); border: 1px solid var(--line-2); height: auto; }
.post-prose del { color: var(--faint); }

.post-prose .table-wrap, .post-prose .codeblock, .post-prose .alert { margin-block: 1.5em; }
.post-prose .table { font-size: 0.9rem; line-height: 1.5; }
.post-prose .table td { vertical-align: top; }
.post-prose .table .num { text-align: right; }
.post-prose .table .center { text-align: center; }
.post-prose .table a { color: var(--text); }
.post-prose .alert { font-size: 0.97rem; }
.post-prose .alert p { line-height: 1.65; margin: 0.35em 0 0; color: var(--muted); }
.post-prose .alert > div { margin: 0; min-width: 0; }
.post-prose .alert ul { margin: 0.4em 0 0; }

/* code blocks: same look as the docs */
.codeblock { margin: 0; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--bg-2); overflow: hidden; }
.codeblock__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px;
  padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.codeblock__label { font: 500 0.74rem/1.3 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.codeblock .copy-btn { position: static; flex: none; }
.codeblock .code { border: 0; border-radius: 0; background: transparent; font-size: 0.84rem; line-height: 1.7; }
.codeblock .code code { font: inherit; color: inherit; background: none; padding: 0; }

.post-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.post-tags__label { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-right: 6px; }
.post-cta { margin-top: 40px; }
.post-cta__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.related { border-top: 1px solid var(--line); background: var(--bg-2); }
.related__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 24px; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 0; border-top: 0; }
  .post-body { margin-inline: 0; width: 100%; }
  .post-toc {
    position: sticky; top: var(--nav-h); z-index: 20; max-height: none; overflow: visible; padding: 0;
    margin: 0 -24px 24px; background: rgba(10, 11, 10, 0.92); backdrop-filter: blur(10px);
    border-block: 1px solid var(--line);
  }
  .post-toc__summary {
    display: flex; align-items: center; gap: 12px; padding: 14px 24px; cursor: pointer; list-style: none;
  }
  .post-toc__summary::-webkit-details-marker { display: none; }
  .post-toc__label { font: 500 0.7rem/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); flex: none; }
  .post-toc__current { flex: 1 1 auto; min-width: 0; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .post-toc__chev { flex: none; color: var(--muted); transition: transform 0.2s var(--ease); }
  .post-toc[open] .post-toc__chev { transform: rotate(180deg); }
  .post-toc .toc { padding: 0 16px 14px; max-height: 60vh; overflow-y: auto; }
  .post-toc .toc__title { display: none; }
  .post-prose h2, .post-prose h3, .post-prose h4 { scroll-margin-top: 64px; }
}
@media (max-width: 760px) {
  .post-feature__link { grid-template-columns: minmax(0, 1fr); }
  .post-feature__art { min-height: 0; border-left: 0; border-top: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; padding: 20px clamp(26px, 4vw, 44px); }
  .post-feature__tag { margin-left: 0; }
  .post-grid { grid-template-columns: minmax(0, 1fr); }
  .post-meta { width: 100%; }
  .post-meta > div { flex: 1 1 40%; padding: 10px 14px; }
  .post-meta > div:nth-child(odd) { border-left: 0; }
  .post-meta > div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .post-prose { font-size: 1.02rem; }
  .post-prose > p:first-child { font-size: 1.08rem; }
  .post-toc { margin-inline: -20px; }
  .post-toc__summary { padding-inline: 20px; }
  .blog-cta, .post-cta { flex-direction: column; align-items: flex-start; }
  .pager { grid-template-columns: auto auto auto; }
}
@media (prefers-reduced-motion: reduce) {
  .post-card, .post-feature__link, .post-toc__chev { transition: none; }
}

/* ---------- QA polish ---------- */
.blog-hero__meta { align-items: center; }
.blog-hero__meta .mono { font-size: 0.8rem; }
.post-card__title { text-wrap: pretty; }
/* Keyboard focus on a card's (stretched) title link: ring the whole card via the link's ::after overlay. */
.post-card__title a:focus-visible::after { outline: 2px solid var(--signal); outline-offset: 2px; }
@media (max-width: 768px) {
  .blog-topic, .blog-rss { min-height: 40px; }
  .crumbs a { padding: 12px 4px; margin: -12px -4px; }
}
/* Long unbroken tokens (IPv6, URLs, file names) wrap instead of widening the page. */
.post-prose p, .post-prose li, .post-prose td, .post-prose blockquote { overflow-wrap: anywhere; }
.post-prose :not(pre) > code { overflow-wrap: anywhere; }
.post-prose .table td, .post-prose .table th { overflow-wrap: normal; }
/* Wide tables (4+ columns) scroll inside .table-wrap; give cells room instead of crushing words. */
.post-prose .table:has(th:nth-child(4)) td { min-width: 8.5rem; }
.post-prose .table:has(th:nth-child(4)) td:first-child { min-width: 6rem; }
/* Divider above the article: same width as the content (the border used to run into the wrap's side padding). */
@media (min-width: 1021px) {
  .post-layout { border-top: 0; background: linear-gradient(var(--line), var(--line)) no-repeat; background-origin: content-box; background-size: 100% 1px; background-position: 0 -40px; }
}
@media (max-width: 768px) {
  .codeblock .copy-btn { min-height: 40px; min-width: 56px; }
}
