/* =========================================
   3-COLUMN BLOG LAYOUT (ToC + Main + Sidebar)
========================================= */

.blog-layout-container {
  width: min(1900px, calc(100vw - 40px));
  max-width: none;
  margin: 40px auto;
  padding: 0 clamp(10px, 1.4vw, 24px);
  display: grid;
  grid-template-columns: clamp(230px, 15vw, 300px) minmax(0, 1fr) clamp(260px, 18vw, 360px);
  gap: clamp(18px, 2vw, 40px);
  align-items: start;
}

/* --- Left Sidebar: Table of Contents --- */
.toc-sidebar {
  position: sticky;
  top: 20px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  margin-bottom: 10px;
}

.toc-header h3 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: block; /* Toggled by JS */
}

.toc-list li {
  margin-bottom: 10px;
}

.toc-list a {
  text-decoration: none;
  color: #475569;
  font-size: 14px;
  transition: color 0.2s;
}

.toc-list a:hover {
  color: #3b82f6;
  font-weight: bold;
}

/* --- Center Column: Main Content --- */
.main-blog-content {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: clamp(26px, 2.5vw, 50px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  line-height: 1.8;
  color: #334155;
}

.main-blog-content h2,
.main-blog-content h3 {
  color: #0f172a;
  scroll-margin-top: 30px; /* Prevents sticky header from covering titles */
}

.main-blog-content img {
  width: 100%;
  border-radius: 8px;
  margin: 30px 0;
  border: 1px solid #e2e8f0;
}

/* --- Right Sidebar: Related Content --- */
.right-sidebar {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.related-widget,
.help-widget {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.related-widget h3 {
  margin-top: 0;
  font-size: 16px;
  color: #0f172a;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 10px;
}

.related-link {
  display: block;
  text-decoration: none;
  color: #3b82f6;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
}

.related-link span {
  display: block;
  color: #64748b;
  font-weight: normal;
  font-size: 12px;
  margin-top: 2px;
}

.related-link:hover {
  text-decoration: underline;
}

.help-widget {
  background: #e0e7ff;
  border-color: #4f46e5;
  text-align: center;
}

.help-widget h3 {
  color: #4f46e5;
  margin-top: 0;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 1100px) {
  .blog-layout-container {
    width: min(1600px, calc(100vw - 28px));
    grid-template-columns: minmax(0, 1fr) clamp(240px, 32vw, 320px);
  }
  .toc-sidebar {
    display: none; /* Hide ToC on medium screens to save space */
  }
}

@media (max-width: 800px) {
  .blog-layout-container {
    grid-template-columns: 1fr;
  }
  .toc-sidebar {
    display: block;
    position: relative;
    top: 0;
  }
  .main-blog-content {
    padding: 30px 20px;
  }
}
