/* =========================================================================
   blog-post.css — shared styles for the blog post detail page.
   Loaded by /blog-post.html AND every /blog/<slug>/index.html emitted by
   build-blog.mjs.
   Scoped to body[data-page="blog-post"] in places where a name collision
   with css/blog.css (legacy) or css/landing-lp.css would otherwise occur.
   ========================================================================= */

/* Subtle blue-grey body background (matches blog.html), with the hero gradient
   fading into the same tone so there's no visible step at the hero's bottom edge. */
body[data-page="blog-post"] { background: #fafbff; }
body[data-page="blog-post"] .post-hero {
  padding: 56px 32px 24px;
  background: linear-gradient(180deg, #f7f9fd 0%, #fafbff 100%);
}
/* Kill the legacy css/blog.css `.post-hero::before` purple overlay — it was
   pinned `inset: 0` and covered the new `.post-wrap` content (only the
   old `.container` had z-index:1 to lift above it). */
body[data-page="blog-post"] .post-hero::before { content: none; }
body[data-page="blog-post"] .post-hero .post-wrap { max-width: 760px; margin: 0 auto; text-align: center; position: relative; z-index: 1; }
body[data-page="blog-post"] .post-hero .crumbs {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700;
  color: var(--muted); letter-spacing: .04em;
  margin-bottom: 12px;
}
body[data-page="blog-post"] .post-hero .crumbs a { color: var(--brand); text-decoration: none; }
body[data-page="blog-post"] .post-hero .ptag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .12em;
  padding: 5px 12px;
  border-radius: 5px;
  background: var(--violet-soft);
  color: var(--violet);
  margin-bottom: 18px;
}
body[data-page="blog-post"] .post-hero h1 {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: clamp(34px, 5vw, 54px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.035em;
  color: var(--ink);
  margin: 0 auto;
  max-width: 22ch;
  text-wrap: balance;
}
body[data-page="blog-post"] .post-hero h1 em {
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--brand);
}
body[data-page="blog-post"] .post-hero .deck {
  margin: 18px auto 0;
  font-size: 18px;
  color: var(--muted);
  line-height: 1.55;
  max-width: 56ch;
}
body[data-page="blog-post"] .post-hero .post-meta {
  margin-top: 32px;
  display: flex; justify-content: center; align-items: center; gap: 14px;
  font-size: 13.5px; color: var(--muted);
}
body[data-page="blog-post"] .post-hero .post-meta .av {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
body[data-page="blog-post"] .post-hero .post-meta b { color: var(--ink); font-weight: 700; }
body[data-page="blog-post"] .post-hero .post-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); }

