/*
 * Template 6 "Tạp chí tin tức" — khối bài viết [iw_mag_posts] (trang chủ).
 * Port từ pattern main-banner (cat-post + main-slider), latest-blog-section (trend-head) và
 * latest-blog của Magazine Blocks 1.3.1. Scope `.iw-mag-block*` / `.iw-mag-item*` / `.iw-mag-slide*`.
 */

.iw-mag__container--home { width: 90%; }
.iw-mag-block { --mag-primary: var(--iw-accent, #2337C6); margin: 0 0 clamp(28px, 4vw, 48px); }
.iw-mag-block a { text-decoration: none; }

/* Tiêu đề khối: kẻ trái 5px màu chính (h5.trend-head). */
.iw-mag-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
}
.iw-mag-block__title {
  position: relative;
  margin: 0;
  padding: 0 0 12px;
  color: #14183A;
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 700;
  line-height: 1.3;
  text-transform: uppercase;
}
/* Gạch màu chính dưới tiêu đề khối (PO 18/11, mẫu sforum). */
.iw-mag-block__title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 150px;
  max-width: 60%;
  height: 4px;
  border-radius: 2px;
  background: var(--mag-primary);
}
.iw-mag-block__more { flex-shrink: 0; color: var(--mag-primary); font-size: 15px; font-weight: 600; }
.iw-mag-block__more:hover { text-decoration: underline; }

.iw-mag-block__items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 15px; }

