/* =========================================================================
   VOIDs' Blog — post.css
   Owner: feat/post-widgets (RFC 1.2 page-post + 2.4 post-widgets)

   Article-page widgets: full-height title -> sticky top bar, collapsible
   left rail (floating TOC scroll-spy + series nav), right gutter author
   sidenotes (-> inline popovers on mobile), reading progress bar, code-block
   copy/lang/line-numbers chrome, prev/next + meta footer.

   Every colour is a theme token from theme.css (--accent, --accent-soft,
   --accent-line, --bg, --fg, --fg-muted, --surface, --surface-2, --border,
   --border-strong, --code-bg). No hardcoded colours — light/dark follow the
   site theme automatically.
   ========================================================================= */

/* ---- layout geometry knobs (overridable by drag-resize JS) -------------- */
/* --sticky-h lives on :root because the sticky bar + progress line are fixed
   elements OUTSIDE .post-shell — they must still resolve the bar height. */
:root {
  --sticky-h: 44px;          /* visual-design §4: sticky bar height 44px */
  --content-max: 65ch;       /* shared by sticky-bar inner + foot + comments */
}
.post-shell {
  --rail-left-w: 16rem;
  --rail-gap: 2rem;
}

/* =========================================================================
   0. Hero title — tame the oversized beautifuljekyll heading (visual-design
      §1 / complaint #6). The theme ships .post-heading h1 at 50px on desktop;
      we bring it to the modular --fs-3xl with a tight line-height so the
      article opens with a confident, not absurd, title. Specificity matches
      the theme's `.intro-header .post-heading h1` desktop media-query rule.
   ========================================================================= */
.intro-header .post-heading h1,
.intro-header.big-img .post-heading h1 {
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

/* =========================================================================
   1 + 2. Sticky reading bar (visual-design §4 / complaints #6,#7)
   ---------------------------------------------------------------------------
   A restrained frosted bar that slides in once the hero title scrolls out:
     · height 44px, semi-transparent --surface @ ~85% + backdrop blur(10px)
     · left  = current post short title, ellipsis-truncated
     · right = ‹ › prev/next arrows (neighbour title shown on hover via title=)
     · bottom = 1px accent reading-progress line that grows with scroll
   The progress line is the old .post-progress element, repositioned to ride
   the bar's bottom edge; post-progress.js still drives its width + .is-visible.
   ========================================================================= */
.post-stickybar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1150;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--sticky-h);
  padding: 0 1rem;
  /* frosted: --surface at ~85% alpha + 10px blur */
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(1.3) blur(10px);
  -webkit-backdrop-filter: saturate(1.3) blur(10px);
  border-bottom: 1px solid var(--border);
  font-family: var(--header-font);
  font-size: 0.9rem;
  /* hidden until the hero title scrolls out; JS toggles .is-visible */
  transform: translateY(-100%);
  transition: transform 0.22s ease;
  pointer-events: none;
}
.post-stickybar.is-visible {
  transform: translateY(0);
  pointer-events: auto;
}
.post-stickybar__inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}
.post-stickybar__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.post-stickybar__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.35rem;
  color: var(--fg-muted);
  text-decoration: none;
  white-space: nowrap;
  font-size: 1.05rem;
  line-height: 1;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.post-stickybar__nav:hover,
.post-stickybar__nav:focus {
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.post-stickybar__nav.is-disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Reading-progress line — 1px accent, rides the sticky bar's bottom edge,
   width driven by post-progress.js. It sits exactly on the bar's bottom
   border; revealed together with the bar via :has() so the two move as one.
   (At scroll-top the bar is hidden AND width is 0, so nothing shows early.) */
.post-progress {
  position: fixed;
  top: calc(var(--sticky-h) - 1px);
  left: 0;
  right: 0;
  height: 1px;
  z-index: 1151;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease;
}
body:has(.post-stickybar.is-visible) .post-progress {
  opacity: 1;
}
.post-progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  transform-origin: left center;
  transition: width 0.1s linear;
}

