/*
Theme Name: Hội nhập thời đại
Author: Hội nhập thời đại
Description: Giao diện tin tức điện tử tổng hợp "Hội nhập thời đại", dựng theo bản thiết kế mẫu: trang chủ 6 hàng, trang chuyên mục dạng lưới 2 cột và trang bài viết chi tiết.
Version: 1.0.0
Requires at least: 5.9
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: hoinhapthoidai
*/

/* ==============================================================
   Toàn bộ thiết kế gốc nằm ở assets/css/main.css (giữ nguyên bản
   của designer). File này chỉ chứa phần bổ sung riêng cho WordPress.
   ============================================================== */

/* Trợ năng */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}

.skip-link:focus {
  clip: auto;
  clip-path: none;
  height: auto;
  width: auto;
  margin: 0;
  top: 8px;
  left: 8px;
  padding: 10px 16px;
  background: #ffffff;
  color: var(--primary-color);
  font-weight: 700;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 100000;
}

/* ==============================================================
   MENU CHÍNH: trạng thái đang xem & menu con do WordPress sinh ra
   ============================================================== */
.main-menu li.current-menu-item > a,
.main-menu li.current-menu-parent > a,
.main-menu li.current-menu-ancestor > a,
.main-menu li.current-post-ancestor > a,
.main-menu li.current-category-ancestor > a,
.main-menu li.current-cat > a,
.main-menu li.current-cat-parent > a,
.main-menu li.current-cat-ancestor > a,
.main-menu li.active > a,
.main-menu li:hover > a,
.main-menu li > a:focus-visible {
  /* Chủ site yêu cầu (13/10/2026): mục đang rê chuột / đang xem tô ĐỎ như nút trang chủ (bản mẫu tô xanh đậm). */
  background-color: var(--accent-red);
  color: #ffffff;
}

/* Nút trang chủ theo cùng quy tắc với các mục menu: bình thường nền xanh, chỉ đỏ khi rê chuột hoặc đang ở trang chủ
   (bản mẫu để nút này lúc nào cũng đỏ). */
.nav-home-btn {
  background-color: transparent;
}

.nav-home-btn:hover,
.nav-home-btn:focus-visible,
body.home .nav-home-btn {
  background-color: var(--accent-red);
  color: #ffffff;
}

.main-menu .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  list-style: none;
  background-color: var(--primary-color);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  display: none;
  z-index: 999;
}

.main-menu li:hover > .sub-menu,
.main-menu li:focus-within > .sub-menu {
  display: block;
}

.main-menu .sub-menu li a {
  padding: 10px 14px;
  white-space: normal;
}

/* ==============================================================
   CHỈNH THEO YÊU CẦU CỦA CHỦ SITE (khác file CSS gốc của bản mẫu)
   ============================================================== */

/* Khối tiêu điểm (chỉ bố cục máy tính; tablet và mobile giữ nguyên như bản mẫu):
   - Bản mẫu chia cột 24% + 52% + 24% rồi cộng thêm 2 khoảng cách 14px nên tràn khỏi khung.
     Chia theo phần (fr) để ba cột luôn nằm gọn trong khung mà vẫn giữ tỉ lệ 24 : 52 : 24.
   - Hai cột bên: hai thẻ luôn cao bằng nhau để ảnh hàng dưới của cột trái và cột phải thẳng hàng,
     dù tiêu đề dài ngắn khác nhau. */
@media (min-width: 1025px) {
  .hero-modern-grid {
    grid-template-columns: minmax(0, 24fr) minmax(0, 52fr) minmax(0, 24fr);
  }

  .hero-col {
    display: grid;
    grid-template-rows: 1fr 1fr;
  }
}

/* Thanh menu bám mép trên khi cuộn. Cả khối đầu trang được ghim, nhưng ghim ở vị trí âm đúng bằng
   chiều cao phần logo + banner, nên phần đó trượt lên khuất và chỉ thanh menu ở lại.
   Chiều cao ấy do JS đo rồi đặt vào --hntd-header-top (126px = khi có banner cao 90px; mobile = 0). */
.has-sticky-menu .site-header {
  position: sticky;
  top: calc(-1 * var(--hntd-header-top, 126px));
  z-index: 900;
}

/* Đang đăng nhập: chừa chỗ cho thanh quản trị của WordPress */
.has-sticky-menu.admin-bar .site-header {
  top: calc(32px - var(--hntd-header-top, 126px));
}

@media (max-width: 782px) {
  .has-sticky-menu.admin-bar .site-header {
    top: calc(46px - var(--hntd-header-top, 126px));
  }
}

/* Mobile: phần logo + banner đã ẩn nên thanh logo + nút menu bám thẳng mép trên (không phụ thuộc JS) */
@media (max-width: 768px) {
  .has-sticky-menu .site-header {
    top: 0;
  }

  .has-sticky-menu.admin-bar .site-header {
    top: 46px;
  }

  /* Menu mở ra dài hơn màn hình thì cuộn được bên trong */
  .has-sticky-menu .main-navigation-bar.mobile-open {
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }
}

