/* Thuật ngữ bấm được (a.term), hộp giải thích (dialog.gl-dlg) và trang /thuat-ngu. Chỉ dùng biến màu của app.css. */

/* Chữ thuật ngữ: giữ màu chữ xung quanh, gạch chân chấm màu nhấn; dấu “?” nhỏ chỉ ở thuật ngữ đầu tiên của mỗi khối */
.term { color: inherit; font-weight: inherit; text-decoration: underline dotted var(--term-line, var(--accent)); text-decoration-thickness: 2px;
  text-underline-offset: .22em; text-decoration-skip-ink: none; cursor: help; border-radius: 4px; -webkit-tap-highlight-color: transparent;
  /* nới vùng chạm cao hơn chữ (chữ nhỏ 11–12 px cũng được ~24 px) mà không làm giãn dòng */
  padding-block: .45em; }
.term:hover { text-decoration-style: solid; background: rgba(var(--mint-rgb), .18); }
.term:active { background: rgba(var(--mint-rgb), .3); }
.term:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* display:inline (không phải inline-grid): dấu “?” dính liền chữ, không tạo chỗ xuống dòng trước dấu hay trước dấu câu đi sau.
   Cỡ chữ tính theo em của chữ xung quanh, KHÔNG dùng --fs-xs: trong đoạn chữ nhỏ (13 px) thì --fs-xs
   cũng đúng 13 px, nên viên “?” to bằng chữ thường, lại còn nâng lên .35em nên nó trèo lên dòng trên —
   đọc trên điện thoại thấy nó lạc hẳn ra khỏi dòng. .74em + nâng .18em thì viên nằm gọn trong lòng dòng. */
.term:where(:not(.term ~ .term))::after { content: '?'; content: '?' / ''; display: inline; padding: .12em .34em; margin-left: .2em;
  border-radius: 99px; font-size: .74em; font-weight: 700; line-height: 1; vertical-align: .18em; font-style: normal;
  background: var(--mint-soft); color: var(--mint-text); box-shadow: inset 0 0 0 1px var(--mint-line); }
/* trong tiêu đề, ô tiêu đề bảng: chỉ gạch chấm, không thêm dấu “?” cho đỡ rối */
:is(h1, h2, h3, h4, th) .term::after { content: none; }
/* dòng nguồn dữ liệu của dòng thời gian: mỗi nguồn một span, chỉ nguồn đầu có dấu “?” */
.lanes-src span ~ span .term::after { content: none; }
/* chip và dòng chân của từng bản ghi lặp lại hàng chục lần: chỉ gạch chấm, không thêm dấu “?” cho đỡ rối */
:is(.tr-tags, .tr-ev .by) .term::after { content: none; }
/* trên khối màu (chữ trắng): gạch chân theo màu chữ; trong thẻ trắng nằm trên khối màu thì về lại màu nhấn */
:is(.hero, .section-sage, .tr-hero, .dn-head) { --term-line: currentColor; }
:is(.hero-panel, .pick, .step-card, .stats-band, .card, .feature, .tr-card) { --term-line: var(--accent); }
@media print { .term { text-decoration: none; } .term::after { content: none !important; } }

