/* ==========================================================================
   Table of Contents – 4D King Results
   Sticky left rail, flat list, underline-on-active.
   ========================================================================== */

.toc-rail {
  position: sticky;
  top: 40px;
  align-self: start;
  max-height: calc(100vh - 80px);
  overflow-y: auto;

  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.toc-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 14px 4px;
  font: inherit;
  cursor: pointer;
}

.toc-toggle-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--primary-red);
}

.toc-toggle-icon {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--primary-red);
  border-bottom: 2px solid var(--primary-red);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  margin-right: 4px;
}

.toc-toggle[aria-expanded="true"] .toc-toggle-icon {
  transform: rotate(-135deg);
}

/* --- List reset ----------------------------------------------------------- */
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-list li {
  margin: 0;
}

/* --- Links ------------------------------------------------------------- */
.toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  color: var(--dark);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  transition: color 0.18s ease;
}

/* Red arrow marker before every link */
.toc-link::before {
  content: "\203A"; /* › */
  flex-shrink: 0;
  line-height: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-red);
  transition: color 0.18s ease;
}

.toc-link:hover {
  color: var(--primary-red);
}

/* --- Active state: underline instead of background fill ------------------- */
.toc-rail li.active .toc-link {
  color: var(--primary-red);
}

.toc-rail li.active .toc-link .toc-text {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 2px;
}

/* --- Empty state ----------------------------------------------------------- */
.no-toc {
  padding: 12px 0;
  text-align: center;
  font-style: italic;
  color: var(--grey);
}

/* ==========================================================================
   Responsive – accordion behavior below 900px
   ========================================================================== */
@media (max-width: 900px) {
  .toc-rail {
    position: static;
    max-height: none;
    overflow-y: visible;
    top: auto;
  }

  .toc-toggle {
    display: flex;
  }

  .toc-panel {
    overflow: hidden;
    height: 0;
    transition: height 0.3s ease;
  }
}