/* ============================================================
   Blog reading experience: hero alignment + progress bar
   + sticky TOC + scrollspy.
   Scoped to blog post pages (requires .article-content).
   Additive: uses the site's own CSS variables, degrades gracefully.
   Loaded only by blog-post pages, so it never affects other pages.
   ============================================================ */

/* ---- Hero alignment fix ----
   The native design renders the hero content in the wide 1280px
   container while the article body sits in a centered 800px column,
   so the hero title sat ~240px left of the body text. Pull the hero
   content into the same 800px reading column and replace the flat
   grey block with a subtle on-brand gradient + hairline divider. */
.article-hero .container {
  max-width: 800px;
}
.article-hero {
  background: linear-gradient(135deg,
      var(--color-bg-secondary, #f8f9fb) 0%,
      rgba(99, 102, 241, 0.08) 100%);
  border-bottom: 1px solid rgba(99, 102, 241, 0.14);
}

/* ---- Reading progress bar (fixed top) ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 1000;
  pointer-events: none;
}
.reading-progress__bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--color-accent, #6366f1), #8b5cf6);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.55);
  transition: width 0.12s linear;
}

/* ---- Table of contents (floating left of the reading column) ---- */
.article-toc {
  position: fixed;
  top: 140px;
  width: 240px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  padding-right: var(--space-4, 1rem);
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  z-index: 50;
}
.article-toc.is-ready {
  opacity: 1;
  transform: translateX(0);
}
/* Faded out when the footer is in view (see blog-reading.js) so the
   position:fixed rail never overlaps the footer. Must stay after
   .is-ready for the source-order tie-break on opacity. */
.article-toc.is-hidden {
  opacity: 0;
  pointer-events: none;
}
.article-toc__title {
  font-size: var(--text-sm, 0.875rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted, #6b7280);
  margin: 0 0 var(--space-3, 0.75rem);
  padding-left: var(--space-3, 0.75rem);
}
.article-toc__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.article-toc__link {
  display: block;
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.45;
  color: var(--color-text-secondary, #4b5563);
  text-decoration: none;
  padding: 6px 0 6px var(--space-3, 0.75rem);
  border-left: 2px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.article-toc__link:hover {
  color: var(--color-accent, #6366f1);
}
.article-toc__link--h3 {
  padding-left: calc(var(--space-3, 0.75rem) + 14px);
  font-size: 0.82rem;
}
.article-toc__link.is-active {
  color: var(--color-accent, #6366f1);
  border-left-color: var(--color-accent, #6366f1);
  font-weight: 600;
}

/* Smooth-scroll offset so headings clear the fixed header */
.article-content h2,
.article-content h3 {
  scroll-margin-top: 90px;
}

/* Not enough room for the left rail -> hide the TOC (progress bar stays) */
@media (max-width: 1200px) {
  .article-toc {
    display: none;
  }
}
