/* =========================================================
 * MUSK - MA TRẬN MỨC ĐỘ TỔN HẠI
 *
 * Element nằm trong Section / Row / Column có sẵn.
 * Không đặt container hoặc max-width tổng.
 *
 * Mỗi hàng đối tượng gồm: icon tròn, tên/ghi chú, khung kết quả
 * "Xác định: Cấp độ N", và một CHUỖI CHẤM SỐ 1→5 nối bằng đường
 * kẻ - chấm trúng cấp độ phóng to tô màu. Không còn bảng nhiều
 * cột, không nút "xem chi tiết", không khối chú thích riêng -
 * chấm phóng to + tô màu tự nó là câu trả lời. Banner kết luận
 * ở cuối tự tính cấp độ cao nhất trong mọi hàng. Xem ghi chú
 * trong file PHP vì sao hai loại shortcode con (cột, hàng)
 * không trả HTML tại chỗ mà ghi vào một kho chung.
 *
 * Tiêu đề dùng hệ .musk-title chung. Cỡ chữ tên đối tượng và mô
 * tả do ux-builder/typography.css quyết định, ở đây không đặt
 * lại - trừ tên đối tượng vì là chữ trong khối tự thiết kế riêng,
 * không đi qua vai trò "tiêu đề chính" chung.
 * ========================================================= */

.musk-harm-matrix {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  padding: 100px 0 50px 0;
}

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

.musk-harm-matrix__inner {
  position: relative;
  z-index: 2;
  width: 100%;
}

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

.musk-harm-matrix__header {
  max-width: 720px;
  margin-bottom: 32px;
}

.musk-harm-matrix__description {
  margin: 16px 0 0;
  color: #4a5872;
  font-weight: 400;
}

/* =========================================================
 * TRỐNG - CHỈ THẤY TRONG UX BUILDER HOẶC KHI THIẾU DỮ LIỆU
 * ========================================================= */

.musk-harm-matrix__empty {
  padding: 28px 20px;
  border: 1px dashed #c7d2fe;
  border-radius: 14px;
  background: #f8faff;
  color: #4b5768;
  font-size: 14px;
  text-align: center;
}

/* =========================================================
 * KHỐI DANH SÁCH - MỘT KHUNG DUY NHẤT
 * ========================================================= */

.musk-harm-matrix__list {
  display: flex;
  flex-direction: column;
  border: 1px solid #e3e9f2;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 16px 40px -24px rgba(11, 20, 36, 0.35);
}

/* =========================================================
 * MỘT HÀNG
 *
 * Lưới có tên vùng (grid-template-areas) - đổi hẳn cách sắp xếp
 * ở mobile thay vì chỉ co giãn, vì 4 khối (icon, tên, kết quả,
 * chuỗi chấm) nằm chung một hàng ngang sẽ vỡ bố cục trên màn
 * hẹp, phải xếp lại thành nhiều hàng dọc.
 * ========================================================= */

.musk-harm-matrix__row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto minmax(140px, 220px);
  grid-template-areas: "icon info result track";
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #edf1f7;
  gap: 16px 20px;
}

.musk-harm-matrix__row:last-child {
  border-bottom: 0;
}

/* =========================================================
 * ICON TRÒN
 * ========================================================= */

