/* ============================================================
   VinFast — Trang liệt kê bài viết (hub Kiến thức xe điện + danh mục)
   template-parts/blog-archive.php. Mobile first: một cột, tab cuộn ngang, hit target ≥44px.
   Breakpoint: 768 (nhóm bài/thẻ lớn 2 cột) · 1024 (hub hai tầng + sidebar sticky).
   ============================================================ */

.vf-ba {
  color: var(--color-text-heading);
}
.vf-ba__wrap {
  width: min(100% - 2 * var(--container-px), calc(var(--container-max) - 2 * var(--container-px-md)));
  margin-inline: auto;
}
.vf-ba :focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* ── Hero ────────────────────────────────────────────────── */
.vf-ba__hero {
  background: linear-gradient(115deg, var(--color-surface) 0%, var(--color-brand-tint-soft) 100%);
  border-bottom: 1px solid var(--color-border);
}
.vf-ba__hero .vf-ba__wrap {
  padding: 0 0 28px;
}
.vf-ba__crumbs { padding-block: var(--space-3); margin-bottom: 24px; } /* khớp chuẩn .vf-hero: H1 cách mép trên 80px */
.vf-ba__count {
  margin: 14px 0 0;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--color-text-muted);
}
.vf-hero-lead:empty + .vf-ba__count,
.vf-hero-title + .vf-ba__count {
  margin-top: 0;
}

/* ── Tab lọc danh mục (liên kết, cuộn ngang trên mobile) ── */
.vf-ba__tabbar {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.vf-ba__tabs {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  /* Mờ dần mép phải: gợi ý còn tab phía sau khi chưa cuộn tới. */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.vf-ba__tabs::-webkit-scrollbar {
  display: none;
}
.vf-ba__tab {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 3px solid transparent;
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--color-text-secondary);
  white-space: nowrap;
  text-decoration: none;
  scroll-snap-align: start;
}
.vf-ba__tab:hover {
  color: var(--color-cta-primary);
}
.vf-ba__tab[aria-current] {
  border-bottom-color: var(--color-cta-primary);
  font-weight: var(--font-extrabold);
  color: var(--color-brand-primary);
}

/* ── Khung nội dung ──────────────────────────────────────── */
.vf-ba__content {
  padding: 32px 0 56px;
}
.vf-ba__layout {
  display: grid;
  gap: 48px;
  align-items: start;
}
.vf-ba__main {
  min-width: 0;
}
.vf-ba__h2 {
  margin: 0 0 16px;
  font-size: var(--font-size-title);
  line-height: 1.2;
  letter-spacing: -0.035em;
  font-weight: var(--font-extrabold);
  color: var(--color-text-heading);
}
.vf-ba__more {
  margin-top: 40px;
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}
.vf-ba__empty {
  margin: 0;
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}

/* ── Thẻ bài viết ────────────────────────────────────────── */
.vf-ba__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 20px;
}
.vf-ba-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.vf-ba-card__thumb {
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--color-surface-mist);
}
.vf-ba-card__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vf-ba-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 6px;
}
.vf-ba-card__kicker {
  align-self: flex-start;
  /* Vùng chạm ≥44px mà không đẩy giãn bố cục */
  padding-block: 12px;
  margin-block: -12px;
  font-size: var(--text-xs);
  font-weight: var(--font-extrabold);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--color-cta-primary);
  text-decoration: none;
}
.vf-ba-card__title {
  margin: 0;
  font-size: var(--text-lg);
  line-height: 1.35;
  letter-spacing: -0.02em;
  font-weight: var(--font-extrabold);
}
.vf-ba-card__title a {
  color: var(--color-text-heading);
  text-decoration: none;
}
/* Cả thẻ bấm được: vùng chạm của tiêu đề phủ toàn thẻ (không cần JS, liên kết ảnh đã ẩn khỏi AT). */
.vf-ba-card {
  position: relative;
}
.vf-ba-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.vf-ba-card__kicker,
.vf-ba-card__more {
  position: relative;
  z-index: 2;
}
.vf-ba-card:hover .vf-ba-card__title a {
  color: var(--color-cta-primary);
}
.vf-ba-card__excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  margin: 0;
  overflow: hidden;
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text-secondary);
}
.vf-ba-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.vf-ba-card__more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: var(--font-extrabold);
  color: var(--color-brand-primary);
  text-decoration: none;
}
.vf-ba-card__more:hover {
  color: var(--color-cta-primary);
}

