/* In-content Table of Contents (0.5.60). Uses editorial tokens so dark video posts and light longform stay consistent. */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Clear the sticky nav pill when jumping to a heading. */
.ed-body h2,
.ed-body h3,
.daily-prose h2,
.daily-prose h3,
.km-feature-prose h2,
.km-feature-prose h3 {
  scroll-margin-top: 110px;
}
html:has(body.admin-bar) .ed-body :is(h2, h3),
html:has(body.admin-bar) .daily-prose :is(h2, h3),
html:has(body.admin-bar) .km-feature-prose :is(h2, h3) {
  scroll-margin-top: 142px;
}
@media screen and (max-width: 782px) {
  html:has(body.admin-bar) .ed-body :is(h2, h3),
  html:has(body.admin-bar) .daily-prose :is(h2, h3),
  html:has(body.admin-bar) .km-feature-prose :is(h2, h3) {
    scroll-margin-top: 156px;
  }
}
@media screen and (max-width: 600px) {
  /* WP admin bar is not fixed at this width. */
  html:has(body.admin-bar) .ed-body :is(h2, h3),
  html:has(body.admin-bar) .daily-prose :is(h2, h3),
  html:has(body.admin-bar) .km-feature-prose :is(h2, h3) {
    scroll-margin-top: 110px;
  }
}

.km-toc {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0 0 1.75rem;
  padding: 1rem 1.15rem 1.05rem;
  border: 1px solid var(--ed-line);
  border-radius: 14px;
  background: var(--ed-surface);
}
.km-toc-heading {
  margin: 0 0 .55rem;
  font-family: var(--ed-font, Inter, Arial, sans-serif);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .16em;
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--ed-muted);
}
/* Beat .ed-body ol / .daily-prose ul padding so items and rules sit flush with the label. */
.km-toc .km-toc-list,
.ed-body .km-toc .km-toc-list,
.daily-prose .km-toc .km-toc-list,
.km-video-body .daily-prose .km-toc .km-toc-list,
.km-feature-prose .km-toc .km-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-inline-start: 0;
}
.km-toc .km-toc-item,
.ed-body .km-toc .km-toc-item,
.daily-prose .km-toc .km-toc-item,
.km-video-body .daily-prose .km-toc .km-toc-item,
.km-feature-prose .km-toc .km-toc-item {
  margin: 0;
  padding: 0;
  padding-inline-start: 0;
  border-top: 1px solid var(--ed-line);
}
.km-toc .km-toc-item:first-child,
.ed-body .km-toc .km-toc-item:first-child,
.daily-prose .km-toc .km-toc-item:first-child {
  border-top: 0;
}
.km-toc-link,
.ed-body .km-toc-link,
.daily-prose .km-toc-link,
.km-video-body .daily-prose .km-toc-link,
.km-feature-prose .km-toc-link {
  display: block;
  padding: .48rem 0;
  font-family: var(--ed-font, Inter, Arial, sans-serif);
  font-size: 15px;
  font-weight: 550;
  line-height: 1.4;
  letter-spacing: -.01em;
  color: var(--ed-text);
  text-decoration: none;
}
.km-toc-link:hover,
.km-toc-link:focus-visible,
.ed-body .km-toc-link:hover,
.ed-body .km-toc-link:focus-visible,
.daily-prose .km-toc-link:hover,
.daily-prose .km-toc-link:focus-visible,
.km-video-body .daily-prose .km-toc-link:hover,
.km-video-body .daily-prose .km-toc-link:focus-visible,
.km-feature-prose .km-toc-link:hover,
.km-feature-prose .km-toc-link:focus-visible {
  color: var(--ed-accent);
  text-decoration: none;
}
.km-toc-link:focus-visible {
  outline: 2px solid var(--ed-accent);
  outline-offset: 3px;
}

/* Tight, even gap after the opening paragraphs. */
.ed-body .km-toc + h2,
.daily-prose .km-toc + h2,
.km-feature-prose .km-toc + h2 {
  margin-top: 1.6em;
}

@media (max-width: 700px) {
  .km-toc {
    width: 100%;
    margin: 0 0 1.5rem;
    padding: .95rem 1rem .9rem;
    border-radius: 12px;
  }
  .km-toc-link {
    font-size: 15px;
    padding: .5rem 0;
  }
}
