/* Article Layout - Two Column with Sticky Sidebar */
.article-layout {
  display: flex;
  gap: 3rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  position: relative;
}

.article-content {
  flex: 1;
  min-width: 0;
  max-width: 800px;
}

.article-sidebar {
  flex: 0 0 280px;
  order: -1; /* Sidebar on left */
}

/* Sticky Table of Contents */
.sticky-toc {
  position: sticky;
  top: 100px; /* Adjust based on your header height */
  background: #f8f9fa;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  padding: 1.5rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.toc-title {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-nav {
  font-size: 0.9rem;
}

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

.toc-item {
  margin: 0;
  line-height: 1.6;
}

.toc-item a {
  display: block;
  padding: 0.4rem 0;
  color: #666;
  text-decoration: none;
  transition: all 0.2s ease;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  margin-left: -0.75rem;
}

.toc-item a:hover {
  color: #0066cc;
  border-left-color: #0066cc;
}

.toc-item a.active {
  color: #0066cc;
  font-weight: 600;
  border-left-color: #0066cc;
  background: rgba(0, 102, 204, 0.05);
}

.toc-h2 {
  margin-top: 0.75rem;
}

.toc-h2:first-child {
  margin-top: 0;
}

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

.toc-nested {
  list-style: none;
  margin: 0.25rem 0 0.5rem 0;
  padding: 0;
}

.toc-nested .toc-item a {
  padding-left: 1.5rem;
  margin-left: -0.75rem;
}

/* Article Content Styling */
.article-content h2 {
  margin: 2.5rem 0 1rem 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
}

.article-content h3 {
  margin: 2rem 0 0.75rem 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: #2a2a2a;
  line-height: 1.4;
}

.article-content h2:first-child {
  margin-top: 0;
}

.article-content p {
  margin: 1rem 0;
  line-height: 1.7;
  color: #333;
}

.article-content strong {
  font-weight: 600;
  color: #1a1a1a;
}

.article-content a {
  color: #0066cc;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 102, 204, 0.3);
  transition: border-color 0.2s;
}

.article-content a:hover {
  border-bottom-color: #0066cc;
}

/* Article Sources */
.article-sources {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e1e4e8;
}

.article-sources h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

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

.source-item {
  margin: 0.75rem 0;
  padding-left: 2rem;
  position: relative;
  line-height: 1.6;
}

.source-item::before {
  content: "[" counter(list-item) "]";
  position: absolute;
  left: 0;
  font-weight: 600;
  color: #666;
  font-size: 0.9em;
}

.source-item a {
  color: #0066cc;
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 102, 204, 0.2);
}

.source-item a:hover {
  border-bottom-color: #0066cc;
}

.source-date {
  color: #777;
  font-size: 0.85em;
  font-style: italic;
}

/* Heading Anchor Links */
h2[id], h3[id] {
  scroll-margin-top: 100px;
}

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

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

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

.sticky-toc::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .article-sidebar {
    flex: 0 0 240px;
  }
  
  .sticky-toc {
    padding: 1.25rem;
  }
}

@media (max-width: 768px) {
  .article-layout {
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .article-sidebar {
    order: 1; /* Move sidebar below content on mobile */
    flex: 1;
  }
  
  .sticky-toc {
    position: static;
    max-height: none;
  }
  
  .article-content h2 {
    font-size: 1.5rem;
  }
  
  .article-content h3 {
    font-size: 1.2rem;
  }
}

/* Print Styles */
@media print {
  .article-sidebar {
    display: none;
  }
  
  .article-content {
    max-width: 100%;
  }
}

.article-sidebar {
  align-self: flex-start;
}

.sticky-toc {
  position: sticky;
  top: 400px; /* Distance from top when scrolling */
  margin-top: 0; /* Remove extra space at start */
}

.source-ref {
  font-size: 0.75em;
  margin-left: 2px;
}

.source-ref a {
  color: #0066cc;
  text-decoration: none;
  border: none;
}

.source-ref a:hover {
  text-decoration: underline;
}

.sources-list {
  list-style: none !important;
  counter-reset: source-counter;
  padding-left: 0 !important;
  margin-left: 0 !important;
}

.source-item {
  padding-left: 2rem;
  position: relative;
  list-style-type: none !important;
}

.source-item::before {
  content: "[" counter(source-counter) "]";
  counter-increment: source-counter;
  position: absolute;
  left: 0;
  font-weight: 600;
  color: #666;
}

.table-of-contents ul,
.table-of-contents .toc-list,
.table-of-contents .toc-nested {
  list-style: none !important;
  list-style-type: none !important;
  padding-left: 0 !important;
  margin-left: 0 !important;
}

.table-of-contents .toc-nested {
  padding-left: 1rem !important;
}

.table-of-contents li {
  list-style: none !important;
  list-style-type: none !important;
}

/* Chart Styling */
.chart-container {
  margin: 2rem 0;
  text-align: center;
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #e1e4e8;
}

.chart-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.chart-caption {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #666;
  font-style: italic;
}

@media (max-width: 768px) {
  .chart-container {
    padding: 1rem;
  }
}