/*
Theme Name:  Đài Loan
Theme URI:   https://dailoan.me
Author:      dailoan.me
Author URI:  https://dailoan.me
Description: Theme hiện đại tối giản cho dailoan.me — tin tức, du lịch, visa và cộng đồng người Việt tại Đài Loan. Load nhanh, chuẩn SEO, responsive.
Version:     6.0.0
Requires at least: 6.2
Tested up to:      6.7
Requires PHP:      8.0
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       dailoan
Tags: news, blog, custom-logo, custom-menu, featured-images, responsive-layout, translation-ready
*/

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  /* Colors — Light Mode */
  --c-red:      #d92b3a;
  --c-red-dk:   #b01f2c;
  --c-navy:     #0f172a;
  --c-ink:      #1e293b;
  --c-muted:    #64748b;
  --c-subtle:   #94a3b8;
  --c-border:   #e2e8f0;
  --c-surface:  #f8fafc;
  --c-white:    #ffffff;
  --c-bg:       #ffffff;

  /* Category accent palette */
  --c-travel:   #0ea5e9;
  --c-visa:     #8b5cf6;
  --c-work:     #f59e0b;
  --c-culture:  #10b981;
  --c-community:#ef4444;

  /* Typography */
  --f-sans:  'DM Sans', system-ui, -apple-system, sans-serif;
  --f-serif: 'Lora', Georgia, serif;

  /* Spacing scale */
  --sp-1: .25rem;  --sp-2: .5rem;   --sp-3: .75rem;
  --sp-4: 1rem;    --sp-5: 1.25rem; --sp-6: 1.5rem;
  --sp-8: 2rem;    --sp-10: 2.5rem; --sp-12: 3rem; --sp-16: 4rem;

  /* Radii */
  --r-sm: 4px;  --r-md: 8px;  --r-lg: 14px;  --r-xl: 20px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.06);
  --shadow-sm: 0 2px 8px rgba(15,23,42,.08);
  --shadow-md: 0 8px 24px rgba(15,23,42,.1);
  --shadow-lg: 0 20px 48px rgba(15,23,42,.14);

  /* Layout */
  --max-w:     1180px;
  --sidebar-w: 300px;
  --gap:       var(--sp-6);

  /* Transitions */
  --transition: .15s ease;
}

/* ============================================================
   DARK MODE TOKENS
   ============================================================ */
