/* Sticky TOC Sidebar Styles */

/* Target the main content container */
#post-container {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    max-width: 1200px; /* Match article width */
    margin: 0 auto;
    padding: 0 1rem;
}

/* Target the main article content */
#post-main {
    flex-grow: 1;
    max-width: 1200px; /* Match article width */
    margin-right: 20px;
}

/* Target the Table of Contents */
#toc-sidebar {
    position: sticky;
    top: 6rem;
    width: 200px;
    height: calc(100vh - 8rem);
    overflow-y: auto;
    z-index: 10;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    order: 2;
    flex-shrink: 0;
}

/* Mobile responsiveness */
@media (max-width: 1024px) {
    #post-container {
        flex-direction: column;
        align-items: center;
    }

    #post-main {
        width: 100%;
        margin-right: 0;
    }
    
    #toc-sidebar {
        position: static;
        width: 100%;
        height: auto;
        max-height: none;
        margin-bottom: 2rem;
        order: 0;
    }
}

/* Styles for the actual ToC list */
.toc {
    margin-bottom: 1rem;
    padding: 0;
}

.toc details {
    border: none;
}

.toc summary {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary);
    cursor: default;
    margin-bottom: 0.75rem;
    padding: 0;
    list-style: none;
}

.toc summary::-webkit-details-marker {
    display: none;
}

.toc .inner {
    margin: 0;
    padding: 0;
}

.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    margin-left: 0; 
}

.toc ul ul {
    margin-left: 1rem;
    border-left: 1px solid var(--border);
}

.toc li {
    margin: 0;
    padding: 0;
}

.toc a {
    display: block;
    padding: 0.4rem 0.75rem;
    color: var(--secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    line-height: 1.4;
    border-left: 3px solid transparent;
}

.toc a:hover {
    color: var(--primary);
    background: var(--theme);
    border-left-color: var(--primary);
}

.toc a.active {
    color: var(--primary);
    background: var(--theme);
    border-left-color: var(--primary);
    font-weight: 500;
}
/* Override: make ToC look inline (remove card background/border from theme) */
.toc {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;            /* remove card-like padding */
  margin: 0 0 1rem 0 !important;    /* minimal spacing below summary */
}

/* Flatten inner container spacing */
.toc .inner {
  margin: 0 !important;
  padding: 0 !important;
}

/* Ensure details wrapper has no border even if theme adds one */
.toc details {
  border: none !important;
}
/* Remove hover/active background so ToC looks inline */
.toc a:hover,
.toc a.active {
  background: transparent !important;
}

/* Keep a subtle cue via left border only */
.toc a.active {
  border-left-color: var(--primary) !important;
}
/* Responsive ToC scaling and hide on small screens */
/* Gradually shrink, then fully hide to avoid overlap with article content */
@media (max-width: 1280px) {
  #toc-sidebar { width: 180px !important; }
}

@media (max-width: 1100px) {
  #toc-sidebar { width: 160px !important; }
}

/* Completely hide ToC on tablet/phones to prevent conflicts */
@media (max-width: 1024px) {
  #toc-sidebar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  #post-main {
    margin-right: 0 !important;
  }
  #post-container {
    justify-content: center !important;
    flex-direction: column !important;
    align-items: center !important;
  }
}
/* Ensure in-page anchor scroll lands below sticky header */
.post-content h1[id],
.post-content h2[id],
.post-content h3[id],
.post-content h4[id],
.post-content h5[id],
.post-content h6[id] {
  scroll-margin-top: var(--anchor-offset) !important;
}