/* Writing index and long-form article.
   The article body is deliberately the quietest surface in the system: no
   gradients, no texture, no accent fills inside .article-body. Everything loud
   sits outside it. */

/* ── Page header (archive surfaces) ────────────────────────────────────────────
   The hero's atmosphere at lower volume: two washes and a masked perforation
   field carried as backgrounds, the sweep line as one pseudo-element. No
   decorative DOM. */
.page-header {
  position: relative;
  overflow: hidden;
  border-bottom: var(--border-width) solid var(--border-hairline);
  background-image: var(--grad-hero);
  background-color: var(--bg-page);
}

.page-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--texture-dots);
  background-size: var(--texture-dots-size);
  opacity: 0.5;
  mask-image: radial-gradient(60% 100% at 90% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(60% 100% at 90% 0%, #000 0%, transparent 70%);
  animation: field-drift 8s linear infinite;
  pointer-events: none;
}

.page-header::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--mark-signal) 22%,
    var(--mark-signal) 78%,
    transparent
  );
  opacity: 0.5;
  animation: signal-sweep 9s var(--ease-in-out) infinite;
  pointer-events: none;
}

.page-header-inner {
  position: relative;
  padding-block: clamp(40px, 6vw, 80px) var(--space-2xl);
}

.page-header-title {
  font-size: var(--step-display);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  max-width: 20ch;
}

.page-header-dek {
  margin-top: var(--space-lg);
  max-width: var(--measure-reading);
  font-size: var(--step-body-lg);
  line-height: 1.62;
  font-weight: var(--weight-light);
  color: var(--text-secondary);
}

/* ── Breadcrumbs ───────────────────────────────────────────────────────────── */
.breadcrumbs {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

.breadcrumbs li {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.breadcrumbs a:hover { color: var(--text-primary); text-decoration: none; }

.breadcrumbs [aria-current="page"] { color: var(--text-muted); }

.breadcrumbs-sep { color: var(--border-strong); }

/* ── Tag filter row ────────────────────────────────────────────────────────────
   Real links to real archive URLs, not a JavaScript filter: every topic stays
   crawlable and shareable. */
.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xl);
}

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding-top: var(--space-lg);
  margin-top: var(--space-2xl);
  border-top: var(--border-width) solid var(--border-hairline);
}

.pagination-count {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-muted);
}

.pagination-list {
  display: flex;
  gap: var(--space-2xs);
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.pagination a,
.pagination span.page-numbers,
.pagination .pagination-edge {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  border: var(--border-width) solid var(--border-hairline);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.pagination a:hover {
  border-color: var(--mark-signal);
  color: var(--text-primary);
  text-decoration: none;
}

.pagination .current {
  border-color: var(--border-signal);
  background: color-mix(in oklch, var(--signal) 12%, transparent);
  color: var(--text-primary);
}

.pagination .dots {
  border-color: transparent;
  color: var(--text-muted);
}

.pagination-edge[aria-disabled="true"] { opacity: 0.4; }

/* ── Article header ────────────────────────────────────────────────────────── */
.article-header {
  position: relative;
  border-bottom: var(--border-width) solid var(--border-hairline);
  overflow: hidden;
}

.article-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--texture-dots);
  background-size: var(--texture-dots-size);
  opacity: 0.45;
  mask-image: radial-gradient(55% 90% at 92% 10%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(55% 90% at 92% 10%, #000 0%, transparent 72%);
  pointer-events: none;
}

/* Sits inside .site-container, not on it: putting both classes on one element
   let the container's auto margins centre the narrower measure. */
.article-header-inner {
  position: relative;
  padding-block: clamp(40px, 6vw, 80px) var(--space-xl);
  max-width: var(--measure-wide);
  margin-inline: 0;
  display: grid;
  gap: var(--space-lg);
}

.article-header-badges {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
  flex-wrap: wrap;
}

.article-title {
  font-size: var(--step-display);
  line-height: var(--lh-display);
  letter-spacing: var(--track-display);
  font-weight: var(--weight-semibold);
  max-width: 26ch;
}

.article-dek {
  font-size: var(--step-body-lg);
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: var(--measure-reading);
  font-weight: var(--weight-light);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  padding-top: var(--space-md);
  border-top: var(--border-width) solid var(--border-hairline);
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-muted);
}

.article-meta-author { color: var(--text-secondary); }

.article-meta-tags {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ── Article shell: contents rail beside the reading column ────────────────── */
.article-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: start;
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: var(--space-2xl);
}

/*
 * Elementor wraps every widget in two divs, so the rail is a grandchild of the
 * grid rather than a grid item. A sticky element only travels inside its own
 * parent, and those wrappers shrink to the rail's own height, which left the
 * rail with zero travel: it read as pinned in place instead of following the
 * reader down the article. Stretch the column and pass the height through.
 */
.article-shell > .article-toc-col {
  align-self: stretch;
  min-width: 0;
}

.article-toc-col > .elementor-widget-container,
.article-toc-col > .elementor-shortcode,
.article-toc-col > .elementor-widget-container > .elementor-shortcode {
  height: 100%;
}

/* The rail is navigation, so it comes first in the DOM for keyboard order. */
.article-toc {
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.article-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-sm);
}

