/* Lớp chuyển động của nền tảng. Mọi hiệu ứng tắt hẳn khi người dùng chọn giảm chuyển động. */

/* Chuyển trang mượt giữa các trang cùng nền tảng (trình duyệt hỗ trợ View Transitions) */
@view-transition { navigation: auto; }
.dau-trang { view-transition-name: dau-trang; }
.chan-trang { view-transition-name: chan-trang; }
::view-transition-old(root) { animation: 160ms ease-in both vt-mo-ra; }
::view-transition-new(root) { animation: 260ms cubic-bezier(.2, .8, .2, 1) both vt-hien-vao; }
@keyframes vt-mo-ra { to { opacity: 0; } }
@keyframes vt-hien-vao { from { opacity: 0; transform: translateY(10px); } }

/* Thanh tiến trình tải trang và tiến trình đọc */
.thanh-doc { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; pointer-events: none; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--lam), #3a6bb8 60%, var(--son)); }
.thanh-tai { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 61; pointer-events: none; background: var(--son); transform-origin: 0 50%; transform: scaleX(0); opacity: 0; }
.thanh-tai.dang { opacity: 1; animation: tai-chay 8s cubic-bezier(.1, .7, .2, 1) forwards; }
@keyframes tai-chay { from { transform: scaleX(0); } to { transform: scaleX(.92); } }

/* Đầu trang thu gọn, đổ bóng khi cuộn */
.dau-trang { transition: box-shadow .25s ease, background-color .25s ease; }
.dau-trang .khung { transition: min-height .25s ease; }
.da-cuon .dau-trang { box-shadow: 0 6px 24px -14px rgba(18, 40, 79, .45); background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px); }
.da-cuon .dau-trang .khung { min-height: 58px; }

/* Thanh điều hướng: gạch chân trượt theo mục */
.dau-trang nav a { position: relative; }
.dau-trang nav a::after { content: ""; position: absolute; left: 10%; right: 10%; bottom: 2px; height: 2px; border-radius: 2px; background: var(--son);
  transform: scaleX(0); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.dau-trang nav a:hover::after, .dau-trang nav a:focus-visible::after { transform: scaleX(1); }

/* Hiện dần khi cuộn tới. Chỉ áp dụng khi script đã chạy (lớp co-hieu-ung trên html). */
.co-hieu-ung .cho-hien { opacity: 0; transform: translateY(18px); }
.co-hieu-ung .cho-hien.da-hien { opacity: 1; transform: none; transition: opacity .6s ease, transform .7s cubic-bezier(.2, .8, .2, 1); transition-delay: calc(var(--tre, 0) * 60ms); }
.co-hieu-ung .cho-hien.tu-trai { transform: translateX(-22px); }
.co-hieu-ung .cho-hien.tu-trai.da-hien { transform: none; }

/* Thẻ nổi nhẹ khi rê chuột */
.the-sp, .the-bai, .the-lo-trinh, .the-thu-vien, .the-chung-nhan, .the-cs, .the-dang-hoc, .the-chu-de, .the-nguoi, .o-tri-thuc, .o-cong-bo, .o-thuat-ngu, .o-chuyen-muc,
.luoi-trao-doi > a, .bon-cap > *, .bon-viec > *, .luoi-tri-thuc > * {
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), box-shadow .3s ease, border-color .3s ease;
}
@media (hover: hover) {
  .the-sp:hover, .the-bai:hover, .the-lo-trinh:hover, .the-thu-vien:hover, .the-cs:hover, .the-dang-hoc:hover, .the-chu-de:hover, .the-nguoi:hover,
  .o-tri-thuc:hover, .o-cong-bo:hover, .luoi-trao-doi > a:hover, .bon-cap > *:hover, .luoi-tri-thuc > *:hover {
    transform: translateY(-4px); box-shadow: 0 18px 36px -22px rgba(18, 40, 79, .55); border-color: #9fb2cf;
  }
  .the-lo-trinh:hover .bia-lo-trinh svg, .the-lo-trinh:hover .bia-lo-trinh > * { transform: scale(1.06); }
}
.bia-lo-trinh { overflow: hidden; }
.bia-lo-trinh svg, .bia-lo-trinh > * { transition: transform .8s cubic-bezier(.2, .8, .2, 1); }

/* Nút: nhấn có phản hồi, ánh sáng lướt trên nút chính */
.btn { transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease, color .2s ease; }
.btn:active { transform: translateY(1px) scale(.985); }
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after { content: ""; position: absolute; inset: 0 auto 0 -60%; width: 45%; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent); transform: skewX(-18deg); transition: left .6s ease; }
.btn-primary:hover::after { left: 120%; }
.gon-song { position: absolute; border-radius: 50%; transform: scale(0); background: rgba(255, 255, 255, .45); pointer-events: none; animation: gon-song .55s ease-out forwards; }
.btn:not(.btn-primary) .gon-song { background: rgba(29, 63, 120, .18); }
@keyframes gon-song { to { transform: scale(2.6); opacity: 0; } }

