/* =========================================================
 * MUSK BLOG - TRANG DANH MỤC / LƯU TRỮ / TÌM KIẾM
 *
 * Chỉ nạp trên các trang đó, không ảnh hưởng trang khác.
 * Hai mốc: desktop và mobile 767px.
 * ========================================================= */

.musk-blog {
  position: relative;
  z-index: 0;
  padding: 100px 0 50px 0;
  background: #f4f6fb;
  color: #17191f;
}

/* Dải vát góc nối liền banner phía trên. */

.musk-blog .musk-top__shape {
  background: #f4f6fb;
}

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

/* Bề ngang do .container của Flatsome quyết định, khớp đúng
   Row trong UX Builder. Không đặt max-width riêng ở đây. */

.musk-blog__container {
  width: 100%;
  margin: 0 auto;
}

.musk-blog__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* =========================================================
 * Ô TÌM KIẾM TRONG BANNER
 *
 * Form được chèn vào banner qua hook musk_page_banner_after_title.
 * Container của banner vốn xếp ngang, phải đổi sang xếp dọc thì
 * form mới nằm dưới tiêu đề thay vì nằm cạnh.
 * ========================================================= */

/* Selector hai lớp để thắng .musk-page-banner__container trong
   page-banner.css — file đó nạp SAU blog.css nên cùng độ ưu
   tiên là nó thắng, và align-items: flex-end của nó đẩy tiêu
   đề lệch sang phải khi khối xếp dọc. */

.musk-page-banner .musk-page-banner__container {
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.musk-page-banner .musk-page-banner__title {
  max-width: 100%;
  text-align: center;
}

/* Viên thuốc trắng, có quầng sáng mờ bao quanh.
   Flatsome đặt sẵn style cho input[type="search"] nên các
   thuộc tính chính phải !important, không thì bị đè thành
   ô vuông trắng trơn. */

.musk-blog__search {
  position: relative;
  z-index: 3;
  width: 100%;
  max-width: 520px;
  padding: 6px;
  border-radius: 999px;
  margin: 24px auto 0;
  background: rgba(255, 255, 255, 0.12);
  transition: background-color 0.3s ease;
}

.musk-blog__search:focus-within {
  background: rgba(255, 255, 255, 0.22);
}

.musk-blog__search-icon {
  position: absolute;
  top: 50%;
  left: 26px;
  z-index: 2;
  display: flex;
  width: 19px;
  height: 19px;
  color: #6b7686;
  transform: translateY(-50%);
  pointer-events: none;
  transition: color 0.25s ease;
}

.musk-blog__search:focus-within .musk-blog__search-icon {
  color: #1558f4;
}

.musk-blog__search-icon svg {
  display: block;
  width: 19px;
  height: 19px;
}

.musk-blog__search-input {
  display: block !important;
  width: 100% !important;
  height: 50px !important;
  min-height: 50px !important;
  padding: 0 22px 0 50px !important;
  border: 0 !important;
  border-radius: 999px !important;
  margin: 0 !important;
  background: #ffffff !important;
  box-shadow: none !important;
  color: #17191f !important;
  font-size: 15px !important;
  line-height: 50px !important;
  outline: 0 !important;
  appearance: none;
  -webkit-appearance: none;
  transition: box-shadow 0.25s ease;
}

.musk-blog__search-input::placeholder {
  color: #98a1ad;
  opacity: 1;
}

.musk-blog__search-input:focus {
  box-shadow: 0 0 0 2px rgba(21, 88, 244, 0.55) !important;
}

.musk-blog__search-input::-webkit-search-cancel-button {
  cursor: pointer;
}

/* =========================================================
 * TAB DANH MỤC
 * ========================================================= */

.musk-blog__tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px;
  border-radius: 999px;
  margin: 0 auto 32px;
  background: #eef1fd;
  gap: 6px;
}

