/* ==========================================================
   E3 Displays — Reads (single): sticky H2-only table of contents
   Place in: /wp-content/themes/e3display/assets/css/reads-toc.css
   ========================================================== */

/* Heading lands below the sticky header when a TOC link is clicked */
body.single-reads .entry-content h2 {
  scroll-margin-top: var(--e3-toc-top, 160px);
}

/* ---------- Sidebar widget ---------- */
.e3-toc__bar {
  height: 3px;
  margin: .75rem 0 .6rem;
  background: rgba(255, 255, 255, .08);
  border-radius: 3px;
  overflow: hidden;
}
.e3-toc__bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--e3-accent, #ee2b24);
  transition: width .15s linear;
}

.e3-toc__list {
  position: relative;
  max-height: min(52vh, 460px);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .2) transparent;
}
.e3-toc__list li { margin: 0; padding: 0; }

body.single-reads .e3-toc__link {
  display: block;
  padding: .45rem .75rem;
  border-left: 2px solid rgba(255, 255, 255, .1);
  color: rgba(240, 240, 241, .65);
  font-size: .875rem;
  line-height: 1.4;
  text-decoration: none;
  box-shadow: none;
  transition: color .2s, border-color .2s, background-color .2s, padding-left .2s;
}
body.single-reads .e3-toc__link:hover,
body.single-reads .e3-toc__link:focus-visible {
  color: #fff;
  text-decoration: none;
  border-left-color: rgba(255, 255, 255, .4);
}
body.single-reads .e3-toc__link.is-active {
  padding-left: 1rem;
  color: #fff;
  font-weight: 600;
  border-left-color: var(--e3-accent, #ee2b24);
  background: rgba(238, 43, 36, .08);
}

/* Theme has `main a { text-decoration: underline !important }` — beat it */
body.single-reads main .e3-toc__link,
body.single-reads main .e3-toc__link:hover,
body.single-reads main .e3-toc__link:focus-visible {
  text-decoration: none !important;
}

/* ---------- Desktop: whole sidebar sticks under the header ---------- */
@media (min-width: 992px) {
  body.single-reads .widget-area {
    position: sticky;
    top: var(--e3-toc-top, 160px);
    max-height: calc(100vh - var(--e3-toc-top, 160px) - 20px);
    overflow-y: auto;
    scrollbar-width: none;
  }
  body.single-reads .widget-area::-webkit-scrollbar { display: none; }
  .e3-toc-mobile { display: none; }
}

/* ---------- Mobile / tablet: collapsible TOC above the article ---------- */
@media (max-width: 991.98px) {
  .e3-toc-widget { display: none; }
  .e3-toc-mobile {
    margin: 0 0 1.5rem;
    background: #141414;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 12px;
  }
  .e3-toc-mobile summary {
    padding: .9rem 1.1rem;
    color: #f0f0f1;
    font-weight: 600;
    cursor: pointer;
  }
  .e3-toc-mobile .e3-toc__list {
    max-height: 50vh;
    padding: 0 1.1rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .e3-toc__bar span,
  .e3-toc__link { transition: none; }
}
