/* Custom Table of Contents */

:root {
  --ctoc-offset: 80px;
  --ctoc-bg: #f7f8f9;
  --ctoc-border: #e3e6ea;
  --ctoc-link: #673de6;
  --ctoc-text: #333;
}

.ctoc {
  background: var(--ctoc-bg);
  border: 1px solid var(--ctoc-border);
  border-radius: 6px;
  padding: 14px 20px;
  margin: 0 0 1.5em;
  width: fit-content;
  min-width: min(100%, 320px);
  max-width: 100%;
}

.ctoc__title {
  cursor: pointer;
  font-weight: 600;
  font-size: 1.1em;
  line-height: 1.45;
  color: var(--ctoc-text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.ctoc__title::-webkit-details-marker {
  display: none;
}
.ctoc__title::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 6px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform .15s;
}
.ctoc[open] > .ctoc__title::before {
  transform: rotate(90deg);
}
.ctoc[open] > .ctoc__title {
  margin-bottom: 8px;
}

.ctoc__nav ul,
.ctoc__nav ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.ctoc__nav ul ul,
.ctoc__nav ol ol {
  padding-left: 18px;
}
.ctoc__nav li {
  margin: 0;
  line-height: 1.9;
}
.ctoc__nav a {
  color: var(--ctoc-link);
  text-decoration: none;
  font-weight: 500;
}
.ctoc__nav a:hover,
.ctoc__nav a:focus {
  text-decoration: underline;
}
.ctoc__nav a.is-active {
  font-weight: 700;
  text-decoration: underline;
}

/* Numbered variant: 1, 1.1, 1.2, 2 ... */
.ctoc--numbered .ctoc__nav ol {
  counter-reset: ctoc;
}
.ctoc--numbered .ctoc__nav li {
  counter-increment: ctoc;
}
.ctoc--numbered .ctoc__nav li > a::before {
  content: counters(ctoc, ".") ". ";
  color: var(--ctoc-text);
  font-weight: 500;
}

/* Keep the heading clear of a sticky header when a link is clicked */
h1[id], h2[id], h3[id], h4[id], h5[id], h6[id] {
  scroll-margin-top: var(--ctoc-offset);
}
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}
