/* ============================================================================
   TABLE OF CONTENTS (Enhanced with Progress & Cartoon Style) - Blog V2
   Extracted from blog-v2.css
   ============================================================================ */

.toc {
  position: sticky;
  top: calc(56px + var(--sp-3, 16px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-3, 16px);
  padding-top: calc(var(--sp-3, 16px) + 3px); /* Account for accent line */
  border-radius: var(--radius-cartoon, 18px);
  border: 2px solid var(--c-border);
  background: var(--c-surface);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 6px 0 #042b33;
  scrollbar-width: thin;
  scrollbar-color: var(--c-accent) rgba(255, 255, 255, 0.05);
}

/* Decorative accent line */
.toc::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--c-accent), var(--c-accent-glow));
  border-radius: var(--radius-cartoon, 18px) var(--radius-cartoon, 18px) 0 0;
  z-index: 1;
}

.toc::-webkit-scrollbar {
  width: 6px;
}

.toc::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
}

.toc::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--c-accent), var(--c-border));
  border-radius: 3px;
}

.toc::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--c-accent-glow), var(--c-accent));
}

.toc__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2, 12px);
  margin-bottom: var(--sp-3, 16px);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--c-text-muted);
  padding-top: var(--sp-1, 8px);
}

.toc__icon {
  color: var(--c-accent);
  filter: drop-shadow(0 2px 0 rgba(4, 43, 51, 0.4));
}

/* Reading Progress in TOC */
.toc__progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill, 50rem);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--c-accent);
}

.toc__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc__item {
  margin: 2px 0;
  position: relative;
}

.toc__item.is-h3 {
  padding-left: 16px;
}

.toc__item.is-h3::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background: var(--c-border);
  border-radius: 50%;
}

.toc__link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-cartoon, 18px);
  color: var(--c-text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.5;
  transition: all var(--motion-med) var(--motion-curve);
  border-left: 3px solid transparent;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  word-wrap: break-word;
  hyphens: auto;
}

.toc__link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c-accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--motion-med) var(--motion-curve);
}

.toc__link:hover {
  background: var(--c-bg-alt);
  color: var(--c-text);
  transform: translateX(4px);
  box-shadow: 0 2px 0 rgba(4, 43, 51, 0.2);
}

.toc__link:hover::before {
  transform: scaleY(0.3);
}

.toc__link.is-active {
  background: var(--c-bg-alt);
  color: var(--c-accent);
  font-weight: 700;
  box-shadow: 0 3px 0 var(--c-border), 0 5px 0 #042b33;
  transform: translateX(6px);
}

.toc__link.is-active::before {
  transform: scaleY(1);
}

@media (prefers-reduced-motion: reduce) {
  .toc__link {
    transition: none;
  }
  .toc__link::before {
    transition: none;
  }
  .toc__link:hover,
  .toc__link.is-active {
    transform: none;
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .toc {
    position: static;
    margin-bottom: var(--sp-3, 16px);
  }
}