/* =========================================================================
   2b. Editorial post header (visual-design §7.2)
   category eyebrow → serif title → subtitle → one meta line (date · updated ·
   reading time · category). Replaces beautifuljekyll's centred intro-header.
   ========================================================================= */
.post-header {
  max-width: var(--content-max);
  margin: 0 auto 2rem;
}
.post-eyebrow {
  display: inline-block;
  font-family: var(--header-font);
  font-size: var(--fs-sm);
  color: var(--accent);
  letter-spacing: 0.04em;
  text-decoration: none;
  margin-bottom: 0.5rem;
}
.post-eyebrow:hover,
.post-eyebrow:focus {
  text-decoration: underline;
  outline: none;
}
.post-header .post-title {
  font-family: var(--header-font);
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
  color: var(--fg);
}
.post-subtitle {
  font-size: var(--fs-lg);
  line-height: 1.5;
  color: var(--fg-muted);
  margin: 0 0 0.9rem;
}
.post-header .post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
  font-family: var(--header-font);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}
.post-header .post-readtime {
  color: var(--accent);
}

/* =========================================================================
   3. Two-column shell:  left rail | article
   ========================================================================= */
.post-shell {
  display: grid;
  grid-template-columns:
    minmax(0, var(--rail-left-w))
    minmax(0, 1fr);
  gap: var(--rail-gap);
  align-items: start;
  max-width: 64rem;
  margin: 1.5rem auto 0;
  padding: 0 1rem;
}
.post-shell__main {
  min-width: 0;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}
/* the article prose: ~65ch, comfortable line-height, accent links */
.post-shell__main .blog-post {
  font-size: 1.05rem;
  line-height: 1.7;
}
.post-shell__main .blog-post a {
  color: var(--accent);
}

/* ---- left rail ---------------------------------------------------------- */
.post-rail {
  position: sticky;
  top: calc(var(--sticky-h) + 1rem);
  align-self: start;
  max-height: calc(100vh - var(--sticky-h) - 2rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  font-family: var(--header-font);
  font-size: 0.95rem;
  min-width: 0;
}
.post-rail__section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.post-rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  color: var(--fg-muted);
}
.post-rail__toggle {
  border: none;
  background: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
}
.post-rail__toggle:hover,
.post-rail__toggle:focus {
  color: var(--accent);
  outline: none;
}
.post-rail__section.is-collapsed .post-rail__body {
  display: none;
}
.post-rail__body {
  overflow-y: auto;
  min-height: 0;
}

/* ---- floating TOC (scroll-spy) ------------------------------------------ */
/* visual-design §1 / complaint #6: TOC was too small. Comfortable .95rem,
   line-height 1.6, .4rem between items; active item = accent left bar + bold. */
.post-toc {
  font-size: 0.95rem;
  line-height: 1.6;
}
.post-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.post-toc ul ul {
  border-left: none;
  padding-left: 0.9rem;
}
.post-toc li {
  margin: 0;
}
.post-toc a {
  display: block;
  padding: 0.2rem 0 0.2rem 0.9rem;
  margin: 0.4rem 0;                 /* .4rem item spacing */
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--fg-muted);
  text-decoration: none;
  line-height: 1.6;
}
.post-toc li:first-child > a { margin-top: 0; }
.post-toc a:hover,
.post-toc a:focus {
  color: var(--fg);
  border-left-color: var(--accent-line);
}
.post-toc a.is-active {
  color: var(--accent);
  border-left: 2px solid var(--accent);   /* accent vertical bar */
  font-weight: 600;                        /* + bold */
}
.post-toc__empty {
  color: var(--fg-muted);
  font-style: italic;
}

