/* ==========================================================================
   Blog post (templates/post.html → /<slug>/index.html). Owner: lead builder.
   Long-form reading: dark title block, a big featured image that straddles
   into the daylight reading surface, a 68ch body with a sticky contents list
   at ≥1200px, recent posts, then the closing call band.
   ========================================================================== */

/* ---------- Reading progress (scroll-driven; hidden where unsupported) ---- */
.post-progress { display: none; }
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .post-progress {
      display: block;
      position: fixed;
      inset: 0 0 auto 0;
      z-index: 101;
      height: 3px;
      background: var(--cyan);
      transform-origin: 0 50%;
      transform: scaleX(0);
      animation: post-progress linear both;
      animation-timeline: scroll(root);
      pointer-events: none;
    }
  }
}
@keyframes post-progress { to { transform: scaleX(1); } }

/* ---------- 1. Title block ------------------------------------------------ */
.post-hero { background: var(--void); padding-top: calc(var(--header-h) + clamp(1.5rem, 4vw, 3.5rem)); }
.post-hero__inner { display: grid; gap: clamp(1.25rem, 2.5vw, 2rem); padding-bottom: clamp(2rem, 4vw, 3.25rem); }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; font-size: .9375rem; color: var(--muted); }
.crumbs li { display: inline-flex; align-items: center; gap: .6rem; min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--line-2); }
.crumbs a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: .22em; }
.crumbs a:hover { color: var(--cyan); }
.crumbs [aria-current] { display: inline-block; max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.post-title {
  font-size: clamp(2.35rem, 1.2rem + 3.7vw, 4.9rem);
  line-height: .98;
  letter-spacing: -.042em;
  max-width: 13.2em;   /* em, not ch: stays the same box while the web font swaps in */
}
.post-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem 2rem; }
.byline { display: flex; align-items: center; gap: .9rem; }
.byline__avatar { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--void), 0 0 0 3px rgba(0, 198, 242, .6); }
.byline__text { display: grid; gap: .1rem; line-height: 1.35; }
.byline__name { font-weight: 600; color: var(--text); }
.byline__sub { font-size: .9375rem; color: var(--muted); }
.byline__read:not(:empty)::before { content: ""; display: inline-block; width: 4px; height: 4px; margin: 0 .6rem; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.share__list { display: flex; gap: .5rem; }
.share__link {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  color: var(--text-2);
  transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}
.share__link svg { width: 18px; height: 18px; }
.share__link:hover { color: var(--void); background: var(--cyan); border-color: var(--cyan); }

/* Featured image straddles dark → daylight */
.post-figure-wrap { background: linear-gradient(180deg, var(--void) 0 50%, var(--daylight) 50% 100%); }
.post-figure {
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-l);
  aspect-ratio: 16 / 8;
  background: var(--night);
  box-shadow: 0 40px 80px -40px rgba(5, 8, 12, .55);
}
.post-figure img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 2. Reading surface -------------------------------------------- */
.post-main { padding-block: clamp(2.75rem, 2rem + 4vw, 5.5rem) clamp(4rem, 3rem + 5vw, 7rem); }
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.post-aside { display: none; }
@media (min-width: 1200px) {
  .post-layout { grid-template-columns: minmax(200px, 1fr) minmax(0, 44rem) minmax(0, 1fr); column-gap: clamp(2.5rem, 4vw, 4.5rem); align-items: start; justify-items: stretch; }
  .post-aside { display: block; position: sticky; top: calc(var(--header-h) + 1.5rem); max-width: 17rem; justify-self: end; }
  .post-body { grid-column: 2; }
  .post-layout--end > .post-nav { grid-column: 2; }
}

.post-toc__title { font-size: .875rem; font-weight: 600; color: var(--ink); margin-bottom: .75rem; }
.post-toc__list { display: grid; gap: .1rem; border-left: 1px solid var(--ink-line); }
.post-toc__list a {
  position: relative;
  display: block;
  padding: .4rem 0 .4rem 1rem;
  font-size: .9rem;
  line-height: 1.35;
  color: var(--ink-muted);
  transition: color var(--dur-fast);
}
.post-toc__list a::before {
  content: "";
  position: absolute; left: -1px; top: .35rem; bottom: .35rem;
  width: 2px;
  background: var(--cyan-deep);
  transform: scaleY(0);
  transition: transform var(--dur) var(--ease-out);
}
.post-toc__list a:hover { color: var(--ink); }
.post-toc__list a[aria-current="true"] { color: var(--ink); font-weight: 500; }
.post-toc__list a[aria-current="true"]::before { transform: scaleY(1); }

