html {
  scroll-behavior: smooth;
}

/* Burger Menu Button - Shows on all screen sizes */
.toc-burger {
  position: fixed;
  right: 20px;
  top: 20px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
}

.toc-burger:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.toc-burger span {
  display: block;
  width: 24px;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.toc-burger.active span:nth-child(1) {
  transform: rotate(45deg) translate(7px, 7px);
}

.toc-burger.active span:nth-child(2) {
  opacity: 0;
}

.toc-burger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* Table of Contents Panel */
.toc-wrapper {
  position: fixed;
  right: -18.6%;
  top: 0;
  width: 18.6%;
  height: 100vh;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 0;
  box-shadow: -2px 0 20px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  z-index: 1000;
  transition: right 0.3s ease;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.toc-wrapper.active {
  right: 0;
}

.toc-header {
  position: sticky;
  top: 0;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.toc-header h4 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.toc-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
  line-height: 1;
}

.toc-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* Burger mode styles - apply to all screen sizes */
.toc-list {
  list-style-type: none;
  padding: 20px;
  margin: 0;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  color: #4a4a4a;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 12px 15px;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-weight: 500;
}

.toc-list a:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  color: white;
  transform: translateX(5px);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.toc-list a:active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
  color: white;
}

/* Overlay */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toc-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Overlay now works for all screen sizes */

/* Mobile adjustments */
@media screen and (max-width: 768px) {
  .toc-wrapper {
    width: 36%;
    right: -36%;
  }

  .toc-burger {
    right: 15px;
    top: 15px;
  }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
  .toc-wrapper {
    width: 24%;
    right: -24%;
  }
}

@media screen and (min-width: 1025px) and (max-width: 1399px) {
  .toc-wrapper {
    width: 18.6%;
    right: -18.6%;
  }
}