/* ---- series nav --------------------------------------------------------- */
.post-series ol {
  list-style: none;
  counter-reset: series;
  margin: 0;
  padding: 0;
}
.post-series li {
  counter-increment: series;
  margin: 0;
}
.post-series a,
.post-series span.post-series__current {
  display: flex;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.3rem;
  color: var(--fg-muted);
  text-decoration: none;
  line-height: 1.4;
}
.post-series a::before,
.post-series span.post-series__current::before {
  content: counter(series);
  flex: 0 0 1.3rem;
  text-align: right;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.post-series a:hover,
.post-series a:focus {
  color: var(--fg);
  background: var(--surface);
}
.post-series .post-series__current {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.post-series .post-series__current::before {
  color: var(--accent);
}

/* =========================================================================
   4. Footnotes — hover popover, no standing gutter (visual-design §7.5)
   The right gutter is gone; footnotes show on hover (post-sidenotes.js builds
   .post-fn-popover, styled in §7). The bottom .footnotes list stays for a11y.
   ========================================================================= */
/* in-text reference marker: plain numeric "1", accent; hover hints a popover */
.post-shell__main .footnote,
.post-shell__main a.footnote {
  color: var(--accent);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  cursor: help;
}

/* =========================================================================
   5. Code block chrome — copy button + language label + line numbers
   ========================================================================= */
.highlighter-rouge {
  position: relative;
}
.highlighter-rouge .highlight {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow: hidden;
}

/* Inline code inside the article body (visual-design §3): --code-bg / --code-fg
   so it darkens with the scheme. The :not(.highlighter-rouge .highlight code)
   guard keeps block-internal tokens untouched. */
.post-shell__main .blog-post :not(pre) > code {
  background: var(--code-bg);
  color: var(--code-fg);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.9em;
}
/* neutralise beautifuljekyll's hardcoded grey gradient + dark left border.
   visual-design §3: bg = --code-bg, text = --code-fg (follows --fg) so the
   block truly darkens in dark mode instead of staying light-on-light. */
.highlighter-rouge .highlight > pre,
.highlighter-rouge .highlight pre.highlight {
  background: var(--code-bg) !important;
  background-image: none !important;
  border: none !important;
  border-left: 3px solid var(--accent-line) !important;
  margin: 0;
  padding: 0.85rem 0.9rem;
  color: var(--code-fg);
  overflow-x: auto;
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--header-font);
  font-size: 0.72rem;
}
.code-toolbar__lang {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
}
.code-toolbar__copy {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg-muted);
  border-radius: 0.3rem;
  padding: 0.12rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  line-height: 1.4;
}
.code-toolbar__copy:hover,
.code-toolbar__copy:focus {
  color: var(--accent);
  border-color: var(--accent-line);
  outline: none;
}
.code-toolbar__copy.is-copied {
  color: var(--accent);
  border-color: var(--accent);
}
/* JS-injected line numbers */
.code-lines {
  counter-reset: codeline;
}
.code-line {
  display: block;
}
.code-line::before {
  counter-increment: codeline;
  content: counter(codeline);
  display: inline-block;
  width: 2.5em;
  margin-right: 1em;
  padding-right: 0.6em;
  text-align: right;
  color: var(--fg-muted);
  border-right: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
  opacity: 0.7;
}

/* =========================================================================
   6. Post footer — prev/next, edit-on-github, meta
   ========================================================================= */
.post-foot {
  max-width: var(--content-max);
  margin: 2.5rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--header-font);
  font-size: 0.9rem;
}
.post-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}
.post-meta-line .post-cat {
  color: var(--accent);
  text-decoration: none;
}
.post-meta-line .post-tags a {
  color: var(--fg-muted);
  text-decoration: none;
}
.post-meta-line .post-tags a:hover {
  color: var(--accent);
}
.post-edit-link {
  color: var(--fg-muted);
  text-decoration: none;
}
.post-edit-link:hover,
.post-edit-link:focus {
  color: var(--accent);
}
/* Prev / next — plain text links (visual-design §7.3), not cards.
   ← {prev title} left, {next title} → right; ellipsis-truncated so a long
   neighbour never blows the layout. No border, no background, no lift. */
