/* Bai viet (/articles/...). Cot chu hep de doc, dung chung cho moi bai va
   moi ngon ngu (/en/articles/... sau nay cung nap file nay). */
.article {
  max-width: calc(44rem + 2 * var(--gutter));
  margin: 2.5rem auto 3rem;
  padding: 0 var(--gutter);
  line-height: 1.7;
}
.article h1 {
  font-family: var(--f-display);
  font-size: clamp(2.2rem, 5vw, 3rem);
  line-height: 1.05;
  margin: 0;
}
.article h2 { font-size: var(--t-md); margin: 2.5rem 0 0.6rem; line-height: 1.3; }
.article h3 { font-size: var(--t-base); margin: 1.5rem 0 0.4rem; }
/* Link tu so do nhay toi #muc: chua cho header sticky (mobile 2 hang ~7rem) de khong che tieu de */
.article h2[id], .article h3[id] { scroll-margin-top: 8rem; }
.article p, .article ul, .article ol { margin: 0 0 0.9rem; }
.article ul, .article ol { padding-left: 1.25rem; }
.article li { margin-bottom: 0.4rem; }
.article code {
  font-family: var(--f-receipt); font-size: 0.86em; white-space: nowrap;
  color: var(--wall-deep); background: #e3e9e7; border: 1px solid #d0d9d6;
  border-radius: 4px; padding: 0.08em 0.4em;
}
/* code trong tieu de: giu nen nhung nho gon hon */
.article h2 code, .article h3 code { font-size: 0.82em; padding: 0.04em 0.35em; }
.article a { color: var(--undo); }

.article-meta { color: var(--muted); font-size: var(--t-sm); margin-top: 0.5rem !important; }
.article-lead {
  font-size: 1.075rem;
  margin-top: 1.5rem !important;
}

/* Hop "tom tat" / "luu y": nen giay, vien trai mau */
.article .note {
  padding: 0.85rem 1rem;
  background: var(--paper);
  border: 1px solid #d2d8d6;
  border-left: 4px solid var(--undo);
  border-radius: 6px;
}
.article .note p:last-child, .article .note ul:last-child { margin-bottom: 0; }
.article .note-warn { border-left-color: var(--pending); }

/* Hinh: SVG ve tay, co chu thich ben duoi */
.article figure { margin: 1.5rem 0; }
.article figure svg { display: block; width: 100%; height: auto; }
/* Man hep: SVG thu nho lam chu qua be -> giu toi thieu 560px, cuon ngang trong khung */
.fig-scroll { overflow-x: auto; }
.fig-scroll svg { min-width: 560px; }
.article figcaption { color: var(--muted); font-size: var(--t-sm); margin-top: 0.5rem; }
.fig-box {
  padding: 1rem;
  background: var(--paper);
  border: 1px solid #d2d8d6;
  border-radius: 6px;
}

