/* ============================================================
   blog.css — Trang blog theo danh mục
   Dùng chung cho: Học bổng, Thông tin trường HQ, Chia sẻ từ DHS
   Theme đổi theo class trên .blog-hero / .blog-body:
     .theme-scholarship (tím) · .theme-info (xanh) · .theme-sharing (cam)
   ============================================================ */

/* ===== Hero ===== */
.blog-hero {
  color: #fff;
  padding: clamp(48px, 8vw, 80px) 0 clamp(56px, 7vw, 84px);
  position: relative;
  overflow: hidden;
  /* Header đồng bộ toàn site: gradient xanh lá – cam */
  background:
    radial-gradient(1200px 320px at 80% 0%, rgba(232,119,46,0.55) 0%, rgba(232,119,46,0) 60%),
    linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, #40916C 100%);
}
.blog-hero::after {
  content: '';
  position: absolute;
  inset: auto -50px -80px auto;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
}
.blog-hero h1 {
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.blog-hero p {
  font-size: clamp(15px, 2vw, 18px);
  color: rgba(255, 255, 255, 0.88);
  max-width: 720px;
  margin: 0;
}
.blog-hero .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}
/* Trang Học bổng: banner Nhất Phong hiện TRỌN dạng card trên nền xanh,
   chữ + nút nằm bên dưới cho thoáng, không che lên ảnh.
   Banner là thẻ <img> nên không bị cắt ở mọi kích thước màn hình. */
.blog-hero.theme-scholarship {
  display: block;
  padding-top: clamp(20px, 3.2vw, 36px);
  padding-bottom: clamp(28px, 5vw, 48px);
  background: linear-gradient(180deg,
    var(--primary-dark) 0%,
    var(--primary) 55%,
    var(--primary-dark) 100%);
}
/* tắt đốm sáng trắng mặc định để không chọi với banner */
.blog-hero.theme-scholarship::after { display: none; }

/* căn banner + chữ về cùng 1 cột hẹp, căn giữa cho cân đối */
.blog-hero.theme-scholarship .container {
  max-width: 800px;
}
.blog-hero .hero-banner {
  display: block;
  width: 100%;
  max-width: 800px;
  height: auto;
  margin: 0 auto clamp(18px, 2.6vw, 28px);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
}

/* ===== Body ===== */
.blog-body { background: #fff; padding: clamp(28px, 5vw, 48px) 0 64px; }
.blog-wrap { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 24px); }
.blog-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 22px;
}
.blog-head h2 { font-size: 22px; font-weight: 700; margin: 0; color: var(--primary-dark); }
.blog-head .count { font-size: 14px; color: var(--muted); font-weight: 600; }