.musk-harm-matrix__avatar {
  display: flex;
  grid-area: icon;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 50%;

  /*
   * Màu nền lấy từ biến CSS PHP in inline theo đúng số cấp độ
   * (xem musk_harm_matrix_level_style()) - giá trị mặc định chỉ
   * để hàng "Chưa xác định" (không có biến) có màu trung tính.
   */
  background: var(--musk-harm-bg, #eef1f7);
}

.musk-harm-matrix__avatar img {
  display: block;
  width: 60% !important;
  max-width: none !important;
  height: 60% !important;
  margin: 0 !important;
  object-fit: contain;
}

/* =========================================================
 * TÊN + GHI CHÚ
 * ========================================================= */

.musk-harm-matrix__info {
  display: flex;
  grid-area: info;
  flex-direction: column;
  min-width: 0;
  gap: 4px;
}

.musk-harm-matrix__info strong {
  color: #0b1424;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}

.musk-harm-matrix__info small {
  color: #8792a3;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
}

/* =========================================================
 * KHUNG KẾT QUẢ
 * ========================================================= */

.musk-harm-matrix__result {
  display: flex;
  grid-area: result;
  flex-direction: column;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  white-space: nowrap;
  gap: 2px;

  /* Xem ghi chú màu ở .musk-harm-matrix__avatar - cùng cơ chế. */
  background: var(--musk-harm-bg, #f6f7fa);
  color: var(--musk-harm-text, #8792a3);
}

.musk-harm-matrix__result-label {
  color: inherit;
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.75;
}

.musk-harm-matrix__result strong {
  font-size: 15px;
  font-weight: 700;
}

.musk-harm-matrix__result--empty {
  border-color: #e3e9f2;
  background: #f6f7fa;
  color: #8792a3;
}

.musk-harm-matrix__result--empty span {
  font-size: 13px;
  font-weight: 500;
}

/* =========================================================
 * CHUỖI CHẤM SỐ - ĐƯỜNG KẺ NỐI NGANG QUA GIỮA CÁC CHẤM
 * ========================================================= */

.musk-harm-matrix__track {
  position: relative;
  display: flex;
  grid-area: track;
  align-items: center;
  justify-content: space-between;
}

.musk-harm-matrix__track-line {
  position: absolute;
  top: 50%;
  right: 12px;
  left: 12px;
  z-index: 0;
  height: 2px;
  background: #e3e9f2;
  transform: translateY(-50%);
}

.musk-harm-matrix__dot {
  position: relative;
  z-index: 1;
  display: flex;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #e3e9f2;
  color: #97a1b3;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.musk-harm-matrix__dot.is-outcome {
  width: 34px;
  height: 34px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;

  /* Xem ghi chú màu ở .musk-harm-matrix__avatar - cùng cơ chế. */
  background: var(--musk-harm-solid, #1558f4);
  box-shadow: 0 6px 14px -4px rgba(11, 20, 36, 0.4);
}

/* =========================================================
 * BANNER KẾT LUẬN
 * ========================================================= */

.musk-harm-matrix__conclusion {
  display: flex;
  align-items: flex-start;
  margin-top: 16px;
  padding: 16px 20px;
  border: 1px solid #b7e4c7;
  border-radius: 14px;
  background: #eafaf0;
  gap: 12px;
}

.musk-harm-matrix__conclusion-icon {
  display: flex;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #2e9e6b;
  color: #ffffff;
}

.musk-harm-matrix__conclusion-icon svg {
  display: block;
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.musk-harm-matrix__conclusion p {
  margin: 3px 0 0;
  color: #1c5a3c;
  font-size: 14px;
  line-height: 1.6;
}

.musk-harm-matrix__conclusion strong {
  font-weight: 700;
}

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

@media (max-width: 1024px) {
  .musk-harm-matrix__row {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    grid-template-areas:
      "icon info result"
      "track track track";
    row-gap: 14px;
  }

  .musk-harm-matrix__avatar {
    width: 48px;
    height: 48px;
  }
}

/* =========================================================
 * MOBILE
 *
 * Xếp dọc hoàn toàn: icon + tên một hàng, kết quả xuống hàng
 * riêng (full width, dễ đọc), chuỗi chấm nằm cuối cùng, đủ
 * rộng để 5 chấm không dồn cục vào nhau.
 * ========================================================= */

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

  .musk-harm-matrix__header {
    margin-bottom: 24px;
  }

  .musk-harm-matrix__list {
    border-radius: 14px;
  }

  .musk-harm-matrix__row {
    grid-template-columns: 44px minmax(0, 1fr);
    grid-template-areas:
      "icon info"
      "result result"
      "track track";
    padding: 18px 16px;
    row-gap: 12px;
  }

  .musk-harm-matrix__avatar {
    width: 44px;
    height: 44px;
  }

  .musk-harm-matrix__info strong {
    font-size: 15px;
  }

  .musk-harm-matrix__result {
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: 8px;
  }

  .musk-harm-matrix__result-label {
    font-size: 12px;
  }

  .musk-harm-matrix__track {
    justify-content: space-between;
    gap: 0;
  }

  .musk-harm-matrix__track-line {
    right: 10px;
    left: 10px;
    width: auto;
  }

  .musk-harm-matrix__dot {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .musk-harm-matrix__dot.is-outcome {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .musk-harm-matrix__conclusion {
    padding: 14px 16px;
  }

  .musk-harm-matrix__conclusion p {
    font-size: 13px;
  }
}
