/* Table of Contents (ToC) - Fixed Right Sidebar */

.toc-wrapper {
  position: relative;
}

.toc-container {
  position: fixed;
  right: 2rem;
  top: 120px;
  max-width: 280px;
  max-height: calc(100vh - 140px);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 8px;
  padding: 1.5rem;
  overflow-y: auto;
  z-index: 100;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toc-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #d4af37;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  padding-bottom: 0.75rem;
}

.toc-header::before {
  content: "📑";
  font-size: 1.1rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.toc-item {
  margin: 0.4rem 0;
}

.toc-link {
  display: block;
  padding: 0.35rem 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  transition: all 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-link:hover {
  color: #d4af37;
  background: rgba(212, 175, 55, 0.1);
  border-left-color: #d4af37;
}

.toc-link.active {
  color: #fff;
  background: rgba(212, 175, 55, 0.15);
  border-left-color: #d4af37;
  font-weight: 600;
}

/* ToC Indentation for heading levels */
.toc-item.level-1 .toc-link {
  padding-left: 0.75rem;
}

.toc-item.level-2 .toc-link {
  padding-left: 1.5rem;
  font-size: 0.8rem;
}

.toc-item.level-3 .toc-link {
  padding-left: 2.25rem;
  font-size: 0.75rem;
}

.toc-item.level-4 .toc-link {
  padding-left: 3rem;
  font-size: 0.7rem;
  opacity: 0.7;
}

/* Scrollbar styling for ToC */
.toc-container::-webkit-scrollbar {
  width: 6px;
}

.toc-container::-webkit-scrollbar-track {
  background: transparent;
}

.toc-container::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 3px;
}

.toc-container::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.5);
}

/* No ToC message */
.toc-empty {
  padding: 0.75rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  font-style: italic;
}

/* Responsive Design */
@media screen and (max-width: 1400px) {
  .toc-container {
    right: 1rem;
    max-width: 240px;
    padding: 1rem;
  }

  .toc-header {
    font-size: 0.8rem;
  }

  .toc-list {
    font-size: 0.8rem;
  }
}

@media screen and (max-width: 1200px) {
  .toc-container {
    position: static;
    max-width: 100%;
    max-height: none;
    margin: 2rem 0;
    border-top: 2px solid rgba(212, 175, 55, 0.2);
    border-right: none;
    border-bottom: none;
    border-left: none;
    padding: 1.5rem 0;
  }

  .toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .toc-item {
    margin: 0;
  }

  .toc-link {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-left: none;
    border-radius: 4px;
    white-space: normal;
  }

  .toc-item.level-2 .toc-link,
  .toc-item.level-3 .toc-link,
  .toc-item.level-4 .toc-link {
    padding-left: 0.75rem;
  }
}

@media screen and (max-width: 768px) {
  .toc-container {
    margin: 1.5rem 0;
    padding: 1rem;
  }

  .toc-header {
    margin-bottom: 0.75rem;
  }

  .toc-list {
    gap: 0.3rem;
  }

  .toc-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }
}
