/*
  Blog post page (/blog/<slug>: static pages build/site.mjs writes from post.html). Clay's post layout (docs/research/2026-10-20-clay-blog-post.md) in our type (type.css), colors and
  buttons (the style guide), minus Clay's right-hand column. Load after type.css, nav.css and blog.css: this file reuses blog.css's
  page width (.blog-container), cover, tabs, card and button, and its two neutrals (Slate #5b6270, Hairline #d2d2d7).
  Breakpoints are Clay's: 768 and 1250 px (and blog.css's 1550, 1900 and 2048 for the page width).
  Motion uses the guide's curve and stays under 300 ms. Reduced motion keeps color and opacity only, and turns smooth scrolling off.

  Blog-only values the guide and type.css do not have (to add to them if the blog stays):
    Band #f0f4fa   the light blue tint behind the top of the page, the title block (Rahul, 2026-11-16: the header, the contents and the
                   article were hard to tell apart); Night on it is 17:1, Slate 5.6:1
    Tint #f5f5f7   the contents panel, the callout's and the code block's fill (also the pagination hover in blog.css); Night on it is 17:1
    Article body   .t-body (17 to 18 px) is smaller than Clay's 18 to 20 px: kept, since the roles are the system
    Pull quote     .t-h4 (20 to 24 px), where Clay's is 26 px
    Contents links 15 px (.t-small) in the rail; from 1250 px down they take .t-body's size (the rule below copies its clamp)
    Share title    .t-label at weight 600 (the role is 500)
*/

.blog-page {
  --tint: #f5f5f7;
  --band: #f0f4fa;
}

/* ── Three parts, told apart at a glance (Rahul, 2026-11-16): the title block on the light blue band, which runs edge to edge from
   under the nav down to the middle of the cover; the contents in a quiet grey panel with its own name; the article on white.
   The band is a border image pushed out to the screen's edges (it paints, it takes no room and never scrolls the page sideways). ── */