/* Cover (aurora overlays declared below in the POLISH block) */
.post-cover {
  max-width: 980px;
  margin: 36px auto 0;
  height: 380px;
  border-radius: 22px;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.post-cover .glyph {
  font-family: "Source Serif 4", "Instrument Serif", serif;
  font-style: italic;
  font-size: 180px;
  color: rgba(255,255,255,.95);
  position: relative;
  text-shadow: 0 10px 40px rgba(0,0,0,.3);
}

/* Body */
.post-body {
  max-width: 720px;
  margin: 56px auto 0;
  padding: 0 32px 80px;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.75;
  color: #1a2236;
  font-weight: 400;
}
.post-body > .lede {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 24px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -.01em;
  margin-bottom: 32px;
}
.post-body p { margin: 0 0 24px; }
.post-body h2 {
  font-family: "Plus Jakarta Sans", sans-serif;
  margin: 52px 0 16px;
  font-size: 31px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1.2;
  scroll-margin-top: 96px;
}
.post-body h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  margin: 32px 0 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--ink);
}
.post-body a {
  color: var(--brand);
  text-decoration: none;
  border-bottom: 1.5px solid rgba(55,136,216,.35);
  transition: border-color .15s ease;
}
.post-body a:hover { border-bottom-color: var(--brand); }
.post-body strong { color: var(--ink); font-weight: 700; }
.post-body em { font-style: italic; }
.post-body ul, .post-body ol { margin: 0 0 24px; padding-left: 24px; }
.post-body li { margin-bottom: 10px; }
.post-body blockquote {
  margin: 32px 0;
  padding: 0 0 0 32px;
  border-left: 4px solid var(--brand);
  font-style: italic;
  font-size: 22px;
  line-height: 1.5;
  color: var(--ink);
  font-family: "Instrument Serif", serif;
  font-weight: 400;
}
.post-body figure { margin: 36px 0; }
.post-body figure .ph {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px;
  text-align: center;
  color: var(--muted);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 14px;
}
.post-body figure figcaption {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--muted-2);
  text-align: center;
  font-family: "Plus Jakarta Sans", sans-serif;
}
.post-body .pullq {
  margin: 40px -32px;
  padding: 32px;
  background: linear-gradient(135deg, var(--brand-softer), #fff);
  border-radius: 14px;
  font-family: "Instrument Serif", serif;
  font-style: italic;
  font-size: 26px;
  line-height: 1.35;
  color: var(--ink);
  text-align: center;
}
.post-body .callout {
  margin: 32px 0;
  padding: 18px 22px;
  background: var(--brand-softer);
  border-left: 4px solid var(--brand);
  border-radius: 0 12px 12px 0;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}
.post-body .callout strong { color: var(--ink); }

.share-bar {
  max-width: 720px;
  margin: 24px auto 0;
  padding: 24px 32px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
  font-family: "Plus Jakarta Sans", sans-serif;
}
.share-bar .actions { display: flex; gap: 6px; }
.share-bar .actions a, .share-bar .actions button {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  display: grid; place-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  font-family: inherit;
}
.share-bar .actions a:hover, .share-bar .actions button:hover { background: var(--brand-softer); color: var(--brand); border-color: var(--brand); }

/* Author card */
.author-card {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 28px 32px;
  background: linear-gradient(135deg, #f3e8ff, #fff);
  border: 1px solid #e9d5ff;
  border-radius: 18px;
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 18px;
  font-family: "Plus Jakarta Sans", sans-serif;
}
.author-card .av {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: #fff;
  font-weight: 800; font-size: 22px;
  display: grid; place-items: center;
}
.author-card .ainfo h4 {
  margin: 0 0 4px;
  font-size: 17px; font-weight: 800;
  color: var(--ink); letter-spacing: -.015em;
}
.author-card .ainfo .role {
  font-size: 12.5px; color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.author-card .ainfo .bio {
  font-size: 13.5px; color: var(--ink-2);
  line-height: 1.55;
}

/* Related */
.related {
  max-width: 1100px;
  margin: 64px auto 0;
  padding: 0 32px;
}
.related h3 {
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.015em;
  color: var(--ink);
  margin: 0 0 18px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.related-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .2s ease;
  display: flex; flex-direction: column;
}
.related-card:hover { transform: translateY(-3px); box-shadow: 0 18px 36px -20px rgba(15,23,42,.16); }
.related-card .img {
  min-height: 120px;
  display: grid; place-items: center;
  color: rgba(255,255,255,.9);
  font-family: "Instrument Serif", serif;
  font-size: 50px; font-style: italic;
}
.related-card.c1 .img { background: linear-gradient(135deg, #2c6cb0, #5aa3e8); }
.related-card.c2 .img { background: linear-gradient(135deg, #b45309, #f59e0b); }
.related-card.c3 .img { background: linear-gradient(135deg, #059669, #10b981); }
.related-card .body { padding: 18px 20px 20px; font-family: "Plus Jakarta Sans", sans-serif; }
.related-card .tag {
  font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  padding: 3px 7px; border-radius: 4px;
  text-transform: uppercase;
}
.related-card.c1 .tag { background: var(--brand-softer); color: var(--brand); }
.related-card.c2 .tag { background: #fff5e6; color: #b45309; }
.related-card.c3 .tag { background: var(--green-soft); color: var(--green); }
.related-card h4 { margin: 8px 0 6px; font-size: 15px; font-weight: 700; line-height: 1.3; color: var(--ink); }
.related-card p { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }

/* ===========================================================================
   POLISH (2026-06-03)  —  sticky TOC, read-progress, hero cascade,
   scroll-reveal, aurora cover, drop cap, motif-grain related cards,
   spacing into the dark CTA.
   =========================================================================== */
:root {
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
@keyframes auroraSpin { to { transform: rotate(360deg); } }

/* Refined post-cover with aurora + grain overlays */
.post-cover {
  background:
    radial-gradient(440px 240px at 74% 26%, rgba(167,139,250,.5), transparent 62%),
    radial-gradient(560px 320px at 18% 84%, rgba(74,153,230,.55), transparent 62%),
    linear-gradient(135deg, #16235e 0%, #2c6cb0 52%, #6d28d9 100%);
}
.post-cover::before {
  content: "";
  position: absolute; inset: -35%;
  background:
    conic-gradient(from 0deg at 50% 50%, rgba(124,58,237,0) 0deg, rgba(196,181,253,.45) 80deg, rgba(125,211,252,.35) 200deg, rgba(124,58,237,0) 360deg);
  filter: blur(40px);
  animation: auroraSpin 24s linear infinite;
  z-index: 0;
}
.post-cover::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background:
    repeating-radial-gradient(circle at 74% 30%, rgba(255,255,255,.09) 0 1px, transparent 1px 28px),
    var(--grain);
  background-size: auto, 150px 150px;
  mix-blend-mode: soft-light;
  opacity: .7;
}
.post-cover .glyph {
  position: relative; z-index: 2;
  text-shadow: 0 12px 44px rgba(0,0,0,.32);
  will-change: transform;
}

/* Drop cap on lede */
.post-body > .lede::first-letter {
  float: left;
  font-family: "Instrument Serif", "Source Serif 4", serif;
  font-style: normal;
  font-weight: 400;
  font-size: 78px;
  line-height: .8;
  padding: 8px 14px 0 0;
  color: var(--brand);
}

/* Two-column reading layout with sticky "On this page" rail */
.post-layout {
  display: grid;
  grid-template-columns: 236px minmax(0, 720px);
  justify-content: center;
  align-items: start;
  gap: 64px;
  max-width: 1120px;
  margin: 0 auto;
}
.post-main { min-width: 0; }
.post-layout .post-body { margin: 56px 0 0; max-width: none; padding: 0 0 32px; }
.post-layout .share-bar { max-width: none; margin: 24px 0 0; }
.post-layout .author-card { max-width: none; margin: 40px 0 0; }

.post-toc {
  position: sticky;
  top: 104px;
  align-self: start;
  margin-top: 64px;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  /* Fade-in is pure CSS so the TOC is never permanently hidden when JS
     fails. JS still adds .in (no-op) + handles scroll-spy active state. */
  animation: heroRise .5s ease both;
  animation-delay: 400ms;
}
.post-toc.in { opacity: 1; transform: none; }
.post-toc .toc-label {
  font-size: 11px; font-weight: 800; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted-2);
  margin-bottom: 18px; padding-left: 17px;
}
.post-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.post-toc a {
  display: block;
  font-size: 14px; line-height: 1.4; font-weight: 500;
  color: var(--muted); text-decoration: none;
  padding: 9px 0 9px 17px;
  border-left: 2px solid var(--border);
  transition: color .2s ease, border-color .2s ease, padding-left .2s ease;
}
.post-toc a:hover { color: var(--ink-2); border-left-color: var(--border-strong); padding-left: 21px; }
.post-toc a.active {
  color: var(--brand); font-weight: 700;
  border-left-color: var(--brand);
}
.post-toc .toc-h3 a { padding-left: 30px; font-size: 13px; }
.post-toc .toc-h3 a:hover { padding-left: 34px; }
@media (max-width: 1080px) {
  .post-layout { grid-template-columns: minmax(0, 720px); padding: 0 32px; }
  .post-toc { display: none; }
  .post-layout .share-bar, .post-layout .author-card { max-width: 720px; margin-left: auto; margin-right: auto; }
}

/* Reading progress bar */
.read-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px; z-index: 60;
  background: transparent;
  pointer-events: none;
}
.read-progress i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--violet));
  box-shadow: 0 0 12px rgba(124,58,237,.5);
  transition: width .1s linear;
}

/* Hero load cascade — pure CSS, no JS dependency.
   Each .hero-rise element fades+rises with a 100ms-staggered delay. If JS
   never runs (CSP block, error in earlier script, etc.) the animation still
   fires and the hero is visible — content is never permanently hidden. */
@keyframes heroRise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.post-hero .crumbs, .post-hero .ptag, .post-hero h1,
.post-hero .deck, .post-hero .post-meta { will-change: transform, opacity; }
.hero-rise {
  animation: heroRise .7s cubic-bezier(.2,.75,.25,1) both;
  animation-delay: 60ms;
}
.post-hero .hero-rise:nth-of-type(2) { animation-delay: 160ms; }
.post-hero .hero-rise:nth-of-type(3) { animation-delay: 260ms; }
.post-hero .hero-rise:nth-of-type(4) { animation-delay: 360ms; }
.post-hero .hero-rise:nth-of-type(5) { animation-delay: 460ms; }
/* JS-added .in remains for backward compat — equivalent to animation end-state. */
.hero-rise.in { opacity: 1; transform: none; }

/* Scroll-reveal for post-article structural blocks (author/related/share only —
   in-article reveals create dead whitespace as the reader scrolls) */
.author-card.reveal, .related-card.reveal, .share-bar.reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity .6s ease, transform .7s cubic-bezier(.2,.75,.25,1);
  will-change: opacity, transform;
}
.reveal.in { opacity: 1; transform: none; }

/* Related card covers: motif + grain + glyph life */
.related-card .img { position: relative; overflow: hidden; }
.related-card .img::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image: var(--motif, none), var(--grain);
  background-size: var(--ms, auto), 140px 140px;
  mix-blend-mode: soft-light; opacity: .85;
}
.related-card .img .g {
  position: relative; z-index: 1;
  display: inline-block;
  transition: transform .4s cubic-bezier(.34,1.56,.64,1);
}
.related-card:hover .img .g { transform: scale(1.15) rotate(-5deg); }
.related-card.c1 .img { --motif: repeating-radial-gradient(circle at 76% 28%, rgba(255,255,255,.13) 0 1px, transparent 1px 17px); }
.related-card.c2 .img { --motif: repeating-linear-gradient(60deg, rgba(255,255,255,.11) 0 2px, transparent 2px 12px); }
.related-card.c3 .img { --motif: repeating-linear-gradient(0deg, rgba(255,255,255,.11) 0 1px, transparent 1px 12px); }
.related-card h4 { transition: color .2s ease; }
.related-card.c1:hover h4 { color: var(--brand); }
.related-card.c2:hover h4 { color: #b45309; }
.related-card.c3:hover h4 { color: var(--green); }

/* Spacing into the dark CTA + the footer that follows. .cta-final itself lives
   in css/lp/landing-lp.css (sitewide). */
body[data-page="blog-post"] .cta-final { margin-top: 80px; }
body[data-page="blog-post"] .footer { padding-top: 70px; }
@media (max-width: 720px) {
  body[data-page="blog-post"] .cta-final { margin-top: 56px; }
  body[data-page="blog-post"] .footer { padding-top: 48px; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-rise, .reveal { opacity: 1 !important; transform: none !important; transition: none !important; animation: none !important; }
  .read-progress i { transition: none; }
  .related-card .img .g { transition: none; }
  .post-cover::before { animation: none; }
}

/* Mobile */
@media (max-width: 720px) {
  body[data-page="blog-post"] .post-hero { padding: 32px 16px 16px; }
  .post-layout { grid-template-columns: minmax(0, 1fr); padding: 0 20px; gap: 0; }
  .post-layout .post-body { margin: 28px 0 0; padding: 0 0 36px; font-size: 17px; line-height: 1.72; }
  .post-layout .share-bar { margin: 24px 0 0; padding: 18px 16px; }
  .post-layout .author-card { margin: 26px 0 0; padding: 22px; grid-template-columns: 48px 1fr; gap: 14px; }
  .author-card .av { width: 48px; height: 48px; font-size: 18px; }
  .post-body > .lede { font-size: 19px; line-height: 1.55; }
  .post-body > .lede::first-letter { font-size: 54px; padding: 5px 9px 0 0; }
  .post-body .pullq { margin: 32px -16px; padding: 24px; font-size: 21px; }
  .post-cover { height: 168px; margin: 22px 20px 0; border-radius: 16px; }
  .post-cover .glyph { font-size: 82px; }
  body[data-page="blog-post"] .post-hero .crumbs { font-size: 11.5px; flex-wrap: wrap; }
  .related { padding: 0 16px; }
  .related-grid { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
  .post-layout { padding: 0 16px; }
}