.article-toc-list li {
  display: flex;
  gap: 10px;
}

.article-toc-num {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  color: var(--text-muted);
  padding-top: 3px;
  transition: color var(--dur-fast) var(--ease-out);
  flex: none;
}

.article-toc-list a {
  font-size: var(--step-small);
  line-height: 1.45;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: var(--border-width) solid transparent;
  padding-left: 10px;
  margin-left: -11px;
  transition: color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
}

.article-toc-list a:hover {
  color: var(--text-primary);
  text-decoration: none;
  border-left-color: var(--border-strong);
}

.article-toc-list li[data-current="true"] .article-toc-num {
  color: var(--text-signal);
}

.article-toc-list li[data-current="true"] a {
  color: var(--text-primary);
  border-left-color: var(--mark-signal);
}

.article-toc-foot {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: var(--border-width) solid var(--border-hairline);
  display: grid;
  gap: var(--space-sm);
}

/* The article body itself is styled by base/prose.css. These are the blocks
   that sit inside it. */

/* ── Key takeaway (snippet bait) ───────────────────────────────────────────── */
.key-takeaway {
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: var(--surface-card);
  border: var(--border-width) solid var(--border-hairline);
  border-left: var(--border-width-thick) solid var(--signal);
  border-radius: var(--radius-sm);
}

.key-takeaway-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-signal);
}

.key-takeaway p {
  font-size: var(--step-body-lg);
  line-height: 1.62;
  color: var(--text-primary);
  max-width: var(--measure-reading);
}

/* ── Callout ───────────────────────────────────────────────────────────────── */
.article-callout {
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-lg);
  background: var(--surface-card);
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--border-hairline);
  border-left: var(--border-width-thick) solid var(--border-strong);
}

.article-callout[data-tone="signal"] { border-left-color: var(--signal); }
.article-callout[data-tone="warn"] { border-left-color: var(--flare); }

[data-theme="light"] .article-callout[data-tone="signal"] { border-left-color: var(--signal-deep); }
[data-theme="light"] .article-callout[data-tone="warn"] { border-left-color: var(--flare-deep); }

.article-callout-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-secondary);
}

.article-callout[data-tone="signal"] .article-callout-label { color: var(--text-signal); }
.article-callout[data-tone="warn"] .article-callout-label { color: var(--text-flare); }

/* ── Inline related ────────────────────────────────────────────────────────── */
.inline-related {
  display: flex;
  gap: var(--space-sm);
  align-items: baseline;
  padding: var(--space-sm) 0 var(--space-sm) var(--space-md);
  border-left: var(--border-width-thick) solid var(--border-strong);
  transition: border-color var(--dur-fast) var(--ease-out);
  font-size: var(--step-small);
}