/* Bang so sanh: man hep thi cuon ngang TRONG khung, khong lam tran trang */
.table-wrap { overflow-x: auto; margin: 1.25rem 0; }
.article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
  background: var(--paper);
}
.article th, .article td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.7rem;
  border: 1px solid #d2d8d6;
}
.article th { background: #e4e9e7; font-weight: 600; }

/* Link sang don mau: the nho, bam duoc ca khoi */
.try-list { list-style: none; padding: 0 !important; display: grid; gap: 0.6rem; }
.try-list a {
  display: block;
  padding: 0.7rem 0.9rem;
  background: var(--paper);
  border: 1px solid #d2d8d6;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.try-list a:hover { border-color: var(--undo); }
.try-list b { display: block; }
.try-list span { color: var(--muted); font-size: var(--t-sm); }

/* Trang danh sach bai viet */
.article-list { list-style: none; padding: 0 !important; margin-top: 1.5rem !important; }
.article-list li { padding: 1rem 0; border-bottom: 1px solid #d2d8d6; margin: 0; }
.article-list a { font-weight: 600; font-size: 1.1rem; }
.article-list p { margin: 0.3rem 0 0; color: var(--muted); }
.article-list .article-meta { margin-top: 0.3rem !important; }

.article-foot {
  margin-top: 2.5rem !important;
  padding-top: 1rem;
  border-top: 1px solid #d2d8d6;
  color: var(--muted);
  font-size: var(--t-sm);
}

/* Cuoi bai: bai tiep theo / bai truoc (the lon) */
.endnav { margin-top: 2.5rem; }
.endnav .next {
  display: block;
  padding: 1rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
}
.endnav .next:hover { border-color: var(--undo); }
.endnav .next small { display: block; color: var(--muted); font-size: var(--t-sm); text-transform: uppercase; letter-spacing: 0.05em; }
.endnav .next b { display: block; font-size: 1.15rem; margin: 0.2rem 0; }
.endnav .next span { color: var(--muted); font-size: var(--t-sm); }
.endnav .prev { margin: 0.75rem 0 0 !important; font-size: var(--t-sm); color: var(--muted); }

/* Trang danh sach bai: nut sap xep + so thu tu khi xem theo lo trinh */
.article-sort { display: flex; align-items: center; gap: 0.5rem; margin-top: 1.25rem; font-size: var(--t-sm); color: var(--muted); }
.article-sort[hidden] { display: none; }
.article-sort button {
  font: 500 var(--t-sm) var(--f-body); color: var(--muted); cursor: pointer;
  background: transparent; border: 1px solid #c7cfcc; border-radius: 999px; padding: 0.35rem 0.9rem;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.article-sort button:hover { color: var(--ink); border-color: var(--ink); background: var(--paper); }
.article-sort button:focus { outline: none; }
.article-sort button:focus-visible { outline: 2px solid var(--undo); outline-offset: 2px; }
/* che do dang chon: to dam, khong doi mau khi re chuot */
.article-sort button[aria-pressed="true"],
.article-sort button[aria-pressed="true"]:hover {
  font-weight: 600; color: var(--on-wall); background: var(--wall-deep); border-color: var(--wall-deep); cursor: default;
}
/* Nhom chu de: so thu tu chay LIEN TUC qua cac nhom (= lo trinh doc) */
.article-groups { counter-reset: art; }
.article-groups[hidden], .article-flat[hidden], .topic-chips[hidden] { display: none; }
.article-groups li { counter-increment: art; position: relative; padding-left: 2.25rem; }
.article-groups li::before {
  content: counter(art); position: absolute; left: 0; top: 1.05rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center;
  font: 600 0.8rem var(--f-receipt); color: var(--muted); border: 1px solid #c7cfcc;
}

.topic-chips {
  display: flex; gap: 0.5rem; margin-top: 1rem; overflow-x: auto; padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.topic-chips::-webkit-scrollbar { display: none; }
.topic-chips a {
  flex: none; font-size: var(--t-sm); color: var(--ink); text-decoration: none; white-space: nowrap;
  border: 1px solid #c7cfcc; border-radius: 999px; padding: 0.3rem 0.75rem; background: var(--paper);
  transition: border-color 0.15s;
}
.topic-chips a:hover { border-color: var(--ink); }
.topic-chips a span { color: var(--muted); margin-left: 0.15rem; }
.article .topic h2 { margin: 2.25rem 0 0; scroll-margin-top: 8rem; display: flex; align-items: baseline; gap: 0.6rem; }
.article .topic h2 small { font-size: var(--t-sm); font-weight: 400; color: var(--muted); }
.article .topic { scroll-margin-top: 8rem; }
.article .topic .article-list { margin-top: 0.5rem !important; }

/* Nut chuyen ngon ngu (build-articles.py sinh, js/lang.js nho lua chon) */
.lang-switch {
  font-size: var(--t-sm);
  color: var(--muted);
  margin-top: 0.25rem !important;
}
.lang-switch [aria-current] { color: var(--ink); font-weight: 600; }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { color: var(--ink); }

/* Cuoi bai: moi gop y (truoc khoi "bai tiep theo") */
.article-ask {
  margin-top: 2.5rem !important;
  padding: 0.75rem 1rem;
  border: 1px dashed #b9c3c0;
  border-radius: 6px;
  color: var(--muted);
  font-size: var(--t-sm);
}
