/* --- TOCBot base styling ----------------------------------------------- */

:root {
  --tocbot-sticky-top: 1rem;
  --tocbot-sticky-bottom-gap: 1rem;
}

#tocbot,
#tocbot-mobile,
#tocbot-mobile-top,
#tocbot-desktop-top {
  min-width: 0;
}

#tocbot ul,
#tocbot-mobile ul,
#tocbot-mobile-top ul,
#tocbot-desktop-top ul {
  width: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Tocbot applies these classes to nested lists when collapseDepth is used. */
#tocbot .is-collapsible,
#tocbot-mobile .is-collapsible,
#tocbot-mobile-top .is-collapsible,
#tocbot-desktop-top .is-collapsible {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 250ms ease-in-out;
}

#tocbot .is-collapsed,
#tocbot-mobile .is-collapsed,
#tocbot-mobile-top .is-collapsed,
#tocbot-desktop-top .is-collapsed {
  max-height: 0;
}

/* --- Desktop left TOC -------------------------------------------------- */

#tocbot .toc-group-link {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 0.3rem 1rem;
  color: var(--color-black);
  text-decoration: none;
  border-left: 2px solid #f8f9fa;
  overflow-wrap: anywhere;
}

#tocbot .toc-group-link:focus,
#tocbot .toc-group-link:hover {
  z-index: 1;
  text-decoration: none;
}

#tocbot .toc-group-link.active {
  z-index: 1;
  font-weight: 600;
  text-decoration: none;
  border-left-color: var(--color-gold);
}

/* H3 links are nested below their H2 and are revealed only for the active branch. */
#tocbot .toc-group .toc-group {
  padding-left: 0.75rem;
}

#tocbot .node-name--H3 {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  font-size: 0.9rem;
  font-weight: 400;
}

/* Ensure a long TOC wraps within its column rather than widening it. */
#tocbot .toc-group-item {
  min-width: 0;
  max-width: 100%;
}

/*
 * Use native sticky positioning instead of fixed positioning. The JavaScript
 * marks the full Bootstrap column as the sticky boundary and stretches the
 * intermediate Drupal block wrappers so the TOC stops at the end of the row.
 */
@media (min-width: 768px) {
  .tocbot-sticky-boundary {
    position: relative;
    align-self: stretch;
    min-height: 0;
  }

  .tocbot-sticky-ancestor {
    height: 100%;
    min-height: 0;
  }

  #tocbot {
    position: sticky !important;
    top: var(--tocbot-sticky-top) !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100% !important;
    max-height: calc(
      100vh - var(--tocbot-sticky-top) - var(--tocbot-sticky-bottom-gap)
    );
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    transform: none !important;
  }
}

/* --- TOCBot mobile and top-bar styling -------------------------------- */

#tocbot-mobile .navbar-toggler,
#tocbot-mobile-top .navbar-toggler {
  color: rgba(255, 255, 255, 0.7);
  background-color: var(--color-dark-gold);
  border-color: rgba(255, 255, 255, 0.7);
  border-radius: 0;
}

#tocbot-mobile .navbar-toggler:focus,
#tocbot-mobile-top .navbar-toggler:focus {
  box-shadow: none;
}

#tocbot-mobile {
  z-index: 100;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
}

#tocbot-mobile-top {
  position: relative;
  background-color: var(--color-dark-gold);
}

/* Scope sticky-top to the TOC component instead of overriding Bootstrap globally. */
#tocbot-mobile-top.sticky-top {
  z-index: 100;
  position: sticky;
  top: 0;
  right: 0;
  left: 0;
  width: 100%;
}

#tocbot-mobile .navbar,
#tocbot-mobile-top .navbar {
  justify-content: flex-start;
  gap: 8px;
  padding: 0.5rem;
  background-color: var(--color-dark-gold);
}

#tocbot-mobile .navbar-collapse,
#tocbot-mobile-top .navbar-collapse {
  max-width: calc(100% - 15px);
  max-height: 300px;
  padding: 0 0 10px;
  overflow-y: auto;
  background-color: var(--color-dark-gold);
}

#tocbot-mobile a,
#tocbot-mobile-top a {
  color: var(--color-white);
  font-size: 0.8rem;
  font-weight: 300;
  overflow-wrap: anywhere;
}

#tocbot-mobile a.active,
#tocbot-mobile-top a.active {
  font-weight: 600;
}

#tocbot-mobile .nav-link,
#tocbot-mobile-top .nav-link {
  padding: 0.3rem 0;
}

/* Indent H3 branches inside the mobile navigation. */
#tocbot-mobile .navbar-nav .navbar-nav,
#tocbot-mobile-top .navbar-nav .navbar-nav {
  padding-left: 1rem;
}

#tocbot-mobile .node-name--H3,
#tocbot-mobile-top .node-name--H3 {
  font-size: 0.75rem;
}

/* --- TOCBot desktop top styling --------------------------------------- */

#tocbot-desktop-top {
  background-color: var(--color-dark-gold);
}

/* Only the root list is horizontal. Nested H3 lists stay grouped below H2. */
#tocbot-desktop-top .js-toc-desktop-top > .toc-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
}

#tocbot-desktop-top .js-toc-desktop-top > .toc-list > li {
  padding: 0.5rem 0;
}

#tocbot-desktop-top .js-toc-desktop-top > .toc-list > li > a {
  padding: 0 15px;
  color: var(--color-white);
  font-size: 0.8rem;
  text-decoration: none;
  text-transform: uppercase;
  border-left: 1px solid var(--color-white);
}

#tocbot-desktop-top .js-toc-desktop-top > .toc-list > li:first-child > a {
  border-left: none;
}

#tocbot-desktop-top .toc-list .toc-list {
  width: 100%;
  padding: 0.35rem 0 0 1rem;
}

#tocbot-desktop-top .toc-list .toc-list a {
  display: block;
  padding: 0.2rem 0.75rem;
  color: var(--color-white);
  font-size: 0.75rem;
  text-decoration: none;
  text-transform: none;
}

#tocbot-desktop-top .toc-list-item.is-active-li {
  background-color: var(--color-white);
}

#tocbot-desktop-top .toc-list-item.is-active-li > a.active {
  color: var(--color-dark-gold) !important;
  font-weight: 700;
  border-left-color: transparent;
}

#tocbot-desktop-top .js-toc-desktop-top > .toc-list > li.is-active-li + li > a,
.secondary-navbar ul > li.is-active-li + li > a {
  border-left: none;
}

/* --- Responsive desktop TOC widths ------------------------------------ */

@media (min-width: 768px) {
  #tocbot {
    max-width: 156px;
  }
}

@media (min-width: 992px) {
  #tocbot {
    max-width: 240px;
  }
}

@media (min-width: 1200px) {
  #tocbot {
    max-width: 300px;
  }
}
