/* =======================================
   NEXT-GEN CREATIVE TOC DESIGN (Light Default + Manual Dark)
   ======================================= */

:root {
  --toc-accent: #0050ff;
  --toc-accent-light: #e8f0ff;
  --toc-radius: 16px;
  --toc-font: "Inter", system-ui, sans-serif;
}

/* === MAIN CONTAINER === */
.custom-toc {
  background: var(--toc-bg, #ffffff);
  border-radius: var(--toc-radius);
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 8px 30px rgba(0,0,0,0.05);
  font-family: var(--toc-font);
  overflow: hidden;
  transform: translateZ(0);
  transition: all 0.3s ease;
  will-change: transform, box-shadow;
}
.custom-toc:hover {
  box-shadow: 0 12px 35px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

/* === HEADER === */
.custom-toc.collapsible h2 {
  margin: 0;
  padding: 14px 18px;
  background: var(--toc-header, linear-gradient(90deg, #f9f9f9, #f0f0f0));
  border-bottom: 1px solid rgba(0,0,0,0.08);
  color: var(--toc-title, #222);
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.custom-toc.collapsible h2::before {
  content: "🧭";
  margin-right: 10px;
  font-size: 22px;
  opacity: 0.8;
}
.custom-toc.collapsible h2:after {
  content: "⤵";
  font-size: 20px;
  opacity: 0.5;
  transition: transform 0.3s ease;
}
.custom-toc.collapsible:not(.collapsed) h2:after {
  transform: rotate(180deg);
}

/* === CONTENT LIST === */
.custom-toc ul {
  list-style: none !important;
  padding: 12px 20px;
  margin: 0;
}
.custom-toc ul li {
  margin: 8px 0;
  line-height: 1.5;
  border-left: 3px solid transparent;
  padding-left: 10px;
  transition: all 0.2s ease;
}
.custom-toc ul li a {
  text-decoration: none;
  color: var(--toc-link, #111);
  font-weight: 500;
  transition: color 0.2s ease;
}
.custom-toc ul li:hover {
  border-left-color: var(--toc-accent);
  background: var(--toc-accent-light);
  transform: translateX(3px);
}
.custom-toc ul li.current {
  border-left-color: var(--toc-accent);
  background: var(--toc-accent-light);
}
.custom-toc ul li.current a {
  color: var(--toc-accent);
  font-weight: 600;
}
.custom-toc ul li.h3 {
  margin-left: 15px;
  opacity: 0.85;
  font-size: 0.95em;
}

/* === STICKY & FIXED BEHAVIOR === */
.custom-toc.sticky-top {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  z-index: 999;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
}
.custom-toc.fixed-bottom {
  position: fixed;
  bottom: 0;
  width: 580px;
  border-radius: 20px 20px 0 0;
  backdrop-filter: blur(10px);
  background: var(--toc-bg, rgba(255,255,255,0.9));
  box-shadow: 0 -4px 25px rgba(0,0,0,0.15);
  overflow-y: auto;
  max-height: 65%;
  z-index: 999;
  opacity: 0.98;
  transform: translateZ(0);
}
.custom-toc h2 {
    font-size: 14px !important;
    margin: auto !important;
}
.custom-toc.fixed-bottom.collapsible h2 {
    background: var(--toc-header, linear-gradient(90deg,#f0f0f0,#fafafa));
    font-size: 14px;
    margin: auto;
}

/* === SMOOTH COLLAPSE === */
.custom-toc.collapsible ul {
  display: none;
  animation: tocFadeIn 0.4s ease forwards;
}
.collapsible:not(.collapsed) ul {
  display: block;
}
@keyframes tocFadeIn {
  from {opacity: 0; transform: translateY(-10px);}
  to {opacity: 1; transform: translateY(0);}
}

/* === SCROLL DOTS INDICATOR === */
.scroll-wrapper {
  position: fixed;
  left: 40px;
  top: 100px;
  list-style: none;
  padding: 0;
  margin: 0;
  z-index: 98;
}
.scroll-item .scroll-tip {
  display: inline-block;
  width: 8px;
  height: 35px;
  background: #e1e1e1;
  border-radius: 6px;
  transition: background 0.3s;
}
.scroll-item:hover .scroll-tip,
.current .scroll-tip {
  background: var(--toc-accent);
}
@media (max-width: 767px) {
  .scroll-wrapper { display: none; }
}

/* === RESPONSIVE === */
@media only screen and (max-width: 600px) {
  .custom-toc.fixed-bottom {
    width: 95%;
    left: 2.5%;
    bottom: 0;
  }
  .custom-toc.collapsible h2 {
    font-size: 17px;
  }
}

/* =======================================
   MANUAL DARK MODE (via body.mode--alt--b)
   ======================================= */

body.mode--alt--b {
  --toc-bg: #1b1b1b;
  --toc-header: linear-gradient(90deg, #242424, #181818);
  --toc-title: #ffffff;
  --toc-link: #e8e8e8;
  --toc-accent: #4f9cff;
  --toc-accent-light: rgba(79,156,255,0.1);
}

body.mode--alt--b .custom-toc {
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 6px 25px rgba(0,0,0,0.5);
}
body.mode--alt--b .custom-toc ul li:hover {
  background: rgba(79,156,255,0.12);
}
