/* ══════════════════════════════════════════════════════════
   Theory Sidebar – Floating section navigation
   ══════════════════════════════════════════════════════════ */

.theory-sidebar {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
  display: flex;
  align-items: flex-start;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.theory-sidebar.hidden {
  transform: translateY(-50%) translateX(-100%);
}

/* ── Panel ────────────────────────────────────────────── */
.toc-panel {
  width: 230px;
  max-height: 70vh;
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-left: none;
  border-radius: 0 var(--radius-lg, 12px) var(--radius-lg, 12px) 0;
  box-shadow: var(--shadow-md, 0 4px 24px rgba(0,0,0,0.3));
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
  padding: 1rem 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.toc-panel::-webkit-scrollbar {
  width: 4px;
}
.toc-panel::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

/* ── Header ───────────────────────────────────────────── */
.toc-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem 0.7rem;
  border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
  margin-bottom: 0.5rem;
}
.toc-header-icon {
  font-size: 0.85rem;
}
.toc-header-text {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #888);
}

/* ── Section links ────────────────────────────────────── */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-link {
  display: block;
  padding: 0.45rem 1rem 0.45rem 1.2rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted, #888);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.toc-link:hover {
  color: var(--text-secondary, #bbb);
  background: rgba(255,255,255,0.03);
}

.toc-link.active {
  color: var(--accent-1, #6C5CE7);
  border-left-color: var(--accent-1, #6C5CE7);
  background: rgba(108, 92, 231, 0.06);
  font-weight: 600;
}

/* ── Toggle button ────────────────────────────────────── */
.toc-toggle {
  pointer-events: auto;
  width: 28px;
  height: 48px;
  background: var(--bg-card, #12121a);
  border: 1px solid var(--border-color, rgba(255,255,255,0.08));
  border-left: none;
  border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted, #888);
  font-size: 0.7rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.toc-toggle:hover {
  color: var(--accent-1, #6C5CE7);
  background: var(--bg-card-hover, #1a1a2e);
}

.toc-toggle .toc-toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.65rem;
}

.theory-sidebar.collapsed .toc-panel {
  display: none;
}

.theory-sidebar.collapsed .toc-toggle {
  border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
}

.theory-sidebar.collapsed .toc-toggle-icon {
  transform: rotate(180deg);
}

/* ── Progress indicator (optional subtle bar at top) ─── */
.toc-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-1, #6C5CE7), var(--accent-7, #a29bfe));
  border-radius: 0 2px 2px 0;
  transition: width 0.3s ease;
  width: 0%;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 1024px) {
  .theory-sidebar {
    display: none;
  }
}

/* On very wide screens, push away from the edge slightly */
@media (min-width: 1600px) {
  .theory-sidebar {
    left: calc((100vw - 1200px) / 2 - 260px);
  }
}

/* ── Tutorial mode: use --tut-accent if defined ────────── */
.theory-sidebar.tutorial-mode .toc-link.active {
  color: var(--tut-accent, var(--accent-1, #6C5CE7));
  border-left-color: var(--tut-accent, var(--accent-1, #6C5CE7));
  background: color-mix(in srgb, var(--tut-accent, var(--accent-1)) 8%, transparent);
}
.theory-sidebar.tutorial-mode .toc-link {
  font-size: 0.75rem;
}
