/* Thanh Bắc Hội — lớp chuyển động kiểu motion graphics, dùng chung cho trang chủ, thanh toán, Khu học viên.
   Chỉ chạy khi <html> có class "mo" (gắn trong <head>, bỏ qua nếu máy đặt "giảm chuyển động").
   Mọi chuyển động dùng translate / scale / opacity / clip-path (không đụng "transform" sẵn có của trang). */
:root {
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Thanh tiến độ cuộn ---------- */
.mo-progress {
  position: fixed; left: 0; top: 0; z-index: 120; width: 100%; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, #143A2B, #1E4D3A 45%, #2B6A50, #6FA88A);
  transform-origin: 0 50%; scale: 0 1; box-shadow: 0 0 12px rgba(30, 77, 58, .45);
}

/* ---------- Chuyển trang: tấm gradient quét ngang, chữ 清北会 ở giữa ---------- */
.mo-wipe {
  position: fixed; inset: 0; z-index: 300; pointer-events: none; display: grid; place-items: center;
  background: var(--grad); transform-origin: 0 50%; scale: 0 1;
}
.mo-wipe b { font: 400 clamp(46px, 8vw, 86px)/1 var(--f-brush); color: rgba(255, 255, 255, .92); letter-spacing: .12em; opacity: 0; translate: 0 24px; }
.mo-wipe.leave { scale: 1 1; transition: scale .55s var(--ease-io); }
.mo-wipe.leave b { opacity: 1; translate: 0 0; transition: opacity .35s .25s, translate .5s var(--ease-out) .2s; }
html.mo-arrive::before {
  content: "清北会"; position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; pointer-events: none;
  background: var(--grad); color: rgba(255, 255, 255, .92); font: 400 clamp(46px, 8vw, 86px)/1 'Ma Shan Zheng', serif; letter-spacing: .12em;
  transform-origin: 100% 50%;
}
html.mo-arrive.mo-arrived::before { scale: 0 1; color: transparent; transition: scale .7s var(--ease-io) .08s, color .2s; }

/* ---------- Che trước khi chạy (tránh nháy chữ lúc tải); motion.js gắn data-mo-done / mo-split / mo-track ---------- */
/* Phần hero không che: chữ lớn và đoạn giới thiệu phải hiện ngay khi tải (Google đo tốc độ theo phần này) */
.mo :is(.stat, .step, .paystep, .faq details, .footer .wrap > div, .sec-head p, .level, .sample, .plan):not([data-mo-done]) { opacity: 0; }
.mo :is(.sec-head h2, .checkout .panel-card h2, .hv-login h2):not(.mo-split) { opacity: 0; }
.mo :is(.sec-head .zh):not(.mo-track) { opacity: 0; }

/* ---------- Hiện dần khi cuộn tới ---------- */
.mo [data-mo] {
  opacity: 0;
  transition: opacity .9s var(--ease-out), translate 1.05s var(--ease-out), scale 1.05s var(--ease-out),
    rotate 1.05s var(--ease-out), filter .9s var(--ease-out), clip-path 1.2s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 1ms);
}
.mo [data-mo="rise"] { translate: 0 48px; filter: blur(6px); }
.mo [data-mo="pop"] { translate: 0 40px; scale: .93; }
.mo [data-mo="left"] { translate: -64px 0; }
.mo [data-mo="right"] { translate: 64px 0; }
.mo [data-mo="zoom"] { scale: .86; filter: blur(8px); }
/* Không dùng clip-path che kín phần tử được theo dõi: trình duyệt coi phần tử bị che kín là chưa lọt vào màn hình, hiệu ứng không bao giờ chạy */
.mo [data-mo="fade"] { }
.mo [data-mo].in { opacity: 1; translate: 0 0; scale: 1; rotate: 0deg; filter: none; }

/* Chữ tiêu đề: từng chữ trồi lên khỏi mặt nạ */
.mo-w { display: inline-block; overflow: hidden; vertical-align: top; padding: .06em .02em .12em; margin: -.06em -.02em -.12em; }
.mo-w > span { display: inline-block; translate: 0 112%; rotate: 5deg; transform-origin: 0 100%;
  transition: translate 1s var(--ease-out), rotate 1s var(--ease-out); transition-delay: calc(var(--d, 0) * 1ms + var(--i, 0) * 60ms); }
