/* templates/blocks/block-1/style.css - v-FINAL-COMPLETE-v13-RESPONSIVE */

/* ===== Wrapper ===================================================== */
.pf-b1 {
  width: var(--pf-container-w, 100%);
  margin: 0 auto var(--pf-bottom-space, 36px);
  padding: var(--pf-pad, 0);

  border-style: var(--pf-b-style, solid);
  border-width: var(--pf-b-width, 0);
  border-color: var(--pf-b-color, transparent);
  border-radius: var(--pf-b-radius, 12px);
  box-shadow: var(--pf-shadow, none);
  background-color: var(--pf-bg, transparent);

  /* Cho phép container queries hoạt động theo bề ngang khối */
  container-type: inline-size;
}

/* ===== Header ====================================================== */
.pf-b1-head {
  display: flex;
  flex-direction: column;
  align-items: var(--pf-head-align, flex-start);
  position: relative;
  padding: var(--pf-head-pad, 0);
  margin: var(--pf-head-m, 0 0 16px 0);
}

.pf-b1-head .pf-title-wrap {
  display: flex;
  align-items: center;
  justify-content: var(--pf-head-align, flex-start);
  width: 100%;
  background: var(--pf-head-bg, transparent);
  color: var(--pf-head-color, inherit);
  flex-wrap: wrap;
  gap: 15px;
}

.pf-b1-head .pf-title {
  margin: 0;
  line-height: 1.25;
  font-size: var(--pf-head-fs, 1.5rem);
  font-weight: var(--pf-head-fw, 700);
  font-style: var(--pf-head-fstyle, normal);
  text-transform: var(--pf-head-tt, none);
}

.pf-b1-head .pf-title a { color: inherit; text-decoration: none; }

/* Decorative line */
.pf-b1-head[data-line="1"][data-line-pos="bottom"]::after,
.pf-b1-head[data-line="1"][data-line-pos="top"]::before {
  content: "";
  display: block;
  position: relative;
  height: var(--pf-head-line-thickness, 3px);
  width: var(--pf-head-line-len, 40%);
  background: var(--pf-head-line-color, currentColor);
  border-radius: 2px;
}
.pf-b1-head[data-line="1"][data-line-pos="bottom"]::after {
  margin-top: var(--pf-head-line-offset, 6px);
}
.pf-b1-head[data-line="1"][data-line-pos="top"]::before {
  margin-bottom: var(--pf-head-line-offset, 6px);
}

/* ===== Grid 2 cột (Left/Right) ==================================== */
.pf-b1-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--pf-gap, 20px);
}

.pf-b1-left {
  grid-column: 1;
  padding: var(--pf-b1-left-pad, 0);
  margin: var(--pf-b1-left-m, 0);
  display: flex;
  flex-direction: column;
  gap: var(--pf-b1-left-gap, 0);
}

.pf-b1-right {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: var(--pf-b1-right-gap, 15px);
  padding: var(--pf-b1-right-pad, 0);
  margin: var(--pf-b1-right-m, 0);
}

/* Reset nền/thanh viền mặc định của card */
.pf-b1 .pf-pcard {
  border-width: 0 !important;
  border-color: transparent !important;
  border-radius: 0 !important;
  background: transparent;
}
.pf-b1 .pf-body-inner { width: 100%; }

/* ===== LEFT column layout ========================================= */
.pf-b1-left .pf-pcard {
  display: flex;
  overflow: hidden;
}

.pf-b1-left[data-layout="column"] .pf-pcard {
  flex-direction: column;
  gap: 0;
}
.pf-b1-left[data-layout="column"] .pf-pcard .pf-body {
  width: 100%;
  padding: 12px 0 0 0;
}

.pf-b1-left[data-layout="row"] .pf-pcard {
  flex-direction: row;
  gap: 15px;
  align-items: center;
}
.pf-b1-left[data-layout="row"] .pf-pcard .pf-body {
  flex: 1;
  min-width: 0;
  padding: 0;
}

/* LEFT thumbnail (tỷ lệ, bo góc, vị trí) */
.pf-b1-left .pf-pcard .pf-thumb {
  width: var(--pf-thumb-w, 100%);
  flex-shrink: 0;
  border-radius: var(--pf-thumb-radius, 6px);
  overflow: hidden;
  position: relative;
}
.pf-b1-left .pf-pcard .pf-thumb::before {
  content: "";
  display: block;
  padding-top: var(--pf-thumb-ratio, 56.25%);
}
.pf-b1-left .pf-pcard .pf-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--pf-thumb-fit, cover);
  object-position: center var(--pf-thumb-valign, 50%);
}

/* LEFT excerpt */
.pf-b1-left[data-excerpt="0"] .pf-excerpt { display: none !important; }
.pf-b1-left .pf-excerpt {
  width: 100%;
  box-sizing: border-box;

  /* multiline clamp */
  display: -webkit-box;
  -webkit-line-clamp: var(--pf-excerpt-lines, 3);
  -webkit-box-orient: vertical;
  overflow: hidden;

  text-align: var(--pf-excerpt-align, left);
  column-count: var(--pf-excerpt-cols, 1);
  column-gap: var(--pf-excerpt-gap, 0px);
}

