/* Persistent Table of Contents Styles */
body {
  /* Remove padding to not push content over */
  padding-left: 0;
}

#TOC {
  position: fixed;
  left: 0;
  top: 0;
  width: 300px;
  height: 100vh;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
  background-color: rgba(249, 249, 249, 0.95); /* Slightly transparent background */
  border-right: 1px solid #e0e0e0;
  font-size: 0.9em;
  transition: opacity 0.2s ease, transform 0.2s ease; /* Faster transition */
  opacity: 0.2; /* Much more faded by default */
  z-index: 1000; /* Make sure it's above content */
}

/* Full opacity when hovered */
#TOC:hover {
  opacity: 1;
  transform: translateX(0);
}

/* When at top of document */
body.at-top #TOC {
  opacity: 0.9;
}

#TOC .toc-section-number {
  color: #777;
}

#TOC ul {
  padding-left: 15px;
}

#TOC > ul {
  padding-left: 0;
}

#TOC li {
  margin-bottom: 6px;
  list-style-type: none;
}

#TOC a {
  text-decoration: none;
  color: #444;
}

#TOC a:hover {
  color: #000;
  text-decoration: underline;
}

/* Active section highlighting */
.toc-active {
  font-weight: bold;
  color: #0066cc !important;
  position: relative;
  display: block;
  padding-left: 5px !important;
}

/* Active item gets a bright left border */
.toc-active::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0;
  height: 100%;
  width: 3px;
  background-color: #0066cc;
  border-radius: 2px;
}

/* Make active item background stand out */
#TOC li:has(> .toc-active) {
  background-color: rgba(0, 102, 204, 0.1);
  border-radius: 3px;
  margin-left: -5px;
  padding-left: 5px;
}

/* Responsive behavior for smaller screens.
   Breakpoint set above the width where centered content (text ~1226px, and the
   ~864px break-out graphics ~1514px) would slide under the 300px fixed sidebar,
   so the ToC drops to the top before it can overlap either. */
@media screen and (max-width: 1550px) {
  body {
    padding-left: 0;
  }
  
  #TOC {
    position: static;
    width: 100%;
    height: auto;
    max-height: 300px;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 15px;
  }
  
  /* Adjust the highlights box on smaller screens */
  .highlights-box {
    position: static;
    width: auto;
    margin: 20px 0;
  }
}
