/* Blog pages. Builds on styles.css tokens; nothing here touches the home page.
   Layout follows an editorial pattern: a soft hero card, a sticky contents
   sidebar beside the article, and image-led cards on the index. */

.blog-page {
  --paper: #FCFCFA;
  --card-soft: #F4F4F1;
  --ink-blog: #0B1B33;
  --body-blog: #46546A;
  --tint: #E8EFFE;
  background: var(--paper);
}
.blog-page .site-header { background: rgba(252, 252, 250, 0.9); }

/* ── Topic bar under the header ─────────────────────────────────────── */

.blog-bar { background: var(--card-soft); border-bottom: 1px solid var(--line); }
.blog-bar__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 52px;
  display: flex;
  align-items: center;
  gap: 32px;
}
.blog-bar__home { font-weight: 700; font-size: 16px; color: var(--ink-blog); flex: none; }
.blog-bar__cats {
  display: flex;
  gap: 28px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 auto;
}
.blog-bar__cats::-webkit-scrollbar { display: none; }
.blog-bar__cats a { font-size: 14px; font-weight: 500; color: #334155; white-space: nowrap; padding: 15px 0; border-bottom: 2px solid transparent; }
.blog-bar__cats a:hover { color: var(--ink-blog); }
.blog-bar__cats a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

.blog-shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 24px var(--gutter) var(--section-y);
}

/* ── Chips and pills ────────────────────────────────────────────────── */

