/* ========= Base ========= */
:root{
  --container: min(760px, calc(100% - 48px));
  --muted: #6b6b6b;
  --border: #eaeaea;
  --accent: #111;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";
  color:#222; line-height:1.8; background:#fff;
}
img{max-width:100%;height:auto;display:block}

/* ========= Layout ========= */
.container{width:var(--container);margin:0 auto}
.site-header{padding:28px 0}
.header-inner{display:flex;align-items:center;justify-content:space-between;gap:24px}
.logo a{font-family:'Poppins',system-ui,sans-serif;font-weight:800;font-size:28px;letter-spacing:-0.02em;color:#000;text-decoration:none}
.primary-nav .menu{list-style:none;display:flex;gap:24px;margin:0;padding:0}
.primary-nav a{font-size:14px;color:#666;text-decoration:none}
.primary-nav a:hover{text-decoration:underline}
.site-main{padding:8px 0 40px}
.site-footer{padding:28px 0;color:#777;font-size:12px;border-top:1px solid var(--border)}
.site-footer a{color:inherit}

/* ========= Single ========= */
body.single .post-title{
  font-family:'Poppins',system-ui,sans-serif; font-weight:600;
  font-size:36px; line-height:1.2; margin:8px 0 18px;
}
.featured-image{margin:14px 0 22px}
body.single .entry-content{font-size:18px;line-height:1.8}
body.single .entry-content p{margin:0 0 18px}
body.single .entry-content h2, body.single .entry-content h3{
  font-family:'Poppins',system-ui,sans-serif;margin:24px 0 12px
}
.post-footer{display:flex;align-items:center;justify-content:space-between;border-top:1px solid var(--border);padding-top:12px;margin-top:18px}
.post-tags a{font-size:12px;color:var(--muted);margin-right:8px}

/* Single max-width 820px (text zone only) */
body.single .post-title,
body.single .entry-content,
body.single .post-footer,
body.single .comments-area{
  max-width:820px;margin-left:auto;margin-right:auto
}

/* ========= Related Posts (desktop base) ========= */
.related-posts{margin-top:28px}
.related-posts h3{font-family:'Poppins',system-ui,sans-serif;margin-bottom:10px}
.related-grid{display:grid;gap:16px;grid-template-columns:repeat(3,1fr)}
.related-card{display:flex;flex-direction:column}
.related-card .thumb{margin-bottom:10px;border-radius:12px;overflow:hidden}
.related-card .thumb img{width:100%;height:100%;object-fit:cover}
.related-card .title a{font-family:'Poppins',system-ui,sans-serif;font-weight:600;font-size:15px;line-height:1.4;color:#000;text-decoration:none}
.related-card .title a:hover{color:#333}
.related-card .excerpt{font-size:13px;color:#555;margin:6px 0 10px;line-height:1.6}
.related-card .read{font-size:12px;color:#888;text-decoration:none}
.related-card .read:hover{text-decoration:underline}

/* ========= Listing (Home + Category/Archive) ========= */
/* Cho phép khu main không bó cứng container 760px trên listing */
body.home .site-main.container,
body.blog .site-main.container,
body.archive .site-main.container{width:auto;max-width:90%;padding-left:0;padding-right:0}

/* Khung listing rộng 1152px */
body.home .listing,
body.blog .listing,
body.archive .listing{max-width:1152px;margin-left:auto;margin-right:auto;padding:12px 0 36px}

/* Header của Category đồng bộ chiều rộng */
body.archive .archive-header{max-width:1152px;margin:0 auto 16px}
body.archive .archive-title{
  font-family:'Poppins',system-ui,sans-serif;font-weight:800;font-size:28px;line-height:1.2;
  margin:8px 0;word-break:break-word;hyphens:auto
}
.archive-description{color:#666;font-size:14px}

/* Grid 2 cột desktop */
body.home .posts-grid,
body.blog .posts-grid,
body.archive .posts-grid{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
  gap:64px 60px;max-width:1152px;margin-left:auto;margin-right:auto
}

/* Card */
.grid-card{display:flex;flex-direction:column;margin-bottom:20px;padding-bottom:10px}
.grid-card .thumb{
  position:relative;aspect-ratio:16/9;border-radius:12px;overflow:hidden;display:block;background:#f4f4f4;margin:0 0 12px
}
.grid-card .thumb img{width:100%;height:100%;object-fit:cover;transition:transform .35s ease}
.grid-card:hover .thumb img{transform:scale(1.03)}
.grid-title{margin:6px 0}
.grid-title a{
  font-family:'Poppins',system-ui,sans-serif;font-weight:600;
  font-size:24px;line-height:1.35;color:#0b0b0b;text-decoration:none;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden
}
.grid-title a:hover{text-decoration:underline}
.grid-meta{color:#7a7a7a;font-size:14px;font-style:italic;margin:0 0 10px}
.grid-excerpt{
  font-size:15px;line-height:1.7;color:#444;margin:0 0 10px;
  display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;
  min-height:calc(1.7em * 3);max-height:calc(1.7em * 3)
}
.grid-tags a{color:#8a8a8a;font-size:12px;text-decoration:none;margin-right:8px}
.grid-tags a::before{content:'#'}

/* Pagination */
.pagination{display:flex;justify-content:center;margin-top:28px}
.pagination .nav-links{display:flex;gap:8px;align-items:center}
.pagination a,.pagination span{
  padding:6px 10px;border:1px solid var(--border);border-radius:6px;font-size:13px;color:#333;text-decoration:none
}
.pagination .current{background:#111;color:#fff;border-color:#111}

/* ========= Embeds ========= */
.entry-content iframe[src*="youtube.com"],
.entry-content iframe[src*="youtu.be"],
.entry-content iframe[src*="vimeo.com"]{width:100%!important;height:auto!important;aspect-ratio:16/9;display:block}

/* ========= Mobile styles ========= */
@media (max-width:1024px){
  /* Grid 1 cột */
  body.home .posts-grid,
  body.blog .posts-grid,
  body.archive .posts-grid{grid-template-columns:1fr !important;gap:28px !important;max-width:100%!important}

  /* Card spacing */
  .grid-card{margin-bottom:12px;padding-bottom:8px}

  /* Thumb */
  .grid-card .thumb{border-radius:12px;margin-bottom:10px}

  /* Title/Meta/Excerpt nhỏ lại */
  .grid-title a{font-size:22px !important}
  .grid-meta{font-size:13px !important;margin-bottom:8px}
  .grid-excerpt{
    font-size:15px !important;line-height:1.7;color:#444;
    -webkit-line-clamp:2;min-height:calc(1.7em * 2);max-height:calc(1.7em * 2);margin-bottom:8px
  }

  /* Related -> card đơn */
  .related-grid{grid-template-columns:1fr !important;gap:16px !important}
  .related-card{
    background:#fff;border:1px solid var(--border);border-radius:14px;padding:14px;
    box-shadow:0 2px 8px rgba(0,0,0,.04)
  }
}
@media (max-width:640px){
  .header-inner{gap:12px}
  .primary-nav .menu{gap:14px}
  body.single .post-title{font-size:30px}
}

/* Khung thumbnail luôn có tỉ lệ 16:9 và nền xám */
.posts-grid .grid-card .thumb{
  display:block;
  aspect-ratio:16/9;
  background:#eee;          /* nền xám */
  border-radius:12px;
  overflow:hidden;
}

/* Ảnh thật thì fill toàn khung */
.posts-grid .grid-card .thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

/* Ẩn ảnh placeholder (không hiện gì, chỉ còn nền xám) */
.posts-grid .grid-card .thumb img[alt="no image"],
.posts-grid .grid-card .thumb img[src*="/assets/img/placeholder"],
.posts-grid .grid-card .thumb img[src$="placeholder.png"]{
  display:none !important;
}

/* Fallback cho trình duyệt cũ chưa hỗ trợ aspect-ratio */
@supports not (aspect-ratio: 1){
  .posts-grid .grid-card .thumb::before{
    content:"";
    display:block;
    padding-top:56.25%; /* 16:9 */
  }
}
/* Ảnh trong nội dung bài luôn căn giữa */
.entry-content img,
.entry-content a > img {
  display: block;
  margin: 16px auto;          /* căn giữa */
}

/* --- MOBILE HAMBURGER --- */
@media (max-width: 991px) {

  /* Để dropdown định vị theo header */
  .site-header .header-inner { position: relative; }

  /* Nút hamburger */
  .hamburger{
    display:inline-block;
    width:36px; height:26px;
    margin-left:auto;            /* đẩy nút sang phải */
    position:relative; cursor:pointer;
  }
  /* 3 gạch (dùng 2 pseudo + 1 bóng để làm gạch giữa) */
  .hamburger::before,
  .hamburger::after{
    content:"";
    position:absolute; left:0; right:0;
    height:2px; background:#111; border-radius:2px;
  }
  .hamburger::before{ top:4px; box-shadow:0 9px 0 #111; } /* gạch trên + giữa */
  .hamburger::after{ bottom:4px; }                         /* gạch dưới */

  /* Ẩn menu mặc định, dùng dạng dropdown */
  .primary-nav{
    position:absolute; top:100%; left:0; right:0;
    background:#fff; border-radius:12px;
    box-shadow:0 10px 24px rgba(0,0,0,.08);
    padding:10px; z-index:999;
    max-height:0; overflow:hidden; opacity:0;
    transition:max-height .25s ease, opacity .2s ease;
  }

  /* Dọc lại các item */
  .primary-nav .menu{
    display:flex; flex-direction:column; gap:8px;
    margin:0; padding:0; list-style:none;
  }
  .primary-nav .menu a{ display:block; padding:10px 8px; }

  /* Khi tick checkbox -> mở menu */
  .nav-toggle:checked ~ .primary-nav{
    max-height:70vh; opacity:1;
  }
}

/* Desktop giữ nguyên menu ngang, ẩn hamburger */
@media (min-width: 992px){
  .nav-toggle, .hamburger{ display:none !important; }
  .primary-nav{ position:static; max-height:none; opacity:1; overflow:visible; box-shadow:none; padding:0; }
  .primary-nav .menu{ display:flex; flex-direction:row; gap:24px; }
}