.post-tabs { background-color: var(--band); }
.post-head { border-image: linear-gradient(var(--band) 0 0) fill 0 // 0 100vmax; }
.post-head:has(+ .post-layout) { padding-bottom: 56px; }   /* no cover: the band ends under the dates */

/* The contents links jump to their heading; smooth only when the visitor has not asked for less motion */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ── Reading bar (2026-11-11): a 3 px Anchor Blue line along the top edge of the screen, in the 16 px above the nav bar, that fills
   as the article's body is read (blog-render.mjs puts it first in <main>, hidden from screen readers). Where the browser has view
   timelines it follows the body's "contain" range: empty while the body's top is below the scroll padding (nav.css: under the nav
   bar), full once its end reaches the bottom of the screen; post.js sets the same scaleX on each scroll elsewhere. Only transform
   changes. With reduced motion asked for it is hidden (2026-11-19 accessibility re-audit, WCAG 2.3.3): it moves with every
   scroll, and the scroll bar already says where you are. <main> is its own stacking context here, so
   the bar sits over everything in the page but under the open phone menu (z 39) and the nav (z 40), and the footer covers it as
   it covers the page. ── */
.blog-page main { isolation: isolate; timeline-scope: --post-read; }
.post-prose { view-timeline: --post-read block; }
.post-progress { position: fixed; top: 0; left: 0; z-index: 6; width: 100%; height: 3px; background-color: var(--anchor); transform: scaleX(0); transform-origin: 0 50%; pointer-events: none; }
@supports (animation-timeline: --post-read) and (timeline-scope: --post-read) {
  .post-progress { animation: post-read auto linear both; animation-timeline: --post-read; animation-range: contain 0% contain 100%; }
}
@keyframes post-read { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .post-progress { display: none; } }

/* ── Top of the page: the category row, then the title block (Clay's y: 128 / 116 / 96 for the row, 254 / 236 / 180 for the title) ── */
.post-tabs { padding-top: 96px; }
@media (min-width: 768px) { .post-tabs { padding-top: 116px; } }
@media (min-width: 1250px) { .post-tabs { padding-top: 128px; } }

.post-head { padding-top: 40px; }
@media (min-width: 768px) { .post-head { padding-top: 88px; } }
@media (min-width: 1250px) { .post-head { padding-top: 94px; } }
.post-head__title { color: var(--fg); }
@media (max-width: 767.98px) { .post-head__title, .post-head__desc { margin-right: 12px; } }
@media (min-width: 1250px) { .post-head__title { max-width: 83.1%; } }
.post-head__desc { max-width: 747px; margin-top: 20px; color: var(--fg); }

.post-meta { display: grid; gap: 8px; margin-top: 40px; color: var(--muted); }
.post-meta p { margin: 0; }
.post-meta__author { display: flex; align-items: center; gap: 8px; }
.post-meta__name { color: var(--fg); font-weight: 600; text-decoration: underline; text-decoration-color: var(--hairline); text-decoration-thickness: 1px; text-underline-offset: 4px; transition: text-decoration-color 150ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .post-meta__name:hover { text-decoration-color: currentColor; } }
.post-meta__dot { padding-inline: 0.5em; }

/* ── Cover: inside the page width and 2.4 to 1 from 1250 px, edge to edge below. A post with no picture has none (the build
   leaves it out), and its article starts under the dates. ── */
.post-head + .post-layout { margin-top: 48px; }
@media (min-width: 768px) { .post-head + .post-layout { margin-top: 64px; } }
@media (min-width: 1250px) { .post-head + .post-layout { margin-top: 72px; } }
/* The band goes on to the middle of the picture: room above it (--top) and under it (--bottom) are padding, so the gradient can find
   the picture's middle */
.post-cover {
  --top: 40px; --bottom: 32px;
  padding-top: var(--top); padding-bottom: var(--bottom);
  border-image: linear-gradient(to bottom, var(--band) calc(var(--top) + (100% - var(--top) - var(--bottom)) / 2), transparent 0) fill 0 // 0 100vmax;
}
@media (min-width: 768px) { .post-cover { --top: 48px; --bottom: 64px; } }
@media (max-width: 1249px) { .post-cover.blog-container { margin-inline: 0; } }
.post-cover .blog-cover { aspect-ratio: 13 / 10; border-radius: 0; }
@media (min-width: 768px) { .post-cover .blog-cover { aspect-ratio: 1169 / 619; } }
@media (min-width: 1250px) { .post-cover .blog-cover { aspect-ratio: 12 / 5; border-radius: 16px; } }

/* ── Layout: the contents panel 256, the article, 203 of air where Clay's right column was (so the article stays near the middle).
   One column below 1250. ── */
@media (min-width: 1250px) {
  .post-layout { display: grid; grid-template-columns: 256px minmax(0, 1fr) 203px; }
  .post-article { padding-inline: 72px 70px; }
}

/* ── Rail: a grey panel named Contents, the table of contents, then the share buttons under a hairline, sticky until the article
   ends. Navigation, so it is quieter than the article: the Tint, 15 px links in Slate, the section being read in Night. ── */
.post-rail__label { display: none; }
@media (min-width: 1250px) {
  .post-rail__inner {
    position: sticky;
    top: 120px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 144px);
    max-height: calc(100dvh - 144px);
    padding: 20px 16px 20px 12px;
    border-radius: 20px;
    background-color: var(--tint);
  }
  .post-rail__label { display: block; flex: none; margin: 0 0 8px; padding-left: 13px; color: var(--fg); font-weight: 600; }
}

