/**
 * Layout 20 — "Lead + 4 + 4"
 *
 * Row 1 is laid out with CSS Grid rather than the shared float/flex columns, so
 * the 2x2 block on the right can stretch to exactly the height of the lead card
 * beside it. Without that the small cards end short and leave a gap.
 */

/* Row 1 is a CSS grid, so it needs a gap of its own — but it has to be the same
   gap the rest of the module uses, or the top row reads wider than the bottom
   one. The shared gutter classes are all driven by these variables, so borrow
   whichever one the chosen gutter maps to. */
.saigonchess1 .jacl-layout__body > .jacl-row {
  --l20-gap: var(--grid-gutter-width, 32px);
}

.saigonchess1 .jacl-layout__body > .jacl-row.no-gutters {
  --l20-gap: 0px;
}

.saigonchess1 .jacl-layout__body > .jacl-row.small-gutters {
  --l20-gap: var(--gutter-small, 3px);
}

.saigonchess1 .jacl-layout__body > .jacl-row.large-gutters {
  --l20-gap: var(--gutter-large, 36px);
}

.saigonchess1 .jacl-layout__body > .jacl-row.extra-large-gutters {
  --l20-gap: var(--gutter-extra-large, 36px);
}

/* ------------------------------------------------------------------ row 1 */

/* Half and half: the lead takes two of the four columns, the 2x2 block the
   other two — so each small card lines up with a card in the row below. */
.saigonchess1 .jacl-layout__body > .jacl-row:first-child {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--l20-gap);
  align-items: stretch;
  margin: 0;
}

.saigonchess1 .jacl-layout__body > .jacl-row:first-child > [class*="jacl-col"] {
  width: auto;
  max-width: none;
  flex: none;
  padding: 0;
}

/* The four small cards: two across, two down, filling the column. */
/* Carries .jacl-row, so it also picks up that class's negative side margins —
   which would eat half the gap between the lead and this block. */
.saigonchess1 .saigonchess1__side {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: var(--l20-gap);
  height: 100%;
  margin: 0;
}

/* The grid supplies the gap here, so the cells must not also carry the gutter
   padding — the two would add up and the 2x2 block would sit twice as loose as
   the row below. Two classes deep to outrank `.jacl-row.<size>-gutters > div`. */
.saigonchess1 .saigonchess1__side > [class*="jacl-col"] {
  width: auto;
  max-width: none;
  flex: none;
  padding: 0;
  min-width: 0;
}

/* Cards fill their grid cell so both rows line up. */
.saigonchess1 .jacl-item,
.saigonchess1 .jacl-item__inner {
  height: 100%;
}

/* The shared media classes (media-8-5, media-4-3 …) pin a fixed aspect ratio.
   Here the card has to fill its grid cell instead, otherwise the picture ends
   short of the cell and the caption — anchored to the bottom — drops out from
   under it onto the page background. */
.saigonchess1 .jacl-item__media,
.saigonchess1 .jacl-item__media a {
  height: 100%;
  aspect-ratio: auto;
}

.saigonchess1 .jacl-item__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The lead needs real height; the small ones stay compact. */
.saigonchess1 .highlight-item .jacl-item__media {
  min-height: 420px;
}

.saigonchess1__side .jacl-item__media {
  min-height: 200px;
}

/* Smaller type in the 2x2 block — the cards are a quarter of the lead's width. */
.saigonchess1__side .jacl-item__title {
  font-size: .95rem;
  line-height: 1.3;
}

/* On a 200px-tall card a three-line headline plus the meta line covers about
   seventy per cent of the picture. Two lines leaves the photo readable.
   The item style sets the clamp and the body padding for cards of any size, so
   both rules here carry the layout class twice to outrank it. */
.saigonchess1 .saigonchess1__side .jacl-item__title a,
.saigonchess1 .saigonchess1__bottom .jacl-item__title a {
  -webkit-line-clamp: 2;
}

.saigonchess1 .saigonchess1__side .jacl-item__body,
.saigonchess1 .saigonchess1__bottom .jacl-item__body {
  padding: 14px 14px 12px;
}

.saigonchess1__side .jacl-item__meta {
  font-size: 11px;
}

/* ------------------------------------------------------------------ row 2 */

.saigonchess1__bottom {
  margin-top: var(--l20-gap);
}

.saigonchess1__bottom .jacl-item__media {
  min-height: 200px;
}

/* --------------------------------------------------------------- narrow */

@media (max-width: 991px) {
  .saigonchess1 .jacl-layout__body > .jacl-row:first-child {
    grid-template-columns: 1fr;
  }

  .saigonchess1 .highlight-item .jacl-item__media {
    min-height: 260px;
  }

  .saigonchess1__side {
    margin-top: var(--l20-gap);
  }
}

@media (max-width: 575px) {
  .saigonchess1__side {
    grid-template-columns: 1fr;
  }
}

/* =========================================================================
   Kiểu bài bọc ảnh trong .scn-media-wrap
   -------------------------------------------------------------------------
   Khối ở trên đặt `height: 100%` theo chuỗi
       .jacl-item > .jacl-item__inner > .jacl-item__media
   Ba kiểu bài scn-cat-in, scn-cat-in-intro và scn-overlay-intro chèn thêm một
   lớp `.scn-media-wrap` vào giữa. Lớp đó cao tự động, mà `height: 100%` của ảnh
   lại tính theo nó → ra 0 → **ảnh biến mất**, phần chữ rơi ra nền trang.

   Dựng thẻ thành cột co giãn: ảnh ăn hết chỗ thừa, chữ lấy đúng chiều cao cần.
   ========================================================================= */

.saigonchess1 .jacl-item__inner {
  display: flex;
  flex-direction: column;
}

.saigonchess1 .scn-media-wrap {
  flex: 1 1 auto;
  min-height: 0;          /* thiếu dòng này thì ảnh không co lại được */
  margin-bottom: 0;
}

.saigonchess1 .scn-media-wrap .jacl-item__media,
.saigonchess1 .scn-media-wrap .jacl-item__media a {
  height: 100%;
  aspect-ratio: auto;
  padding-bottom: 0;
}

.saigonchess1 .jacl-item__inner > .jacl-item__body {
  flex: 0 0 auto;
  /* `assets/style.css` (nền JA) đặt `height: 100%` cho MỌI .jacl-item__body.
     Trong thẻ flex dọc, phần chữ nuốt trọn chiều cao và ép khung ảnh còn 0 —
     đo được: body 763px, khung ảnh 0px. Trả về auto để ảnh lấy phần còn lại. */
  height: auto;
  padding-top: 12px;
}

/* .scn-overlay đặt body tuyệt đối lên ảnh nên không dính flex. */
.saigonchess1 .scn-overlay .jacl-item__inner > .jacl-item__body {
  padding-top: 0;
}