.inline-related:hover { border-left-color: var(--mark-signal); }

.inline-related-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
  flex: none;
}

/* ── FAQ ───────────────────────────────────────────────────────────────────── */
.faq-block { display: grid; gap: var(--space-lg); }

.faq-list {
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-item { background: var(--surface-card); }
.faq-item + .faq-item { border-top: var(--border-width) solid var(--border-hairline); }

.faq-item h3 { margin: 0; }

.faq-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: transparent;
  border: none;
  border-left: var(--border-width-thick) solid transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--step-body);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  transition: border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out);
}

.faq-trigger:hover { background: var(--surface-hover); }

.faq-trigger[aria-expanded="true"] { border-left-color: var(--mark-signal); }

.faq-sign {
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.faq-trigger[aria-expanded="true"] .faq-sign { color: var(--text-signal); }

/* Answers stay in the DOM at zero height so crawlers and find-in-page see
   them; only the row height animates. */
.faq-answer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-base) var(--ease-out);
}

/* The trigger is inside its <h3> for heading semantics, so it is not a sibling
   of the answer and an adjacent-sibling selector never matches. :has() reads the
   state from the button's own aria-expanded, keeping one source of truth rather
   than mirroring the state onto a second element. */
.faq-item:has(.faq-trigger[aria-expanded="true"]) .faq-answer {
  grid-template-rows: 1fr;
}

.faq-answer > div { overflow: hidden; }

.faq-answer p {
  padding: 0 var(--space-lg) var(--space-lg);
  padding-left: calc(var(--space-lg) + 2px);
  color: var(--text-body);
  font-size: var(--step-small);
  line-height: 1.7;
  max-width: 62ch;
}

/* ── Share row ─────────────────────────────────────────────────────────────── */
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: center;
}

.share-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 2px;
}

/* ── Prev / next ───────────────────────────────────────────────────────────── */
.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border-hairline);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.prev-next a,
.prev-next span {
  display: grid;
  gap: 6px;
  padding: var(--space-lg);
  background: var(--surface-card);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-out);
}

.prev-next a:hover { background: var(--surface-hover); text-decoration: none; }

.prev-next [data-dir="next"] { text-align: right; }

.prev-next-label {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color var(--dur-fast) var(--ease-out);
}

.prev-next a:hover .prev-next-label { color: var(--text-signal); }

.prev-next-title {
  color: var(--text-primary);
  font-size: var(--step-small);
  line-height: 1.4;
  font-weight: var(--weight-medium);
}

/* ── Related posts ─────────────────────────────────────────────────────────── */
.related-posts { display: grid; gap: var(--space-xl); }

.related-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: var(--border-width) solid var(--border-hairline);
}

.related-head-copy { display: grid; gap: var(--space-sm); }

.related-pillar {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--text-signal);
  white-space: nowrap;
  text-decoration: none;
}

.related-pillar:hover { text-decoration: underline; }

/* ── Mobile collapse ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  /* The rail becomes a collapsed summary above the article rather than a
     sticky column, so it never eats the reading width. */
  .article-shell { grid-template-columns: 1fr; }

  .article-toc {
    position: static;
    max-height: none;
    border: var(--border-width) solid var(--border-hairline);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-card);
  }

  .article-toc-foot { display: none; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next [data-dir="next"] { text-align: left; }
  .article-meta-tags { margin-left: 0; }
}

/* Post count inside a topic tag. */
.topic-tag-count {
  color: var(--text-muted);
  font-size: var(--step-micro);
}


/* ── Callout body ──────────────────────────────────────────────────────────── */
.article-callout-body {
  font-size: var(--step-small);
  line-height: 1.68;
  color: var(--text-body);
}

.article-callout-body p { margin: 0; }

.article-callout-body p + p { margin-top: var(--space-xs); }

/* ── Code block ────────────────────────────────────────────────────────────
   The kit's CodeBlock: mono chrome bar, coarse highlight, copy button. The
   highlight spans are produced server-side so no library ships. */