.mo-split.in .mo-w > span, .mo-split.mo-seen .mo-w > span { translate: 0 0; rotate: 0deg; }
/* chữ gradient (Shadowing) giữ màu khi đã tách từng chữ */
.hero-card h1.mo-split em { background: none; }
.hero-card h1 em .mo-w > span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Chữ giãn khoảng cách khi hiện (kicker, chữ Hán trong tiêu đề mục) */
.mo .mo-track:not(.mo-seen) { letter-spacing: .9em; opacity: 0; filter: blur(4px); }
.mo .mo-track { transition: letter-spacing 1.4s var(--ease-out), opacity 1s var(--ease-out), filter 1s; transition-delay: calc(var(--d, 0) * 1ms); }

/* ---------- Trang chủ ---------- */
/* Hero: cảnh nền phóng chậm + trôi khi cuộn; thẻ giữa hiện ra, con dấu đóng xuống */
.mo .hero .panel .still { animation: mo-kenburns 16s var(--ease-out) both; translate: 0 calc(var(--py, 0) * 1px); transform-origin: 50% 30%; }
@keyframes mo-kenburns { from { scale: 1.1; } to { scale: 1; } }
.mo .hero .panel .tag { animation: mo-tag 1.2s var(--ease-out) .6s both; }
@keyframes mo-tag { from { opacity: 0; translate: 0 -24px; clip-path: inset(0 0 100% 0); } to { opacity: 1; translate: 0 0; clip-path: inset(0); } }
.mo .hero-card { animation: mo-card 1.1s var(--ease-out) .15s both; }
@keyframes mo-card { from { translate: 0 26px; scale: .97; } to { translate: 0 0; scale: 1; } }
/* Chữ "Shadowing" ánh gradient chạy chậm */
.mo .hero-card h1 em { background-size: 220% 100%; animation: mo-sheen 6s ease-in-out infinite alternate; }
@keyframes mo-sheen { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }
.mo .hero-card .seal { animation: mo-stamp .7s var(--ease-back) .75s both; }
@keyframes mo-stamp { 0% { opacity: 0; scale: 2.4; rotate: -24deg; } 70% { opacity: 1; } 100% { opacity: 1; scale: 1; rotate: 0deg; } }
.mo .hero-card .seal::after { content: ""; position: absolute; inset: -6px; border-radius: 12px; border: 2px solid var(--other);
  opacity: 0; animation: mo-ring .9s var(--ease-out) 1.2s both; pointer-events: none; }
.hero-card .seal { position: relative; }
@keyframes mo-ring { from { opacity: .7; scale: .8; } to { opacity: 0; scale: 1.6; } }

/* Nút chính: vệt sáng lướt qua + hút nhẹ theo con trỏ */
.btn-brand, .btn-gold { position: relative; overflow: hidden; isolation: isolate; transition: transform .15s ease, box-shadow .2s ease, background .2s, translate .35s var(--ease-out), filter .2s; }
.btn-brand::after, .btn-gold::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 45%; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .38), transparent); translate: 0 0; rotate: 0deg;
}
.btn-brand:hover::after, .btn-gold:hover::after, .btn.mo-shine::after { animation: mo-shine .85s var(--ease-io); }
@keyframes mo-shine { from { translate: 0 0; } to { translate: 420% 0; } }
.btn-brand:hover, .btn-gold:hover { box-shadow: 0 12px 30px rgba(30, 77, 58, .38); }

/* Bảng tin chạy chữ */
.mo-marq { flex: 1; min-width: 0; overflow: hidden; display: flex; align-items: center;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); }
.mo-marq ul { overflow: visible !important; width: max-content; gap: 0 !important; padding: 0 !important; animation: mo-marq var(--marq, 36s) linear infinite; }
.mo-marq li { padding-right: 44px; }
.mo-marq li::before { margin-left: 22px; }
.mo-marq:hover ul { animation-play-state: paused; }
@keyframes mo-marq { to { translate: -50% 0; } }

/* Số liệu: chữ Hán nền trồi lên */
.stat::after { transition: translate 1.4s var(--ease-out) .2s, opacity 1.4s; }
.mo .stat:not(.mo-seen)::after { translate: 0 70%; opacity: 0; }

/* Tiêu đề mục: gạch chân tự vẽ */
.mo .sec-head { transition: background-size 1.5s var(--ease-io) .1s; }
.mo .sec-head:not(.mo-seen) { background-size: 0 2px; }
.sec-head::after { transition: width 1.1s var(--ease-out) .5s; }
.mo .sec-head:not(.mo-seen)::after { width: 0; }

/* Chữ Hán lớn trôi chậm sau mỗi mục (chiều sâu khi cuộn) */
section.block { position: relative; overflow: clip; isolation: isolate; }
.mo-ghost {
  position: absolute; right: -2%; top: 10px; z-index: -1; pointer-events: none; user-select: none;
  font: 400 clamp(150px, 22vw, 300px)/1 var(--f-brush); color: var(--mid); opacity: .045;
  translate: 0 calc(var(--py, 0) * 1px); rotate: -6deg;
}
#lo-trinh .mo-ghost, #bang-gia .mo-ghost { left: -2%; right: auto; rotate: 6deg; }