/* ===== RIGHT column layout ======================================== */
.pf-b1-right .pf-pcard {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 12px;
  overflow: hidden;
}
.pf-b1-right .pf-pcard .pf-thumb {
  width: var(--pf-b1-side-thumb-w, 60px);
  height: var(--pf-b1-side-thumb-h, 60px);
  flex: 0 0 auto;
  border-radius: var(--pf-thumb-radius, 6px);
  overflow: hidden;
  position: relative;
}
.pf-b1-right .pf-pcard .pf-thumb::before { display: none !important; }
.pf-b1-right .pf-pcard .pf-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--pf-thumb-fit, cover);
  object-position: center center;
}
.pf-b1-right .pf-pcard .pf-body {
  flex: 1 1 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pf-b1-right .pf-pcard .pf-excerpt { display: none; }

/* ===== Category tag positioning =================================== */
.pf-b1 .pf-thumb { position: relative; }
.pf-b1 .pf-thumb > .pf-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}
.pf-b1 [data-catalign="right"] .pf-thumb > .pf-badge { left: auto; right: 8px; }
.pf-b1 [data-catalign="center"] .pf-thumb > .pf-badge { left: 50%; transform: translateX(-50%); }

.pf-b1 [data-catalign="left"] .pf-body,
.pf-b1 [data-catalign="left"] .pf-body-inner { text-align: left; }

.pf-b1 [data-catalign="center"] .pf-body,
.pf-b1 [data-catalign="center"] .pf-body-inner { text-align: center; }

.pf-b1 [data-catalign="right"] .pf-body,
.pf-b1 [data-catalign="right"] .pf-body-inner { text-align: right; }

.pf-b1 .pf-body .pf-badge { display: inline-block; }

/* ===== Text & Meta ================================================= */
.pf-b1 .pf-pcard .pf-title a { text-decoration: none; }

.pf-b1 .pf-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--pf-meta-gap, 8px);
  justify-content: var(--pf-meta-justify, flex-start);
}

.pf-b1 .pf-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.pf-b1 .pf-meta-icon {
  width: 1em;
  height: 1em;
  stroke-width: 2px;
  fill: none;
  stroke: currentColor;
  flex-shrink: 0;
}

/* ===== Front-end toggles (ẩn/hiện theo data-attr) ================== */
.pf-b1 [data-thumb="0"] .pf-thumb,
.pf-b1 [data-cat="0"] [data-meta="category"],
.pf-b1 [data-meta="0"] .pf-meta,
.pf-b1 [data-author="0"] [data-meta="author"],
.pf-b1 [data-date="0"] [data-meta="date"],
.pf-b1 [data-excerpt="0"] .pf-excerpt {
  display: none !important;
}

/* ===== Container Queries: chia 1 cột khi hẹp ======================= */
@container (max-width: 768px) {
  .pf-b1-grid {
    grid-template-columns: 1fr;
    gap: var(--pf-gap-m, var(--pf-gap, 20px));
  }
  .pf-b1-left,
  .pf-b1-right {
    grid-column: 1 / -1;
    width: 100%;
  }
}

/* Mobile refinements: ép LEFT luôn dọc + tinh chỉnh RIGHT */
@container (max-width: 700px) {
  /* LEFT: luôn dọc bất kể data-layout */
  .pf-b1-left .pf-pcard {
    flex-direction: column !important;
    gap: 0 !important;
  }
  .pf-b1-left .pf-pcard .pf-body {
    width: 100%;
    padding: 12px 0 0 0 !important;
  }
  .pf-b1-left .pf-pcard .pf-thumb {
    width: 100% !important;
  }

  /* RIGHT gọn hơn */
  .pf-b1-right .pf-pcard {
    gap: 10px !important;
    align-items: center;
  }
  .pf-b1-right .pf-pcard .pf-thumb {
    width: clamp(72px, 24vw, 120px) !important;
    height: clamp(72px, 24vw, 120px) !important;
  }

  /* Tiêu đề co giãn an toàn */
  .pf-b1 .pf-pcard .pf-title {
    font-size: clamp(1rem, 2vw + .9rem, 1.25rem);
  }
}

/* Container query nhỏ hơn cho RIGHT nếu cần */
@container (max-width: 480px) {
  .pf-b1-right .pf-pcard { gap: 10px; align-items: center; }
  .pf-b1-right .pf-pcard .pf-thumb {
    width: clamp(80px, 25vw, 120px);
    height: clamp(80px, 25vw, 120px);
  }
  .pf-b1 .pf-pcard .pf-title {
    font-size: clamp(1rem, 2vw + .9rem, 1.25rem);
  }
}

/* ===== Fallback: khi trình duyệt KHÔNG hỗ trợ container queries ==== */
@supports not (container-type: inline-size) {
  @media (max-width: 768px) {
    .pf-b1-grid { grid-template-columns: 1fr; }
    .pf-b1-left, .pf-b1-right { grid-column: auto; }
  }
  @media (max-width: 700px) {
    .pf-b1-left .pf-pcard {
      flex-direction: column !important;
      gap: 0 !important;
    }
    .pf-b1-left .pf-pcard .pf-body {
      width: 100%;
      padding: 12px 0 0 0 !important;
    }
    .pf-b1-left .pf-pcard .pf-thumb {
      width: 100% !important;
    }
    .pf-b1-right .pf-pcard {
      gap: 10px !important;
      align-items: center;
    }
    .pf-b1-right .pf-pcard .pf-thumb {
      width: clamp(72px, 24vw, 120px) !important;
      height: clamp(72px, 24vw, 120px) !important;
    }
  }
}

/* ===== Builder preview tweaks (chỉ trong builder) ================== */
.b-block-preview .pf-b1 .pf-pcard { background: #1e2b3b; color: #cbd5e1; }
.b-block-preview .pf-b1 .pf-meta { color: #94a3b8; }
.b-block-preview .pf-b1 a { color: #f1f5f9; }
/* Highlight Search Term cho block-1 */
.pf-b1 mark.pf-search-hl {
  padding: .08em .18em;
  border-radius: .22em;
  background-color: #ffe082;
  color: #333;
}