/* ==================== BLOG HERO ==================== */
.blog-hero {
  padding-block: calc(var(--nav-h) + var(--s-9)) var(--s-8);
  background: radial-gradient(ellipse 900px 500px at 15% 0%, rgba(212, 175, 55, 0.08), transparent 60%), var(--ink-black);
  border-bottom: 1px solid rgba(232, 227, 217, 0.08);
}

.blog-hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-7);
}

.blog-hero .section-head {
  margin-bottom: 0;
  max-width: 620px;
}

/* H1 mặc định (--fs-display-xl, tới 6.4rem) quá to khi đứng cạnh ảnh minh
   họa bên phải — thu về mức vừa cân đối 2 cột, vẫn giữ vai trò H1 lớn nhất
   trang. */
.blog-hero .section-head h1 {
  font-size: clamp(2.4rem, 2rem + 2vw, 3.6rem);
}

.blog-hero-gif {
  flex: none;
  width: clamp(340px, 38vw, 560px);
  height: auto;
  aspect-ratio: 692 / 388;
  object-fit: contain;
  /* File .webp đã được tách nền giấy (lumakey) ra alpha trong suốt từ
     .gif gốc — rồng mực "bay" thẳng trên nền .blog-hero, không cần khung. */
}

@media (max-width: 860px) {
  .blog-hero-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .blog-hero-gif {
    width: clamp(240px, 72vw, 380px);
    align-self: center;
  }
}

/* ==================== POST GRID (listing) ==================== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-6);
}

@media (max-width: 1024px) {
  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .post-grid {
    grid-template-columns: 1fr;
  }
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  text-decoration: none;
  padding: var(--s-6);
  overflow: hidden;
}

.post-card-tag {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--vermilion-bright);
  background: rgba(127, 29, 29, 0.16);
  border: 1px solid rgba(127, 29, 29, 0.35);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
}

.post-card h3 {
  font-size: 1.35rem;
  line-height: 1.35;
}

.post-card p {
  color: var(--ceramic-ivory-dim);
  font-size: var(--fs-small);
  max-width: none;
  flex: 1;
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-size: 0.78rem;
  color: var(--muted);
  padding-top: var(--s-2);
  border-top: 1px solid rgba(232, 227, 217, 0.1);
}

.post-card-meta .dot::before {
  content: "·";
  margin-right: var(--s-3);
}

/* Ảnh đại diện — tranh thủy mặc cổ điển (public domain, Walters/Met/Europeana),
   phân bổ ngẫu nhiên cho từng bài để đỡ đơn điệu, thay vì mảng đen trơn. */
.post-card-thumb {
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  margin: calc(var(--s-6) * -1) calc(var(--s-6) * -1) 0;
  width: calc(100% + var(--s-6) * 2);
  filter: sepia(0.15) saturate(0.85);
  opacity: 0.88;
}

/* ==================== SINGLE POST LAYOUT ==================== */
.post-header {
  padding-block: calc(var(--nav-h) + var(--s-8)) var(--s-7);
  border-bottom: 1px solid rgba(232, 227, 217, 0.08);
}

.post-header .container {
  max-width: var(--content-narrow);
}

.post-header h1 {
  margin-top: var(--s-4);
  font-size: clamp(1.9rem, 1.6rem + 1.8vw, 3rem);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-5);
  font-size: var(--fs-small);
  color: var(--ceramic-ivory-dim);
}

.post-meta .dot::before {
  content: "·";
  margin-right: var(--s-3);
  color: var(--muted);
}

.post-header-thumb {
  width: 100%;
  max-height: 380px;
  object-fit: cover;
  border-radius: var(--r-lg);
  margin-top: var(--s-6);
  border: 1px solid var(--ink-glass-border);
  filter: sepia(0.12) saturate(0.9);
}

/* 3 cột trên desktop rộng: mục lục bám trái | nội dung | sidebar bám phải.
   Dưới 1200px mục lục rail ẩn đi, thay bằng hộp mục lục đầu bài (xem
   .post-toc-inline) để tránh 3 cột chật chội trên tablet. */
.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--s-9);
  align-items: start;
}

@media (min-width: 1200px) {
  .post-layout {
    grid-template-columns: 200px minmax(0, 1fr) 320px;
  }
}

@media (max-width: 960px) {
  .post-layout {
    grid-template-columns: 1fr;
  }
}

.post-body {
  min-width: 0;
}

/* Mục lục rail — bám (sticky) theo lề trái khi cuộn, chỉ hiện ≥1200px. */
.post-toc-rail {
  display: none;
}

@media (min-width: 1200px) {
  .post-toc-rail {
    display: block;
    position: sticky;
    top: calc(var(--nav-h) + var(--s-6));
    align-self: start;
  }

  .post-toc-rail .post-toc-title {
    font-size: 0.95rem;
  }

  .post-toc-rail ol {
    gap: var(--s-3);
  }

  .post-toc-rail a {
    font-size: 0.8rem;
    border-bottom: none;
    padding: 0;
    line-height: 1.4;
  }

  .post-toc-rail a::before {
    font-size: 0.68rem;
  }

  /* Hộp mục lục đầu bài chỉ dùng làm fallback dưới 1200px — ẩn khi rail hiện. */
  .post-toc-inline {
    display: none;
  }
}

