/* Sticky TOC Frontend Styles (v3) */
.stoc{
  --stoc-bg: rgba(255,255,255,.92);
  --stoc-border: rgba(0,0,0,.08);
  --stoc-text: #111;
  --stoc-muted: rgba(0,0,0,.6);
  --stoc-accent: #f59e0b;
  --stoc-progress-color: var(--stoc-accent);
  --stoc-progress-track: rgba(0,0,0,.06);
  --stoc-percent-color: var(--stoc-muted);
  --stoc-header-bg: transparent;
  --stoc-header-text: var(--stoc-text);
  --stoc-font-family: inherit;
  --stoc-header-font-size: 14px;
  --stoc-header-font-weight: 600;
  --stoc-list-font-size: 13px;
  --stoc-list-font-weight: 500;
  --stoc-link-color: var(--stoc-text);
  --stoc-link-hover: var(--stoc-accent);
  --stoc-link-active: var(--stoc-accent);
  --stoc-toggle-icon-color: currentColor;
  --stoc-radius: 14px;
  --stoc-shadow: 0 10px 30px rgba(0,0,0,.08);
  --stoc-tx: 0px;
  --stoc-ty: 0px;
  --stoc-hide-ty: 0px;
  position: relative;
  font-family: var(--stoc-font-family);
  border:1px solid var(--stoc-border);
  background: var(--stoc-bg);
  border-radius: var(--stoc-radius);
  box-shadow: var(--stoc-shadow);
  overflow:hidden;
  max-width: 320px;
}
.stoc-style-opt-2{
  --stoc-accent:#2563eb;
  --stoc-bg:#ffffff;
}

/* New preset: Minimal */
.stoc-style-minimal{
  --stoc-bg:#ffffff;
  --stoc-border: rgba(0,0,0,.10);
  --stoc-shadow: none;
  --stoc-radius: 12px;
  --stoc-accent:#2563eb;
}

/* New preset: Glass */
.stoc-style-glass{
  --stoc-bg: rgba(255,255,255,.72);
  --stoc-border: rgba(0,0,0,.10);
  --stoc-shadow: 0 14px 40px rgba(0,0,0,.10);
  --stoc-radius: 16px;
  --stoc-accent:#f59e0b;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* New preset: Bold */
.stoc-style-bold{
  --stoc-bg:#0b1220;
  --stoc-border: rgba(255,255,255,.12);
  --stoc-text: #eef2ff;
  --stoc-muted: rgba(238,242,255,.70);
  --stoc-link-color: var(--stoc-text);
  --stoc-link-hover:#a78bfa;
  --stoc-link-active:#a78bfa;
  --stoc-header-bg: rgba(255,255,255,.06);
  --stoc-header-text: var(--stoc-text);
  --stoc-accent:#a78bfa;
  --stoc-progress-track: rgba(255,255,255,.12);
  --stoc-shadow: 0 14px 40px rgba(0,0,0,.18);
}
.stoc .stoc-header{
  position:relative;
  padding:10px 10px 0;
  background: var(--stoc-header-bg);
  color: var(--stoc-header-text);
  border-top-left-radius: var(--stoc-radius);
  border-top-right-radius: var(--stoc-radius);
}
.stoc .stoc-toggle{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  background:transparent;
  border:none;
  padding:10px 10px 10px;
  cursor:pointer;
  color:var(--stoc-header-text);
}
.stoc .stoc-toggle:focus-visible{
  outline:2px solid var(--stoc-accent);
  outline-offset:2px;
  border-radius:12px;
}
.stoc .stoc-icon{
  width:28px;
  height:28px;
  display:grid;
  place-items:center;
  border-radius:10px;
  background: rgba(0,0,0,.04);
}
 .stoc .stoc-title{
  font-size: var(--stoc-header-font-size);
  font-weight: var(--stoc-header-font-weight);
  text-align:left;
  flex:1;
}
.stoc .stoc-meta{
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--stoc-muted);
  font-size:12px;
}
.stoc .stoc-chevron{ color: var(--stoc-toggle-icon-color);
  transition: transform .2s ease;
  display:inline-grid;
  place-items:center;
}
.stoc-state-open .stoc-chevron{ transform: rotate(180deg); }

