/* ══════════════════════════════════════════════════════════════════════
   Docs-style post layout (_layouts/post.html, _includes/docs-sidebar.html)
     ≥1280px : series/parts nav | article | "On this page"
     1120-1279: article | "On this page"
     <1120   : article only (series box at the top of the post instead)
   ══════════════════════════════════════════════════════════════════════ */

/* The post title now lives inside the middle column */
.docs-layout .ed-post-head { max-width: none; margin-bottom: 2rem; }

/* Left column */
.docs-nav { display: none; }

@media (min-width: 1280px) {
  article[data-toc] { max-width: var(--tac-container) !important; }
  .article-editorial-grid.docs-layout {
    grid-template-columns: 14.5rem minmax(0, var(--ed-measure)) 14.5rem !important;
    gap: 3rem !important;
    justify-content: center;
    align-items: start;
  }
  .docs-nav {
    display: block;
    position: sticky;
    top: 5.25rem;
    max-height: calc(100vh - 6.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--tac-border-strong) transparent;
    padding: 0.25rem 0.5rem 1rem 0;
  }
  /* the sidebar already lists every part: hide the duplicate box at the top */
  .docs-layout .ed-series-box { display: none; }
}

@media (min-width: 1120px) and (max-width: 1279px) {
  .article-editorial-grid.docs-layout {
    grid-template-columns: minmax(0, var(--ed-measure)) 15rem !important;
  }
}

.docs-nav-head {
  position: sticky;   /* series name + progress stay visible while the list scrolls */
  top: -0.25rem;
  z-index: 1;
  background: var(--tac-bg);
  padding-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-bottom: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--tac-border);
}
.docs-nav-kicker {
  font-family: var(--tac-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tac-green);
}
.docs-nav-title {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--tac-text) !important;
  text-decoration: none !important;
}
.docs-nav-title:hover { color: var(--tac-green) !important; }
.docs-nav-progress-label { margin-top: 0.5rem; font-size: 0.78rem; color: var(--tac-faint); }
.docs-nav-progress {
  display: block;
  height: 4px;
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--tac-elevated);
  overflow: hidden;
}
.docs-nav-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--tac-green); }

.docs-nav-list { list-style: none; margin: 0; padding: 0; }
.docs-nav-list li { margin: 0 !important; }
.docs-nav-list a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.42rem 0.6rem;
  border-radius: 8px;
  border-left: 2px solid transparent;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--tac-muted) !important;
  text-decoration: none !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.docs-nav-list a:hover { background: var(--tac-elevated); color: var(--tac-text) !important; }
.docs-nav-list a.is-current {
  background: var(--tac-green-glow);
  border-left-color: var(--tac-green);
  border-radius: 0 8px 8px 0;
  color: var(--tac-text) !important;
  font-weight: 600;
}
.docs-nav-num {
  flex: 0 0 1.5rem;
  font-family: var(--tac-mono);
  font-size: 0.72rem;
  color: var(--tac-faint);
  text-align: right;
}
.docs-nav-list a.is-current .docs-nav-num { color: var(--tac-green); }
.docs-nav-text { min-width: 0; }
.docs-nav-all {
  display: inline-block;
  margin: 0.75rem 0 0 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--tac-green) !important;
}

/* Right column: match the left one */
@media (min-width: 1120px) {
  .docs-layout .toc-sticky-sidebar { top: 5.25rem; }
}

/* Focus mode hides both side columns */
html[data-read-focus="1"] .docs-nav { display: none !important; }
html[data-read-focus="1"] .article-editorial-grid.docs-layout {
  grid-template-columns: minmax(0, var(--ed-measure)) !important;
  justify-content: center;
}

/* Wide screens: the frame grows to 1440px (responsive.css); give the side
   columns the extra room, keep the text column at its reading width. */