/* Thẻ nghiêng theo con trỏ */
.mo-tilt { transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .5s var(--ease-out), box-shadow .3s; will-change: transform; }
.mo-tilt.mo-tilting { transition: transform .12s linear, box-shadow .3s; box-shadow: 0 26px 60px rgba(62, 6, 71, .18); }
.step .n { transition: scale .9s var(--ease-back) .3s, rotate .9s var(--ease-back) .3s; }
.mo .step:not(.mo-seen) .n { scale: 1.8; rotate: -30deg; }
.sample .thumb img { transition: scale 1.6s var(--ease-out), translate 1.6s var(--ease-out); }
.mo .sample:not(.mo-seen) .thumb img { scale: 1.22; }
.sample:hover .thumb img { scale: 1.05; }
.plan .ribbon { transition: translate .9s var(--ease-back) .6s, opacity .5s .6s; }
.mo .plan:not(.mo-seen) .ribbon { translate: 0 -30px; opacity: 0; }
.paystep .i { transition: rotate 1s var(--ease-back) .3s, scale 1s var(--ease-back) .3s; }
.mo .paystep:not(.mo-seen) .i { rotate: -180deg; scale: .3; }

/* Hỏi đáp: mở ra mượt */
.faq details p { transition: opacity .45s var(--ease-out), translate .45s var(--ease-out); }
.faq details.mo-opening p { opacity: 0; translate: 0 -8px; }

/* Thanh menu: vạch vàng trượt theo mục đang xem */
.nav .wrap { position: relative; }
.mo-ind { position: absolute; left: 0; bottom: 0; height: 3px; width: 1px; background: var(--gold); border-radius: 3px 3px 0 0;
  transform-origin: 0 50%; transition: translate .6s var(--ease-out), scale .6s var(--ease-out), opacity .3s; pointer-events: none; opacity: 0; }
.nav.mo-has-ind a, .nav.mo-has-ind a:hover, .nav.mo-has-ind a.active { border-bottom-color: transparent; }

/* ---------- Trang thanh toán ---------- */
.mo .progress li::before { transition: background .5s, color .5s, scale .5s var(--ease-back); }
.mo .progress li.on::before, .mo .progress li.done::before { scale: 1.12; }
.qr-box { position: relative; overflow: hidden; }
.mo .qr-box::after {
  content: ""; position: absolute; left: 8%; right: 8%; top: 10px; height: 3px; border-radius: 3px; pointer-events: none;
  background: linear-gradient(90deg, transparent, #2B6A50, transparent); box-shadow: 0 0 16px 3px rgba(43, 106, 80, .4);
  animation: mo-scan 2.6s var(--ease-io) infinite alternate;
}
@keyframes mo-scan { from { translate: 0 0; } to { translate: 0 230px; } }
.mo .success .check { animation: mo-check .8s var(--ease-back) both, mo-pulse 1.8s ease-out .8s 2; }
@keyframes mo-check { from { scale: 0; rotate: -120deg; } to { scale: 1; rotate: 0deg; } }
@keyframes mo-pulse { from { box-shadow: 0 0 0 0 rgba(31, 122, 77, .45); } to { box-shadow: 0 0 0 26px rgba(31, 122, 77, 0); } }

/* Màn mới hiện ra (đổi bước thanh toán, đăng nhập → bảng học) */
.mo .mo-enter { animation: mo-enter .8s var(--ease-out) both; }
@keyframes mo-enter { from { opacity: 0; translate: 0 34px; scale: .98; } to { opacity: 1; translate: 0 0; scale: 1; } }

/* ---------- Khu học viên ---------- */
.mo .mo-stagger { animation: mo-item .6s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes mo-item { from { opacity: 0; translate: 26px 0; } to { opacity: 1; translate: 0 0; } }
.mo .mo-media { animation: mo-media .7s var(--ease-out) both; }
@keyframes mo-media { from { opacity: 0; scale: 1.04; filter: blur(8px); } to { opacity: 1; scale: 1; filter: none; } }
.hv-progress-fill, #p-fill { transition: width .9s var(--ease-out); }
.mo .hv-top { background-size: 200% 100% !important; animation: mo-flow 9s ease-in-out infinite alternate; }
@keyframes mo-flow { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }

@media (prefers-reduced-motion: reduce) {
  .mo-progress, .mo-wipe, .mo-ghost, .mo-ind { display: none !important; }
  html.mo-arrive::before { display: none; }
}