.chip-cat, .chip-tag, .tag-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  padding: 7px 10px;
  white-space: nowrap;
}
.chip-cat { background: var(--tint); color: #1E3A8A; }
.chip-cat:hover { background: #DCE6FD; }
.chip-tag, .tag-pill { background: #ECECE8; color: #4B5563; }
.tag-pill { font-size: 12px; padding: 6px 9px; }

/* ── Post hero ──────────────────────────────────────────────────────── */

.post-hero {
  background: var(--card-soft);
  border-radius: 28px;
  padding: clamp(48px, 8vw, 104px) clamp(20px, 4vw, 64px);
  text-align: center;
  /* The title card runs wider than the text column, close to the full window. */
  margin-inline: calc(-1 * max(0px, (min(100vw - 48px, 1640px) - 100%) / 2));
}
.post-hero__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 26px; }
.post-hero h1 {
  font-size: clamp(34px, 4.7vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  font-weight: 700;
  color: var(--ink-blog);
  margin: 0 auto 24px;
  max-width: 1180px;
  text-wrap: balance;
}
.post-hero__lede {
  font-size: clamp(17px, 1.6vw, 19px);
  line-height: 1.6;
  color: var(--body-blog);
  max-width: 60ch;
  margin: 0 auto;
  text-wrap: pretty;
}

.byline {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 14px;
  margin-top: 26px;
  font-size: 14px;
  color: var(--body-blog);
}
.byline a { color: var(--ink-blog); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: #9AA5B4; }
.byline__sep { width: 1px; height: 16px; background: #CBD2DB; }
.byline__avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.byline__avatar--lg { width: 56px; height: 56px; font-size: 18px; flex: none; }


/* ── Two-column layout ──────────────────────────────────────────────── */

.post-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 740px);
  justify-content: center;
  gap: clamp(40px, 6vw, 96px);
  margin-top: clamp(40px, 5vw, 64px);
}
.post-side__inner { position: sticky; top: 96px; display: grid; gap: 24px; }

.toc { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.toc__title { font-size: 20px; font-weight: 600; color: var(--ink-blog); letter-spacing: -0.01em; margin: 0 0 14px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.toc li { margin: 0; }
.toc a { display: block; font-size: 14.5px; line-height: 1.4; color: #334155; padding: 6px 0 6px 12px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--ink-blog); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }
.toc details > summary { list-style: none; cursor: pointer; position: relative; }
.toc details > summary::-webkit-details-marker { display: none; }
.toc details > summary::before {
  content: "";
  position: absolute;
  left: -8px; top: 13px;
  width: 6px; height: 6px;
  border-right: 1.5px solid #64748B;
  border-bottom: 1.5px solid #64748B;
  transform: rotate(-45deg);
  transition: transform .15s;
}
.toc details[open] > summary::before { transform: rotate(45deg); }
.toc details ol { margin: 2px 0 6px 12px; border-left: 1px solid var(--line); }
.toc details ol a { font-size: 13.5px; color: #64748B; }

.side-cta {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}
.side-cta__title { font-size: 19px; line-height: 1.35; font-weight: 600; color: var(--ink-blog); margin: 0 0 20px; letter-spacing: -0.01em; }
.btn--dark { background: var(--ink-blog); color: #fff; width: 100%; justify-content: center; border-radius: 10px; }
.btn--dark:hover { background: #142A4D; }

.share { display: flex; gap: 10px; }
.share a, .share button {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--card-soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-blog);
  padding: 0;
}
.share svg { width: 17px; height: 17px; fill: currentColor; }
.share a:hover, .share button:hover { background: #ECECE8; }
.share__copy.is-done { background: var(--tint); color: var(--accent); }

/* ── Article ────────────────────────────────────────────────────────── */

.post-summary {
  margin: 0 0 36px;
  padding: 24px 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
}
.post-summary .label { display: block; margin-bottom: 8px; color: var(--accent); }
.post-summary p { margin: 0; font-size: 17px; line-height: 1.65; color: var(--ink-blog); }

.post-body { font-size: 17.5px; line-height: 1.75; color: var(--body-blog); }
.post-body > :first-child { margin-top: 0; }
.post-body h2 {
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--ink-blog);
  margin: 1.8em 0 0.55em;
  scroll-margin-top: 110px;
  text-wrap: balance;
}
.post-body h3 {
  font-size: 22px;
  line-height: 1.3;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--ink-blog);
  margin: 1.7em 0 0.45em;
  scroll-margin-top: 110px;
}
.post-body p { margin: 0 0 1.15em; }
.post-body a { color: var(--ink-blog); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: #8A97A8; }
.post-body a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.post-body ul, .post-body ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.post-body li { margin: 0.45em 0; padding-left: 0.15em; }
.post-body li::marker { color: #64748B; }
.post-body strong { color: var(--ink-blog); font-weight: 650; }
.post-body blockquote {
  margin: 1.8em 0;
  padding: 28px 32px;
  background: var(--card-soft);
  border-radius: 18px;
  font-size: 22px;
  line-height: 1.5;
  color: #475569;
}
.post-body blockquote p:last-child { margin: 0; }
.post-body code { font-family: var(--font-mono); font-size: 0.86em; background: #EEEEEA; padding: 2px 6px; border-radius: 5px; color: var(--ink-blog); }
.post-body pre { background: var(--ink-blog); color: #E2E8F0; padding: 20px; border-radius: 14px; overflow-x: auto; }
.post-body pre code { background: none; padding: 0; color: inherit; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 2.6em 0; }
.post-figure { margin: 2em 0; }
.post-figure--cover { margin: 2.2em 0 0.6em; }
.post-figure--cover img { aspect-ratio: 16 / 9; object-fit: cover; }
.post-figure:not(.post-figure--cover) img { border: 1px solid var(--line); }
.post-figure img { display: block; width: 100%; height: auto; border-radius: 18px; }
.post-figure figcaption { font-size: 14px; color: #64748B; margin-top: 10px; text-align: center; }

.post-table { overflow-x: auto; margin: 1.8em 0; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.post-table table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.post-table th, .post-table td { text-align: left; vertical-align: top; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.post-table th { background: var(--card-soft); font-weight: 650; color: var(--ink-blog); }
.post-table tr:last-child td { border-bottom: 0; }

.post-faq { margin-top: 56px; }
.post-faq h2, .post-sources h2 { font-size: 28px; letter-spacing: -0.025em; font-weight: 700; color: var(--ink-blog); margin: 0 0 16px; }
.post-faq details { border-top: 1px solid var(--line); padding: 18px 0; }
.post-faq details:last-child { border-bottom: 1px solid var(--line); }
.post-faq summary { cursor: pointer; font-weight: 600; font-size: 17px; color: var(--ink-blog); }
.post-faq details p { margin: 10px 0 0; font-size: 16px; line-height: 1.7; color: var(--body-blog); }

.post-cta {
  margin: 56px 0 0;
  padding: clamp(28px, 4vw, 40px);
  border-radius: 24px;
  background: var(--ink-blog);
  color: #fff;
}
.post-cta .label { color: var(--accent-tint); }
.post-cta h2 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -0.025em; margin: 10px 0 10px; color: #fff; }
.post-cta p { color: #B6C2D4; font-size: 16px; line-height: 1.65; margin: 0 0 24px; max-width: 54ch; }
.post-cta .btn { margin: 0 10px 10px 0; }
.post-cta .btn--ghost { color: #fff; border-color: #33476A; }

.post-sources { margin-top: 48px; }
.post-sources ol { padding-left: 20px; margin: 0; font-size: 14px; line-height: 1.6; color: #64748B; }
.post-sources li { margin: 6px 0; }
.post-sources a { color: #475569; text-decoration: underline; text-underline-offset: 3px; word-break: break-word; }

.author-card {
  display: flex;
  gap: 18px;
  margin-top: 48px;
  padding: 24px;
  background: var(--card-soft);
  border-radius: 18px;
}
.author-card p { margin: 0; }
.author-card__name { font-weight: 650; font-size: 17px; color: var(--ink-blog); }
.author-card__role { font-size: 14px; color: #64748B; margin-top: 2px !important; }
.author-card__bio { font-size: 15px; line-height: 1.6; color: var(--body-blog); margin-top: 10px !important; }

.post-related { margin-top: 96px; padding-top: 48px; border-top: 1px solid var(--line); }
.post-related h2, .blog-section__head h2 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -0.03em; font-weight: 700; color: var(--ink-blog); margin: 0 0 28px; }

/* ── Index and cards ────────────────────────────────────────────────── */

.blog-hero { text-align: center; padding: clamp(40px, 6vw, 72px) 0 clamp(36px, 5vw, 56px); }
.blog-hero h1 { font-size: clamp(38px, 5.4vw, 64px); line-height: 1.05; letter-spacing: -0.04em; font-weight: 700; color: var(--ink-blog); margin: 0 0 16px; }
.blog-hero p { font-size: 18px; line-height: 1.6; color: var(--body-blog); max-width: 56ch; margin: 0 auto; }
.blog-voice-link { margin-top: 22px !important; }

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 48px 32px;
}
.post-card { display: flex; flex-direction: column; }
.post-card__media { display: block; border-radius: 20px; overflow: hidden; background: var(--card-soft); }
.post-card__media img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; transition: transform .35s ease; }
.post-card:hover .post-card__media img { transform: scale(1.025); }
.post-card__body { padding-top: 20px; }
.post-card__meta { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #64748B; }
.post-card__title { font-size: 21px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 650; color: var(--ink-blog); margin: 14px 0 10px; text-wrap: pretty; }
.post-card__title a:hover { color: var(--accent); }
.post-card__desc { font-size: 15.5px; line-height: 1.55; color: var(--body-blog); margin: 0; }
.post-card__tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.post-card--featured {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: center;
  padding-bottom: clamp(40px, 5vw, 64px);
  margin-bottom: clamp(40px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
}
.post-card--featured .post-card__media { border-radius: 24px; }
.post-card--featured .post-card__body { padding-top: 0; }
.post-card--featured .post-card__title { font-size: clamp(28px, 3.2vw, 40px); line-height: 1.15; letter-spacing: -0.03em; font-weight: 700; margin: 18px 0 14px; }
.post-card--featured .post-card__desc { font-size: 17px; }

.blog-section { margin-top: clamp(56px, 6vw, 88px); padding-top: clamp(40px, 5vw, 56px); border-top: 1px solid var(--line); }
.blog-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.blog-section__head a { font-size: 15px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.blog-empty { color: #64748B; text-align: center; }

/* Author page reuses the list hero. */
.blog-head { max-width: 760px; padding: 48px 0 32px; }
.blog-head .eyebrow { display: block; margin-bottom: 14px; }
.blog-head h1 { font-size: clamp(34px, 4.6vw, 52px); letter-spacing: -0.035em; font-weight: 700; color: var(--ink-blog); margin: 0 0 10px; }
.post-lede { font-size: 18px; color: var(--body-blog); margin: 0; }
.author-bio { font-size: 16px; line-height: 1.7; color: var(--body-blog); max-width: 62ch; margin-top: 16px; }

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 40px; }
}

@media (max-width: 860px) {
  .post-layout { grid-template-columns: 1fr; }
  .post-side__inner { position: static; }
  .post-side .side-cta, .post-side .share { display: none; }
  .toc { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 14px; }
  .post-card--featured { grid-template-columns: 1fr; }
  .blog-bar__home { display: none; }
  .blog-bar__cats { margin: 0; }
}

@media (max-width: 620px) {
  .post-grid { grid-template-columns: 1fr; gap: 40px; }
  .post-hero { border-radius: 20px; }
  .post-body { font-size: 17px; }
  .post-body blockquote { font-size: 19px; padding: 22px; }
  .byline__sep { display: none; }
}

.post-card__title a, .blog-hero a:not(.btn) { color: inherit; }
.post-card__title a:hover { color: var(--accent); }

/* ── Reading progress and listen button ─────────────────────────────── */

.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: transparent; pointer-events: none; }
.read-progress span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; transition: transform .1s linear; }

.listen { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 22px; }
.listen__note { flex-basis: 100%; margin: 4px 0 0; font-size: 14px; color: #64748B; }
.listen__note[hidden] { display: none; }
.listen[hidden] { display: none; }
.listen__btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 12px;
  border-radius: 999px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-blog);
  font: 600 14.5px var(--font-sans); cursor: pointer;
}
.listen__btn:hover { border-color: var(--accent); }
.listen__btn svg { width: 26px; height: 26px; padding: 5px; border-radius: 50%; background: var(--accent); fill: #fff; }
.listen__pause { display: none; }
.listen[data-state="playing"] .listen__play { display: none; }
.listen[data-state="playing"] .listen__pause { display: block; }
.listen__time { font-weight: 500; color: #64748B; }
.listen__time { font-variant-numeric: tabular-nums; }
.listen:not([data-audio])[data-state="playing"] .listen__time, .listen:not([data-audio])[data-state="paused"] .listen__time { display: none; }
.listen__stop { border: 0; background: none; color: #64748B; font: 500 14px var(--font-sans); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .read-progress span { transition: none; } }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.blog-shell > .visually-hidden + .post-card { margin-top: clamp(16px, 3vw, 32px); }