@media (min-width: 1500px) {
  .article-editorial-grid.docs-layout {
    grid-template-columns: 17rem minmax(0, var(--ed-measure)) 17rem !important;
    gap: 4rem !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   "On this page" (right column), styled to match the series list on the
   left: small accent label, progress bar, thin rail per item, wrapping
   titles, active item = accent rail + soft tint. Markup/JS: post.html
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1120px) {
  :root:root .toc-sticky-sidebar {
    border-left: 0 !important;
    padding: 0.25rem 0.25rem 1rem 0 !important;
    scrollbar-width: none;
  }
}
:root:root .toc-sticky-sidebar::-webkit-scrollbar { width: 0; }
:root:root .toc-sticky-sidebar:hover { scrollbar-width: thin; scrollbar-color: var(--tac-border-strong) transparent; }
:root:root .toc-sticky-sidebar:hover::-webkit-scrollbar { width: 6px; }
:root:root .toc-sticky-sidebar:hover::-webkit-scrollbar-thumb { background: var(--tac-border-strong); border-radius: 3px; }

.toc-head {
  position: sticky;
  top: -0.25rem;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
  padding: 0.25rem 0 0.9rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--tac-border);
  background: var(--tac-bg);
}
:root:root .toc-head .toc-title {
  display: inline;
  margin: 0;
  font: 600 0.7rem var(--tac-mono) !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: var(--tac-green) !important;
}
.toc-progress-label { font-size: 0.75rem; color: var(--tac-faint); font-variant-numeric: tabular-nums; }
.toc-progress {
  flex-basis: 100%;
  height: 4px;
  margin-top: 0.4rem;
  border-radius: 999px;
  background: var(--tac-elevated);
  overflow: hidden;
}
.toc-progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--tac-green); transition: width 0.15s linear; }

:root:root .toc-nav-list { font: inherit; margin: 0; padding: 0; list-style: none; }
:root:root .toc-nav-list li { margin: 0 !important; }
:root:root .toc-sticky-sidebar .toc-link {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: normal;
  text-overflow: clip;
  padding: 0.36rem 0.6rem 0.36rem 0.85rem;
  border-left: 2px solid var(--tac-border);
  border-radius: 0 8px 8px 0;
  font: 400 0.84rem/1.4 var(--tac-font) !important;
  color: var(--tac-faint) !important;
  transform: none !important;
  transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}
:root:root .toc-nav-list li.toc-sub .toc-link { padding-left: 1.6rem; font-size: 0.8rem !important; }
:root:root .toc-sticky-sidebar .toc-link:hover {
  color: var(--tac-text) !important;
  border-left-color: var(--tac-border-strong);
  background: color-mix(in srgb, var(--tac-elevated) 60%, transparent);
}
:root:root .toc-sticky-sidebar .toc-link.active {
  color: var(--tac-text) !important;
  font-weight: 600 !important;
  border-left-color: var(--tac-green);
  background: var(--tac-green-glow);
}
.toc-top-link {
  display: inline-block;
  margin: 0.9rem 0 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--tac-faint) !important;
  text-decoration: none !important;
}
.toc-top-link:hover { color: var(--tac-green) !important; }

/* Left column: same quiet scrollbar */
@media (min-width: 1280px) {
  .docs-nav { scrollbar-width: none; }
  .docs-nav::-webkit-scrollbar { width: 0; }
  .docs-nav:hover { scrollbar-width: thin; }
  .docs-nav:hover::-webkit-scrollbar { width: 6px; }
  .docs-nav:hover::-webkit-scrollbar-thumb { background: var(--tac-border-strong); border-radius: 3px; }
}
/* tocbot.css (loaded by the theme) draws a full-height #eee bar before every
   .toc-link; our rail is the link's own left border */
:root:root .toc-sticky-sidebar .toc-link::before,
:root:root .toc-sticky-sidebar .toc-link::after { display: none !important; content: none !important; }

/* ── Post header: smaller cover so the article starts on the first screen ── */
@media (min-width: 768px) {
  .docs-layout .ed-post-head .post-cover-wrapper {
    max-width: 520px !important;
    margin: 1.75rem 0 0 !important;
    text-align: left !important;
  }
  .docs-layout .ed-post-head .post-cover-wrapper img { width: 100% !important; height: auto !important; }
}

/* ── "Continue where you left off": bottom of the screen, above the reading
   bar, instead of covering the top of the page ── */
:root:root .ed-resume {
  top: auto;
  bottom: 78px;
  transform: translate(-50%, 12px);
  width: max-content;
}
:root:root .ed-resume.is-in { transform: translate(-50%, 0); }
:root:root .ed-resume #ed-resume-text { flex: 1 1 auto; line-height: 1.35; }
@media (max-width: 575px) {
  :root:root .ed-resume { bottom: 74px; font-size: 0.84rem; }
}

/* ── Comments (giscus) ─────────────────────────────────────────────── */
.post-comments {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--tac-border);
}
:root:root .post-comments-title {
  margin: 0 0 0.35rem !important;
  font-size: 1.35rem !important;
  font-weight: 700 !important;
  color: var(--tac-text) !important;
}
:root:root .post-comments-title::before { content: none !important; }
.post-comments-note { margin: 0 0 1.25rem; font-size: 0.92rem; color: var(--tac-muted); }
.post-comments .giscus { min-height: 120px; }
