/* blog-post.css: styles for post detail + Markdown output */

.post-hero {
  background: linear-gradient(120deg, #f5f8ff, #fff7f1);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.post-hero-inner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2rem;
  align-items: center;
}

.post-category {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(13, 110, 253, 0.1);
  color: #1d4ed8;
  font-weight: 600;
  font-size: 0.8rem;
}

.post-title {
  margin: 0.75rem 0;
  font-size: 2.4rem;
  font-weight: 700;
  color: #0f172a;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  color: #64748b;
  font-size: 0.9rem;
}

.post-hero-media {
  text-align: center;
}

.post-cover {
  width: 100%;
  max-width: 420px;
  border-radius: 18px;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.15);
  object-fit: cover;
}

.post-content {
  font-size: 1.05rem;
  color: #1f2937;
  line-height: 1.75;
  overflow-x: hidden;
}

.post-body {
  max-width: 860px;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

.post-toc-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
}

.post-body-container {
  margin-left: 0;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

.post-main {
  padding-right: 2rem;
}

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

.ad-slot {
  border: 1px dashed #cbd5f5;
  border-radius: 16px;
  background: #f8fafc;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ad-slot-label {
  font-weight: 600;
}

.related-posts {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
}

.related-posts-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 1.5rem;
}

.related-list {
  background: #ffffff;
}

.related-item {
  border-bottom: 1px solid #e9ecef;
  padding: 1rem 0;
}

.related-item:last-child {
  border-bottom: none;
}

.related-item-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.related-item-link:hover {
  color: #0d6efd;
}

.related-item-title {
  color: #1a1a1a;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  transition: color 0.2s ease;
}

.related-item-link:hover .related-item-title {
  color: #0d6efd;
}

.related-item-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #6c757d;
  font-size: 0.875rem;
}

.markdown-content h1 {
  font-size: 2rem;
  margin-top: 2rem;
}

.markdown-content h2 {
  font-size: 1.75rem;
  margin-top: 2rem;
}

.markdown-content h3 {
  font-size: 1.35rem;
  margin-top: 1.5rem;
}

.markdown-content p {
  margin: 0 0 1rem;
}

.markdown-content blockquote {
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  color: #475569;
}

.markdown-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 12px;
  overflow-x: auto;
  max-width: 100%;
}

.markdown-content pre code {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

.markdown-content code {
  font-family: "Courier New", monospace;
  word-break: break-all;
}

.markdown-content ul,
.markdown-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-content img {
  max-width: 100%;
  border-radius: 12px;
  margin: 1rem 0;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid #e2e8f0;
  padding: 0.6rem;
  text-align: left;
}

@media (max-width: 767.98px) {
  .post-title {
    font-size: 1.8rem;
  }

  .related-posts-title {
    font-size: 1.35rem;
  }

  .post-body-container {
    padding-left: 1rem;
    padding-right: 1rem;
    overflow-x: hidden;
  }

  .post-main {
    padding-right: 0;
  }

  .post-body {
    max-width: 100%;
  }

  .markdown-content pre {
    font-size: 0.85rem;
    padding: 0.75rem;
    border-radius: 8px;
  }

  .markdown-content blockquote {
    padding: 0.75rem 1rem;
    margin-left: 0;
    margin-right: 0;
  }

  .markdown-content h1 { font-size: 1.5rem; }
  .markdown-content h2 { font-size: 1.35rem; }
  .markdown-content h3 { font-size: 1.15rem; }
}

@media (min-width: 992px) {
  .post-sidebar {
    position: sticky;
    top: 1.5rem;
  }
}

/* Table of Contents */
.post-toc {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid #e2e8f0;
  border-left: 4px solid #1d4ed8;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.toc-title {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toc-title::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  background: #1d4ed8;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cline x1='8' y1='6' x2='21' y2='6'/%3E%3Cline x1='8' y1='12' x2='21' y2='12'/%3E%3Cline x1='8' y1='18' x2='21' y2='18'/%3E%3Cline x1='3' y1='6' x2='3.01' y2='6'/%3E%3Cline x1='3' y1='12' x2='3.01' y2='12'/%3E%3Cline x1='3' y1='18' x2='3.01' y2='18'/%3E%3C/svg%3E");
  mask-size: contain;
  -webkit-mask-size: contain;
  flex-shrink: 0;
}

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

.toc-list > li {
  counter-increment: toc-counter;
  margin: 0;
  padding: 0;
}

.toc-list > li > a::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  margin-right: 0.6rem;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}

.toc-list > li:hover > a::before {
  color: #1d4ed8;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  color: #334155;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.4;
  display: block;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.toc-list a:hover {
  color: #1d4ed8;
  background: rgba(29, 78, 216, 0.06);
}

.toc-list ul {
  list-style: none;
  padding-left: 1.5rem;
  margin: 0;
  border-left: 2px solid #e2e8f0;
  margin-left: 0.65rem;
}

.toc-list ul a {
  font-weight: 400;
  font-size: 0.84rem;
  color: #64748b;
}

.toc-list ul a:hover {
  color: #1d4ed8;
}

/* Smooth scroll for anchor links */
html {
  scroll-behavior: smooth;
}

/* Offset for sticky navbar when jumping to anchors */
.post-body h2[id],
.post-body h3[id],
.post-body h4[id] {
  scroll-margin-top: 80px;
}

/* Active TOC link */
.toc-list a.toc-active {
  color: #1d4ed8;
  background: rgba(29, 78, 216, 0.08);
  font-weight: 600;
}