/* Thẻ lớn (bài mới nhất) */
.vf-ba-card--featured {
  background: var(--color-surface-alt);
}
.vf-ba-card--featured .vf-ba-card__body {
  justify-content: center;
  gap: 12px;
  padding: 20px 20px 22px;
}
.vf-ba-card--featured .vf-ba-card__title {
  font-size: var(--font-size-h3);
  line-height: 1.25;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.vf-ba-card--featured .vf-ba-card__excerpt {
  -webkit-line-clamp: 4;
  font-size: var(--text-base);
}
.vf-ba-card--featured .vf-ba-card__foot {
  margin-top: 0;
}
.vf-ba-card--featured .vf-ba-card__more {
  font-size: var(--text-sm);
}

/* ── Nhóm bài trên hub: một bài lớn + tối đa ba hàng nhỏ ── */
.vf-ba-group + .vf-ba-group {
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}
.vf-ba-group__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.vf-ba-group__heading .vf-ba__h2 {
  margin: 0;
}
.vf-ba-group__all {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--color-brand-primary);
  text-decoration: none;
}
.vf-ba-group__all:hover {
  color: var(--color-cta-primary);
}
.vf-ba-group__stories,
.vf-ba-group__list {
  display: grid;
  gap: var(--space-6);
  align-items: start;
}
.vf-ba-group__list {
  margin: 0;
  padding: 0;
  list-style: none;
  gap: var(--space-4);
}
.vf-ba-group__item {
  display: contents;
}
.vf-ba-card--lead {
  border: 0;
  border-radius: 0;
  background: transparent;
}
.vf-ba-card--lead .vf-ba-card__thumb {
  overflow: hidden;
  border-radius: var(--radius-lg);
}
.vf-ba-card--lead .vf-ba-card__body {
  padding: var(--space-4) 0 0;
}
.vf-ba-card--lead .vf-ba-card__title {
  font-size: var(--font-size-h3);
}
.vf-ba-card--compact {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-3);
  border: 0;
  border-radius: 0;
  background: transparent;
}
.vf-ba-card--compact .vf-ba-card__thumb {
  overflow: hidden;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-md);
}
.vf-ba-card--compact .vf-ba-card__body {
  min-width: 0;
  gap: var(--space-2);
  padding: 0;
}
.vf-ba-card--compact .vf-ba-card__title {
  font-size: var(--text-base);
  line-height: 1.4;
}
.vf-ba-card--compact .vf-ba-card__foot {
  margin-top: 0;
  padding-top: 0;
  font-size: var(--text-xs);
}

/* ── Phân trang ──────────────────────────────────────────── */
.vf-ba__pager {
  margin-top: 40px;
}
.vf-ba__pager ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.vf-ba__pager .page-numbers {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.vf-ba__pager a.page-numbers:hover {
  border-color: var(--color-cta-primary);
  color: var(--color-cta-primary);
}
.vf-ba__pager .page-numbers.current {
  border-color: var(--color-surface-dark);
  background: var(--color-surface-dark);
  font-weight: var(--font-extrabold);
  color: var(--color-text-inverse);
}
.vf-ba__pager .page-numbers.dots {
  min-width: 0;
  border: 0;
}
.vf-ba__pager :is(.prev, .next) {
  font-weight: var(--font-extrabold);
  color: var(--color-brand-primary);
}

/* ── Sidebar ─────────────────────────────────────────────── */
.vf-ba__aside {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
/* Dưới 1024px tab đã đủ để chuyển danh mục. */
.vf-ba__cats {
  display: none;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.vf-ba__cats h2 {
  margin: 0 0 12px;
  font-size: var(--text-lg);
  font-weight: var(--font-extrabold);
  letter-spacing: -0.02em;
}
.vf-ba__cats ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--color-border);
}
.vf-ba__cats a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 4px 0 12px;
  border-bottom: 1px solid var(--color-border);
  border-left: 2px solid transparent;
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.vf-ba__cats a:hover {
  color: var(--color-cta-primary);
}
.vf-ba__cats a[aria-current] {
  border-left-color: var(--color-cta-primary);
  font-weight: var(--font-extrabold);
  color: var(--color-cta-primary);
}
.vf-ba__cta {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
}
.vf-ba__cta h2 {
  margin: 0 0 8px;
  font-size: var(--text-xl);
  line-height: 1.3;
  font-weight: var(--font-extrabold);
  letter-spacing: -0.02em;
  color: inherit;
}
.vf-ba__cta p {
  margin: 0 0 18px;
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-brand-tint);
}
.vf-ba__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 10px;
  font-size: var(--text-sm);
  font-weight: var(--font-extrabold);
  text-decoration: none;
}
.vf-ba__btn + .vf-ba__btn {
  margin-top: 10px;
}
.vf-ba__btn--primary {
  background: var(--gradient-action);
  color: var(--color-text-inverse);
}
.vf-ba__btn--ghost {
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--color-text-inverse);
}
.vf-ba__btn--ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-inverse);
}

