/* DGS Table of Contents.
   Desktop (wide): rail floats in the LEFT MARGIN of the content column —
   the content keeps its original width and position (openlayer pattern).
   Narrow/mobile: full-bleed horizontal scroll strip sticky below the site
   header (crai-insights jumpnav twin, light theme). The sticky offset is
   set at runtime via --fp-toc-top on the root element. */

.fp-toc-layout {
  position: relative;
}

/* ---- wide desktop: floating left rail ---- */
@media (min-width: 1200px) {
  .fp-toc {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(-26rem - var(--space-l, 3rem));
    width: 26rem;
  }

  .fp-toc__inner {
    position: sticky;
    top: calc(var(--fp-toc-top, 100px) + 24px);
    max-height: calc(100vh - var(--fp-toc-top, 100px) - 48px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
}

/* ---- shared link styles ---- */
.fp-toc__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dark-muted, var(--neutral));
  margin-bottom: var(--space-xs);
}

.fp-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

.fp-toc__link {
  display: block;
  font-size: var(--text-s);
  line-height: 1.45;
  color: var(--text-dark-muted, var(--neutral));
  text-decoration: none;
  border-left: 2px solid transparent;
  padding: 0.3em 0 0.3em 1em;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.fp-toc__link:hover {
  color: var(--text-dark, var(--black));
}

.fp-toc__link.is-active {
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}

/* CTA pinned at the bottom of the desktop rail (hidden in the strip) */
.fp-toc__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  margin-top: var(--space-m);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  padding: 0.5em 1.4em;
  border-radius: var(--radius-circle);
  background-image: linear-gradient(10deg, var(--primary) 34%, var(--secondary) 66%, var(--accent) 100%);
  color: var(--white, #fff);
  text-decoration: none;
  transition: filter 0.2s ease;
}

.fp-toc__cta:hover {
  filter: brightness(1.12);
  color: var(--white, #fff);
}

/* ---- narrow/mobile: full-bleed sticky strip below the nav ---- */
@media (max-width: 1199px) {
  .fp-toc {
    position: sticky;
    top: var(--fp-toc-top, 60px);
    z-index: 900;
    width: 100vw;
    max-width: none;
    margin-left: calc(50% - 50vw);
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--primary-trans-20);
  }

  .fp-toc__inner {
    padding: var(--space-xs) var(--gutter);
  }

  .fp-toc__label,
  .fp-toc__cta {
    display: none;
  }

  .fp-toc__list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--space-xs);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .fp-toc__list::-webkit-scrollbar {
    display: none;
  }

  .fp-toc__link {
    flex-shrink: 0;
    white-space: nowrap;
    border-left: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-circle);
    padding: 0.35em 1em;
    font-size: var(--text-xs);
    font-weight: 600;
    /* long headings truncate — a pill never exceeds ~3/4 of the screen */
    max-width: 72vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .fp-toc__link.is-active {
    background: var(--primary-trans-10);
    border-color: var(--primary);
    color: var(--primary);
  }
}

/* anchor targets land below the sticky chrome */
.fp-toc-layout h2[id] {
  scroll-margin-top: 140px;
}