.musk-blog__tab {
  text-transform: capitalize;
  display: inline-flex;
  align-items: center;
  padding: 9px 20px;
  border-radius: 999px;
  background: transparent;
  color: #4b5768;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

.musk-blog__tab:hover {
  color: #1558f4;
}

.musk-blog__tab.is-active {
  background: #ffffff;
  color: #1558f4;
  box-shadow: 0 2px 8px rgba(8, 20, 46, 0.08);
}

/* =========================================================
 * DROPDOWN LỌC - CHỈ DÙNG Ở MOBILE
 * ========================================================= */

.musk-blog__filter {
  display: none;
  position: relative;
  width: 100%;
  margin: 0 0 22px;
}

.musk-blog__filter-select {
  width: 100% !important;
  height: 50px !important;
  min-height: 50px !important;
  padding: 0 46px 0 18px !important;
  border: 1px solid #c7d2fe !important;
  border-radius: 12px !important;
  margin: 0 !important;
  background: #ffffff !important;
  box-shadow: none !important;
  color: #1e2a44 !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.musk-blog__filter-select:focus {
  border-color: #1558f4 !important;
  box-shadow: 0 0 0 3px rgba(21, 88, 244, 0.14) !important;
  outline: none !important;
}

.musk-blog__filter-icon {
  position: absolute;
  top: 50%;
  right: 16px;
  display: flex;
  width: 20px;
  height: 20px;
  color: #1558f4;
  transform: translateY(-50%);
  pointer-events: none;
}

.musk-blog__filter-icon svg {
  display: block;
  width: 20px;
  height: 20px;
}

/* =========================================================
 * LƯỚI BÀI VIẾT
 * ========================================================= */

.musk-blog__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 24px;
}

.musk-blog__card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 16px;
  border: 1px solid #e9ecf2;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(8, 20, 46, 0.04);
  transition:
    transform 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.musk-blog__card:hover {
  transform: translateY(-3px);
  border-color: #d9e0ee;
}

/* Ảnh nằm lọt trong thẻ, không tràn ra sát mép. */

.musk-blog__card-media {
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  margin-bottom: 16px;
  background: #dde3ee;
}

.musk-blog__card-media img {
  display: block;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  margin: 0 !important;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.musk-blog__card:hover .musk-blog__card-media img {
  transform: scale(1.04);
}

/* Nội dung */

.musk-blog__card-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 0;
}

/* Danh mục và thời gian đọc nằm chung trong MỘT viên thuốc,
   không phải hai khối rời. */

.musk-blog__card-meta {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  max-width: 100%;
  padding: 6px 14px;
  border: 1px solid #e3e7f6;
  border-radius: 999px;
  margin-bottom: 14px;
  background: #f5f7ff;
  gap: 10px;
}

.musk-blog__card-tag {
  overflow: hidden;
  color: #141499;
  font-size: 13px;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.musk-blog__card-tag:hover {
  color: #1558f4;
}

.musk-blog__card-time {
  flex: 0 0 auto;
  color: #7a8496;
  font-size: 13px;
  white-space: nowrap;
}

.musk-blog__card-title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  margin: 0 0 10px;
  color: #0b1b3b;
  font-weight: 700;
  line-height: 1.4;
}

.musk-blog__card-title a {
  color: inherit;
  text-decoration: none;
}

.musk-blog__card-title a:hover {
  color: #1558f4;
}

.musk-blog__card-excerpt {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  margin: 0 0 18px;
  color: #8b94a3;
  line-height: 1.65;
}

/* Chân thẻ */

.musk-blog__card-footer {
  display: flex;
  align-items: center;
  margin-top: auto;
  gap: 8px;
}

.musk-blog__card-avatar {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50%;
  margin: 0 !important;
}

.musk-blog__card-author {
  color: #4b5768;
  font-size: 13px;
  font-weight: 700;
}

.musk-blog__card-date {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  color: #8a939f;
  font-size: 13px;
  gap: 5px;
}

/* Icon đồng hồ nhỏ trước ngày. Ăn màu chữ nhờ currentColor,
   đổi màu ngày là icon đổi theo. */

.musk-blog__card-date-icon {
  display: block;
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
}

/* =========================================================
 * XEM THÊM
 * ========================================================= */

.musk-blog__more {
  margin-top: 34px;
  text-align: center;
}

