/* ── Blog CSS ─────────────────────────────────────────────────────── */

/* ── Blog header ─────────────────────────────────────────────────── */
.blog-header {
  background: linear-gradient(135deg, #F8FAFF 0%, #EEF2FF 100%);
  border-bottom: 1px solid var(--border);
  padding: 80px 0 56px;
}
.blog-header-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  flex-wrap: wrap;
}
.blog-header-text .section-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-500);
  background: rgba(124,58,237,0.08);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 16px;
}
.blog-header-text h1 {
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--navy-900);
  margin: 0 0 12px;
  line-height: 1.15;
}
.blog-header-text p {
  font-size: 1.05rem;
  color: var(--text-mid);
  max-width: 520px;
  margin: 0;
}
.blog-search-wrap { flex-shrink: 0; min-width: 280px; }
.blog-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.blog-search-btn {
  position: absolute;
  left: 10px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--text-lo);
}
.blog-search-btn:hover { color: var(--brand-500); }
.blog-search-icon {
  width: 18px;
  height: 18px;
}
.blog-search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.95rem;
  color: var(--navy-900);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.blog-search-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.blog-search-input::placeholder { color: var(--text-lo); }

/* ── Category bar ────────────────────────────────────────────────── */
.blog-cat-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 64px;
  z-index: 40;
}
.cat-nav-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cat-nav {
  display: flex;
  gap: 4px;
  padding: 10px 0;
  white-space: nowrap;
}
.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-mid);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.cat-btn:hover { border-color: var(--brand-500); color: var(--brand-500); background: rgba(124,58,237,0.05); }
.cat-btn--active { border-color: var(--brand-500); background: var(--brand-500); color: #fff; }
.cat-btn--active:hover { background: var(--brand-600, #6d28d9); border-color: var(--brand-600, #6d28d9); }
.cat-count {
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.75rem;
}
.cat-btn--active .cat-count { background: rgba(255,255,255,0.2); }

/* ── Blog main ───────────────────────────────────────────────────── */
.blog-main { padding: 56px 0 80px; }
.blog-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.posts-count { font-size: 0.875rem; color: var(--text-lo); font-weight: 500; }

.blog-error-banner {
  background: #fff0f0;
  border: 1.5px solid #fca5a5;
  color: #b91c1c;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

/* ── Posts grid ──────────────────────────────────────────────────── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 28px;
  margin-bottom: 48px;
}

/* ── Post card ───────────────────────────────────────────────────── */
.post-card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .2s, box-shadow .2s;
}
.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(15,23,41,0.1);
}
.post-card-image-wrap { display: block; overflow: hidden; aspect-ratio: 16/9; }
.post-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.post-card:hover .post-card-image { transform: scale(1.03); }
.post-card-image--placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--bg-2) 0%, #DDE5FF 100%);
}
.post-card-body { padding: 24px; display: flex; flex-direction: column; flex: 1; }
.post-card-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.post-cat-badge {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--brand-500);
  background: rgba(124,58,237,0.08);
  border-radius: 999px;
  padding: 3px 10px;
  text-decoration: none;
  transition: background .15s;
}
.post-cat-badge:hover { background: rgba(124,58,237,0.15); }
.post-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 10px;
  color: var(--navy-900);
}
.post-card-title a { text-decoration: none; color: inherit; }
.post-card-title a:hover { color: var(--brand-500); }
.post-card-excerpt {
  font-size: 0.875rem;
  color: var(--text-mid);
  line-height: 1.6;
  margin: 0 0 16px;
  flex: 1;
}
.post-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-lo);
  flex-wrap: wrap;
}
.post-meta-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.post-meta-avatar--fallback {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-500);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.post-meta-dot { opacity: 0.4; }
.post-meta-author { font-weight: 600; color: var(--navy-900); }

/* ── Blog empty ──────────────────────────────────────────────────── */
.blog-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 0;
  color: var(--text-lo);
}