/* Body typography */
.post-body {
  width: 100%;
  max-width: 44rem;
  font-size: clamp(1.0625rem, 1rem + .3vw, 1.1875rem);
  line-height: 1.72;
  color: #1B2531;
  font-feature-settings: "kern", "liga";
  hanging-punctuation: first;
}
.post-body > * + * { margin-top: 1.15em; }
.post-body > p:first-child { font-size: 1.2em; line-height: 1.55; color: var(--ink); letter-spacing: -.008em; }
.post-body h2 {
  margin-top: 2.1em;
  font-size: clamp(1.7rem, 1.2rem + 1.5vw, 2.45rem);
  line-height: 1.06;
  letter-spacing: -.034em;
  color: var(--ink);
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
}
.post-body h2 + * { margin-top: .75em; }
.post-body h3 {
  margin-top: 1.7em;
  font-size: clamp(1.25rem, 1.1rem + .5vw, 1.5rem);
  letter-spacing: -.022em;
  color: var(--ink);
}
.post-body h3 + * { margin-top: .55em; }
.post-body strong { font-weight: 600; color: var(--ink); }
.post-body a {
  color: var(--cyan-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  text-decoration-color: rgba(0, 108, 140, .4);
  transition: color var(--dur-fast), text-decoration-color var(--dur-fast);
}
.post-body a:hover { color: var(--ink); text-decoration-color: var(--ink); }
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body li + li { margin-top: .5em; }
.post-body li { padding-left: .25em; }
.post-body ul { list-style: none; padding-left: 1.35em; }
.post-body ul > li { position: relative; }
.post-body ul > li::before {
  content: "";
  position: absolute;
  left: -1.1em; top: .72em;
  width: .42em; height: .42em;
  border-radius: 50%;
  background: var(--cyan-deep);
}
.post-body ol > li::marker { color: var(--cyan-ink); font-weight: 600; }
.post-body blockquote {
  padding-left: 1.25rem;
  border-left: 3px solid var(--cyan-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.35em;
  line-height: 1.25;
  letter-spacing: -.02em;
  color: var(--ink);
}
.post-body figure { margin-block: 2.2em; }
.post-body figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(82vh, 760px);
  margin-inline: auto;
  border-radius: var(--radius);
  background: #E4EBF1;
}
.post-body figcaption { margin-top: .7rem; font-size: .9rem; color: var(--ink-muted); text-align: center; }
.post-body hr { border: 0; height: 1px; background: var(--ink-line); margin-block: 2.5em; }

/* Older / newer */
.post-layout--end { margin-top: clamp(3rem, 2rem + 3vw, 4.5rem); }
.post-nav {
  width: 100%;
  max-width: 44rem;
  display: grid;
  gap: 1rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--ink-line);
}
@media (min-width: 640px) { .post-nav { grid-template-columns: 1fr 1fr; gap: 2rem; } }
.post-nav__link { display: grid; gap: .45rem; align-content: start; padding: .25rem 0; color: var(--ink); }
.post-nav__link--newer { text-align: right; }
@media (min-width: 640px) { .post-nav__link--newer { grid-column: 2; } }
.post-nav__dir { display: inline-flex; align-items: center; gap: .4rem; font-size: .875rem; font-weight: 600; color: var(--cyan-ink); }
.post-nav__link--newer .post-nav__dir { justify-content: flex-end; }
.post-nav__dir svg { width: 12px; height: 12px; }
.post-nav__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
  letter-spacing: -.022em;
  text-wrap: balance;
  transition: color var(--dur-fast);
}
.post-nav__link:hover .post-nav__title { color: var(--cyan-ink); }

/* ---------- 3. Recent posts ----------------------------------------------- */
.post-recent { background: var(--void); padding-block: clamp(4.5rem, 3rem + 5vw, 8rem) clamp(3rem, 2rem + 3vw, 5rem); }
.post-recent__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem 2rem; margin-bottom: clamp(1.75rem, 3vw, 2.75rem); }
.post-recent__title { font-size: var(--step-3); letter-spacing: -.038em; }
.recent-grid { display: grid; gap: clamp(1.75rem, 3vw, 2.5rem) clamp(1rem, 2vw, 2rem); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.recent-card { position: relative; display: grid; gap: .55rem; align-content: start; }
.recent-card__media { overflow: hidden; border-radius: var(--radius); aspect-ratio: 16 / 10; background: var(--night); margin-bottom: .45rem; }
.recent-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform .9s var(--ease-out); }
.recent-card__meta { font-size: .875rem; color: var(--muted); }
.recent-card__title { font-size: clamp(1.2rem, 1.05rem + .5vw, 1.45rem); line-height: 1.15; letter-spacing: -.025em; text-wrap: balance; }
.recent-card__title a { transition: color var(--dur-fast); }
.recent-card .stretched::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.recent-card:hover .recent-card__media img { transform: scale(1.035); }
.recent-card:hover .recent-card__title a, .recent-card .stretched:focus-visible { color: var(--cyan); }

/* ---------- Small screens -------------------------------------------------- */
@media (max-width: 767.98px) {
  .post-figure { aspect-ratio: 16 / 10; border-radius: var(--radius); }
}
/* Phones: the title block + featured image fill the first screen, so the floating call
   button sits over the photo instead of the opening paragraph. */
@media (max-width: 599.98px) {
  .post-hero { min-height: 100svh; display: flex; flex-direction: column; }
  .post-figure-wrap { flex: 1 0 auto; display: flex; flex-direction: column; }
  .post-figure-wrap > .container { flex: 1; display: flex; flex-direction: column; }
  .post-figure { position: relative; flex: 1; aspect-ratio: auto; min-height: 62vw; }
  .post-figure img { position: absolute; inset: 0; }
}
@media (max-width: 767.98px) {
  .post-meta { align-items: flex-start; }
  .crumbs [aria-current] { max-width: 20ch; }
  .post-body > p:first-child { font-size: 1.12em; }
}

/* Load check: the inline stylesheet guard re-fetches this file if this rule is missing. Keep it last. */
:root { --css-post: 1; }
