/* =========================================================
   Contract X-Ray site - shared scrollspy sidebar
   Sticky table-of-contents that highlights the current section
   ========================================================= */

.scrollspy-wrap {
  position: relative;
}

.scrollspy {
  position: sticky;
  top: 96px;
  align-self: start;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 13px;
  line-height: 1.4;
  border-left: 1px solid var(--border, rgba(27, 54, 93, 0.14));
  padding: 4px 0 4px 0;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.scrollspy-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted, #7A7F8C);
  padding: 0 20px 14px 20px;
  margin: 0 0 4px 0;
}

.scrollspy ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scrollspy a {
  display: block;
  padding: 8px 20px 8px 19px;
  color: var(--ink-muted, #7A7F8C);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  line-height: 1.35;
}

.scrollspy a:hover {
  color: var(--ink-soft, #4A4F5C);
  background: rgba(45, 139, 154, 0.04);
}

.scrollspy a.is-active {
  color: var(--navy, #1B365D);
  font-weight: 600;
  border-left-color: var(--teal, #2D8B9A);
  background: rgba(45, 139, 154, 0.06);
}

/* ── Mobile pill: collapses sidebar to a top sticky control ── */
.scrollspy-pill {
  display: none;
  position: sticky;
  top: 73px;
  z-index: 50;
  background: var(--paper, #FFFCF6);
  border-bottom: 1px solid var(--border, rgba(27, 54, 93, 0.14));
  padding: 12px 0;
  margin: 0 -16px 16px -16px;
}

.scrollspy-pill-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 14px;
  font-weight: 600;
  color: var(--navy, #1B365D);
  cursor: pointer;
  padding: 6px 16px;
  text-align: left;
}

.scrollspy-pill-toggle::after {
  content: "▾";
  color: var(--teal, #2D8B9A);
  font-size: 12px;
  margin-left: 12px;
  transition: transform 0.2s ease;
}

.scrollspy-pill[data-open="true"] .scrollspy-pill-toggle::after {
  transform: rotate(180deg);
}

.scrollspy-pill ul {
  list-style: none;
  margin: 10px 16px 4px 16px;
  padding: 0;
  display: none;
  flex-direction: column;
  gap: 2px;
}

.scrollspy-pill[data-open="true"] ul {
  display: flex;
}

.scrollspy-pill a {
  display: block;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink-soft, #4A4F5C);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 3px;
}

.scrollspy-pill a.is-active {
  color: var(--navy, #1B365D);
  font-weight: 600;
  border-left-color: var(--teal, #2D8B9A);
  background: rgba(45, 139, 154, 0.06);
}

/* ── Layout: 2-column wrap, sidebar visible at 1024px+ ── */
@media (min-width: 1024px) {
  .scrollspy-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 48px;
    max-width: var(--container-max, 1320px);
    margin: 0 auto;
    padding: 0 var(--side-pad, 56px);
  }

  .scrollspy-layout > .scrollspy-content {
    min-width: 0;
  }

  /* Inside the layout, neutralize child container padding */
  .scrollspy-layout .container,
  .scrollspy-layout .container-narrow {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 1023.98px) {
  .scrollspy {
    display: none;
  }
  .scrollspy-pill {
    display: block;
  }
}

/* Smooth scroll with offset for sticky header */
html {
  scroll-padding-top: 96px;
  scroll-behavior: smooth;
}

@media (max-width: 1023.98px) {
  html {
    scroll-padding-top: 132px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scrollspy a, .scrollspy-pill-toggle::after { transition: none; }
}