.musk-blog__more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  height: auto;
  min-height: 44px;
  padding: 11px 30px;
  border: 1px solid #cfd6e0;
  border-radius: 999px;
  margin: 0;
  background: #ffffff;
  box-shadow: none;
  color: #17191f;
  font-size: 14px;
  font-weight: 700;
  text-transform: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition:
    border-color 0.25s ease,
    color 0.25s ease;
}

.musk-blog__more-btn:hover:not(:disabled) {
  border-color: #1558f4;
  color: #1558f4;
}

.musk-blog__more-btn.is-loading {
  opacity: 0.6;
  cursor: default;
}

.musk-blog__more-btn.is-hidden {
  display: none;
}

.musk-blog__more-status {
  margin: 12px 0 0;
  color: #8a939f;
  font-size: 14px;
}

.musk-blog__pagination {
  margin-top: 20px;
}

.musk-blog__empty {
  padding: 50px 0;
  color: #66707f;
  text-align: center;
}

/* =========================================================
 * TABLET
 *
 * Lưới 2 cột, hàng tab cuộn ngang thay vì xuống dòng.
 * ========================================================= */

@media (max-width: 1024px) {
  .musk-blog__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }

  .musk-blog__tabs {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    border-radius: 14px;
    overscroll-behavior-x: contain;
  }

  .musk-blog__tab {
    flex: 0 0 auto;
  }
}

/* =========================================================
 * MOBILE
 * ========================================================= */

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

  .musk-blog__search {
    max-width: 100%;
    padding: 5px;
    margin-top: 16px;
  }

  .musk-blog__search-icon {
    left: 22px;
  }

  .musk-blog__search-input {
    height: 44px !important;
    min-height: 44px !important;
    padding-left: 44px !important;
    font-size: 14px !important;
    line-height: 44px !important;
  }

  /* Hàng tab đổi thành dropdown. Danh mục nhiều thì cuộn
     ngang trên màn hình hẹp rất khó bấm trúng. */

  .musk-blog__tabs {
    display: none;
  }

  .musk-blog__filter {
    display: block;
  }

  .musk-blog__grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* -------------------------------------------------------
   * THẺ NẰM NGANG
   *
   * Ảnh nhỏ nằm bên phải, ngang với nhãn và tiêu đề. Phần mô
   * tả và chân thẻ chạy hết bề ngang bên dưới ảnh.
   *
   * DOM là: media > body > (meta, title, excerpt, footer).
   * display: contents ở body cho các con của nó tham gia
   * thẳng vào lưới của thẻ, nhờ vậy sắp được từng phần vào
   * đúng ô mà không phải đổi markup.
   * ------------------------------------------------------- */

  .musk-blog__card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px;
    align-items: start;
    padding: 14px;
    gap: 0 14px;
  }

  .musk-blog__card-body {
    display: contents;
  }

  .musk-blog__card-media {
    grid-row: 1 / span 2;
    grid-column: 2;
    width: 96px;
    aspect-ratio: 1 / 1;
    margin-bottom: 0;
    border-radius: 10px;
  }

  .musk-blog__card-meta {
    grid-row: 1;
    grid-column: 1;
    width: max-content !important;
    padding: 4px 12px;
    margin-bottom: 10px;
  }

  .musk-blog__card-title {
    grid-row: 2;
    grid-column: 1;
    font-size: 16px !important;
  }

  .musk-blog__card-excerpt {
    grid-row: 3;
    grid-column: 1 / -1;
    margin-top: 8px;
    margin-bottom: 8px;
    font-size: 12px !important;
    line-height: 18px !important;
  }

  .musk-blog__card-footer {
    grid-row: 4;
    grid-column: 1 / -1;
  }

  .musk-blog__card-tag {
    font-size: 12px;
  }

  /* Mobile bỏ thời gian đọc, giữ ảnh đại diện trước tên. */

  .musk-blog__card-time {
    display: none;
  }

  .musk-blog__more {
    margin-top: 24px;
  }

  .musk-blog__more-btn {
    width: 100%;
  }
}

/* =========================================================
 * REDUCED MOTION
 * ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .musk-blog__card,
  .musk-blog__card-media img {
    transition: none !important;
  }

  .musk-blog__card:hover {
    transform: none !important;
  }

  .musk-blog__card:hover .musk-blog__card-media img {
    transform: none !important;
  }
}