/* Under 1250 px the contents fold into the same grey panel above the article, behind its Contents button */
@media (max-width: 1249px) {
  .post-toc { margin-bottom: 32px; padding: 0 20px; border-radius: 16px; background-color: var(--tint); }
  .post-toc__list { padding-bottom: 16px; }
  html:not(.js) .post-toc__list { padding-top: 16px; }
}
@media (min-width: 768px) and (max-width: 1249px) { .post-toc { margin-bottom: 56px; } }
/* 4 px of room all round, so the focus ring is not clipped by the scrolling box */
@media (min-width: 1250px) {
  .post-toc { min-height: 0; margin: -4px; padding: 4px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
  /* A long list fades out where there is more to scroll to (post.js sets data-less above and data-more below) */
  .post-toc[data-less], .post-toc[data-more] {
    --fade-top: 0px;
    --fade-bottom: 0px;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
  }
  .post-toc[data-less] { --fade-top: 28px; }
  .post-toc[data-more] { --fade-bottom: 36px; }
}
.post-toc__list { display: grid; }
.post-toc__link { position: relative; display: block; padding: 3px 0; color: var(--muted); transition: color 150ms var(--ease-out); }
.post-toc__item--sub .post-toc__link { padding-left: 16px; }
@media (max-width: 1249px) { .post-toc__link { font-size: clamp(1.0625rem, 1.037rem + 0.11vw, 1.125rem); line-height: 1.6; } }   /* .t-body */
@media (min-width: 1250px) {
  .post-toc__link { padding: 6px 0 6px 13px; }
  .post-toc__item--sub .post-toc__link { padding-left: 23px; }
  /* The section being read: a 5 px dot in the gutter and Night text */
  .post-toc__link::after { content: ""; position: absolute; top: calc(6px + (1lh - 5px) / 2); left: 0; width: 5px; height: 5px; border-radius: 9999px; background-color: var(--fg); opacity: 0; transition: opacity 150ms var(--ease-out); }
  .post-toc__link[aria-current="location"] { color: var(--fg); }
  .post-toc__link[aria-current="location"]::after { opacity: 1; }
}
@media (hover: hover) and (pointer: fine) { .post-toc__link:hover { color: var(--fg); } }
/* Under 1250 px the list folds behind a Contents button between two hairlines, so the article starts on a phone's first
   screen; post.js opens it. Folded only under .js (set in the head), so a page whose script never runs shows the list. */
.post-toc__toggle { display: none; }
@media (max-width: 1249px) {
  .js .post-toc__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    color: var(--fg);
    text-align: left;
  }
  .js .post-toc__toggle svg { flex: none; width: 14px; height: 14px; transition: transform 200ms var(--ease-out); }
  .js .post-toc__toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .js .post-toc:not([data-open]) .post-toc__list { display: none; }
  .js .post-toc[data-open] .post-toc__list { padding-top: 12px; transition: opacity 150ms var(--ease-out); }
  @starting-style { .js .post-toc[data-open] .post-toc__list { opacity: 0; } }
}

/* ── Share: the buttons themselves are in blog.css (a case study's copy link is the same button) ── */
/* In the rail from 1250 px (level with the contents text), after the article below it (Clay: 28 px title and 72 px buttons on a tablet, 20 and 52 on a phone) */
.post-share--rail { display: none; }
.post-share--end { display: flex; flex-direction: column; align-items: center; margin-top: 38px; }
.post-share--end .post-share__list { gap: 12px; margin-top: 24px; }
.post-share--end .post-share__btn { width: 52px; height: 52px; }
.post-share--end .post-share__btn svg { width: 22px; height: 22px; }
.post-share--end .post-share__btn .post-share__brand { width: 19px; height: 19px; }
@media (min-width: 768px) {
  .post-share--end .post-share__list { gap: 16px; margin-top: 32px; }
  .post-share--end .post-share__btn { width: 72px; height: 72px; }
  .post-share--end .post-share__btn svg { width: 28px; height: 28px; }
  .post-share--end .post-share__btn .post-share__brand { width: 24px; height: 24px; }
}
@media (min-width: 1250px) {
  .post-share--rail { display: block; flex: none; margin: 16px 0 0 13px; padding-top: 20px; border-top: 1px solid var(--hairline); }
  .post-share--end { display: none; }
}