.post-toc-inline {
  margin-bottom: var(--s-8);
}

.post-toc-title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--gold-ink);
  margin-bottom: var(--s-4);
}

.post-toc-rail ol,
.post-toc-inline ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  counter-reset: toc;
}

.post-toc-rail li,
.post-toc-inline li {
  counter-increment: toc;
}

.post-toc-rail a,
.post-toc-inline a {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  color: var(--ceramic-ivory-dim);
  font-size: var(--fs-small);
  border-bottom: 1px dashed rgba(232, 227, 217, 0.14);
  transition: color var(--dur-fast), border-color var(--dur-fast), padding-left var(--dur-base) var(--ease-expo);
}

.post-toc-rail a::before,
.post-toc-inline a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--font-display);
  font-variant-numeric: lining-nums;
  color: var(--gold-ink);
  flex: none;
}

.post-toc-rail a:hover,
.post-toc-rail a:focus-visible,
.post-toc-rail a.is-active,
.post-toc-inline a:hover,
.post-toc-inline a:focus-visible,
.post-toc-inline a.is-active {
  color: var(--gold-ink);
  border-color: var(--gold);
  padding-left: var(--s-2);
}

/* Nội dung bài viết */
.post-content {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--ceramic-ivory);
  max-width: 68ch;
}

.post-content > * + * {
  margin-top: var(--s-6);
}

.post-content h2 {
  font-size: clamp(1.4rem, 1.3rem + 0.6vw, 1.75rem);
  margin-top: var(--s-9);
  scroll-margin-top: calc(var(--nav-h) + var(--s-5));
}

.post-content h3 {
  font-size: 1.25rem;
  margin-top: var(--s-7);
  scroll-margin-top: calc(var(--nav-h) + var(--s-5));
  color: var(--gold-ink);
}

.post-content p,
.post-content li {
  color: var(--ceramic-ivory-dim);
  max-width: none;
}

.post-content ul,
.post-content ol {
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.post-content li::marker {
  color: var(--gold-ink);
}

.post-content strong {
  color: var(--ceramic-ivory);
  font-weight: 600;
}

.post-content blockquote {
  margin: 0;
  padding: var(--s-5) var(--s-6);
  border-left: 2px solid var(--gold);
  background: rgba(212, 175, 55, 0.05);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ceramic-ivory);
}

.post-cta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  margin-top: var(--s-9) !important;
  padding: var(--s-7);
  text-align: center;
}

/* Vòng ensō mực + hoa mai đỏ xoay chậm — cùng ảnh/hiệu ứng với CTA cuối
   trang chủ (cta-final), mang qua đây để CTA cuối mỗi bài blog cũng có
   điểm nhấn thủy mặc dát vàng nhất quán với trang chủ.
   Bug đã sửa: post-cta là card nền SÁNG (ink-card, không có scrim tối như
   cta-final), nếu giữ nguyên opacity/kích thước gốc, vòng hoa che thẳng
   lên chữ khiến tiêu đề gần như không đọc được. Giảm hẳn kích thước +
   độ mờ để chỉ còn là điểm nhấn trang trí phía sau, không cạnh tranh
   với nội dung — cùng tinh thần với .section-bg-image dùng ở nơi khác. */
.post-cta .enso {
  z-index: 0;
  width: min(38vw, 260px);
  opacity: 0.2;
}

.post-cta-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
}

.post-cta h3 {
  margin: 0;
}

.post-cta p {
  color: var(--ceramic-ivory-dim);
  max-width: 46ch;
}

/* ==================== SIDEBAR (related + popular) ==================== */
.post-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  position: sticky;
  top: calc(var(--nav-h) + var(--s-5));
}

.sidebar-block-title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--ceramic-ivory);
  margin-bottom: var(--s-5);
}

.sidebar-block-title .seal-mark {
  width: 22px;
  height: 22px;
  margin-top: 0;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.sidebar-item {
  display: flex;
  gap: var(--s-4);
  text-decoration: none;
  align-items: flex-start;
}

.sidebar-item-rank {
  flex: none;
  font-family: var(--font-display);
  font-variant-numeric: lining-nums;
  font-size: 1.4rem;
  color: rgba(212, 175, 55, 0.4);
  line-height: 1.2;
  width: 1.6em;
}

.sidebar-item-body h4 {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ceramic-ivory);
  line-height: 1.4;
  transition: color var(--dur-fast);
}

.sidebar-item:hover .sidebar-item-body h4,
.sidebar-item:focus-visible .sidebar-item-body h4 {
  color: var(--gold-ink);
}

.sidebar-item-body span {
  display: block;
  margin-top: var(--s-1);
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 960px) {
  .post-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .post-sidebar .ink-card {
    flex: 1 1 280px;
  }
}