/* ===== Card grid ===== */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.blog-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.blog-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px -8px rgba(15,23,42,0.18);
}
.blog-card:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
/* ===== Bài nổi bật (is_featured) — sao vàng + viền nổi bật, đồng bộ "trường nổi bật" ===== */
.blog-card.is-featured {
  border-color: #f59e0b;
  box-shadow: 0 0 0 1px #fcd34d inset, var(--shadow-sm);
}
.blog-card.is-featured:hover { border-color: #f59e0b; }
.blog-featured-badge {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 3px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}

/* ===== Cover image ===== */
.blog-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--primary-light), #fff);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.blog-cover::after {
  content: attr(data-emoji);
  font-size: 46px; line-height: 1; opacity: 0.45;
}
.blog-cover img {
  position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; object-fit: cover;
}
.blog-card-body {
  padding: 18px 22px 20px;
  display: flex; flex-direction: column; flex: 1;
}
.blog-card .meta {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-bottom: 10px;
}
.blog-card .meta .cat {
  padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 10px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.blog-card .meta .school-name { font-weight: 600; color: var(--primary-dark); }
.blog-card .title {
  font-size: 17px; font-weight: 700; margin: 0 0 8px;
  color: var(--primary-dark); line-height: 1.4;
}
.blog-card .excerpt {
  font-size: 14px; color: #475569; margin: 0 0 14px; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.blog-card .read-more { margin-top: auto; font-size: 13px; font-weight: 700; }

/* ===== Category colors (badge + theme accents) ===== */
.cat.cat-scholarship { background: #ede9fe; color: #5b21b6; }
.cat.cat-info { background: var(--primary-light); color: var(--primary-dark); }
.cat.cat-student_sharing { background: #ffedd5; color: #9a3412; }
.cat.cat-deadline { background: var(--accent-light); color: var(--accent-dark); }
.cat.cat-announcement { background: #f1f5f9; color: #334155; }

.theme-scholarship .blog-card:hover { border-color: #c4b5fd; }
.theme-scholarship .blog-card .read-more { color: #6d28d9; }
.theme-scholarship .blog-cover { background: linear-gradient(135deg, #ede9fe, #faf5ff); }
.theme-topik .blog-card:hover { border-color: #93c5fd; }
.theme-topik .blog-card .read-more { color: #1d4ed8; }
.theme-topik .blog-cover { background: linear-gradient(135deg, #dbeafe, #eff6ff); }
.theme-info .blog-card:hover { border-color: var(--primary); }
.theme-info .blog-card .read-more { color: var(--primary); }
.theme-info .blog-cover { background: linear-gradient(135deg, var(--primary-light), #fff); }
.theme-sharing .blog-card:hover { border-color: #fdba74; }
.theme-sharing .blog-card .read-more { color: #c2410c; }
.theme-sharing .blog-cover { background: linear-gradient(135deg, #ffedd5, #fff7ed); }

.empty-state {
  padding: 48px 18px;
  background: var(--primary-pale, #f0f7f3);
  border: 1px dashed var(--primary-light, #cfe6da);
  border-radius: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty-state .empty-emoji { font-size: 36px; line-height: 1; margin-bottom: 12px; }
.empty-state .empty-title {
  font-size: 17px; font-weight: 700; color: var(--primary-dark); margin-bottom: 6px;
}
.empty-state .empty-desc { margin: 0; font-size: 14px; color: var(--muted); }
.loading-skeleton {
  height: 150px;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 16px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Detail popup ===== */
.blog-popup {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.7);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1100;
  padding: clamp(8px, 3vw, 16px);
}
.blog-popup.is-open { display: flex; animation: modalFadeIn 0.2s ease; }
.blog-popup-card {
  background: #fff;
  border-radius: 18px;
  max-width: 760px;
  width: 100%;
  max-height: min(92vh, 100dvh - 16px);
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
  min-height: 0;
}
.blog-popup-card .pop-head {
  padding: 22px 60px 16px 26px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
  flex-shrink: 0;
}
.blog-popup-card .pop-title {
  font-size: clamp(17px, 2.4vw, 21px);
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 6px;
  line-height: 1.3;
  overflow-wrap: break-word;
  word-break: normal;
}
.blog-popup-card .pop-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; color: var(--muted);
}
.blog-popup-card .pop-meta .cat {
  padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 10px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.blog-popup-card .pop-meta .school-name { font-weight: 600; color: var(--primary-dark); }
.blog-popup-card .pop-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #f1f5f9;
  font-size: 20px;
  border: none;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.blog-popup-card .pop-close:hover { background: #e2e8f0; }
.blog-popup-card .pop-body {
  padding: 20px 26px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  font-size: 15px;
  color: #334155;
  line-height: 1.7;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
  text-align: left;
}
/* Nội dung copy-paste/Quill có thể kèm canh giữa/phải/đều — ép canh trái cho
   đồng nhất theo yêu cầu hiển thị. */
.blog-popup-card .pop-body [style*="text-align"],
.blog-popup-card .pop-body .ql-align-center,
.blog-popup-card .pop-body .ql-align-right,
.blog-popup-card .pop-body .ql-align-justify {
  text-align: left !important;
}
.blog-popup-card .pop-body > *:first-child { margin-top: 0; }
.blog-popup-card .pop-body > *:last-child { margin-bottom: 0; }
.blog-popup-card .pop-body p { margin: 0 0 12px; }
.blog-popup-card .pop-body ul,
.blog-popup-card .pop-body ol { margin: 8px 0 14px; padding-left: 22px; }
.blog-popup-card .pop-body li { margin-bottom: 5px; }
.blog-popup-card .pop-body img {
  max-width: 100%; height: auto; border-radius: 8px; margin: 12px auto; display: block;
}
/* Emoji dán từ Facebook/Word là <img> nhỏ (emoji.php) — giữ inline trong dòng
   chữ thay vì rớt xuống thành block riêng như ảnh thường. */
.blog-popup-card .pop-body img[src*="emoji.php"],
.blog-popup-card .pop-body img[src*="/emoji/"] {
  display: inline; width: 1.15em; height: 1.15em;
  margin: 0 1px; vertical-align: -0.2em; border-radius: 0;
}
.blog-popup-card .pop-body h1,
.blog-popup-card .pop-body h2,
.blog-popup-card .pop-body h3 {
  font-size: 16px; font-weight: 700; color: var(--primary-dark);
  margin: 16px 0 8px; line-height: 1.35;
}
.blog-popup-card .pop-body blockquote {
  border-left: 3px solid var(--accent); padding-left: 12px; margin: 10px 0;
  color: #475569; font-style: italic;
}
.blog-popup-card .pop-body a { color: var(--accent-dark); text-decoration: underline; overflow-wrap: anywhere; }
.blog-popup-card .pop-body table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px;
}
.blog-popup-card .pop-body td,
.blog-popup-card .pop-body th { border: 1px solid var(--border); padding: 6px 8px; }
.blog-popup-card .pop-foot {
  padding: 14px 26px 20px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}
.blog-popup-card .pop-cta {
  width: 100%;
  padding: 13px 18px;
  background: var(--grad-cta);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: block;
  text-align: center;
  text-decoration: none;
}
.blog-popup-card a.pop-cta[hidden] { display: none; }
.pop-foot:has(> [hidden]:only-child) { display: none; }

@media (max-width: 700px) {
  .blog-popup-card { border-radius: 14px; max-height: min(94vh, 100dvh - 12px); }
  .blog-popup-card .pop-head { padding: 18px 52px 12px 18px; }
  .blog-popup-card .pop-body { padding: 16px 18px 12px; }
  .blog-popup-card .pop-foot { padding: 12px 18px 16px; }
  .blog-popup-card .pop-close { top: 10px; right: 10px; width: 32px; height: 32px; font-size: 18px; }
}
