/* ==========================================================================
   Table of Contents - Integrated Minimalist Design
   ========================================================================== */

/* 1. Base Container */
.gh-toc-container {
  max-width: 70%;
  margin-top: 3rem;
  margin-bottom: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.gh-toc-title {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.9);
}

/* 2. List & Tracking Line */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 90%;
  /* Creates the vertical timeline rail */
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.toc-item {
  margin-bottom: 0;
}

/* 3. Forcing overrides against custom.css */
.gh-toc-container .toc-list .toc-link {
  display: block;
  /* Expand click area and push text away from the line */
  padding: 0.8rem 0 0.8rem 1.5rem;

  /* CRITICAL: Defeat the custom.css global link overrides */
  text-decoration: none !important;
  color: rgba(255, 255, 255, 0.45) !important;

  font-size: 1.4rem;
  font-weight: 400;
  position: relative;
  transition: all 0.2s ease;
}

/* Indent H3s further to show hierarchy */
.gh-toc-container .toc-list .toc-level-h3 .toc-link {
  padding-left: 2.5rem;
  font-size: 1.3rem;
}

/* Hover & Active States */
.gh-toc-container .toc-list .toc-link:hover {
  color: rgba(255, 255, 255, 0.9) !important;
}

.gh-toc-container .toc-list .toc-link.is-active {
  color: #ffffff !important;
  font-weight: 700;
}

/* Active Highlight Bar (Animates along the track) */
.gh-toc-container .toc-list .toc-link::before {
  content: "";
  position: absolute;
  /* Overlap the faded left border perfectly */
  left: -2px;
  top: 0;
  width: 2px;
  height: 0;
  background-color: #ffffff; /* Or use your brand accent color here */
  transition: height 0.3s ease;
}

.gh-toc-container .toc-list .toc-link.is-active::before {
  height: 100%;
}

/* ==========================================================================
   Desktop Adaptation (Sticky Behavior)
   ========================================================================== */
@media (min-width: 1024px) {
  .gh-toc-container {
    position: sticky;
    top: 3rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    /* Hide the ugly scrollbar for a cleaner look */
    scrollbar-width: none;
  }

  .gh-toc-container::-webkit-scrollbar {
    display: none;
  }
}
@media (max-width: 1023px) {
  /* 1. Force the ToC to the absolute top of the CSS Grid */
  html body .gh-canvas .gh-article-meta {
    /* order: -999 !important; */
    grid-row: 1 !important; /* Tells the CSS Grid this element MUST be in row 1 */
    /* position: relative !important; /* Strips away any absolute/sticky positioning */
    display: block !important; /* Prevents flex/grid weirdness inside the container */

    /* width: 100%;
    margin-top: 0 !important;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1); */
  }

  /* 2. Explicitly force the first H2 into the second row so it can't fight for the top spot */
  html body .gh-canvas > h2:first-of-type {
    grid-row: 2 !important;
    /* order: -998 !important; */
  }
}
