/* ============================================
   BLOG STYLES — Full markdown rendering
   Scrollable with particle scroll indicator,
   KaTeX, Mermaid, highlight.js integration
   ============================================ */

/* ── Blog Page Container ── */
.blog-page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  z-index: 10;
  pointer-events: auto;
  background-color: var(--bg-primary);
  transition: background-color 0.4s ease, opacity 0.5s ease;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.blog-page::-webkit-scrollbar { display: none; }

/* Top/bottom edge gradients on blog page */
.blog-page::before,
.blog-page::after {
  content: '';
  position: sticky;
  display: block;
  left: 0;
  right: 0;
  height: 30px;
  pointer-events: none;
  z-index: 20;
  flex-shrink: 0;
}
.blog-page::before {
  top: 0;
  background-color: var(--bg-primary);
  -webkit-mask-image: linear-gradient(to bottom, black, transparent);
  mask-image: linear-gradient(to bottom, black, transparent);
  transition: background-color 0.4s ease;
}
.blog-page::after {
  bottom: 0;
  background-color: var(--bg-primary);
  -webkit-mask-image: linear-gradient(to top, black, transparent);
  mask-image: linear-gradient(to top, black, transparent);
  transition: background-color 0.4s ease;
}

/* ── Blog content fade-in ── */
.blog-content-fadein {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.blog-content-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Header ── */
.blog-header {
  text-align: center;
  padding: var(--sp-lg) var(--sp-2xl) var(--sp-md);
}
.blog-title {
  font-family: var(--font-mono);
  font-size: var(--ts-lg);
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-xs);
  line-height: 1.3;
}
.blog-summary {
  font-family: var(--font-mono);
  font-size: var(--ts-xs);
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  line-height: 1.5;
}
.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: var(--sp-xs);
}

/* ── Body — opaque content ── */
.blog-body {
  padding: var(--sp-md) 12%;
  color: var(--text-secondary);
  transition: color 0.4s ease;
}

/* ── Back Button ── */
.blog-back-wrapper {
  text-align: center;
  padding: var(--sp-xl) var(--sp-lg);
}
.blog-back {
  font-family: var(--font-mono);
  font-size: var(--ts-xs);
  font-weight: 400;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: 0.06em;
  padding: var(--sp-2xs) var(--sp-sm);
  transition: color var(--ease-base);
  pointer-events: auto;
}
.blog-back:hover { color: var(--text-primary); }

/* ─────────────────────────────────────────────
   MARKDOWN TYPOGRAPHY
   ───────────────────────────────────────────── */

.blog-body h1,
.blog-body h2,
.blog-body h3,
.blog-body h4,
.blog-body h5,
.blog-body h6 {
  font-family: var(--font-mono);
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.3;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  letter-spacing: 0.02em;
}
.blog-body h1 { font-size: 1.6rem; }
.blog-body h2 { font-size: 1.3rem; border-bottom: 1px solid var(--c-border); padding-bottom: 0.4em; }
.blog-body h3 { font-size: 1.1rem; }
.blog-body h4 { font-size: 0.95rem; color: var(--text-secondary); }
.blog-body h5 { font-size: 0.85rem; color: var(--text-muted); }
.blog-body h6 { font-size: 0.8rem; color: var(--text-muted); }

.blog-body p {
  font-family: var(--font-mono);
  font-size: var(--ts-sm);
  font-weight: 300;
  line-height: 1.8;
  margin-bottom: 1.2em;
  color: var(--text-secondary);
}

.blog-body a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--text-muted);
  transition: text-decoration-color var(--ease-base);
}
.blog-body a:hover {
  text-decoration-color: var(--text-primary);
}

.blog-body strong {
  color: var(--text-primary);
  font-weight: 600;
}
.blog-body em {
  font-style: italic;
  color: var(--text-secondary);
}

/* ── Lists ── */
.blog-body ul,
.blog-body ol {
  font-family: var(--font-mono);
  font-size: var(--ts-sm);
  font-weight: 300;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 1.2em;
  padding-left: 1.8em;
}
.blog-body li { margin-bottom: 0.4em; }
.blog-body li strong { color: var(--text-primary); }

/* ── Blockquote ── */
.blog-body blockquote {
  border-left: 3px solid var(--text-muted);
  padding: var(--sp-sm) var(--sp-md);
  margin: 1.2em 0;
  background: rgba(128,128,128,0.06);
  border-radius: 0 4px 4px 0;
}
.blog-body blockquote p {
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.4em;
}
.blog-body blockquote p:last-child { margin-bottom: 0; }

/* ── Horizontal Rule ── */
.blog-body hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 2em 0;
  opacity: 0.5;
}

/* ── Images ── */
.blog-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5em auto;
  border-radius: 4px;
  opacity: 0.9;
}

/* ── Tables ── */
.blog-body table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--ts-xs);
  margin: 1.5em 0;
}
.blog-body th {
  text-align: left;
  font-weight: 500;
  color: var(--text-primary);
  padding: var(--sp-xs) var(--sp-sm);
  border-bottom: 2px solid var(--c-border);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.blog-body td {
  padding: var(--sp-xs) var(--sp-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--c-border);
  font-weight: 300;
}
.blog-body tr:last-child td { border-bottom: none; }

/* ─────────────────────────────────────────────
   CODE BLOCKS
   ───────────────────────────────────────────── */
.blog-body pre {
  margin: 1.5em 0;
  border-radius: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.blog-body pre::-webkit-scrollbar { display: none; }

.blog-body pre code {
  display: block;
  padding: var(--sp-md) var(--sp-lg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.7;
  tab-size: 2;
}

/* Override highlight.js background to match theme */
.blog-body pre code.hljs {
  background: rgba(0,0,0,0.35);
  border-radius: 6px;
}
[data-theme="light"] .blog-body pre code.hljs {
  background: rgba(0,0,0,0.06);
}

/* Inline code */
.blog-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(128,128,128,0.15);
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────
   KATEX FORMULAS
   ───────────────────────────────────────────── */
.blog-body .katex-display {
  margin: 1.5em 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.blog-body .katex-display::-webkit-scrollbar { display: none; }

.blog-body .katex { color: var(--text-primary); }

/* ─────────────────────────────────────────────
   MERMAID DIAGRAMS
   ───────────────────────────────────────────── */
.blog-mermaid {
  display: flex;
  justify-content: center;
  margin: 1.5em 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.blog-mermaid::-webkit-scrollbar { display: none; }
.blog-mermaid svg {
  max-width: 100%;
  height: auto;
}
