/* ===== Design tokens ===== */
:root {
  --red: #B21F2D;
  --ink: #1A1A1A;
  --cream: #F5F1EC;
  --gray: #6E6E6E;
  --border: #E4E0DA;
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --sans: system-ui, 'Segoe UI', Roboto, Arial, sans-serif;
  --maxw: 1140px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: #fff; line-height: 1.5; }
img { max-width: 100%; display: block; height: auto; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--red); }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.3; margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ===== Header ===== */
.topbar { display: flex; align-items: center; gap: 20px; padding-top: 14px; padding-bottom: 14px; }
.logo { font-family: var(--serif); font-weight: 700; font-size: 32px; color: var(--red); letter-spacing: -0.5px; }
.logo:hover { color: var(--red); }
.today { color: var(--gray); font-size: 13px; margin-right: auto; }
.search { display: flex; }
.search input { border: 1px solid var(--border); border-right: 0; border-radius: 4px 0 0 4px; padding: 7px 10px; font-size: 13px; width: 200px; font-family: var(--sans); }
.search input:focus { outline: 2px solid var(--red); outline-offset: -1px; }
.search button { border: 0; background: var(--red); color: #fff; padding: 0 14px; border-radius: 0 4px 4px 0; font-size: 13px; cursor: pointer; font-family: var(--sans); }

.nav { position: sticky; top: 0; z-index: 100; background: #fff; border-top: 1px solid var(--border); border-bottom: 2px solid var(--red); }
.nav.is-stuck { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08); }
.nav-inner { display: flex; gap: 4px; overflow-x: auto; }
.nav-inner { scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav-inner a { padding: 10px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.nav-inner a.active { color: var(--red); }

/* ===== Story card chung ===== */
.story figure { overflow: hidden; border-radius: 4px; background: var(--cream); }
.story h3 { font-size: 16px; font-weight: 600; margin-top: 8px; }
.story h3:hover, .story h1:hover { color: var(--red); }
.meta { display: block; color: var(--gray); font-size: 12px; margin-top: 6px; }
.sapo { color: #444; font-size: 15px; margin: 10px 0 0; }

/* ===== Hero ===== */
.hero { display: grid; grid-template-columns: 2fr 1fr; gap: 28px; padding-top: 24px; padding-bottom: 24px; }
.hero-main h1 { font-size: 30px; font-weight: 700; margin-top: 14px; }
.hero-side { display: flex; flex-direction: column; gap: 16px; }
.side-story a { display: grid; grid-template-columns: 100px 1fr; gap: 10px; align-items: start; }
.side-story h3 { font-size: 14.5px; margin-top: 0; }
.side-story .meta { margin-top: 2px; }
.side-story + .side-story { border-top: 1px solid var(--border); padding-top: 16px; }

/* ===== Dải tin nhanh ===== */
.quick-strip { background: var(--cream); padding: 20px 0; }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.quick-card h3 { font-size: 15px; }

/* ===== Lưới chính: nội dung + sidebar ===== */
.main-grid { display: grid; grid-template-columns: 1fr 300px; gap: 32px; padding-top: 28px; padding-bottom: 28px; }

/* ===== Khối chuyên mục ===== */
.cat-block + .cat-block { margin-top: 36px; }
.cat-block { scroll-margin-top: 56px; }
.cat-title { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 2px solid var(--red); padding-bottom: 8px; margin-bottom: 16px; }
.cat-title h2 { font-size: 20px; margin: 0; }
.cat-title h2 a { color: var(--red); }
.cat-title .more { font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: var(--gray); }
.cat-title .more:hover { color: var(--red); }
.cat-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.cat-main h3 { font-size: 20px; }
.cat-subs { display: flex; flex-direction: column; gap: 14px; }
.sub-story a { display: grid; grid-template-columns: 84px 1fr; gap: 10px; align-items: start; }
.sub-story h3 { font-size: 13.5px; margin-top: 0; }
.sub-story + .sub-story { border-top: 1px solid var(--border); padding-top: 14px; }

/* ===== Sidebar ===== */
.side-title { font-size: 18px; color: var(--red); border-bottom: 2px solid var(--red); padding-bottom: 8px; margin-bottom: 4px; }
.rank-list { counter-reset: rank; }
.rank-list li { counter-increment: rank; display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; font-family: var(--serif); }
.rank-list li::before { content: counter(rank); color: var(--red); font-size: 22px; font-weight: 700; line-height: 1; min-width: 18px; }
.sidebar { position: sticky; top: 56px; align-self: start; }

/* ===== Footer ===== */
.site-footer { background: var(--ink); color: #cfcac2; margin-top: 12px; font-size: 13.5px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; padding-top: 32px; padding-bottom: 24px; }
.footer-logo { font-family: var(--serif); font-weight: 700; font-size: 24px; color: #fff; margin: 0 0 8px; }
.footer-desc { margin: 0; line-height: 1.6; }
.footer-head { color: #fff; font-weight: 700; margin: 0 0 10px; }
.footer-links li { padding: 3px 0; }
.site-footer a:hover { color: #fff; }
.footer-bottom { border-top: 1px solid #3a3a3a; padding-top: 14px; padding-bottom: 18px; color: #8f8a83; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .hero { grid-template-columns: 1fr; }
  .hero-side { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .side-story + .side-story { border-top: 0; padding-top: 0; }
  .hero-side .article-item + .article-item { border-top: 0; padding-top: 0; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .main-grid { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .layout-grid-5, .layout-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .layout-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .has-sidebar { grid-template-columns: 1fr; }
}

/* ===== Article page ===== */
.breadcrumb { padding: 14px 0 2px; font-size: 13px; color: var(--gray); }
.breadcrumb a { font-weight: 600; }
.breadcrumb .sep { margin: 0 6px; color: var(--gray); }
.article h1 { font-size: 34px; margin: 8px 0 12px; }
.detail-meta { font-size: 13px; color: var(--gray); margin: 0 0 14px; }
.detail-meta .cat { color: var(--red); font-weight: 700; }
.detail-meta .author { font-weight: 600; color: var(--ink); }
.article-sapo { font-size: 17px; font-weight: 600; color: #444; margin: 0 0 18px; }
.article figure { margin: 0 0 6px; }
.article figcaption { font-size: 13px; color: var(--gray); text-align: center; padding: 8px 0 12px; }
.article-body { font-family: var(--serif); font-size: 17px; line-height: 1.7; }
.article-body p { margin: 0 0 18px; }
.article-body h2 { font-size: 22px; margin: 26px 0 12px; }
.article-body blockquote { margin: 0 0 18px; padding: 14px 18px; background: var(--cream); border-left: 3px solid var(--red); font-style: italic; }
.article-author { text-align: right; font-weight: 700; font-family: var(--serif); margin: 18px 0 0; }
.article-tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 20px; }
.tag { background: var(--cream); color: var(--red); font-size: 13px; font-weight: 600; padding: 5px 14px; border-radius: 999px; }
.tag:hover { background: var(--red); color: #fff; }
.share { margin-left: auto; display: flex; gap: 8px; }
.share a { border: 1px solid var(--border); border-radius: 4px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.share a:hover { border-color: var(--red); }
.related { margin-top: 32px; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ===== Category & search pages ===== */
.cat-head { border-bottom: 2px solid var(--red); padding: 14px 0 10px; }
.cat-head h1 { font-size: 30px; color: var(--red); }
.cat-desc { color: var(--gray); font-size: 14px; margin: 6px 0 0; }
.cat-feature { padding: 18px 0 4px; }
.cat-feature h2 { font-size: 24px; margin: 10px 0 0; }
.row-list { margin-top: 14px; }
.row-story { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 18px 0; border-top: 1px solid var(--border); }
.row-story h3 { font-size: 17px; margin: 0 0 6px; }
.sapo-sm { font-size: 14px; color: var(--gray); margin: 0 0 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-story .meta { margin-top: 0; }
.pagination { display: flex; justify-content: center; gap: 8px; padding: 20px 0 8px; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; font-weight: 600; }
.pagination .active { background: var(--red); border-color: var(--red); color: #fff; }

/* ===== Search page ===== */
.search-head { border-bottom: 2px solid var(--red); padding: 14px 0 10px; }
.search-head h1 { font-size: 26px; }
#search-summary { color: var(--gray); font-size: 14px; margin: 6px 0 0; }
#no-results { padding: 24px 0 8px; font-size: 15px; }
mark { background: #FBE9A8; color: inherit; padding: 0 2px; border-radius: 2px; }

/* ===== Trending bar ===== */
.trending { border-bottom: 1px solid var(--border); }
.trending-inner { display: flex; align-items: center; gap: 8px; padding-top: 10px; padding-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.trending-inner::-webkit-scrollbar { display: none; }
.trending-label { color: var(--red); font-weight: 700; font-size: 13px; white-space: nowrap; }
.trending .tag { white-space: nowrap; }
.trending-weather { margin-left: auto; color: var(--gray); font-size: 13px; white-space: nowrap; }

/* ===== Cat subnav + editorial main ===== */
.cat-subnav { display: flex; gap: 14px; margin: 0 16px; flex: 1; min-width: 0; overflow: hidden; }
.cat-subnav a { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--gray); white-space: nowrap; }
.cat-subnav a:hover { color: var(--red); }
.cat-main { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; align-items: start; }
.cat-main-text h3 { margin-top: 0; }
.cat-main-text .sapo { font-size: 14px; }

/* ===== Multimedia (nền tối) ===== */
.mm { background: var(--ink); color: #fff; padding: 26px 0; margin-top: 12px; }
.mm-head { display: flex; align-items: baseline; gap: 16px; border-bottom: 2px solid var(--red); padding-bottom: 10px; margin-bottom: 18px; }
.mm-head h2 { color: #fff; font-size: 22px; text-transform: uppercase; letter-spacing: 1px; }
.mm-tabs { display: flex; gap: 8px; margin-left: auto; }
.mm-tabs a { border: 1px solid #3a3a3a; border-radius: 4px; padding: 4px 12px; font-size: 12.5px; font-weight: 600; color: #cfcac2; }
.mm-tabs a:hover { color: #fff; border-color: var(--red); }
.mm-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; }
.mm .article-item .article-title { color: #fff; }
.mm .article-item .article-meta { color: #8f8a83; }
.mm-main { --title-size: 20px; }
.mm-fig { position: relative; }
.mm-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; color: #fff; background: rgba(0, 0, 0, 0.25); }
.mm-side .article-item { border-top: 1px solid #3a3a3a; padding: 14px 0; }
.mm-side .article-item:first-child { border-top: 0; padding-top: 0; }
.mm-ic { color: var(--red); font-size: 12px; margin-right: 4px; }

/* ===== Magazine strip ===== */
.mag { padding: 26px 0 10px; }
.mag .cat-title h2 { color: var(--red); }
.mag-nav { display: flex; gap: 8px; }
.mag-nav button { width: 34px; height: 34px; border: 1px solid var(--border); background: #fff; border-radius: 4px; font-size: 18px; cursor: pointer; color: var(--ink); }
.mag-nav button:hover { border-color: var(--red); color: var(--red); }
.mag-track { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 6px; }
.mag-track::-webkit-scrollbar { display: none; }
.mag-track .article-item--overlay { flex: 0 0 220px; scroll-snap-align: start; }

/* ===== Đảo layout khối chẵn + hover motion ===== */
/* Giả định: .cat-col chỉ chứa các SECTION là .cat-block — chèn section khác sẽ làm lệch khối chẵn/lẻ (div .ad-infeed chen giữa là chủ ý: div không ảnh hưởng nth-of-type) */
.cat-block:nth-of-type(even) .article-item--feature { grid-template-columns: 1.3fr 1fr; }
.cat-block:nth-of-type(even) .article-item--feature .article-thumbnail { order: 0; }
a { transition: color 0.15s ease; }
.story img, .mag-card img { transition: transform 0.35s ease; }
.story a:hover img, .mag-card a:hover img { transform: scale(1.04); }

/* ===== Ad placeholders — khi thay ad thật: GỠ aria-hidden khỏi wrapper, giữ nhãn "Quảng cáo" đọc được ===== */
.ad { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: #F4F4F5; border: 1px dashed var(--border); border-radius: 4px; color: var(--gray); }
.ad span { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.ad em { font-style: normal; font-size: 13px; }
.ad-billboard { height: 250px; max-width: 970px; margin: 16px auto 4px; }
.ad-mpu { width: 300px; height: 250px; margin: 20px auto 0; }
.ad-infeed { height: 90px; margin: 36px 0; }
.ad-inarticle { width: 300px; height: 250px; margin: 0 auto 18px; }

/* ===== Component: article-item =====
   Base = dọc (thumb trên, chữ dưới). Bề rộng thumb và cỡ tiêu đề chạy qua
   custom property, nên modifier cỡ chỉ set biến chứ không định nghĩa lại grid.
   .article-content là bắt buộc: --horizontal và --feature là grid 2 cột, không
   có wrapper thì title/summary/meta thành grid item riêng và rơi sai cell. */
.article-item .article-thumbnail { display: block; overflow: hidden; border-radius: 4px; background: var(--cream); }
.article-item .article-title { font-family: var(--serif); font-size: var(--title-size, 16px); font-weight: 600; line-height: 1.3; margin: 8px 0 0; }
.article-item .article-title a:hover { color: var(--red); }
.article-item .article-summary { color: #444; font-size: var(--summary-size, 15px); margin: 8px 0 0; }
.article-item .article-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; color: var(--gray); font-size: 12px; margin-top: 6px; }
.article-item .article-category { color: var(--red); font-weight: 600; }
.article-item .article-category:hover { color: var(--red); text-decoration: underline; }
.article-item img { transition: transform 0.35s ease; }
.article-item .article-thumbnail:hover img { transform: scale(1.04); }

/* Thumb trái, chữ phải */
.article-item--horizontal { display: grid; grid-template-columns: var(--thumb-w, 100px) 1fr; gap: 10px; align-items: start; }
.article-item--horizontal .article-title { margin-top: 0; }
.article-item--horizontal .article-meta { margin-top: 4px; }

/* Token cỡ — chỉ set biến */
.article-item--compact { --thumb-w: 84px; --title-size: 13.5px; }
.article-item--wide { --thumb-w: 240px; --title-size: 17px; --summary-size: 14px; }

/* Chữ trái, ảnh phải */
.article-item--feature { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; align-items: start; --title-size: 20px; --summary-size: 14px; }
.article-item--feature .article-thumbnail { order: 2; }
.article-item--feature .article-title { margin-top: 0; }

/* Bài mở đầu hero */
.article-item--hero { --title-size: 30px; --summary-size: 15px; }
.article-item--hero .article-title { font-weight: 700; margin-top: 14px; }

/* Tiêu đề đè lên ảnh */
.article-item--overlay { position: relative; border-radius: 6px; overflow: hidden; }
.article-item--overlay .article-thumbnail { border-radius: 0; }
.article-item--overlay img { height: 308px; object-fit: cover; }
.article-item--overlay .article-content { position: absolute; inset: auto 0 0 0; padding: 44px 12px 12px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.8)); }
.article-item--overlay .article-title { margin: 0; color: #fff; --title-size: 15.5px; }

/* Không có ảnh — chỉ tiêu đề + thời gian */
.article-item--text { --title-size: 14px; }
.article-item--text .article-title { margin-top: 0; }

/* Cần rule này vì [hidden] thua display:grid — dùng cho lọc ở search.html */
.article-item[hidden] { display: none; }

/* rank-list vẽ số bằng counter + li::before; --text base không phải flex nên phải chỉ định lại */
.rank-list .article-item--text { display: flex; align-items: baseline; gap: 12px; }
.rank-list .article-item--text .article-title { font-size: 14px; }

.hero-side .article-item + .article-item { border-top: 1px solid var(--border); padding-top: 16px; }
.cat-subs .article-item + .article-item { border-top: 1px solid var(--border); padding-top: 14px; }

/* Cỡ tiêu đề riêng theo khối chứa — khôi phục cỡ chữ trước refactor */
.hero-side .article-item { --title-size: 14.5px; }
.quick-strip .article-item { --title-size: 15px; }

/* ===== Hệ arrangement — container quyết định cách sắp, card không tự giữ layout ===== */
.listing-layout { display: grid; gap: 20px; }
.layout-grid-2 { grid-template-columns: repeat(2, 1fr); }
.layout-grid-3 { grid-template-columns: repeat(3, 1fr); }
.layout-grid-4 { grid-template-columns: repeat(4, 1fr); }
.layout-grid-5 { grid-template-columns: repeat(5, 1fr); }
.layout-special { grid-template-columns: 2fr 1fr; }
.has-sidebar { grid-template-columns: 1fr 300px; gap: 32px; }

/* Override mobile — phải nằm sau mọi base rule: cùng specificity, thắng thua theo thứ tự trong file */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .search { width: 100%; }
  .search input { width: 100%; }
  .hero-main h1 { font-size: 23px; }
  .hero-side { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 20px; }
  .article h1 { font-size: 26px; }
  .article-body { font-size: 16px; }
  .related-grid { grid-template-columns: 1fr; }
  .share { margin-left: 0; width: 100%; }
  .row-story { grid-template-columns: 1fr; }
  .pagination a, .pagination span { min-width: 30px; height: 30px; }
  .trending-weather { display: none; }
  .cat-subnav { display: none; }
  .cat-main { grid-template-columns: 1fr; }
  .mm-grid { grid-template-columns: 1fr; }
  .mm-tabs { margin-left: 0; }
  .mm-head { flex-wrap: wrap; }
  .cat-block:nth-of-type(even) .article-item--feature { grid-template-columns: 1fr; }
  .cat-block:nth-of-type(even) .article-item--feature .article-thumbnail { order: 2; }
  .ad-billboard { height: 100px; }
  .layout-grid-5, .layout-grid-4, .layout-grid-3, .layout-grid-2 { grid-template-columns: 1fr; }
  .layout-special { grid-template-columns: 1fr; }
  .article-item--feature { grid-template-columns: 1fr; }
  .article-item--feature .article-thumbnail { order: 2; }
  .article-item--wide { grid-template-columns: 1fr; }
}

.row-story[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  a, .story img, .mag-card img, .article-item img { transition: none; }
  .story a:hover img, .mag-card a:hover img, .article-item .article-thumbnail:hover img { transform: none; }
}