/* Hộp giải thích: tấm trượt từ đáy trên điện thoại, hộp giữa màn hình trên máy tính */
html.gl-lock, html.gl-lock body { overflow: hidden; }
.gl-dlg { width: 100%; max-width: 100%; max-height: none; margin: auto 0 0; padding: 0; border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow); font-family: var(--font); }
.gl-dlg::backdrop { background: var(--glass-dark, rgba(10, 30, 90, .32)); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.gl-dlg-in { max-height: min(84vh, 620px); max-height: min(84dvh, 620px); overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); }
.gl-dlg-in::before { content: ''; display: block; width: 44px; height: 5px; margin: 0 auto 8px; border-radius: 99px; background: var(--line-2); }
.gl-dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gl-dlg-g { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mint-text); min-width: 0; }
.gl-dlg-x { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-size: var(--fs-h2); line-height: 1; cursor: pointer; font-family: var(--font); }
.gl-dlg-x:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.gl-dlg-x:focus-visible, .gl-dlg-t:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gl-dlg-t { font-size: var(--fs-page); line-height: 1.25; margin: 2px 0 4px; color: var(--text); overflow-wrap: anywhere; }
.gl-dlg-t:focus { outline: none; }
.gl-dlg-full { margin: 0 0 10px; font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
.gl-dlg-short { margin: 0 0 12px; font-size: var(--fs-body); line-height: 1.55; overflow-wrap: anywhere; }
.gl-dlg-here { padding: 12px 14px; border-radius: var(--r-sm); background: var(--mint-soft); border: 1px solid var(--mint-line); font-size: var(--fs-body); line-height: 1.5; overflow-wrap: anywhere; }
.gl-dlg-here b { color: var(--mint-text); }
.gl-dlg-links { list-style: none; margin: 8px 0 0; padding: 0; display: grid; }
.gl-dlg-links a { display: flex; align-items: center; min-height: 44px; color: var(--accent-text); font-weight: 600; text-decoration: none; }
.gl-dlg-links a:hover { text-decoration: underline; }
/* Hai nút cuối hộp, bằng nhau, nằm trong lề: “Tất cả thuật ngữ” (phụ) và “Đã hiểu” (chính, đóng hộp).
   Dính đáy để mục dài mấy thì ngón tay cũng chạm được nút đóng mà không phải cuộn. */
.gl-dlg-act { position: sticky; bottom: 0; z-index: 1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px -18px 0; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel); box-shadow: 0 -10px 14px -10px rgba(15, 27, 61, .2); }
.gl-dlg-act .btn { width: 100%; min-width: 0; min-height: 48px; padding-inline: 10px; text-align: center; white-space: normal; }
.gl-dlg [hidden] { display: none !important; }
@media (min-width: 600px) {
  .gl-dlg { margin: auto; max-width: 460px; border-radius: var(--r-lg); }
  .gl-dlg-in { padding: 18px 22px 22px; }
  .gl-dlg-in::before { display: none; }
  .gl-dlg-act { margin-inline: -22px; padding: 12px 22px 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .gl-dlg[open] { animation: gl-up .2s ease-out; }
  @keyframes gl-up { from { transform: translateY(28px); opacity: .4; } to { transform: none; opacity: 1; } }
}

/* ---------- Trang /thuat-ngu ---------- */
.gl-hero { padding-bottom: 0; }
.gl-hero > .container { grid-template-columns: 1fr; }
.gl-hero .container { max-width: 880px; }
.gl-search { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; scroll-margin-top: 76px; }
.gl-q { flex: 1 1 220px; }
.gl-q input { min-height: 56px; border-radius: 999px; border-color: transparent; font-size: max(16px, var(--fs-body)); box-shadow: var(--shadow-soft); }
.gl-go { flex: 1 0 auto; }
@media (min-width: 521px) { .gl-go { flex-grow: 0; } }
.gl-body { padding-bottom: 40px; }
.gl-back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.gl-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.gl-chips .chip { min-height: 44px; }
/* Điện thoại: giữ chủ ý cũ — THẤY HẾT các nhóm, không giấu nhóm nào ngoài mép màn hình — nhưng bỏ
   flex-wrap thuần. Đo được: 7 nút lọc xếp 3–4 hàng và hàng CUỐI chỉ còn trơ một nút “Kết nối” ở
   320 / 390 / 414px. Mục 6 của HỆ KÍCH THƯỚC (app.css) cấm đúng chuyện đó cho hàng nút / chip.
   Nay dùng khuôn .btn-grid: LƯỚI 2 cột ô bằng nhau, nút lẻ cuối TRẢI HẾT HÀNG — không nút nào
   đứng trơ, mọi nút vẫn hiện, vẫn cao 44px. Lúc đang gõ tìm thì .gl-tim vẫn gom về một hàng cuộn ngang. */
@media (max-width: 559px) {
  .gl-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .gl-chips > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .gl-chips .chip { width: 100%; min-width: 0; padding: 0 12px; text-align: center; justify-content: center; }
  /* [kiểm tra cuối] Đang gõ tìm: 3 hàng chip đẩy kết quả xuống dưới bàn phím — gom về MỘT hàng
     cuộn ngang (chỉ trong lúc tìm) để thấy ngay số kết quả và mục đầu tiên. Gõ xong, xóa ô tìm thì chip lại đủ hàng. */
  .gl-chips.gl-tim { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .gl-chips.gl-tim::-webkit-scrollbar { display: none; }
  .gl-chips.gl-tim .chip { flex: none; width: auto; white-space: nowrap; }
  .gl-chips.gl-tim + .gl-count { margin-top: 4px; }
  .gl-chips.gl-tim ~ .gl-group { margin-top: 14px; }
}
.gl-n { font-size: var(--fs-xs); font-weight: 600; opacity: .75; }
.gl-count { margin: 8px 0 0; }
.gl-empty { margin: 16px 0; padding: 14px 16px; border-radius: var(--r-sm); background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--text); }
.gl-group { margin-top: 26px; }
.gl-group h2 { display: flex; align-items: center; gap: 10px; font-size: var(--fs-page); margin: 0 0 12px; }
.gl-group h2::before { content: ''; flex: none; width: 6px; height: 1.1em; border-radius: 99px; background: var(--mint-grad); }
.gl-list { display: grid; gap: 12px; }
@media (min-width: 760px) { .gl-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gl-entry { min-width: 0; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); scroll-margin-top: 96px; overflow-wrap: anywhere; }
.gl-entry:target { border-color: var(--mint-2); box-shadow: 0 0 0 3px rgba(var(--mint-rgb), .45), var(--shadow-card); }
.gl-entry h3 { font-size: var(--fs-h2); margin: 0 0 4px; }
.gl-full { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--muted); }
.gl-short { margin: 0 0 10px; line-height: 1.55; }
.gl-here { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--mint-soft); font-size: var(--fs-body); line-height: 1.5; }
.gl-here b { color: var(--mint-text); }
.gl-links { display: flex; flex-wrap: wrap; gap: 0 16px; margin: 6px 0 0; }
.gl-links a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }
.gl-foot { margin-top: 28px; }

/* Cụm thuật ngữ ngắn: giữ nguyên một dòng, kể cả dấu “?” đi kèm.
   Lớp này do h.term() tự gắn khi nhãn ≤16 ký tự và ≤3 từ (xem src/lib/format.js). */
.term-lien { white-space: nowrap; }

/* Nhãn nguồn nằm lẫn trong câu (“… đánh dấu ✍️ Tự khai.”) cao hơn dòng chữ nên đẩy
   riêng dòng ấy giãn ra, làm cả đoạn trông so le. Hạ nó về đúng đường chữ và thu nhỏ
   một chút: nhãn to bằng chữ thường thì thẻ bao quanh luôn cao hơn lòng dòng. */
p .src-tag { vertical-align: -.15em; font-size: .85em; line-height: 1.3; padding: 1px .45em; }
/* Giữ “dấu [✍️ Tự khai].” liền một khối: không thể để viên nhãn tụt xuống đứng
   một mình một dòng, cũng không để dấu chấm hết câu rạch ra khỏi nó. */
.src-lien { white-space: nowrap; }
