/* Sticky sidebar navigation */
.sidebar {
  flex: 0 0 305px;
  position: sticky;
  top: 100px;
  align-self: flex-start;
  max-height: calc(100dvh - 140px);
  overflow-y: auto;
}
/* TOC card */
.toc {
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.toc-header {
  gap: 4px;
  align-self: stretch;
}

.toc-title {
  color: var(--cl-white);
  font-weight: 500;
  text-transform: uppercase;
  margin: 0;
}

/* TOC list */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

/* ===== H2 GROUP ===== */
.toc-group {
  position: relative;
  left: -2px;
}

/* H2 button */
.toc-h2 {
  width: 100%;
  background: none;
  border: none;
  padding: 4px 8px; /* keep padding on button itself */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  color: var(--ca-white-70);
  text-align: left;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  box-sizing: border-box;
  font-size: var(--text-p1-fz);
  line-height: var(--text-p1-lh);
  font-family: var(--ff-text);
  font-weight: 600;
}
.toc-h2 span {
  display: block;
}

.toc-h2:hover {
  border-left-color: rgba(255, 255, 255, 0.3);
}
.toc-h2:hover span {
  color: var(--cl-white);
}
.toc-group .toc-h2.active {
  border-left-color: var(--cl-green);
  color: var(--cl-green);
}
/* Chevron */
.toc-chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}
/* Rotate when open */
.toc-group.open .toc-chevron {
  transform: rotate(180deg);
}
/* ===== H3 SUBLIST ===== */
.toc-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
/* Open accordion */
.toc-group.open .toc-sublist {
  max-height: 1000px; /* large enough */
}

/* H3 items */
.toc-item-sub {
  padding-left: 20px;
}

.toc-item-sub a {
  color: var(--ca-white-70);
  text-decoration: none;
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: var(--text-p2-fz);
  line-height: var(--text-p2-lh);
  font-family: var(--ff-text);
  font-weight: 500;
}
/* Hover H3 */
.toc-item-sub:hover a {
  color: var(--cl-white);
}
.toc-item-sub.active {
  border-left: 2px solid var(--cl-green);
}
/* Active H3 */
.toc-item-sub.active a {
  color: var(--cl-green);
}

@media (max-width: 1139px) {
  .toc-h2 {
    font-size: var(--text-p2-fz);
    line-height: var(--text-p2-lh);
  }
  .toc-item-sub a {
    font-size: 12px;
    line-height: var(--text-p3-lh);
  }
}

/* ===== Mobile ===== */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    flex: 1;
    max-height: none;
    margin-bottom: 20px;
    width: 100%;
  }
  .toc {
    overflow-y: auto;
  }
  .content {
    max-width: 100%;
  }
}
@media (max-width: 600px) {
  .container {
    padding: 20px 15px;
  }
  .toc {
    padding: 15px;
  }
  .toc-title {
    font-size: 1em;
  }
}