/* ----- mini: ảnh 100×70 bo 8px + chuyên mục + tiêu đề (cat-post) ----- */
.iw-mag-item--mini { display: flex; align-items: center; gap: 14px; min-width: 0; }
.iw-mag-item--mini .iw-mag-item__thumb {
  flex: 0 0 100px;
  height: 70px;
  border-radius: 8px;
  overflow: hidden;
  background: #dadada;
}
.iw-mag-item--mini .iw-mag-item__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.iw-mag-item__body { min-width: 0; }
.iw-mag-item__cat {
  display: inline-block;
  color: var(--mag-primary);
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.iw-mag-item--mini .iw-mag-item__title { margin: 6px 0 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.iw-mag-item__title a { color: #283941; overflow-wrap: anywhere; }
.iw-mag-item__title a:hover { color: var(--mag-primary); }

/* ----- slider: ảnh cao 600px bo 15px, chữ trắng đè lên (main-slider) ----- */
.iw-mag-slider { position: relative; border-radius: 15px; overflow: hidden; }
.iw-mag-slide { position: relative; height: 600px; border-radius: 15px; overflow: hidden; background: #dadada; }
.iw-mag-slide__img { position: absolute; inset: 0; display: block; }
.iw-mag-slide__img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 35%, rgba(0, 0, 0, 0.72) 100%);
}
.iw-mag-slide__img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.iw-mag-slide__cat {
  position: absolute;
  top: 40px;
  left: 2%;
  z-index: 2;
  padding: 4px 14px;
  border-radius: 6px;
  background: var(--mag-primary);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}
.iw-mag-slide__content { position: absolute; left: 2%; right: 2%; bottom: 20px; z-index: 2; color: #ffffff; }
.iw-mag-slide__title { margin: 0 0 12px; color: #ffffff; max-width: 900px; font-size: clamp(20px, 2.6vw, 34px); font-weight: 700; line-height: 1.3; }
.iw-mag-slide__title a { color: #ffffff; }
.iw-mag-slide__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: 15px; }
.iw-mag-slide__meta img { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; }
.iw-mag .iw-mag-slider__nav,
.iw-mag-slider__nav {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 36px;
  height: 50px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translateY(-50%);
  cursor: pointer;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6));
}
.iw-mag-slider__nav--prev { left: 30px; }
.iw-mag-slider__nav--next { right: 30px; }
.iw-mag-slider__nav::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border: solid #ffffff;
  border-width: 3px 3px 0 0;
  transform: translate(-70%, -50%) rotate(45deg);
}
.iw-mag-slider__nav--prev::after { transform: translate(-30%, -50%) rotate(-135deg); }
.iw-mag-slider__nav:hover,
.iw-mag-slider__nav:focus { background: transparent; }
.iw-mag-slider__nav:hover::after { border-color: #ffffff; opacity: .8; }

/* ----- grid: ảnh 250px bo 15px, tiêu đề, tóm tắt (latest-blog-section) ----- */
.iw-mag-item--grid .iw-mag-item__thumb,
.iw-mag-item--cards .iw-mag-item__thumb { display: block; overflow: hidden; background: #dadada; }
.iw-mag-item--grid .iw-mag-item__thumb { height: 250px; border-radius: 15px; }
.iw-mag-item--grid .iw-mag-item__thumb img,
.iw-mag-item--cards .iw-mag-item__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.iw-mag-item--grid .iw-mag-item__title,
.iw-mag-item--cards .iw-mag-item__title { margin: 14px 0 8px; font-size: 18px; font-weight: 700; line-height: 1.4; }
.iw-mag-item__excerpt { margin: 0; color: #1c222a; font-size: 15px; line-height: 1.65; }

/* ----- cards: thẻ trắng bo 20px đổ bóng, nhấc lên khi rê chuột (latest-blog) ----- */
.iw-mag-block--cards .iw-mag-block__items { gap: 28px 24px; }
.iw-mag-item--cards {
  border-radius: 20px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.13);
  transition: transform .5s;
}
.iw-mag-item--cards:hover { transform: translateY(-10px); }
.iw-mag-item--cards .iw-mag-item__thumb { height: 300px; }
.iw-mag-item--cards .iw-mag-item__body { padding: 0 20px 22px; }
.iw-mag-item__more { display: inline-block; margin-top: 10px; color: var(--mag-primary); font-weight: 500; }
.iw-mag-item__more:hover { text-decoration: underline; }

.iw-mag-home__content { margin-top: 32px; }

@media (max-width: 1199px) {
  .iw-mag-block__items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .iw-mag-slide { height: 400px; }
}
@media (max-width: 991px) {
  .iw-mag__container--home { width: auto; }
}
@media (max-width: 767px) {
  .iw-mag-block__items { grid-template-columns: minmax(0, 1fr); }
  /* Tiêu đề khối gọn 1 dòng trên điện thoại (PO 18/11 14:32: "Chuyên mục Công nghệ giải trí" bị xuống dòng). */
  .iw-mag-block__head { gap: 10px; margin-bottom: 16px; }
  .iw-mag-block__title { font-size: 16px; letter-spacing: 0; padding-bottom: 10px; }
  .iw-mag-block__title::after { width: 90px; height: 3px; }
  .iw-mag-block__more { flex-shrink: 0; padding: 4px 0 4px 8px; font-size: 20px; line-height: 1; }
  .iw-mag-block__prefix { display: none; }
  .iw-mag-block__more-text {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  /* Khung "Nổi bật nhất" trên điện thoại: chữ nhật ngang 5:3 (PO 18/11). */
  .iw-mag-slide { height: auto; aspect-ratio: 5 / 3; }
  .iw-mag-slide__title { font-size: 18px; margin-bottom: 6px; }
  .iw-mag-slide__meta { font-size: 13px; }
  .iw-mag-slide__meta img { width: 26px; height: 26px; }
  .iw-mag-slide__cat { top: 16px; }
  .iw-mag-slider__nav--prev { left: 10px; }
  .iw-mag-slider__nav--next { right: 10px; }
  .iw-mag-item--cards .iw-mag-item__thumb { height: 220px; }
}

/* ===== PO 18/11: Chủ đề hot, dòng tác giả · thời gian, bài dạng hàng ===== */

/* Chủ đề hot: ô vuông ảnh + "#Tên thẻ" (vuốt ngang khi không đủ chỗ). */
.iw-mag-tags-hot {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.iw-mag-hot-tag {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--iw-banner-grad-from, #3012FB), var(--iw-banner-grad-to, #0BC0D6));
  scroll-snap-align: start;
}
.iw-mag-hot-tag img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.iw-mag-hot-tag__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, .45);
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.iw-mag-hot-tag:hover .iw-mag-hot-tag__name { background: rgba(0, 0, 0, .65); }

/* Dòng tác giả · thời gian. */
.iw-mag-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  margin: 0 0 8px;
  color: #6b7280;
  font-size: 14px;
}
.iw-mag-item__author { color: var(--mag-primary); font-weight: 500; }
.iw-mag-item__time::before { content: "🕒"; margin-right: 4px; font-size: 12px; }

/* Bài dạng hàng (Bài viết cùng chủ đề): ảnh trái, chữ phải; 2 cột trên máy tính. */
.iw-mag-block--row .iw-mag-block__items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; }
.iw-mag-item--row { display: grid; grid-template-columns: 40% minmax(0, 1fr); gap: 14px; align-items: start; }
.iw-mag-item--row .iw-mag-item__thumb { display: block; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #dadada; }
.iw-mag-item--row .iw-mag-item__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.iw-mag-item--row .iw-mag-item__title { margin: 0 0 6px; font-size: 17px; font-weight: 600; line-height: 1.4; }
.iw-mag-item--row .iw-mag-item__excerpt { display: none; }

/* Nút "Xem thêm" (trang chuyên mục). */
.iw-mag-more-wrap { margin: 24px 0 0; text-align: center; }
.iw-mag-more {
  display: inline-block;
  min-width: 180px;
  padding: 10px 24px;
  border: 1px solid var(--mag-primary);
  border-radius: 999px;
  color: var(--mag-primary);
  font-weight: 600;
}
.iw-mag-more:hover { background: var(--mag-primary); color: #ffffff; }
.iw-mag-more.is-loading { opacity: .6; pointer-events: none; }

/* Điện thoại: mọi bài trong danh sách hiện dạng hàng — ảnh chữ nhật trái | tiêu đề, tác giả, thời gian phải. */
@media (max-width: 767px) {
  .iw-mag-tags-hot { grid-auto-columns: 42%; gap: 12px; }
  .iw-mag-block--row .iw-mag-block__items { grid-template-columns: minmax(0, 1fr); }
  .iw-mag-item--grid,
  .iw-mag-item--cards,
  .iw-mag-item--row {
    display: grid;
    grid-template-columns: 44% minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
  }
  .iw-mag-item--cards:hover { transform: none; }
  .iw-mag-item--grid .iw-mag-item__thumb,
  .iw-mag-item--cards .iw-mag-item__thumb,
  .iw-mag-item--row .iw-mag-item__thumb { height: auto; aspect-ratio: 16 / 10; border-radius: 8px; }
  .iw-mag-item--cards .iw-mag-item__body { padding: 0; }
  .iw-mag-item--grid .iw-mag-item__title,
  .iw-mag-item--cards .iw-mag-item__title,
  .iw-mag-item--row .iw-mag-item__title {
    display: -webkit-box;
    margin: 0 0 6px;
    overflow: hidden;
    font-size: 16px;
    font-weight: 600;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .iw-mag-item__meta { flex-direction: column; gap: 4px; font-size: 13px; }
  .iw-mag-item--grid .iw-mag-item__excerpt,
  .iw-mag-item--cards .iw-mag-item__excerpt,
  .iw-mag-item--cards .iw-mag-item__more { display: none; }
}
