/* Article body. The markup inside .article-body is generated by the CMS block renderer (ADR-0006) and is fixed:
   style it, never change it. Everything, text included, spans the article column, so text and pictures share one right edge. The
   column itself is capped by the layout (--content in .l-with-sidebar--article and .l-narrow), not by the blocks. */
@layer blocks {
  .article-body { font-family: var(--font-serif); font-size: var(--fs-lg); line-height: var(--lh-loose); color: var(--ink); }
  .article-body > * + * { margin-top: var(--space-6); }

  .article-body a { color: var(--brand); }
  .article-body a:hover { color: var(--brand-strong); }
  .article-body h1, .article-body h2 { margin-top: var(--space-12); font-size: var(--fs-h2-sm); line-height: var(--lh-tight); }
  .article-body h3 { margin-top: var(--space-8); font-size: var(--fs-h3-sm); line-height: var(--lh-snug); }
  .article-body h4, .article-body h5, .article-body h6 { margin-top: var(--space-8); font-family: var(--font-serif); font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
  .article-body :is(h1, h2, h3, h4, h5, h6) + * { margin-top: var(--space-3); }
  .article-body > :first-child { margin-top: 0; }

  .article-body :where(ul, ol):not([class]) { padding-left: var(--space-6); }
  .article-body :where(ul, ol):not([class]) > li + li, .article-body :where(li) > :where(ul, ol) { margin-top: var(--space-2); }
  .article-body ul:not([class]) > li::marker { color: var(--accent); }
  .article-body ol:not([class]) > li::marker { font-family: var(--font-sans); font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--accent-strong); }

  /* quote */
  .blk-quote { margin-block: var(--space-8); padding-top: var(--space-4); border-top: var(--rule) solid var(--accent); }
  .blk-quote p { font-size: var(--fs-xl); font-style: italic; line-height: var(--lh-normal); }
  .blk-quote p + p { margin-top: var(--space-3); }
  .blk-quote cite { display: block; margin-top: var(--space-3); font-family: var(--font-sans); font-size: var(--fs-sm); font-style: normal; color: var(--ink-muted); }
  .blk-quote cite::before { content: "— "; }

  /* image */
  .blk-image, .blk-gallery, .blk-embed { margin-block: var(--space-8); }
  .blk-image img { width: 100%; border-radius: var(--radius-sm); background: var(--surface-alt); }
  .blk-image figcaption, .blk-gallery figcaption { margin-top: var(--space-2); font-family: var(--font-sans); font-size: var(--fs-sm); line-height: var(--lh-normal); color: var(--ink-muted); }
  .blk-caption { color: var(--ink); }
  /* A gallery lifted into the cover position sits in the article grid, which already spaces its rows. */
  .c-article__gallery > .blk-gallery { margin-block: 0; }
  .blk-credit { white-space: nowrap; }

  /* gallery: 2 = pair, 3 = one large + two, 4 = 2 x 2, 5 and more = grid */
  .blk-gallery__items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); padding: 0; list-style: none; }
  .blk-gallery__items li { margin: 0; min-width: 0; }
  .blk-gallery__items a { display: block; height: 100%; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-alt); }
  .blk-gallery__items a:focus-visible { outline-offset: calc(-1 * var(--focus-width)); }
  .blk-gallery__items img { width: 100%; height: 100%; aspect-ratio: 3 / 2; object-fit: cover; transition: opacity var(--dur-1); }
  .blk-gallery__items a:hover img { opacity: 0.85; }
  .blk-gallery[data-count="3"] .blk-gallery__items { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .blk-gallery[data-count="3"] li:first-child { grid-row: span 2; }
  .blk-gallery[data-count="3"] li:first-child img { aspect-ratio: auto; }

  /* embed: the link is a facade; js/embed.js swaps it for the player after a click */
  .blk-embed { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-inverse); }
  .blk-embed__facade { position: absolute; inset: 0; display: grid; place-items: center; text-decoration: none; }
  .blk-embed__facade img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  .blk-embed__play { position: relative; display: inline-flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background-color: var(--btn-color); background-image: linear-gradient(to bottom, var(--btn-sheen), transparent); color: var(--on-brand); font-family: var(--font-sans); font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: var(--lh-snug); box-shadow: var(--btn-raise); transition: box-shadow var(--dur-2), filter var(--dur-2), translate var(--dur-2); }
  .blk-embed__play::before { content: ""; border-style: solid; border-width: 0.45em 0 0.45em 0.75em; border-color: transparent transparent transparent currentColor; }
  @media (hover: hover) {
    .blk-embed__facade:hover .blk-embed__play { box-shadow: var(--btn-raise-hover); filter: brightness(var(--btn-hover-brightness)); translate: 0 calc(-1 * var(--btn-lift)); }
  }
  .blk-embed__facade:active .blk-embed__play { background-image: linear-gradient(to bottom, var(--btn-sheen-pressed), transparent); box-shadow: var(--btn-pressed); filter: none; translate: 0 var(--btn-lift); }
  .blk-embed__facade:focus-visible { outline-offset: calc(-1 * var(--focus-width)); outline-color: var(--focus-on-dark); }
  /* YouTube Shorts: portrait player, capped so it does not fill the whole column */
  .blk-embed[data-shape="short"] { aspect-ratio: 9 / 16; max-inline-size: 22.5rem; margin-inline: auto; }
  .blk-embed__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

  /* in-article ad */
  .article-body > .ad-slot { margin-block: var(--space-8); }

  /* legacy HTML fallback */
  .blk-html > * + * { margin-top: var(--space-6); }
  /* Wide tables scroll inside a focusable, named region (the sanitiser adds it), not the page. */
  .blk-table { max-inline-size: 100%; overflow-x: auto; }
  .blk-table:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
  .blk-table { overscroll-behavior-x: contain; }
  /* Data tables (editor table blocks and legacy HTML tables): row rules, shaded header row, cells wide enough to read; the region scrolls, the page does not. */
  .blk-table table { inline-size: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: var(--fs-sm); line-height: var(--lh-normal); font-variant-numeric: tabular-nums; }
  .blk-table th, .blk-table td { padding: var(--space-2) var(--space-3); border-block-end: 1px solid var(--border); text-align: start; vertical-align: top; min-inline-size: 7rem; }
  .blk-table th { background: var(--surface-alt); font-weight: var(--fw-semibold); }
  .blk-table thead th { border-block-end: 2px solid var(--ink); }
  .blk-table td > p, .blk-table th > p { margin: 0; }
  .blk-table td > p + p, .blk-table th > p + p { margin-block-start: var(--space-2); }
  .blk-table tbody th[scope="row"] { background: transparent; }
  .blk-html img { height: auto; border-radius: var(--radius-sm); }
  .blk-html iframe { width: 100%; border: 0; }
  .blk-html table { width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: var(--fs-sm); line-height: var(--lh-normal); }
  .blk-html th, .blk-html td { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); text-align: left; vertical-align: top; min-width: 7rem; }
  .blk-html th, .blk-html thead td { background: var(--surface-alt); font-weight: var(--fw-semibold); }
  .blk-html caption { padding-bottom: var(--space-2); font-weight: var(--fw-semibold); text-align: left; }
  .blk-html font { font: inherit; color: inherit; }
  .blk-html center { text-align: left; }
  .blk-html hr { border: 0; border-top: 1px solid var(--border); }

  @media (min-width: 48em) {
    .article-body h1, .article-body h2 { font-size: var(--fs-h2); }
    .article-body h3 { font-size: var(--fs-h3); }
    .blk-gallery__items { gap: var(--space-3); }
    .blk-gallery:not([data-count="2"], [data-count="3"], [data-count="4"]) .blk-gallery__items { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }
}