.post-prevnext {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.75rem;
  font-family: var(--header-font);
  font-size: 0.95rem;
}
.post-prevnext a {
  color: var(--accent);
  text-decoration: none;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.post-prevnext a:hover,
.post-prevnext a:focus {
  text-decoration: underline;
  outline: none;
}
.post-prevnext .post-prevnext--next {
  text-align: right;
}

/* =========================================================================
   6b. Comments (giscus) — always-on section + unconfigured placeholder card
   visual-design §4 / complaint #8. Heading always renders; while giscus IDs
   are null stubs we show a dark-correct placeholder so the integration is
   visible. Every colour is a token, so the card reads in both schemes.
   ========================================================================= */
.post-comments {
  max-width: var(--content-max);
  margin: 2.5rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.post-comments__heading {
  font-family: var(--header-font);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--fg);
  margin: 0 0 1rem;
}
.post-comments__giscus {
  min-height: 8rem;
}

/* Unconfigured placeholder card */
.post-comments__placeholder {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.4rem;
  border: 1px dashed var(--border-strong);
  border-radius: 0.6rem;
  background: var(--accent-tint);
  font-family: var(--header-font);
}
.post-comments__placeholder-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.15rem;
}
.post-comments__placeholder-text {
  flex: 1 1 auto;
  min-width: 0;
}
.post-comments__placeholder-title {
  margin: 0;
  color: var(--fg);
  font-weight: 600;
  font-size: 0.95rem;
}
.post-comments__placeholder-body {
  margin: 0.15rem 0 0;
  color: var(--fg-muted);
  font-size: 0.88rem;
}
.post-comments__placeholder-link {
  flex: 0 0 auto;
  align-self: center;
  white-space: nowrap;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid var(--accent-line);
  border-radius: 0.4rem;
  padding: 0.35rem 0.7rem;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.post-comments__placeholder-link:hover,
.post-comments__placeholder-link:focus {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

/* =========================================================================
   7. Mobile drawer + inline footnote popovers (responsive collapse)
   RFC 1.6: left rail -> hamburger drawer; right gutter -> inline popovers.
   ========================================================================= */
.post-rail__drawer-toggle {
  display: none;
  position: fixed;
  left: 0.75rem;
  bottom: 1rem;
  z-index: 1160;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--accent-soft);
}
.post-rail__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1158;
  background: color-mix(in srgb, var(--fg) 35%, transparent);
}

/* inline footnote popover (mobile): bubble anchored under tapped marker */
.post-fn-popover {
  position: absolute;
  z-index: 1170;
  max-width: min(20rem, 88vw);
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  box-shadow: 0 4px 18px var(--accent-soft);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--fg);
}
.post-fn-popover[hidden] {
  display: none;
}
.post-fn-popover__num {
  color: var(--accent);
  font-weight: 600;
  margin-right: 0.35rem;
  font-variant-numeric: tabular-nums;
}
.post-fn-popover p {
  margin: 0;
  display: inline;
}

/* --- breakpoints --------------------------------------------------------- */
/* Right gutter removed entirely (visual-design §7.5); shell is two-column at all
   widths above the drawer breakpoint. */
/* Below ~800px drop the left rail to a drawer. */
@media (max-width: 800px) {
  .post-shell {
    grid-template-columns: minmax(0, 1fr);
    max-width: 42rem;
  }
  .post-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1159;
    width: min(20rem, 82vw);
    max-height: none;
    padding: 4rem 1.25rem 1.5rem;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .post-shell.is-drawer-open .post-rail {
    transform: translateX(0);
  }
  .post-shell.is-drawer-open .post-rail__backdrop {
    display: block;
  }
  .post-rail__drawer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .post-prevnext {
    flex-direction: column;
  }
  .post-prevnext a {
    max-width: 100%;
  }
  .post-prevnext .post-prevnext--next {
    text-align: left;
  }
  .post-comments__placeholder {
    flex-wrap: wrap;
  }
  .post-comments__placeholder-link {
    margin-left: calc(2.6rem + 1rem); /* align under the text, past the icon */
  }
}

/* Respect reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  .post-progress__bar,
  .post-stickybar,
  .post-rail {
    transition: none;
  }
}