.dark {
  --c-bg:      #0f172a;
  --c-white:   #0f172a;
  --c-ink:     #e2e8f0;
  --c-navy:    #f1f5f9;
  --c-muted:   #94a3b8;
  --c-subtle:  #64748b;
  --c-border:  #1e293b;
  --c-surface: #1e293b;
  color-scheme: dark;
}
.dark .site-header { background: rgba(15,23,42,.95); }
.dark .primary-nav { background: #0f172a; }
.dark .ticker       { background: #1e293b; }
.dark .logo-mark    { background: var(--c-red); }
.dark .logo-text    { background: rgba(255,255,255,.08); }
.dark .post-card__thumb,
.dark .hero__main-img { background: #1e293b; }
.dark .topic-pill   { background: #1e293b; border-color: #334155; }
.dark .badge--blue   { background: #0c2d3d; }
.dark .badge--purple { background: #2d1b5e; }
.dark .badge--amber  { background: #3d2c00; }
.dark .badge--green  { background: #0a2e1e; }
.dark .badge--red    { background: #3d0a10; }
.dark .author-card  { background: #1e293b; }
.dark .post-nav a   { background: #1e293b; }
.dark .comment-form input,
.dark .comment-form textarea { background: #1e293b; color: var(--c-ink); }
.dark .entry-content blockquote { background: #1e293b; }
.dark .tag-cloud a  { background: #1e293b; border-color: #334155; }
.dark .entry-tags a { background: #1e293b; border-color: #334155; }
.dark .header-search-form input { background: #1e293b; color: var(--c-ink); }
.dark img { opacity: .92; }

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--f-sans);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--f-serif);
  font-weight: 700;
  line-height: 1.25;
  color: var(--c-navy);
  letter-spacing: -.02em;
}
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
h3 { font-size: clamp(1rem, 2.5vw, 1.25rem); }
h4 { font-size: 1rem; }

/* ============================================================
   LAYOUT
   ============================================================ */
.wrap {
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

/* ============================================================
   READING PROGRESS BAR [v5 NEW]
   ============================================================ */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--c-red), #f87171);
  z-index: 9999;
  transition: width .1s linear;
  border-radius: 0 2px 2px 0;
}

/* ============================================================
   HEADER — shrink on scroll [v5 ENHANCED]
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-xs);
  transition: transform .25s ease, box-shadow .2s ease, padding .2s ease;
}
.site-header.is-scrolled .header-inner { padding-block: .6rem; }
.site-header.is-hidden { transform: translateY(-100%); }

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding-block: .875rem;
  transition: padding .2s ease;
}

/* Logo */
.site-logo {
  display: flex;
  align-items: center;
  gap: 0;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-mark {
  background: var(--c-red);
  color: #fff;
  font-family: var(--f-sans);
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: -.01em;
  padding: .3rem .6rem;
  border-radius: var(--r-sm) 0 0 var(--r-sm);
  line-height: 1;
}
.logo-text {
  background: var(--c-navy);
  color: #fff;
  font-family: var(--f-sans);
  font-weight: 700;
  font-size: .95rem;
  padding: .3rem .6rem;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  line-height: 1;
}

/* Nav */
.primary-nav { flex: 1; }
.primary-nav ul {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.primary-nav a {
  display: block;
  padding: .35rem .7rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--c-ink);
  border-radius: var(--r-sm);
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.primary-nav a:hover { background: var(--c-surface); color: var(--c-red); }
.primary-nav .current-menu-item > a,
.primary-nav .current-menu-ancestor > a {
  color: var(--c-red);
  background: #fef2f4;
  font-weight: 600;
}
.dark .primary-nav .current-menu-item > a,
.dark .primary-nav .current-menu-ancestor > a { background: rgba(217,43,58,.15); }

/* Category nav pills */
.cat-nav-item[data-cat="travel"]    a { --pill-c: var(--c-travel); }
.cat-nav-item[data-cat="visa"]      a { --pill-c: var(--c-visa); }
.cat-nav-item[data-cat="work"]      a { --pill-c: var(--c-work); }
.cat-nav-item[data-cat="community"] a { --pill-c: var(--c-community); }

/* Header utilities */
.header-utils {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
  flex-shrink: 0;
}

/* Header search */
.header-search-form {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.header-search-form input[type="search"] {
  width: 180px;
  padding: .4rem .75rem;
  font-size: .85rem;
  border: 1px solid var(--c-border);
  border-radius: 99px;
  background: var(--c-surface);
  color: var(--c-ink);
  transition: border-color var(--transition), width .2s;
  outline: none;
}
.header-search-form input[type="search"]:focus {
  border-color: var(--c-red);
  width: 220px;
}
.header-search-form button {
  background: var(--c-red);
  color: #fff;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition);
}
.header-search-form button:hover { background: var(--c-red-dk); }

/* Dark mode toggle [v5 NEW] */
#dm-toggle {
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
#dm-toggle:hover { border-color: var(--c-red); color: var(--c-red); }
#dm-toggle .dm-icon-dark  { display: block; }
#dm-toggle .dm-icon-light { display: none; }
.dark #dm-toggle .dm-icon-dark  { display: none; }
.dark #dm-toggle .dm-icon-light { display: block; }

/* Mobile toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: .4rem .55rem;
  font-size: 1rem;
  line-height: 1;
  color: var(--c-ink);
}

@media (max-width: 840px) {
  .nav-toggle { display: flex; align-items: center; }
  .primary-nav {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 0; right: 0;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    padding: var(--sp-4);
    box-shadow: var(--shadow-md);
  }
  .primary-nav.is-open { display: block; }
  .primary-nav ul { flex-direction: column; gap: var(--sp-1); }
  .primary-nav a { padding: .5rem .75rem; font-size: 1rem; }
  .header-search-form { display: none; }
  .header-utils { order: -1; gap: var(--sp-1); }
}

/* ============================================================
   BREAKING NEWS TICKER
   ============================================================ */
.ticker {
  background: var(--c-navy);
  color: rgba(255,255,255,.75);
  font-size: .78rem;
  display: flex;
  align-items: center;
  overflow: hidden;
  height: 32px;
}
.ticker__label {
  background: var(--c-red);
  color: #fff;
  font-weight: 700;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 .75rem;
  height: 100%;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}
.ticker__track { overflow: hidden; flex: 1; }
.ticker__inner {
  display: inline-flex;
  gap: 3rem;
  white-space: nowrap;
  animation: dl-ticker 35s linear infinite;
}
.ticker__inner a { color: rgba(255,255,255,.85); }
.ticker__inner a:hover { color: #fff; }
@keyframes dl-ticker {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  padding-block: .625rem;
  font-size: .78rem;
  color: var(--c-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
}
.breadcrumb a { color: var(--c-muted); transition: color var(--transition); }
.breadcrumb a:hover { color: var(--c-red); }
.breadcrumb-sep { color: var(--c-border); }

/* ============================================================
   CATEGORY BADGE
   ============================================================ */
.badge {
  display: inline-block;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: .15rem .55rem .2rem;
  border-radius: 3px;
  line-height: 1.4;
}
.badge--red    { background: #fee2e5; color: var(--c-red); }
.badge--blue   { background: #e0f2fe; color: #0369a1; }
.badge--purple { background: #ede9fe; color: #6d28d9; }
.badge--amber  { background: #fef3c7; color: #92400e; }
.badge--green  { background: #d1fae5; color: #065f46; }

/* ============================================================
   POST META
   ============================================================ */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  font-size: .78rem;
  color: var(--c-muted);
  margin-top: .5rem;
}
.post-meta__sep { color: var(--c-border); }

/* ============================================================
   HERO LAYOUT
   ============================================================ */
.hero { padding: var(--sp-8) 0 var(--sp-6); }
.hero__grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--sp-6);
  align-items: start;
}
@media (max-width: 900px) { .hero__grid { grid-template-columns: 1fr; } }

.hero__main {}
.hero__main-img {
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--c-surface);
  box-shadow: var(--shadow-sm);
}
.hero__main-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .45s ease;
}
.hero__main:hover .hero__main-img img { transform: scale(1.03); }
.hero__main-body { padding-top: var(--sp-4); }
.hero__main-title {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  margin: var(--sp-2) 0 var(--sp-3);
  line-height: 1.2;
}
.hero__main-title a:hover { color: var(--c-red); }
.hero__main-excerpt {
  color: var(--c-muted);
  font-size: .95rem;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero__list { display: flex; flex-direction: column; }
.hero__item {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--c-border);
}
.hero__item:last-child { border-bottom: none; }
.hero__item-thumb {
  width: 88px; height: 62px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-surface);
}
.hero__item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.hero__item-title {
  font-size: .9rem;
  font-weight: 700;
  font-family: var(--f-serif);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hero__item-title a:hover { color: var(--c-red); }

/* ============================================================
   TOPIC PILLS
   ============================================================ */
.topics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-3);
  padding-bottom: var(--sp-8);
}
@media (max-width: 640px) { .topics-bar { grid-template-columns: repeat(2, 1fr); } }

.topic-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-white);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
}
.topic-pill:hover {
  border-color: var(--topic-c);
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  transform: translateY(-2px);
}
.topic-pill__icon {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--topic-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.topic-pill__text strong {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  color: var(--c-navy);
  font-family: var(--f-sans);
}
.topic-pill__text span { font-size: .73rem; color: var(--c-muted); }

.topic-pill--travel    { --topic-c: var(--c-travel);    --topic-bg: #e0f2fe; }
.topic-pill--visa      { --topic-c: var(--c-visa);      --topic-bg: #ede9fe; }
.topic-pill--work      { --topic-c: var(--c-work);      --topic-bg: #fef3c7; }
.topic-pill--community { --topic-c: var(--c-community); --topic-bg: #fee2e5; }

/* ============================================================
   SECTION HEADING
   ============================================================ */
.section-heading {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
}
.section-heading__line {
  width: 3px; height: 1.1em;
  background: var(--section-c, var(--c-red));
  border-radius: 2px;
  flex-shrink: 0;
  align-self: center;
}
.section-heading h2 {
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-family: var(--f-sans);
  color: var(--c-navy);
}
.section-heading__more {
  margin-left: auto;
  font-size: .78rem;
  font-weight: 600;
  color: var(--section-c, var(--c-red));
  white-space: nowrap;
}
.section-heading__more:hover { text-decoration: underline; }

/* ============================================================
   POST CARD — [v5] skeleton loading state
   ============================================================ */
.post-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.post-card__thumb {
  border-radius: var(--r-md);
  overflow: hidden;
  aspect-ratio: 16/10;
  background: var(--c-surface);
  margin-bottom: var(--sp-3);
  flex-shrink: 0;
  position: relative;
}
.post-card__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .35s ease, opacity .3s ease;
  opacity: .95;
}
.post-card:hover .post-card__thumb img { transform: scale(1.04); opacity: 1; }
.post-card__body { flex: 1; display: flex; flex-direction: column; }
.post-card__title {
  font-size: .975rem;
  font-weight: 700;
  line-height: 1.4;
  margin: var(--sp-2) 0 var(--sp-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card__title a:hover { color: var(--c-red); }
.post-card__excerpt {
  font-size: .83rem;
  color: var(--c-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

/* Horizontal card */
.post-card--h {
  flex-direction: row;
  gap: var(--sp-3);
  align-items: flex-start;
}
.post-card--h .post-card__thumb {
  width: 110px; height: 78px;
  aspect-ratio: unset;
  flex-shrink: 0;
  margin-bottom: 0;
}
.post-card--h .post-card__title { font-size: .875rem; -webkit-line-clamp: 2; }
.post-card--h .post-card__excerpt { display: none; }

/* ============================================================
   GRID UTILITIES
   ============================================================ */
.g-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--gap); }
.g-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: var(--gap); }
.g-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: var(--gap); }
@media (max-width: 900px) { .g-3, .g-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px) { .g-2, .g-3, .g-4 { grid-template-columns: 1fr; } }

/* ============================================================
   MAIN CONTENT + SIDEBAR
   ============================================================ */
.layout-main { padding-block: var(--sp-8) var(--sp-12); }
.layout-cols {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: var(--sp-8);
  align-items: start;
}
@media (max-width: 960px) { .layout-cols { grid-template-columns: 1fr; } }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  position: sticky;
  top: 80px;
  content-visibility: auto;
  contain-intrinsic-size: 0 640px;
}
.widget {}
.widget-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-navy);
  font-family: var(--f-sans);
  border-left: 2px solid var(--c-red);
  padding-left: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.ranked-list { display: flex; flex-direction: column; }
.ranked-list__item {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: .65rem 0;
  border-bottom: 1px solid var(--c-border);
}
.ranked-list__item:last-child { border-bottom: none; }
.ranked-list__num {
  font-size: 1.35rem;
  font-weight: 900;
  font-family: var(--f-serif);
  color: var(--c-border);
  line-height: 1;
  width: 22px;
  flex-shrink: 0;
  padding-top: .1rem;
}
.ranked-list__title { font-size: .85rem; font-weight: 600; line-height: 1.4; color: var(--c-ink); }
.ranked-list__title a:hover { color: var(--c-red); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag-cloud a {
  display: inline-block;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: .75rem;
  font-weight: 500;
  padding: .2rem .6rem;
  border-radius: 99px;
  transition: all var(--transition);
}
.tag-cloud a:hover { background: var(--c-red); color: #fff; border-color: var(--c-red); }

/* ============================================================
   SINGLE POST
   ============================================================ */
.post-header { margin-bottom: var(--sp-6); }
.post-header__title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  line-height: 1.2;
  margin: var(--sp-3) 0 var(--sp-4);
}
.post-cover {
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  margin-bottom: var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.post-cover img { width: 100%; height: 100%; object-fit: cover; }

/* [v5] Share buttons on single post */
.post-share {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  flex-wrap: wrap;
}
.post-share__label { font-size: .78rem; color: var(--c-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-muted);
  transition: all var(--transition);
  cursor: pointer;
}
.share-btn:hover { border-color: var(--c-red); color: var(--c-red); background: #fef2f4; }
.share-btn--native { background: var(--c-red); color: #fff; border-color: var(--c-red); }
.share-btn--native:hover { background: var(--c-red-dk); color: #fff; border-color: var(--c-red-dk); }

/* Entry content */
.entry-content {
  font-size: 1.025rem;
  line-height: 1.85;
  color: #334155;
}
.dark .entry-content { color: #cbd5e1; }
.entry-content > * + * { margin-top: 1.25rem; }
.entry-content h2 { margin-top: 2.5rem; font-size: 1.5rem; }
.entry-content h3 { margin-top: 2rem; font-size: 1.2rem; }
.entry-content a { color: var(--c-red); text-decoration: underline; text-underline-offset: 3px; }
.entry-content img { border-radius: var(--r-md); }
.entry-content blockquote {
  border-left: 3px solid var(--c-red);
  padding: var(--sp-4) var(--sp-6);
  background: var(--c-surface);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-style: italic;
  color: var(--c-muted);
  font-family: var(--f-serif);
  font-size: 1.05rem;
}
.entry-content ul { padding-left: 1.4rem; list-style: disc; }
.entry-content ol { padding-left: 1.4rem; list-style: decimal; }
.entry-content li { margin-bottom: .35rem; }
.entry-content table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.entry-content th, .entry-content td { border: 1px solid var(--c-border); padding: .5rem .75rem; text-align: left; }
.entry-content th { background: var(--c-surface); font-weight: 600; }
.entry-content figure { text-align: center; }
.entry-content figcaption { font-size: .8rem; color: var(--c-muted); margin-top: .4rem; }

/* [v5] Table of Contents */
.toc {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-6);
  font-size: .9rem;
}
.toc__title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--c-navy);
  font-family: var(--f-sans);
  border-left: 2px solid var(--c-red);
  padding-left: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.toc ol { padding-left: 1.25rem; list-style: decimal; }
.toc li { padding: .2rem 0; }
.toc a { color: var(--c-muted); transition: color var(--transition); }
.toc a:hover { color: var(--c-red); }

/* Post tags */
.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--c-border);
}
.entry-tags a {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  font-size: .78rem;
  padding: .25rem .65rem;
  border-radius: 99px;
}
.entry-tags a:hover { background: var(--c-red); color: #fff; border-color: var(--c-red); }

/* Author box */
.author-card {
  display: flex;
  gap: var(--sp-4);
  align-items: center;
  padding: var(--sp-5);
  background: var(--c-surface);
  border-radius: var(--r-lg);
  margin-top: var(--sp-8);
  border: 1px solid var(--c-border);
}
.author-card__avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.author-card__avatar img { width: 100%; height: 100%; object-fit: cover; }
.author-card__name { font-weight: 700; font-family: var(--f-sans); margin-bottom: .15rem; }
.author-card__bio { font-size: .85rem; color: var(--c-muted); }

/* Post nav */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
}
.post-nav a {
  display: block;
  padding: var(--sp-4);
  background: var(--c-surface);
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  font-size: .875rem;
  transition: border-color var(--transition);
}
.post-nav a:hover { border-color: var(--c-red); }
.post-nav__label { font-size: .7rem; color: var(--c-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: .25rem; }
.post-nav__title { font-weight: 600; color: var(--c-navy); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-nav a:nth-child(2) { text-align: right; }
@media (max-width: 480px) { .post-nav { grid-template-columns: 1fr; } }

/* ============================================================
   RELATED POSTS
   ============================================================ */
.related { margin-top: var(--sp-8); }

/* ============================================================
   COMMENTS
   ============================================================ */
.comments { margin-top: var(--sp-8); }
.comments__title { font-size: 1.1rem; font-family: var(--f-sans); margin-bottom: var(--sp-5); }
.comment-list > li { padding-block: var(--sp-4); border-bottom: 1px solid var(--c-border); }
.comment-author b { font-weight: 700; }
.comment-metadata { font-size: .78rem; color: var(--c-muted); }
.comment-body { margin-top: var(--sp-2); font-size: .9rem; }
.comment-form input,
.comment-form textarea {
  width: 100%;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: .6rem .9rem;
  font-size: .9rem;
  color: var(--c-ink);
  background: var(--c-white);
  outline: none;
  transition: border-color var(--transition);
  display: block;
  margin-bottom: var(--sp-3);
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--c-red); }
.comment-form textarea { min-height: 110px; resize: vertical; }
.comment-form .submit {
  background: var(--c-red);
  color: #fff;
  border: none;
  padding: .6rem 1.5rem;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: .9rem;
  transition: background var(--transition);
}
.comment-form .submit:hover { background: var(--c-red-dk); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: var(--sp-8);
}
.pagination a, .pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px; height: 36px;
  padding-inline: .5rem;
  border-radius: var(--r-sm);
  font-size: .85rem;
  font-weight: 600;
  border: 1px solid var(--c-border);
  color: var(--c-ink);
  transition: all var(--transition);
}
.pagination a:hover, .pagination .current {
  background: var(--c-red);
  color: #fff;
  border-color: var(--c-red);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--c-navy);
  color: #94a3b8;
  content-visibility: auto;
  contain-intrinsic-size: 0 420px;
}
.dark .site-footer { background: #020617; }
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: var(--sp-8);
  padding-block: var(--sp-12);
}
@media (max-width: 840px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-6); } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }

.footer-logo { display: inline-flex; margin-bottom: var(--sp-4); }
.footer-logo .logo-mark { background: var(--c-red); }
.footer-logo .logo-text { background: rgba(255,255,255,.1); }
.footer-desc { font-size: .875rem; line-height: 1.7; margin-bottom: var(--sp-4); }

.social-row { display: flex; gap: var(--sp-2); }
.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: #cbd5e1;
  font-size: .78rem;
  font-weight: 700;
  transition: background var(--transition), color var(--transition);
  border: 1px solid rgba(255,255,255,.1);
}
.social-btn:hover { background: var(--c-red); color: #fff; border-color: var(--c-red); }

.footer-col h4 {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #e2e8f0;
  font-family: var(--f-sans);
  margin-bottom: var(--sp-4);
}
.footer-col ul li { padding-block: .3rem; border-bottom: 1px solid rgba(255,255,255,.05); }
.footer-col ul li:last-child { border-bottom: none; }
.footer-col ul a { font-size: .83rem; color: #64748b; transition: color var(--transition); }
.footer-col ul a:hover { color: var(--c-red); }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,.07);
  padding-block: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
  font-size: .78rem;
  color: #475569;
}
.footer-bottom a { color: #64748b; transition: color var(--transition); }
.footer-bottom a:hover { color: var(--c-red); }

/* ============================================================
   BACK TO TOP
   ============================================================ */
.back-top {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--c-navy);
  color: #fff;
  border: none;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, background var(--transition);
  z-index: 300;
  box-shadow: var(--shadow-md);
}
.back-top.show { opacity: 1; pointer-events: auto; }
.back-top:hover { background: var(--c-red); }

/* ============================================================
   [v5 NEW] IMAGE FADE-IN WHEN LOADED
   ============================================================ */
img[loading="lazy"] { opacity: 0; transition: opacity .4s ease; }
img[loading="lazy"].img-loaded,
img[loading="lazy"][src] { opacity: 1; }

/* ============================================================
   UTILITIES
   ============================================================ */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-header, .site-footer, .sidebar, .ticker, .back-top,
  #reading-progress, #dm-toggle { display: none !important; }
  .layout-cols { grid-template-columns: 1fr !important; }
}

/* ============================================================
   [v6] TOC — active link highlight khi scroll
   ============================================================ */
.toc a.is-active {
  color: var(--c-red);
  font-weight: 600;
}

/* ============================================================
   [v6] CRITICAL CSS — Above-the-fold inline hint
   Nếu dùng plugin Critical CSS, ưu tiên extract các rules:
   .site-header, .ticker, .hero__main-img, .post-cover
   ============================================================ */

/* ============================================================
   [v6] CONTENT-VISIBILITY — tăng rendering performance
   Áp dụng cho các section không trong viewport
   ============================================================ */
.related,
.comments,
.author-card,
.post-nav {
  content-visibility: auto;
  contain-intrinsic-size: 0 300px;
}

/* ============================================================
   [v6] FONT-DISPLAY swap fallback — giảm CLS
   Chỉ cần khi self-host, Google Fonts đã có &display=swap
   ============================================================ */
@font-face {
  font-family: 'DM Sans';
  font-display: swap;
  /* Được override bởi /fonts/fonts.css nếu self-host */
}

/* ============================================================
   [v6] IMAGE aspect-ratio để tránh CLS
   ============================================================ */
.post-card__thumb img,
.hero__main-img img,
.hero__item-thumb img {
  aspect-ratio: 16/10;
  object-fit: cover;
  width: 100%;
  height: auto;
}
.post-card--h .post-card__thumb img {
  aspect-ratio: 6/5;
}

/* ============================================================
   [v6] FOCUSED OUTLINE rõ ràng hơn cho a11y
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--c-red);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ============================================================
   [v6] SKIP LINK — accessibility
   ============================================================ */
.skip-link {
  position: absolute;
  top: -9999px;
  left: 0;
  background: var(--c-red);
  color: #fff;
  padding: .5rem 1rem;
  z-index: 9999;
  font-size: .875rem;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.skip-link:focus {
  top: 0;
}