.stoc .stoc-progress{
  height:4px;
  width:calc(100% - 20px);
  margin:0 10px 10px;
  background: var(--stoc-progress-track);
  border-radius:999px;
  overflow:hidden;
}
.stoc .stoc-progress-bar{
  display:block;
  height:100%;
  width:0%;
  background: var(--stoc-progress-color);
  border-radius:999px;
  transition: width .1s linear;
}

.stoc .stoc-body{
  max-height: 420px;
  overflow:auto;
  padding: 0 10px 10px;
}
.stoc-state-closed .stoc-body{ display:none; }

.stoc .stoc-list{
  list-style: none;
  margin:0;
  padding: 0 4px 6px;
}

.stoc .stoc-list.stoc-list-scrollable{
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}
.stoc .stoc-list li{
  margin: 0;
}
.stoc .stoc-list a{
  display:block;
  padding:8px 10px;
  border-radius: 10px;
  color: var(--stoc-link-color);
  font-size: var(--stoc-list-font-size);
  font-weight: var(--stoc-list-font-weight);
  text-decoration:none;
}
.stoc .stoc-list a:hover{
  background: rgba(0,0,0,.04);
}
.stoc .stoc-list a.stoc-active{
  background: rgba(245,158,11,.14);
  color: var(--stoc-link-color);
}
.stoc-style-opt-2 .stoc-list a.stoc-active{
  background: rgba(37,99,235,.12);
}
.stoc-numbers-true .stoc-list{
  counter-reset: stoc;
}
.stoc-numbers-true .stoc-list > li > a::before{
  counter-increment: stoc;
  content: counter(stoc) ". ";
  color: var(--stoc-muted);
  font-weight:600;
}
.stoc .stoc-list ol{
  list-style:none;
  margin:0 0 0 14px;
  padding:0;
  border-left:1px dashed rgba(0,0,0,.10);
}
.stoc .stoc-list ol a{
  padding-left: 12px;
}

/* Sticky positioning */
.stoc.stoc-fixed{
  position: fixed;
  top: var(--stoc-top, 12px);
  z-index: 9999;
  transform: translateX(var(--stoc-tx, 0px)) translateY(calc(var(--stoc-ty, 0px) + var(--stoc-hide-ty, 0px)));
}
.stoc-side-right.stoc-fixed{ right: 18px; }
.stoc-side-left.stoc-fixed{ left: 18px; }
.stoc-side-inline.stoc-fixed{ left: 50%; --stoc-tx: -50%; }
.stoc-fixed.stoc-boundary{ left: auto; right: auto; }
.stoc-corner.stoc-fixed{ --stoc-tx: 0px; max-height: 70vh; overflow:auto; }

/* Auto-hide */
.stoc.stoc-hidden,
  .stoc.stoc-stop-hidden{
  --stoc-hide-ty: 10px;
  opacity: 0;
  pointer-events:none;
  transition: opacity .25s ease, transform .25s ease;
}
.stoc{
  transition: opacity .25s ease, transform .25s ease;
  will-change: transform, opacity;
}

/* Mobile bottom bar */
@media (max-width: 768px){
  .stoc{
    max-width: none;
    width: calc(100% - 24px);
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 9999;
    border-radius: 16px;
    /* Mobile hide/show UX: visible by default */
    transform: translateY(0);
    opacity: 1;
    transition: transform .28s ease, opacity .28s ease;
    will-change: transform, opacity;
  }
  .stoc.stoc-fixed{ top: auto; }
  .stoc .stoc-body{ max-height: 45vh; }

  /* When auto-hidden on mobile, slide DOWN off-screen and fade out */
  .stoc.stoc-hidden,
  .stoc.stoc-stop-hidden{
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
  }
}

.stoc.stoc-open .stoc-plus-vert{opacity:0;}

.stoc.stoc-progress-line .stoc-progress{height:2px;margin:0 10px 10px;border-radius:0;}


/* Mobile hide/show animation: slide DOWN off-screen when hidden, slide UP into view when shown. */
@media (max-width: 768px){
  .stoc{
    transform: translateY(0);
  }
  .stoc.stoc-hidden,
  .stoc.stoc-stop-hidden{
    transform: translateY(120%);
  }
}


/* Hide/lock in stop zone on desktop too */
.stoc.stoc-stop-hidden{
  opacity:0;
  visibility:hidden;
  pointer-events:none;
}
