.posts-section {
  padding: 32px 20px 48px;
}

.filter-section,
.posts-section {
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
}

/* style.css có "* { max-width: 100% }" nên .row không giãn ra để bù lề âm của gutter,
   làm các thẻ bị lệch trái. Gỡ giới hạn đó cho lưới bài viết. */
#postsGrid { max-width: none; }

.blog-hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 64px 20px 56px;
  text-align: center;
  color: white;
}

.blog-hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.blog-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 18px;
}

.blog-hero h1 {
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 14px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.blog-hero p {
  font-size: 1.05rem;
  opacity: 0.92;
  margin: 0;
}

/* ===== Filter Section ===== */
.filter-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 24px 20px;
  border-bottom: 1px solid #eef0f4;
}

/* Chip lọc: máy tính / máy tính bảng */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 480px;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 50px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  flex-shrink: 0;
  color: #444;
}

.filter-btn[hidden] { display: none; }

.filter-btn:hover {
  border-color: var(--cat-color, #667eea);
  color: var(--cat-color, #667eea);
  transform: translateY(-2px);
}

.filter-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
}

.filter-count {
  background: rgba(0,0,0,0.06);
  border-radius: 50px;
  padding: 1px 8px;
  font-size: 11px;
}

.filter-btn.active .filter-count {
  background: rgba(255,255,255,0.25);
}

/* Ô chọn "Lọc: ..." : chỉ hiện trên điện thoại, bấm vào ra danh sách */
.filter-select {
  display: none;
  position: relative;
  flex: 0 0 auto;
}

.filter-select-label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  pointer-events: none;
}

.filter-select select {
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid #e0e0e0;
  border-radius: 50px;
  background: #fff url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23667eea' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  padding: 10px 30px 10px 52px;
  font-size: 16px; /* >= 16px để iOS không tự phóng to */
  font-weight: 700;
  color: #374151;
  cursor: pointer;
  transition: all 0.25s ease;
}

.filter-select select:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  outline: none;
}

/* ===== Post Card (thẻ dọc gọn: ảnh trên, chữ dưới) ===== */
.post-item article {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  padding: 12px;
  transition: all 0.25s ease;
  border: 2px solid #f0f0f0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.post-item article:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 40px rgba(0,0,0,0.12);
  border-color: #667eea;
}

.post-thumbnail {
  display: block;
  flex: none;
  overflow: hidden;
  border-radius: 0.5rem;
}

.post-thumbnail img,
.thumbnail-fallback {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.post-item article:hover .post-thumbnail img,
.post-item article:hover .thumbnail-fallback {
  transform: scale(1.04);
}

.thumbnail-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--cat-color, #667eea) 12%, white);
}

.thumbnail-fallback i {
  font-size: 2rem;
  color: var(--cat-color, #667eea);
  opacity: 0.85;
}

.post-content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.post-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--cat-color, #667eea);
  background: color-mix(in srgb, var(--cat-color, #667eea) 12%, white);
  padding: 3px 10px;
  border-radius: 50px;
  margin-bottom: 6px;
}

.post-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  line-height: 1.35;
}

/* Tiêu đề tối đa 2 dòng để các thẻ đều chiều cao */
.post-title a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #1a1a1a;
  text-decoration: none;
  transition: color 0.2s;
}

.post-title a:hover {
  color: #667eea;
}

.post-summary {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dòng thông tin luôn nằm sát đáy thẻ */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  margin-top: auto;
}

.post-meta small {
  font-size: 12px;
}

.post-item {
  animation: fadeInUp 0.5s ease-out backwards;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

#noResults {
  padding: 40px 12px;
  color: #6b7280;
}

@media (prefers-reduced-motion: reduce) {
  .post-item { animation: none; }
  .post-item article,
  .post-thumbnail img,
  .thumbnail-fallback { transition: none; }
}



/* Điện thoại: bộ lọc là ô chọn + ô tìm kiếm trên cùng một hàng, thẻ bài viết dạng hàng ngang gọn */
@media (max-width: 767.98px) {
  .blog-hero { padding: 48px 20px 40px; }
  .blog-hero h1 { font-size: 1.7rem; }

  .filter-section {
    flex-wrap: wrap; /* màn hình rất hẹp: ô tìm kiếm tự xuống dòng riêng */
    gap: 10px;
    padding: 12px 20px;
  }
  .filter-tabs { display: none; }
  .filter-select { display: block; }
  .search-box { flex: 1 1 140px; min-width: 140px; }
  .search-box i { left: 12px; }
  .search-box input { padding: 10px 10px 10px 34px; }

  .posts-section { padding: 16px 20px 32px; }
  #postsGrid { --bs-gutter-y: 0.625rem; }

  .post-item article {
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    padding: 10px;
  }
  .post-item article:hover { transform: none; }

  .post-thumbnail { width: 96px; }
  .post-thumbnail img,
  .thumbnail-fallback {
    width: 96px;
    height: 96px;
    aspect-ratio: 1 / 1;
  }
  .thumbnail-fallback i { font-size: 1.6rem; }

  .post-badge { font-size: 11px; padding: 2px 10px; margin-bottom: 4px; }
  .post-title { font-size: 1rem; margin-bottom: 4px; }
  .post-summary { display: none; }
  .post-meta small:last-child { display: none; } /* ẩn lượt xem cho gọn */
}

/* Search Box */
.search-box {
  position: relative;
  flex: 0 1 320px;
}

.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  border-radius: 50px;
  border: 2px solid #e0e0e0;
  padding: 10px 20px 10px 42px;
  font-size: 16px; /* >= 16px để iOS không tự phóng to khi bấm vào */
  transition: all 0.25s ease;
}

.search-box input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
  outline: none;
}

/* Máy tính bảng / màn hình vừa: ô tìm kiếm xuống dòng riêng, rộng hết cỡ */
@media (max-width: 1099.98px) {
  .search-box { flex: 1 1 100%; }
}

/* Điện thoại: bộ lọc là ô chọn + ô tìm kiếm trên cùng một hàng, thẻ bài viết dạng hàng ngang gọn */
@media (max-width: 767.98px) {
  .search-box { flex: 1 1 140px; min-width: 140px; }
  .search-box i { left: 12px; }
  .search-box input { padding: 10px 10px 10px 34px; }
}

.alert {
    display: none;
}