/* ═══════════════════════════════════════════════════════════
   blog.css — Blog listing & post article styles
   Loaded alongside style.css on blog pages only
   ═══════════════════════════════════════════════════════════ */

/* ── Blog container (listing page) ─────────────────────── */

/* Pure white background for blog pages */
body {
  background: #ffffff !important;
}

[data-theme="dark"] body {
  background: #0d0d0f !important;
}

.blog-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.blog-header {
  margin-bottom: 3rem;
}

.blog-back-link {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  text-decoration: none;
  transition: color 0.2s;
}
.blog-back-link:hover {
  color: var(--accent, #4a9eff);
}

.blog-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0.5rem 0 0;
  letter-spacing: -0.02em;
}

/* ── Post list ─────────────────────────────────────────── */
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list-item {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border, rgba(128,128,128,0.15));
}
.post-list-item:first-child {
  border-top: 1px solid var(--border, rgba(128,128,128,0.15));
}

.post-date {
  flex-shrink: 0;
  width: 100px;
  font-size: 0.82rem;
  color: var(--text-muted, #888);
  padding-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.post-list-body {
  flex: 1;
  min-width: 0;
}

.post-list-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  text-decoration: none;
  line-height: 1.4;
  transition: color 0.2s;
}
.post-list-title:hover {
  color: var(--accent, #4a9eff);
}

.post-list-desc {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  margin: 0.35rem 0 0;
  line-height: 1.5;
}

.post-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.post-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: var(--tag-bg, rgba(128,128,128,0.12));
  color: var(--text-muted, #888);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.post-empty {
  color: var(--text-muted, #888);
  font-style: italic;
  padding: 2rem 0;
}

/* ── Article container (single post page) ──────────────── */
.post-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.post-back-link {
  font-size: 0.85rem;
  color: var(--text-muted, #888);
  text-decoration: none;
  transition: color 0.2s;
}
.post-back-link:hover {
  color: var(--accent, #4a9eff);
}

/* ── Post header ───────────────────────────────────────── */
.post-header {
  margin: 1.5rem 0 2.5rem;
}

.post-header-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.post-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 0 0 1rem;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted, #888);
}

.post-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.post-author {
  font-weight: 600;
  color: var(--text, #e0e0e0);
}

.post-meta-sep {
  color: var(--text-muted, #888);
  opacity: 0.5;
}

/* ── Post body — long-form typography ──────────────────── */
.post-body {
  line-height: 1.75;
  font-size: 1rem;
  color: var(--text, #e0e0e0);
}

.post-body h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border, rgba(128,128,128,0.15));
  letter-spacing: -0.01em;
}

.post-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.post-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

.post-body p {
  margin: 0 0 1.25rem;
}

.post-body a {
  color: var(--accent, #4a9eff);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.post-body a:hover {
  opacity: 0.8;
}

.post-body strong {
  font-weight: 700;
  color: var(--text-strong, inherit);
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
  margin: 0 0 1.25rem;
}

.post-body li {
  margin-bottom: 0.4rem;
}

.post-body blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid var(--accent, #4a9eff);
  background: var(--tag-bg, rgba(128,128,128,0.08));
  border-radius: 0 4px 4px 0;
  color: var(--text-muted, #aaa);
  font-size: 0.95rem;
}
.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border, rgba(128,128,128,0.15));
  margin: 2.5rem 0;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1.5rem 0;
}

/* ── Code blocks ───────────────────────────────────────── */
.post-body code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Consolas', monospace;
  font-size: 0.85em;
}

/* Inline code */
.post-body p code,
.post-body li code,
.post-body td code {
  padding: 0.15em 0.4em;
  border-radius: 3px;
  background: var(--code-inline-bg, rgba(128,128,128,0.15));
  color: var(--code-inline-text, #f0a);
  font-size: 0.85em;
  word-break: break-word;
}

/* Fenced code blocks */
.post-body pre {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  background: var(--code-bg, #1a1a2e);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  border: 1px solid var(--border, rgba(128,128,128,0.15));
}
.post-body pre code {
  padding: 0;
  background: none;
  color: var(--code-text, #e0e0e0);
  font-size: inherit;
  border-radius: 0;
}

/* ── Post footer ───────────────────────────────────────── */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border, rgba(128,128,128,0.15));
}

/* ═══════════════════════════════════════════════════════════
   TOC sidebar (post pages)
   Mirrors the CV page's .toc / .page-body pattern
   ═══════════════════════════════════════════════════════════ */

.post-page-body {
  display: flex;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
  gap: 2rem;
}

/* ── Sticky sidebar ────────────────────────────────────── */
.post-toc {
  position: sticky;
  top: 2rem;
  align-self: flex-start;
  flex-shrink: 0;
  width: 200px;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding-right: 1rem;
  border-right: 1px solid var(--border, rgba(128,128,128,0.15));
}

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

.post-toc li {
  margin-bottom: 0.15rem;
}

.post-toc-link {
  display: block;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted, #888);
  text-decoration: none;
  border-radius: 3px;
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.post-toc-link:hover {
  color: var(--text, #e0e0e0);
  background: var(--tag-bg, rgba(128,128,128,0.08));
}

.post-toc-link.active {
  color: var(--accent, #4a9eff);
  border-left-color: var(--accent, #4a9eff);
  background: var(--tag-bg, rgba(128,128,128,0.08));
}

/* Indent h3 entries */
.post-toc-h3 .post-toc-link {
  padding-left: 1.1rem;
  font-size: 0.74rem;
}

/* ── Article main (right of TOC) ───────────────────────── */
.post-main {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  padding-bottom: 4rem;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .post-page-body {
    flex-direction: column;
    max-width: 720px;
  }
  .post-toc {
    position: static;
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border, rgba(128,128,128,0.15));
    padding: 0 0 0.75rem;
    margin-bottom: 1rem;
  }
  .post-toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
  }
  .post-toc li {
    margin-bottom: 0;
  }
  .post-toc-link {
    border-left: none;
    padding: 0.25rem 0.5rem;
  }
  .post-toc-link.active {
    border-left: none;
    background: var(--tag-bg, rgba(128,128,128,0.12));
  }
  .post-toc-h3 .post-toc-link {
    padding-left: 0.5rem;
  }
}

@media (max-width: 640px) {
  .blog-container,
  .post-container {
    padding: 1.5rem 1rem 3rem;
  }

  .post-list-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .post-date {
    width: auto;
  }

  .post-title {
    font-size: 1.6rem;
  }

  .post-body pre {
    font-size: 0.78rem;
    padding: 0.75rem 1rem;
  }
}

/* ── Fade-in on blog pages ─────────────────────────────── */
.top-controls,
.blog-container,
.post-container,
.post-page-body {
  opacity: 0;
  animation: fadeInUp 0.8s ease forwards;
}

.top-controls {
  animation-delay: 0s;
}

.blog-container,
.post-container {
  animation-delay: 0.15s;
}

.post-page-body {
  animation-delay: 0.3s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   Tables
   ============================================================ */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.88rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-body th,
.post-body td {
  padding: 0.65rem 0.95rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.post-body th {
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  border-bottom: 2px solid var(--border);
}

.post-body tr:last-child td {
  border-bottom: none;
}

.post-body tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

/* Code inside table cells — keep it readable, no huge padding */
.post-body td code,
.post-body th code {
  font-size: 0.82rem;
  padding: 0.1rem 0.35rem;
}

/* Horizontal scroll on narrow viewports */
@media (max-width: 640px) {
  .post-body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}