/**
 * Kiểu hiển thị cho những thẻ mà trình soạn bài viết trong CSM tạo ra.
 *
 * Tiêu đề, trích dẫn, ảnh đã có sẵn trong từng trang bài; file này bù phần còn
 * lại (tiêu đề phụ, danh sách, bảng, đường kẻ, khối định dạng sẵn) để mọi trang
 * dùng article-body.js hiển thị giống nhau, thay vì mỗi trang tự viết một kiểu.
 */

.article-body h3 {
  margin: 42px 0 16px;
  color: var(--gold-deep, #8e6a2f);
  font-family: var(--display, "Montserrat", sans-serif);
  font-size: clamp(20px, 2.4vw, 27px);
  font-weight: 500;
  line-height: 1.2;
}
.article-body h4 {
  margin: 32px 0 13px;
  color: var(--ink, #20211f);
  font-family: var(--display, "Montserrat", sans-serif);
  font-size: clamp(17px, 1.9vw, 21px);
  font-weight: 600;
  line-height: 1.25;
}

.article-body ul,
.article-body ol { margin: 0 0 26px; padding-left: 24px; }
.article-body li { margin-bottom: 10px; padding-left: 4px; }
.article-body li::marker { color: var(--gold, #b79552); }
/* Danh sách lồng: bắt cả trường hợp lồng chéo (ol chứa ul và ngược lại). */
.article-body li > ul,
.article-body li > ol { margin: 10px 0 0; }

.article-body hr {
  width: 120px;
  margin: 46px auto;
  border: 0;
  border-top: 1px solid var(--gold, #b79552);
}

/* Bảng tràn ngang trên điện thoại thì cuộn trong khung, không làm vỡ trang. */
.article-body table {
  display: block;
  width: 100%;
  margin: 32px 0;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 15px;
}
.article-body th,
.article-body td {
  padding: 11px 14px;
  border: 1px solid var(--line, #ddd6c6);
  text-align: left;
  vertical-align: top;
  line-height: 1.6;
}
.article-body th {
  background: rgba(183, 149, 82, .12);
  color: var(--gold-deep, #8e6a2f);
  font-weight: 600;
}

.article-body pre {
  margin: 0 0 26px;
  padding: 16px 18px;
  background: rgba(183, 149, 82, .08);
  border-left: 3px solid var(--gold, #b79552);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-x: auto;
}

.article-body s { text-decoration: line-through; }

@media (max-width: 720px) {
  .article-body table { font-size: 14px; }
  .article-body th,
  .article-body td { padding: 9px 11px; }
}

/* Dán từ Word có thể mang theo Tiêu đề 1, 5, 6 — cần kiểu hiển thị để không
   rơi về cỡ chữ mặc định của trình duyệt. */
.article-body h1 {
  margin: 52px 0 20px;
  color: var(--gold-deep, #8e6a2f);
  font-family: var(--display, "Montserrat", sans-serif);
  font-size: clamp(26px, 3.2vw, 38px);
  font-weight: 500;
  line-height: 1.16;
}
.article-body h5 {
  margin: 26px 0 11px;
  font-family: var(--display, "Montserrat", sans-serif);
  font-size: 16px;
  font-weight: 600;
}
.article-body h6 {
  margin: 24px 0 10px;
  color: var(--muted, #686862);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Album ảnh soạn trong CSM (thư viện ảnh → chọn từ 2 ảnh). Lớp riêng
   article-album, không đụng .article-gallery có bố cục riêng của từng bài. */
.article-body .article-album {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 26px 0;
}
.article-body .article-album figure { margin: 0; }
.article-body .article-album img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
/* Điện thoại: hai cột; số ảnh lẻ thì ảnh đầu trải ngang làm ảnh chính. */
@media (max-width: 620px) {
  .article-body .article-album figure:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  .article-body .article-album figure:first-child:nth-last-child(odd) img { aspect-ratio: 16 / 9; }
}
/* Máy tính: lưới 6 phần, mỗi ảnh chiếm 2 (3 ảnh một hàng). Hàng cuối không
   để ô trống: dư 2 ảnh thì mỗi ảnh nửa hàng, dư 1 ảnh thì trải hết hàng. */
@media (min-width: 621px) {
  .article-body .article-album { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 36px 0; }
  .article-body .article-album figure { grid-column: span 2; }
  .article-body .article-album figure:nth-child(3n+1):nth-last-child(2),
  .article-body .article-album figure:nth-child(3n+1):nth-last-child(2) + figure { grid-column: span 3; }
  .article-body .article-album figure:nth-child(3n+1):last-child { grid-column: 1 / -1; }
  .article-body .article-album figure:nth-child(3n+1):last-child img { aspect-ratio: 16 / 9; }
  /* Album 4 ảnh: lưới 2 × 2 cân hơn 3 + 1. */
  .article-body .article-album figure:first-child:nth-last-child(4),
  .article-body .article-album figure:first-child:nth-last-child(4) ~ figure { grid-column: span 3; }
  .article-body .article-album figure:first-child:nth-last-child(4) ~ figure img { aspect-ratio: 4 / 3; }
}