/* ── The article. Clay's rhythm: paragraphs 30 apart, h2 80 above and 32 below, pictures 56 above and below. ── */
.post-prose { color: var(--fg); }
.post-prose > :first-child { margin-top: 0; }
.post-prose p { margin-block: 30px; }
.post-prose h2 { margin: 80px 0 32px; scroll-margin-top: 24px; }        /* the jump lands 112 px down (88 px scroll padding, nav.css): the nav bar ends at 80 */
.post-prose h3 { margin: 48px 0 24px; scroll-margin-top: 24px; }
.post-prose h3.post-faq__q { margin: 40px 0 24px; }
@media (max-width: 1249px) { .post-prose h2 { margin-bottom: 28px; } }
@media (max-width: 767.98px) { .post-prose h3 { margin-top: 40px; margin-bottom: 28px; } }

.post-prose a:not(.blog-button, .post-figure__open) { color: var(--anchor); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color 150ms var(--ease-out); }
.post-prose a:not(.blog-button, .post-figure__open):hover { color: var(--anchor-deep); }
.post-prose strong { font-weight: 700; }

.post-prose :is(ul, ol) { display: grid; gap: 12px; margin: 24px 0 28px; }
.post-prose li { position: relative; padding-left: 22px; }
.post-prose ul > li::before { content: ""; position: absolute; top: calc((1lh - 6px) / 2); left: 0; width: 6px; height: 6px; border-radius: 9999px; background-color: var(--fg); }
.post-prose ol { counter-reset: step; }
.post-prose ol > li { padding-left: 28px; counter-increment: step; }
.post-prose ol > li::before { content: counter(step) "."; position: absolute; left: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.post-figure { margin: 56px 0; }
@media (max-width: 767.98px) { .post-figure { margin: 48px 0; } }
.post-figure[data-size="medium"] { max-width: 75%; margin-inline: auto; }
.post-figure__open { display: block; width: 100%; border-radius: 12px; cursor: zoom-in; }
.post-figure__open img { width: 100%; height: auto; border-radius: 12px; outline: 1px solid rgba(12, 14, 18, 0.08); outline-offset: -1px; }
.post-figure figcaption { margin-top: 16px; color: var(--muted); text-align: center; }

.post-quote { margin: 56px 0; color: var(--fg); }
.post-callout { margin: 40px 0; padding: 24px 28px; border-radius: 16px; background-color: var(--tint); }
.post-callout p { margin: 0; }
.post-callout .post-callout__title { margin-bottom: 8px; }
.post-cta { margin-block: 40px; }
.post-divider { margin: 56px 0; border: 0; border-top: 1px solid var(--hairline); }

/* A code block (portable-text.mjs): on the callout's tint, the file's name (when it has one) and the copy button (copy.js adds it,
   since it needs a script) along the top, the code under them. Lines wrap, so a long one never pushes the page sideways. */
.post-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; margin: 40px 0; border-radius: 16px; background-color: var(--tint); }
.post-code__name { grid-column: 1; padding: 14px 12px 0 20px; color: var(--muted); overflow-wrap: anywhere; }
.post-code pre { grid-column: 1 / -1; margin: 0; padding: 14px 20px 20px; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 0.875rem; line-height: 1.65; color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.post-code > pre:first-child { padding-top: 20px; }
.post-code__copy {
  grid-column: 2;
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin: 8px 8px 0 0;
  padding: 0 14px 0 12px;
  border-radius: 9999px;
  background-color: #fff;
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--fg);
  transition: scale 150ms var(--ease-out);
}
.post-code__copy svg { flex: none; width: 16px; height: 16px; }
.post-code__done { display: none; }
.post-code__copy[data-copied] { background-color: var(--fg); box-shadow: none; color: #fff; }
.post-code__copy[data-copied] .post-code__icon { display: none; }
.post-code__copy[data-copied] .post-code__done { display: block; }
@media (hover: hover) and (pointer: fine) { .post-code__copy:hover { background-color: var(--fg); box-shadow: none; color: #fff; } }
.post-code__copy:active { scale: 0.97; }

/* ── After the article: the service that does what the post is about, on the callout's tint, and the way to its page ── */
.post-service { margin-top: 64px; padding: 24px 20px; border-radius: 16px; background-color: var(--tint); color: var(--fg); }
@media (min-width: 768px) { .post-service { padding: 32px; } }
.post-service p { margin: 0; }
.post-service__text { margin-top: 8px; max-width: 60ch; }
.post-service__more { margin-top: 16px; }
/* A text link, not a pill: its words name the service and can run to two lines on a phone, the arrow after the last word */
.post-service__link { color: var(--anchor); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; transition: color 150ms var(--ease-out); }
.post-service__link:hover { color: var(--anchor-deep); }
.post-service__link svg { display: inline-block; width: 18px; height: 18px; margin-left: 6px; vertical-align: -3px; transition: translate 150ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .post-service__link:hover svg { translate: 3px 0; } }
@media (prefers-reduced-motion: reduce) { .post-service__link:hover svg { translate: 0 0; } }

/* ── More on the category: three cards from 1250 px, a sideways row that runs to the screen edges below ── */
.post-more { padding-top: 80px; padding-bottom: 80px; }
.post-more__title { color: var(--fg); }
.post-more__list {
  display: flex;
  gap: 12px;
  margin-top: 40px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.post-more__list::-webkit-scrollbar { display: none; }
.post-more__list > li { flex: 0 0 311px; scroll-snap-align: start; }
/* Phones: the row runs to both screen edges (Clay's list is 390 wide there, its heading too), the first card at the gutter */
@media (max-width: 767.98px) {
  .post-more__title { margin-right: calc(-1 * var(--gutter)); }
  .post-more__list { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); }
}
@media (min-width: 768px) { .post-more__list { gap: 16px; } .post-more__list > li { flex-basis: 336px; } }
@media (min-width: 1250px) {
  .post-more__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; overflow: visible; }
}

.post-missing { padding: 160px 0 120px; }
.post-missing p { margin: 16px 0 32px; }

/* ── Lightbox: a native dialog, Night at 94% behind it ── */
.post-lightbox { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; }
.post-lightbox[open] { display: grid; place-items: center; }
.post-lightbox::backdrop { background-color: rgba(12, 14, 18, 0.94); }
.post-lightbox__image { max-width: min(92vw, 1400px); max-height: 88vh; width: auto; height: auto; border-radius: 12px; background-color: #fff; cursor: zoom-out; }
.post-lightbox__close { position: absolute; top: 12px; right: 12px; display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 9999px; background-color: rgba(255, 255, 255, 0.12); color: #fff; transition: background-color 150ms var(--ease-out), scale 160ms var(--ease-out); }
.post-lightbox__close svg { width: 22px; height: 22px; }
@media (hover: hover) and (pointer: fine) { .post-lightbox__close:hover { background-color: rgba(255, 255, 255, 0.22); } }
.post-lightbox__close:active { scale: 0.97; }
.post-lightbox__close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
html:has(.post-lightbox[open]) { overflow: hidden; }
.post-lightbox { opacity: 0; transition: opacity 150ms var(--ease-out), overlay 150ms allow-discrete, display 150ms allow-discrete; }
.post-lightbox[open] { opacity: 1; }
@starting-style { .post-lightbox[open] { opacity: 0; } }
.post-lightbox::backdrop { opacity: 0; transition: opacity 150ms var(--ease-out), overlay 150ms allow-discrete, display 150ms allow-discrete; }
.post-lightbox[open]::backdrop { opacity: 1; }
@starting-style { .post-lightbox[open]::backdrop { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .post-lightbox__close:active { scale: 1; }
  .js .post-toc__toggle svg { transition: none; }
  .js .post-toc[data-open] .post-toc__list { transition: opacity 120ms ease; }
  .post-code__copy:active { scale: 1; }
}

/* "Results vary by business." under a post that cites a case study's numbers (blog-render.mjs), as every page with client results has it */
.post-vary { margin-top: 24px; color: var(--slate); font-style: italic; }