/* ── Khám phá xe ─────────────────────────────────────────── */
.vf-ba__cars {
  padding-bottom: 56px;
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}
.vf-ba__cars-box {
  padding: 24px 20px 8px;
  border: 1px solid var(--color-brand-tint);
  border-radius: var(--radius-lg);
  background: var(--color-brand-tint-soft);
}
.vf-ba__cars h2 {
  margin: 0 0 4px;
  font-size: var(--font-size-h3);
  font-weight: var(--font-extrabold);
  letter-spacing: -0.03em;
  color: var(--color-brand-deep);
}
.vf-ba__cars-box > p {
  margin: 0 0 8px;
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}
.vf-ba__cars ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 0 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.vf-ba__cars li {
  border-top: 1px solid var(--color-brand-tint);
}
.vf-ba__cars li a {
  display: block;
  padding: 14px 0 16px;
  color: var(--color-text-heading);
  text-decoration: none;
}
.vf-ba__cars li strong {
  display: block;
  font-size: var(--text-lg);
  font-weight: var(--font-extrabold);
  color: var(--color-brand-primary);
}
.vf-ba__cars li a:hover strong {
  color: var(--color-cta-primary);
}
.vf-ba__cars li a > span {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* ── Breakpoints ─────────────────────────────────────────── */
@media (min-width: 768px) {
  .vf-ba__wrap {
    width: min(100% - 2 * var(--container-px-md), calc(var(--container-max) - 2 * var(--container-px-md)));
  }
  .vf-ba__content {
    padding-bottom: 72px;
  }
  .vf-ba-card--featured {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
  .vf-ba-card--featured .vf-ba-card__thumb {
    height: 100%;
    aspect-ratio: auto;
    min-height: 100%;
  }
  .vf-ba-group__stories {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
  .vf-ba-group__stories--single {
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
  }
  .vf-ba-card--compact {
    grid-template-columns: 104px minmax(0, 1fr);
  }
  .vf-ba__tabs {
    -webkit-mask-image: none;
    mask-image: none;
  }
}
@media (min-width: 1024px) {
  .vf-ba__layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
  /* Bài lớn phủ toàn hàng; các bài nhỏ chia đều hàng dưới theo số bài thực tế. */
  .vf-ba-group__stories {
    grid-template-columns: minmax(0, 1fr);
    max-width: none;
  }
  .vf-ba-card--lead {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6);
  }
  .vf-ba-card--lead .vf-ba-card__thumb {
    height: 100%;
    min-height: 240px;
    aspect-ratio: auto;
  }
  .vf-ba-card--lead .vf-ba-card__body {
    justify-content: center;
    padding: var(--space-4) 0;
  }
  .vf-ba-group__list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: var(--space-6);
  }
  .vf-ba-card--compact {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .vf-ba-card--compact .vf-ba-card__thumb {
    aspect-ratio: 16 / 9;
  }
  .vf-ba-card--compact .vf-ba-card__foot {
    margin-top: auto;
  }
  .vf-ba-group__item:only-child .vf-ba-card--compact {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
    align-items: center;
  }
  .vf-ba__cats {
    display: block;
  }
  .vf-ba__aside {
    position: sticky;
    top: 96px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .vf-ba__tabs {
    scroll-behavior: auto;
  }
}
