.toc-container {
  width: 12rem;
  position: relative;
  left: -0.175em;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  display: none;
}

.toc-container.fixed-position {
  opacity: 1;
  position: fixed;
  top: 12rem;
  margin-top: 0;
  padding-left: 1rem;
  z-index: 10;
  left: auto;
}

.toc-nav {
  font-family: var(--sans);
}

.toc-list,
.toc-list li,
.toc-item {
  list-style: none;
  margin: 0;
  padding: 0;
}

.prose .toc-container .toc-list {
  margin-left: 0 !important;
  padding-left: 0 !important;
}

.prose .toc-container .toc-list li {
  margin: 0 !important;
  padding: 0 !important;
}

.toc-item::before,
.toc-item::marker {
  display: none;
}

.toc-link {
  display: block;
  color: transparent;
  text-decoration: none;
  position: relative;
  padding-left: 0;
  height: 1.125rem;
  width: 100%;
  min-height: 1rem;
  font-size: 0;
  line-height: 1.125rem;
  text-indent: 2rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition:
    color 0.2s ease-out,
    font-size 0.2s ease-out,
    text-indent 0.2s ease-out;
  cursor: pointer;
}

.toc-link::after {
  content: attr(data-text);
  position: absolute;
  left: -0.5rem;
  top: 0;
  font-family: var(--sans);
  font-size: var(--font-size-s);
  letter-spacing: var(--spacing-m);
  line-height: 1.125rem;
  color: var(--text-primary);
  opacity: 0;
  transition:
    opacity 0.2s ease-out,
    left 0.2s ease-out;
  pointer-events: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100%;
}

.toc-link:hover::after {
  opacity: 1;
  left: -0.75rem;
}

.toc-level-0 .toc-link:hover::after {
  opacity: 0;
}

.toc-level-1 .toc-link:hover::before,
.toc-level-2 .toc-link:hover::before,
.toc-level-3 .toc-link:hover::before {
  width: 0.75rem;
  transition: width 0.1s ease-out;
}

.toc-link.active {
  color: var(--text-primary);
}

/* Horizontal line indicators */
.toc-level-0 .toc-link::before,
.toc-level-1 .toc-link::before,
.toc-level-2 .toc-link::before,
.toc-level-3 .toc-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.75rem;
  height: 1px;
  background-color: var(--text-tertiary);
  transform: translateY(-50%);
  opacity: 0.4;
  transition: all 0.1s ease-out;
}

.toc-link:hover::before,
.toc-link.active::before {
  opacity: 0.8;
  background-color: var(--text-primary);
}

/* Hide on mobile */
@media (max-width: 768px) {
  .toc-container {
    display: none !important;
  }
}