/* ── Skeletons ───────────────────────────────────────────────────── */
.post-card--skeleton { pointer-events: none; }
.sk {
  border-radius: 8px;
  background: linear-gradient(90deg, #EEF2FF 25%, #DDE5FF 50%, #EEF2FF 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 100% 0 }
  100% { background-position: -100% 0 }
}
.sk-img { aspect-ratio: 16/9; border-radius: 0; }
.post-card--skeleton .post-card-body { gap: 10px; }
.sk-badge  { height: 20px; width: 80px; }
.sk-title  { height: 22px; width: 90%; }
.sk-text   { height: 14px; width: 100%; }
.sk-text--short { width: 70%; }
.sk-meta   { height: 18px; width: 60%; }

/* ── Pagination ──────────────────────────────────────────────────── */
.blog-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 0;
}
.pg-pages { display: flex; gap: 4px; }
.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--navy-900);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s;
}
.pg-btn:hover { border-color: var(--brand-500); color: var(--brand-500); }
.pg-btn--active { border-color: var(--brand-500); background: var(--brand-500); color: #fff; }
.pg-btn--disabled { opacity: 0.4; pointer-events: none; }
.pg-ellipsis { display: flex; align-items: center; justify-content: center; width: 32px; color: var(--text-lo); }

/* ═══════════════════════════════════════════════════════════════════
   Single post
═══════════════════════════════════════════════════════════════════ */

/* Hidden by default; JS (.style.display='') or SSR (.ssr-ready) reveals it */
#blog-post { display: none; }
#blog-post.ssr-ready { display: block; }

/* ── Hero ────────────────────────────────────────────────────────── */
.post-hero {
  width: 100%;
  height: 420px;
  background: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
  background-size: cover;
  background-position: center;
  position: relative;
}
.post-hero--loaded { background-color: transparent; }
.post-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 30%, rgba(15,23,41,0.6) 100%);
}

/* ── Post header ─────────────────────────────────────────────────── */
.post-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 40px 0;
}
.post-header .breadcrumb,
.post-header .post-cats,
.post-header .post-title,
.post-header .post-meta-bar {
  text-align: left;
  margin-left: 0;
  margin-right: auto;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-lo);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-mid); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand-500); }
.post-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.post-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--navy-900);
  line-height: 1.2;
  margin: 0 0 20px;
}
.post-meta-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: var(--text-mid);
  flex-wrap: wrap;
}

/* ── Post layout ─────────────────────────────────────────────────── */
.post-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 48px;
  padding-top: 56px;
  padding-bottom: 80px;
  align-items: start;
}
@media (max-width: 900px) {
  .post-layout { grid-template-columns: 1fr; }
  .post-sidebar { display: none; }
}

/* ── Prose (post content) ────────────────────────────────────────── */
.prose {
  color: var(--navy-900);
  font-size: 1.05rem;
  line-height: 1.8;
  max-width: 740px;
}
.prose h1, .prose h2, .prose h3, .prose h4 {
  color: var(--navy-900);
  font-weight: 700;
  line-height: 1.25;
  margin: 2em 0 0.75em;
}
.prose h2 { font-size: 1.55rem; }
.prose h3 { font-size: 1.25rem; }
.prose h4 { font-size: 1.05rem; }
.prose p { margin: 0 0 1.25em; }
.prose a { color: var(--brand-500); text-decoration: underline; }
.prose a:hover { color: var(--brand-600, #6d28d9); }
.prose strong { font-weight: 700; }
.prose em { font-style: italic; }
.prose ul, .prose ol { margin: 0 0 1.25em 1.5em; }
.prose li { margin-bottom: 0.5em; }
.prose blockquote {
  border-left: 4px solid var(--brand-500);
  padding: 12px 20px;
  margin: 1.5em 0;
  color: var(--text-mid);
  font-style: italic;
  background: var(--bg-2);
  border-radius: 0 8px 8px 0;
}
.prose pre {
  background: #1e1b4b;
  color: #c4b5fd;
  border-radius: 12px;
  padding: 20px 24px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.7;
  margin: 1.5em 0;
}
.prose code {
  background: var(--bg-2);
  color: var(--brand-500);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 0.88em;
  font-family: 'JetBrains Mono', monospace;
}
.prose pre code { background: none; color: inherit; padding: 0; border-radius: 0; font-size: inherit; }
.prose img {
  max-width: 100%;
  border-radius: 12px;
  margin: 1.5em 0;
  display: block;
}
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 0.92rem; }
.prose th, .prose td { padding: 10px 14px; border: 1px solid var(--border); }
.prose th { background: var(--bg-2); font-weight: 600; text-align: left; }
.prose figure { margin: 1.5em 0; }
.prose figcaption { font-size: 0.82rem; color: var(--text-lo); text-align: center; margin-top: 8px; }

/* ── Post tags ───────────────────────────────────────────────────── */
.post-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.tags-label { font-size: 0.8rem; font-weight: 600; color: var(--text-lo); text-transform: uppercase; letter-spacing: 0.05em; }
.tag-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-mid);
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  text-decoration: none;
  transition: all .15s;
}
.tag-badge:hover { border-color: var(--brand-500); color: var(--brand-500); }

