/* Table of Contents Container */
.toc-container {
  background: linear-gradient(135deg, #F8F6F3 0%, #FFFFFF 100%);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 24px;
  margin: 32px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  position: relative;
  overflow: hidden;
}

/* Post Layout: Content + TOC Sidebar */
@media (min-width: 1200px) {
  .post-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 48px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
  }
  
  .post-content {
    min-width: 0;
  }
  
  .toc-sidebar {
    position: sticky;
    top: 100px;
    align-self: start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
  }
  
  .toc-sidebar .toc-container {
    margin: 0;
  }
}

/* TOC Header */
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #D4AF37;
}

.toc-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: #0A1628;
  margin: 0;
}

/* Mobile collapse toggle */
@media (max-width: 768px) {
  .toc-header {
    cursor: pointer;
    user-select: none;
  }
  
  .toc-header::after {
    content: '−';
    font-size: 1.5rem;
    color: #D4AF37;
    transition: transform 0.3s;
  }
  
  .toc-container.collapsed .toc-header::after {
    content: '+';
  }
  
  .toc-container.collapsed .toc-nav {
    display: none;
  }
}

/* TOC List */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-sublist {
  list-style: none;
  padding: 0;
  margin: 8px 0 8px 24px;
}

/* TOC Items */
.toc-item {
  margin-bottom: 8px;
}

.toc-h2 {
  font-weight: 600;
}

.toc-h3 {
  font-size: 0.9375rem;
}

/* TOC Links */
.toc-link {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: #4A4A4A;
  transition: all 0.2s ease;
  position: relative;
}

.toc-link:hover {
  background: rgba(212, 175, 55, 0.1);
  color: #0A1628;
  transform: translateX(4px);
}

.toc-link.active {
  background: rgba(212, 175, 55, 0.2);
  color: #0A1628;
  font-weight: 600;
}

.toc-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 100%;
  background: #D4AF37;
  border-radius: 0 3px 3px 0;
}

/* TOC Number */
.toc-number {
  color: #D4AF37;
  font-weight: 700;
  font-size: 0.875rem;
  min-width: 32px;
  flex-shrink: 0;
}

/* TOC Text */
.toc-text {
  flex: 1;
  line-height: 1.4;
}

/* Reading Progress Bar */
.toc-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #D4AF37, #F4D03F);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 12px 12px 0 0;
  z-index: 10;
}

/* Scrollbar for sticky TOC */
.toc-sidebar::-webkit-scrollbar {
  width: 6px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: #F8F6F3;
  border-radius: 3px;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: #D4AF37;
  border-radius: 3px;
}

.toc-sidebar::-webkit-scrollbar-thumb:hover {
  background: #C09F2F;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .toc-container {
    padding: 16px;
    margin: 24px 0;
  }
  
  .toc-link {
    padding: 6px 8px;
    font-size: 0.9375rem;
  }
  
  .toc-number {
    min-width: 28px;
    font-size: 0.8125rem;
  }
  
  .toc-text {
    font-size: 0.9375rem;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1199px) {
  .post-layout {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
  }
  
  .toc-container {
    margin: 32px 0;
  }
}

/* Print styles */
@media print {
  .toc-container {
    border: 1px solid #ccc;
    box-shadow: none;
    page-break-inside: avoid;
  }
  
  .toc-progress {
    display: none;
  }
  
  .toc-link {
    color: #000;
  }
}

