/* =========================================================
 * MUSK - THẺ XẾP CHỒNG KHI CUỘN
 *
 * Element nằm trong Section / Row / Column có sẵn.
 * Không đặt container hoặc max-width tổng.
 *
 * Hiệu ứng: mỗi thẻ là position: sticky với chỗ dừng riêng.
 * Cuộn xuống thì thẻ sau trượt lên đè lên thẻ trước, thẻ trước
 * đứng yên ở chỗ dừng của nó. Không cần JavaScript.
 *
 * Ba biến điều khiển, PHP đặt sẵn giá trị:
 *   --musk-stack-top   chỗ dừng của thẻ đầu, chừa chỗ cho header
 *   --musk-stack-peek  mỗi thẻ dừng thấp hơn thẻ trước bấy nhiêu
 *   --musk-stack-i     số thứ tự thẻ, đếm từ 0
 *
 * Cỡ chữ tiêu đề thẻ và nội dung do ux-builder/typography.css
 * quyết định, ở đây không đặt lại.
 * ========================================================= */

.musk-stack-cards {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  padding: 100px 0 50px 0;

  --musk-stack-top: 100px;
  --musk-stack-peek: 16px;
}

.musk-stack-cards,
.musk-stack-cards *,
.musk-stack-cards *::before,
.musk-stack-cards *::after {
  box-sizing: border-box;
}

.musk-stack-cards__inner {
  position: relative;
  z-index: 2;
  width: 100%;
}

/* =========================================================
 * HEADER
 * ========================================================= */

.musk-stack-cards__header {
  margin-bottom: 44px;
  text-align: center;
}

.musk-stack-cards__description {
  max-width: 720px;
  margin: 12px auto 0;
  color: #29394f;
  font-weight: 400;
}

/* =========================================================
 * DANH SÁCH
 *
 * KHÔNG đặt overflow ở đây. Bất kỳ giá trị overflow nào khác
 * visible trên thẻ cha đều làm position: sticky của thẻ con
 * mất tác dụng - đây là lỗi hay gặp nhất với kỹ thuật này.
 * ========================================================= */

.musk-stack-cards__list {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 26px;
}

/* =========================================================
 * THẺ
 * ========================================================= */

.musk-stack-cards__card {
  position: sticky;
  top: calc(var(--musk-stack-top) + var(--musk-stack-i, 0) * var(--musk-stack-peek));

  /* Thẻ sau phải nằm trên thẻ trước, không thì nó chui xuống dưới
     và không che được gì. */
  z-index: calc(1 + var(--musk-stack-i, 0));

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  align-items: stretch;
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  background: var(--musk-stack-bg, #ffffff);
  box-shadow: 0 14px 36px rgba(8, 28, 68, 0.1);
}

/* Ảnh bên trái: đổi chỗ bằng grid-column, không đổi markup - thứ
   tự đọc của trình đọc màn hình vẫn là chữ trước, ảnh sau. */

.musk-stack-cards__card--image-left .musk-stack-cards__body {
  grid-column: 2;
}

.musk-stack-cards__card--image-left .musk-stack-cards__media {
  grid-column: 1;
  grid-row: 1;
}

.musk-stack-cards__card--no-image {
  grid-template-columns: minmax(0, 1fr);
}

/* =========================================================
 * CỘT CHỮ
 * ========================================================= */

.musk-stack-cards__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 40px 42px;
}

.musk-stack-cards__card-title {
  margin: 0;
  color: #0b1b3b;
  font-weight: 700;
}

.musk-stack-cards__card-description {
  margin: 14px 0 0;
  color: #29394f;
  font-weight: 400;
}

/* =========================================================
 * NỘI DUNG HTML NGƯỜI DÙNG NHẬP
 * ========================================================= */

.musk-stack-cards__content {
  margin-top: 18px;
  color: #29394f;
  font-weight: 400;
}

.musk-stack-cards__content > *:first-child {
  margin-top: 0;
}

.musk-stack-cards__content > *:last-child {
  margin-bottom: 0;
}

.musk-stack-cards__content p {
  margin: 0 0 10px;
}

.musk-stack-cards__content ul,
.musk-stack-cards__content ol {
  padding: 0;
  margin: 0;
  list-style: none;
}

.musk-stack-cards__content li {
  position: relative;
  margin: 0 0 10px !important;
  padding-left: 20px;
  list-style: none;
}

.musk-stack-cards__content li:last-child {
  margin-bottom: 0 !important;
}

.musk-stack-cards__content li::before {
  content: "";
  position: absolute;
  top: 0.6em;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--musk-stack-accent, #1558f4);
}

.musk-stack-cards__content a {
  color: var(--musk-stack-accent, #1558f4);
  text-decoration: none;
}

.musk-stack-cards__content a:hover {
  text-decoration: underline;
}

/* =========================================================
 * CỘT ẢNH
 * ========================================================= */

.musk-stack-cards__media {
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.musk-stack-cards__media img {
  display: block;
  width: 100% !important;
  max-width: none !important;
  height: 100%;
  margin: 0 !important;
  object-fit: cover;
  object-position: center;
}

/* =========================================================
 * TABLET
 * ========================================================= */

@media (max-width: 1024px) {
  .musk-stack-cards__body {
    padding: 30px 28px;
  }
}

/* =========================================================
 * MOBILE
 *
 * Tắt hẳn hiệu ứng xếp chồng. Màn hình hẹp thì thẻ cao gần bằng
 * cả màn hình, dính thẻ lại là phần đuôi bị cắt mất và người
 * đọc không có cách nào thấy nốt.
 * ========================================================= */

@media (max-width: 767px) {
  .musk-stack-cards {
    padding: 50px 0;
  }

  .musk-stack-cards__header {
    margin-bottom: 30px;
  }

  .musk-stack-cards__list {
    gap: 16px;
  }

  .musk-stack-cards__card {
    position: static;
    top: auto;
    z-index: auto;
    grid-template-columns: minmax(0, 1fr);
    border-radius: 14px;
  }

  /* Một cột thì phải trả ảnh về đúng thứ tự, không thì ảnh nằm
     đè lên chữ ở cùng ô lưới. */

  .musk-stack-cards__card--image-left .musk-stack-cards__body,
  .musk-stack-cards__card--image-left .musk-stack-cards__media {
    grid-column: 1;
    grid-row: auto;
  }

  .musk-stack-cards__body {
    padding: 24px 20px;
  }

  .musk-stack-cards__card-description {
    margin-top: 10px;
  }

  .musk-stack-cards__content {
    margin-top: 14px;
  }

  .musk-stack-cards__content li {
    margin-bottom: 8px !important;
    padding-left: 17px;
  }

  .musk-stack-cards__media {
    aspect-ratio: 16 / 10;
  }
}