/* Mở đầu trang chủ: lưới chấm trôi rất chậm, chữ hiện theo từng dòng */
.mo-dau::before { animation: luoi-troi 60s linear infinite; }
@keyframes luoi-troi { to { background-position: 240px 120px; } }
.co-hieu-ung .mo-dau h1, .co-hieu-ung .mo-dau .khung > div > p, .co-hieu-ung .mo-dau .hanh-dong { animation: len-dan .8s cubic-bezier(.2, .8, .2, 1) both; }
.co-hieu-ung .mo-dau .khung > div > p { animation-delay: .12s; }
.co-hieu-ung .mo-dau .hanh-dong { animation-delay: .24s; }
@keyframes len-dan { from { opacity: 0; transform: translateY(16px); } }
.trien-lon svg .vong-chu, .trien-lon svg text textPath { transform-box: fill-box; }

/* Đầu các trang mục (Diễn đàn, Học tập, Tri thức...) */
.co-hieu-ung .tieu-de-trang h1, .co-hieu-ung .dau-khoi h1 { animation: len-dan .7s cubic-bezier(.2, .8, .2, 1) both; }

/* Số đếm lên */
.dem-so { font-variant-numeric: tabular-nums; }

/* Thanh tỉ lệ và cột biểu đồ mọc lên khi hiện */
.co-hieu-ung .cho-moc { transform: scaleX(0); transform-origin: 0 50%; }
.co-hieu-ung .cho-moc.da-moc { transform: none; transition: transform 1s cubic-bezier(.2, .8, .2, 1); transition-delay: calc(var(--tre, 0) * 40ms); }
.co-hieu-ung .cho-moc-doc { transform: scaleY(0); transform-origin: 50% 100%; transform-box: fill-box; }
.co-hieu-ung .cho-moc-doc.da-moc { transform: none; transition: transform .9s cubic-bezier(.2, .8, .2, 1); transition-delay: calc(var(--tre, 0) * 45ms); }

/* Dòng thời gian chính sách: trục vẽ dần theo vị trí cuộn */
.dong-thoi-gian { position: relative; }
.truc-ve { position: absolute; left: var(--truc-x, 0); top: 0; width: 2px; height: 100%; background: var(--son); transform-origin: 50% 0; transform: scaleY(var(--tien, 0)); pointer-events: none; opacity: .75; }

/* Chuỗi tin chạy ngang: dừng khi rê chuột */
.dong-tin:hover * { animation-play-state: paused !important; }

/* Thông báo trượt vào */
.vung-thong-bao .alert { animation: tb-truot .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes tb-truot { from { opacity: 0; transform: translateY(-10px); } }

/* Nút lên đầu trang */
.len-dau { position: fixed; right: 18px; bottom: 18px; z-index: 40; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--ke); background: var(--giay); color: var(--lam);
  display: grid; place-items: center; box-shadow: 0 10px 26px -14px rgba(18, 40, 79, .55); opacity: 0; transform: translateY(14px) scale(.9); pointer-events: none;
  transition: opacity .25s ease, transform .3s cubic-bezier(.2, .8, .2, 1), background-color .2s ease; }
.len-dau.hien { opacity: 1; transform: none; pointer-events: auto; }
.len-dau:hover { background: var(--lam); color: #fff; }
.len-dau svg { width: 20px; height: 20px; }

/* Chứng nhận: con triện đóng xuống khi trang mở */
.co-hieu-ung .trien-cn { animation: dong-trien-nho .7s cubic-bezier(.2, .9, .25, 1) .35s both; }

/* Câu trả lời đúng và sai trong bài kiểm tra */
.dung { animation: nay-dung .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes nay-dung { 40% { transform: scale(1.012); } }
.sai { animation: lac-sai .4s ease both; }
@keyframes lac-sai { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* Bình chọn: con số nảy khi thay đổi */
.nay { animation: nay-so .45s cubic-bezier(.2, .8, .2, 1); }
@keyframes nay-so { 35% { transform: scale(1.35); color: var(--son); } }

/* Ô nhập: viền sáng dần khi đặt con trỏ */
.form-control, .form-select { transition: border-color .2s ease, box-shadow .25s ease; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 4px rgba(29, 63, 120, .12); }

/* Đường dẫn trong bài: gạch chân chạy */
.bai-viet a:not(.btn), .noi-dung-bai a:not(.btn), .than-bai-hoc a:not(.btn) { background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .3s ease; text-decoration: none; border-bottom: 1px solid rgba(29, 63, 120, .25); }
.bai-viet a:not(.btn):hover, .noi-dung-bai a:not(.btn):hover, .than-bai-hoc a:not(.btn):hover { background-size: 100% 1px; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .co-hieu-ung .cho-hien, .co-hieu-ung .cho-moc, .co-hieu-ung .cho-moc-doc { opacity: 1 !important; transform: none !important; }
  .thanh-doc, .thanh-tai, .truc-ve { display: none; }
}
@media print {
  .thanh-doc, .thanh-tai, .len-dau, .truc-ve { display: none !important; }
  .co-hieu-ung .cho-hien { opacity: 1 !important; transform: none !important; }
}

/* Thiết bị cảm ứng không có trạng thái di chuột: bỏ vệt sáng trên nút
   để nó không bị kẹt lại sau một lần chạm. */
@media (hover: none) {
  .btn-primary::after { display: none; }
}