/* ── Author card ─────────────────────────────────────────────────── */
.post-author-section { margin-top: 48px; }
.author-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.author-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.author-card-avatar--fallback {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-500);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.author-card-name { font-weight: 700; font-size: 1rem; color: var(--navy-900); margin: 0 0 4px; }
.author-card-desc { font-size: 0.88rem; color: var(--text-mid); margin: 0; }

/* ── Comments ────────────────────────────────────────────────────── */
.comments-section {
  margin-top: 56px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
.comments-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 28px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.comments-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-mid);
}
.comments-loading { color: var(--text-lo); font-size: 0.9rem; padding: 20px 0; }
.comments-empty { color: var(--text-lo); font-size: 0.95rem; }
.comments-list { display: flex; flex-direction: column; gap: 20px; }
.comment-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.comment-item--reply {
  margin-left: 48px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}
.comment-avatar { flex-shrink: 0; }
.comment-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.comment-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-500);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.comment-body { flex: 1; }
.comment-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.comment-author { font-weight: 700; font-size: 0.9rem; color: var(--navy-900); }
.comment-date { font-size: 0.78rem; color: var(--text-lo); }
.comment-content { font-size: 0.92rem; color: var(--text-mid); line-height: 1.65; }
.comment-content p { margin: 0 0 0.5em; }
.comment-reply-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brand-500);
  padding: 4px 0;
  margin-top: 6px;
  display: block;
}
.comment-reply-btn:hover { text-decoration: underline; }

/* ── Comment form ────────────────────────────────────────────────── */
.comment-form-section {
  margin-top: 48px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}
.comment-form-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 20px;
}
.reply-note {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(124,58,237,0.07);
  border: 1.5px solid rgba(124,58,237,0.2);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.88rem;
  color: var(--brand-500);
  margin-bottom: 16px;
  font-weight: 500;
}
.cancel-reply-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-lo);
  text-decoration: underline;
  padding: 0;
}
.moderation-note {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.form-success {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #15803d;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.comment-form .form-error {
  background: #fff0f0;
  border: 1.5px solid #fca5a5;
  color: #b91c1c;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 16px;
}
.comment-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 600px) { .comment-form .form-row { grid-template-columns: 1fr; } }
.comment-form .form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.comment-form label { font-size: 0.875rem; font-weight: 600; color: var(--navy-900); }
.required { color: var(--brand-500); }
.comment-form .form-input,
.comment-form .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 0.95rem;
  color: var(--navy-900);
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}
.comment-form .form-input:focus,
.comment-form .form-textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.comment-form .form-textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: 0.78rem; color: var(--text-lo); margin: 4px 0 0; }
.form-actions { display: flex; align-items: center; gap: 16px; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.post-sidebar { position: sticky; top: 100px; }
.post-sidebar-inner { display: flex; flex-direction: column; gap: 20px; }
.sidebar-widget {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.sidebar-widget-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-lo);
  margin: 0 0 12px;
}
.sidebar-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy-900);
  text-decoration: none;
  transition: color .15s;
}
.sidebar-back-link:hover { color: var(--brand-500); }
.sidebar-widget-text { font-size: 0.85rem; color: var(--text-mid); margin: 0 0 14px; line-height: 1.6; }
.sidebar-cta { display: block; text-align: center; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .blog-header { padding: 56px 0 40px; }
  .blog-header-inner { flex-direction: column; align-items: flex-start; }
  .blog-search-wrap { width: 100%; min-width: unset; }
  .posts-grid { grid-template-columns: 1fr; }
  .post-hero { height: 260px; }
  .post-layout { padding-top: 40px; }
}