.code-block {
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--border-hairline);
  background: var(--surface-sunken);
  overflow: hidden;
}

.code-block-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 9px 12px;
  border-bottom: var(--border-width) solid var(--border-hairline);
  background: var(--surface-card);
}

.code-block-dots {
  display: flex;
  gap: 4px;
}

.code-block-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border-strong);
}

.code-block-dots span:first-child { background: var(--mark-signal, var(--signal)); }

.code-block-name {
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  color: var(--text-secondary);
}

.code-block-copy {
  margin-left: auto;
  background: transparent;
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: var(--step-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.code-block-copy:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.code-block pre {
  margin: 0;
  padding: var(--space-md) 0;
  overflow-x: auto;
  font-size: var(--step-mono);
  line-height: 1.75;
  color: var(--text-body);
  background: transparent;
}

.code-block code {
  display: block;
  min-width: max-content;
  font-family: var(--font-mono);
}

.code-line {
  display: flex;
  padding-inline: var(--space-md);
}

.code-num {
  width: 2.5ch;
  margin-right: var(--space-md);
  text-align: right;
  color: var(--text-muted);
  opacity: 0.6;
  user-select: none;
  flex: none;
}

.code-keyword { color: var(--text-signal); }
.code-string  { color: var(--text-flare); }
.code-comment { color: var(--text-muted); font-style: italic; }

/*
 * Hand placed chip rows (books band). The filter variant carries a large top
 * margin because it sits under an archive heading; a static row is just part of
 * the block that contains it, so it spaces itself from its own siblings.
 */
.tag-filter-static {
  margin-top: var(--space-sm);
}


/* ── Search ──────────────────────────────────────────────────────── */
/* A results page with no way to change the query is a dead end, so the header
   carries the field that produced it. */
.search-form-row {
  margin-top: var(--space-lg);
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
  flex-wrap: wrap;
  max-width: 620px;
}

.search-form-row .field {
  flex: 1;
  min-width: 240px;
  margin: 0;
}

.search-form-row .field input {
  width: 100%;
}

.search-empty {
  display: grid;
  gap: var(--space-md);
  justify-items: start;
  padding: var(--space-lg);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.search-empty-body {
  color: var(--text-secondary);
  font-size: var(--step-body);
  line-height: 1.7;
  max-width: 52ch;
  margin: 0;
}

/* The kit gives the blog, book and review headers a richer hero wash than the
   topic archives, which keep the plain one. */
.page-header-rich {
  background-image: var(--grad-hero-rich);
}

/* Reviews swap the perforation field for the blueprint grid, masked from the
   top edge. The grid is a static motif in the kit, so the drift stops with it. */
.page-header.page-header-grid::before {
  background-image: var(--texture-grid);
  background-size: var(--texture-grid-size);
  mask-image: radial-gradient(120% 100% at 50% 0%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(120% 100% at 50% 0%, #000 10%, transparent 75%);
  animation: none;
}

/* Shelf heading above the review grid: names what the grid is before the reader
   meets it, and rules off the header from the cards. */
.shelf-heading {
  font-size: var(--step-h2);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: var(--border-width) solid var(--border-hairline);
}

/* ── Article hero ─────────────────────────────────────────────────────────────
   The header already carries a dotted texture masked to the top right. A photo
   dropped straight on top of it would sit on two competing backgrounds, so the
   image gets a hairline and its own radius and reads as a distinct object.

   21/9 rather than the card's 16/10: at the article measure a taller crop
   pushes the opening paragraph below the fold. */
.article-header .post-media {
  margin-top: var(--space-xl);
  border: var(--border-width) solid var(--border-hairline);
  border-radius: var(--radius-md);
}

/* Portrait and small imports would be blown up past their pixel width by a
   full-bleed hero. Capping the height keeps a 550px import sharp. */
.article-header .post-media {
  max-height: 520px;
}

@media (max-width: 758px) {
  .article-header .post-media {
    margin-top: var(--space-lg);
    aspect-ratio: 16 / 9;
  }
}