@media (max-width: 600px) {
  /* Dưới 600px thanh quản trị của WordPress không còn cố định */
  .has-sticky-menu.admin-bar .site-header {
    top: 0;
  }
}

/* Banner đứng yên ngay dưới thanh menu khi cuộn (chủ site yêu cầu 27/10/2026): cột banner hàng "Tin tổng hợp"
   trang chủ và banner cuối thanh bên ở trang chuyên mục / bài viết / trang tĩnh (Tin hot, Đọc nhiều vẫn trôi bình thường).
   Vị trí bám (--hntd-ad-top) do JS tính: dưới thanh menu đang ghim + thanh quản trị; nếu khối banner cao hơn màn hình
   thì bám theo mép dưới để vẫn xem được banner cuối. Từ 1024px trở xuống thanh bên nằm dưới bài nên không bám. */
@media (min-width: 1025px) {
  .hntd-sticky-ads {
    position: sticky;
    top: var(--hntd-ad-top, 70px);
  }

  /* Thanh bên kéo dài hết cột thì banner mới có chỗ để đứng yên suốt chiều dài bài */
  .grid-8-4 .site-sidebar {
    min-height: 100%;
  }
}

/* Thanh menu trên màn hình hẹp hơn khung 1180px (laptop nhỏ, iPad ngang): bản mẫu để 7 mục không xuống dòng
   nên cả trang bị tràn ngang. Thu nhỏ chữ và khoảng đệm cho vừa một hàng. */
@media (min-width: 769px) and (max-width: 1194px) {
  .main-menu li a {
    font-size: 12px;
    letter-spacing: 0;
    padding-left: 6px;
    padding-right: 6px;
  }

  .nav-home-btn {
    padding: 0 14px;
  }

  .nav-search-btn {
    padding: 0 12px;
  }
}

/* Tablet dọc (769–1024px) vẫn không đủ chỗ: cho riêng thanh menu vuốt ngang, trang không tràn.
   (Menu con thả xuống sẽ bị cắt trong khoảng rộng này; site hiện không dùng menu con.) */
@media (min-width: 769px) and (max-width: 1024px) {
  .nav-wrapper-left {
    min-width: 0;
  }

  .main-menu {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .main-menu::-webkit-scrollbar {
    display: none;
  }
}

/* Tiêu đề thẻ tiêu điểm nhỏ: tối đa 3 dòng theo bảng thông số. */

.hero-card-small .card-title {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Toàn bộ giao diện vuông góc: bỏ bo tròn ở mọi khối, dải tiêu đề, nút, ô nhập và ảnh
   (file CSS gốc bo 2–6px ở rất nhiều chỗ nên ghi đè một lần cho gọn).
   Chỉ giữ hình tròn cho ảnh đại diện cạnh tên tác giả và vòng xoay báo đang tải. */
.site-header *,
.main-content-wrapper *,
.site-footer *,
.scroll-top-btn,
.skip-link {
  border-radius: 0 !important;
}

.article-meta-avatar,
.infinite-spinner {
  border-radius: 50% !important;
}

/* Nội dung bài viết căn đều hai bên (sapo và thân bài).
   Đoạn nào người soạn đã chủ động căn giữa/phải/trái thì giữ nguyên. */
.article-sapo,
.entry-content p,
.entry-content li,
.entry-content blockquote {
  text-align: justify;
}

.entry-content .has-text-align-center {
  text-align: center;
}

.entry-content .has-text-align-right {
  text-align: right;
}

.entry-content .has-text-align-left {
  text-align: left;
}

/* Cuộn vô tận: khối báo đang tải, nút "Xem thêm", ẩn phân trang với người đọc */
.infinite-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 46px;
  padding-top: 18px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.infinite-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: hntd-spin 0.8s linear infinite;
}

.infinite-loader:not(.is-loading) .infinite-spinner,
.infinite-loader:not(.is-loading) .infinite-text {
  display: none;
}

.infinite-more-btn {
  padding: 8px 22px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #ffffff;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.infinite-more-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-color);
  color: #ffffff;
}

.has-infinite-scroll .pagination-wrapper {
  display: none;
}

@keyframes hntd-spin {
  to { transform: rotate(360deg); }
}

/* Tiêu đề dải chuyên mục có gắn link về trang chuyên mục */
.section-heading a,
.section-heading a:hover {
  color: #ffffff;
}

/* ==============================================================
   QUẢNG CÁO: ô chứa mã nhúng (AdSense, iframe...)
   ============================================================== */
.ad-code {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  text-align: center;
}

.ad-code iframe,
.ad-code ins {
  max-width: 100%;
}

/* ==============================================================
   NỘI DUNG BÀI VIẾT / TRANG do trình soạn thảo WordPress sinh ra
   ============================================================== */
/* Ảnh căn trái/phải trong bài không được tràn xuống các khối phía dưới.
   (Không dùng clearfix trên .entry-content vì sẽ làm lệch khoảng cách so với thiết kế.) */
.article-signature,
.article-source-box,
.article-tags-box,
.article-content .social-share-bar,
.related-posts-section,
.page-links {
  clear: both;
}

.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: #1a202c;
  margin: 22px 0 12px;
}

.entry-content h2 { font-size: 20px; }
.entry-content h3 { font-size: 18px; }
.entry-content h4 { font-size: 16px; }
.entry-content h5,
.entry-content h6 { font-size: 15px; }

.entry-content ul,
.entry-content ol {
  margin: 0 0 16px 24px;
  line-height: 1.8;
  color: #2d3748;
}

.entry-content li > ul,
.entry-content li > ol {
  margin-bottom: 0;
}

.entry-content a {
  color: var(--primary-color);
}

.entry-content a:hover {
  text-decoration: underline;
}

.entry-content img {
  border-radius: 0;
}

.entry-content figure,
.entry-content .wp-caption {
  max-width: 100%;
  margin: 22px 0;
  text-align: center;
}

.entry-content figure img,
.entry-content .wp-caption img,
.entry-content img.aligncenter {
  margin-left: auto;
  margin-right: auto;
}

.entry-content figcaption,
.entry-content .wp-caption-text {
  font-size: 13px;
  font-style: italic;
  color: #64748b;
  margin-top: 8px;
  margin-bottom: 16px;
  text-align: center;
}

.entry-content .aligncenter {
  margin-left: auto;
  margin-right: auto;
}

.entry-content .alignleft {
  float: left;
  max-width: 50%;
  margin: 6px 20px 12px 0;
}

.entry-content .alignright {
  float: right;
  max-width: 50%;
  margin: 6px 0 12px 20px;
}

.entry-content blockquote {
  margin: 0 0 16px;
  padding: 12px 18px;
  background: #f8fafc;
  border-left: 3px solid var(--primary-color);
  border-radius: 0 4px 4px 0;
  font-style: italic;
  color: #334155;
}

.entry-content blockquote p:last-child {
  margin-bottom: 0;
}

.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 14px;
}

.entry-content th,
.entry-content td {
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: left;
}

.entry-content th {
  background: #f8fafc;
  font-weight: 600;
  color: #1e293b;
}

.entry-content iframe,
.entry-content video,
.entry-content embed,
.entry-content object {
  max-width: 100%;
}

.entry-content hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 22px 0;
}

.entry-content pre {
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 13px;
  overflow-x: auto;
}

.page-links {
  margin: 16px 0;
  font-family: var(--font-heading);
  font-weight: 600;
  color: #334155;
}

.page-links a,
.page-links > span {
  margin-left: 6px;
}

/* Sapo chữ mực xanh: màu xanh chủ đạo của giao diện (bản mẫu gốc dùng xám #334155) */
.article-sapo {
  color: var(--primary-color);
}

/* Thanh chia sẻ lặp lại ở cuối bài */
.social-share-bar.is-bottom {
  margin-top: 20px;
  border-bottom: none;
  padding-bottom: 0;
}

/* ==============================================================
   PHÂN TRANG: dùng lại kiểu .pagination-item của bản thiết kế
   ============================================================== */
.pagination-wrapper .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  background: #ffffff;
  transition: all 0.2s ease;
}

.pagination-wrapper a.page-numbers:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.pagination-wrapper .page-numbers.current {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #ffffff;
}

.pagination-wrapper .page-numbers.dots {
  border-color: transparent;
  min-width: 0;
  padding: 0 2px;
}

/* ==============================================================
   TRẠNG THÁI RỖNG, TRANG 404, Ô TÌM KIẾM TRONG TRANG
   ============================================================== */
.no-results {
  padding: 30px 0;
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

.error-404 {
  padding: 50px 0 60px;
  text-align: center;
}

.error-404 .error-code {
  font-family: var(--font-heading);
  font-size: 72px;
  font-weight: 700;
  line-height: 1;
  color: var(--primary-color);
  margin-bottom: 12px;
}

.error-404 .article-title {
  margin-bottom: 8px;
}

.error-404 .error-home-link {
  display: inline-block;
  margin-top: 18px;
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--primary-color);
}

.inline-search-form {
  display: flex;
  gap: 6px;
  max-width: 420px;
  margin: 20px auto 0;
}

.inline-search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 13.5px;
  outline: none;
}

.inline-search-form input[type="search"]:focus {
  border-color: var(--primary-color);
}

.inline-search-form button {
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
}

/* ==============================================================
   CHÂN TRANG
   ============================================================== */
.footer-content-block a:hover {
  color: var(--primary-color);
}

.footer-bottom-copy {
  border-top: 1px solid var(--border-color);
}

/* ==============================================================
   MOBILE
   ============================================================== */
@media (max-width: 768px) {
  .main-menu .sub-menu {
    position: static;
    display: block;
    min-width: 0;
    box-shadow: none;
    background-color: rgba(0,0,0,0.12);
  }

  .main-menu .sub-menu li a {
    padding: 10px 16px 10px 30px;
  }

  .entry-content .alignleft,
  .entry-content .alignright {
    float: none;
    max-width: 100%;
    margin: 16px auto;
  }
}
