/* linh-vat.css — chuyển động của 6 linh vật (site/js/linhvat.js). Linh vật phẳng, KHÔNG đổ bóng:
   sức sống đến từ chuyển động kiểu hoạt hình — co giãn (squash & stretch), có đà và nảy (overshoot),
   các bộ phận lệch nhịp nhau (đầu trễ sau thân, phụ kiện trễ sau đầu), mắt chớp + liếc.
   Cảm xúc = class cam-*: nghi (đứng chờ, nhún nhẹ) · vui (bật nhảy ăn mừng rồi nhún phấn khích)
   · buon (gục xuống, thở dài, lắc đầu) · chao (vẫy tay, nghiêng đầu theo nhịp).
   Tâm xoay từng bộ phận đặt inline (toạ độ viewBox) → transform-box: view-box; mắt dùng fill-box. */
.lv { display: inline-block; width: var(--co, 160px); aspect-ratio: 1; line-height: 0; vertical-align: bottom; flex: none; }
.lv svg { display: block; width: 100%; height: 100%; overflow: visible; }
.lv g { transform-box: view-box; }

/* ---- hiện/ẩn mắt + miệng theo cảm xúc */
.lv .m-cuoi, .lv .m-buon, .lv .mg-vui, .lv .mg-buon { display: none; }
.lv.cam-vui .m-mo, .lv.cam-buon .m-mo { display: none; }
.lv.cam-vui .m-cuoi, .lv.cam-buon .m-buon { display: inline; }
.lv.cam-vui .mg-nghi, .lv.cam-chao .mg-nghi, .lv.cam-buon .mg-nghi { display: none; }
.lv.cam-vui .mg-vui, .lv.cam-chao .mg-vui, .lv.cam-buon .mg-buon { display: inline; }

/* ================= NGHỈ: nhún co giãn đều như đang thở + đầu trễ nhịp + mắt chớp, liếc */
.lv-toan { animation: lv-nhun-nhe 1.6s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes lv-nhun-nhe { 0%, 100% { transform: scale(1.03, .97); } 50% { transform: translateY(-3px) scale(.98, 1.03); } }
.lv-dau { animation: lv-dau-lu 1.6s cubic-bezier(.45, 0, .55, 1) -.2s infinite; }
@keyframes lv-dau-lu { 0%, 100% { transform: rotate(-2deg); } 50% { transform: translateY(-2px) rotate(2deg); } }
.lv-phu { animation: lv-dua 1.6s cubic-bezier(.45, 0, .55, 1) -.45s infinite; }
@keyframes lv-dua { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
.lv-tay { animation: lv-tay-du 1.6s cubic-bezier(.45, 0, .55, 1) -.3s infinite; }
@keyframes lv-tay-du { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
/* chớp mắt: hai lần liền rồi nghỉ lâu — trông tự nhiên hơn chớp đều */
.lv .m-mo { transform-box: fill-box; transform-origin: center; animation: lv-chop 4.2s infinite; }
@keyframes lv-chop { 0%, 86%, 90%, 94%, 100% { transform: none; } 88%, 92% { transform: scaleY(.1); } }
/* liếc: con ngươi nhìn sang trái, giữa, phải rồi về giữa */
.lv .lv-ngoi { animation: lv-liec 6s cubic-bezier(.6, 0, .3, 1) infinite; }
@keyframes lv-liec { 0%, 18%, 62%, 100% { transform: none; } 24%, 40% { transform: translate(-3px, 1px); } 46%, 56% { transform: translate(3px, -1px); } }

/* mỗi loài một nhịp riêng → 6 con đứng cạnh nhau không nhún/chớp cùng lúc */
.lv-con-trung { --t: 1.5s; } .lv-khung-long { --t: 1.8s; } .lv-duoi-bien { --t: 2.2s; }
.lv-vu-tru { --t: 2s; } .lv-bau-troi { --t: 1.7s; } .lv-sa-mac { --t: 1.9s; } .lv-hs { --t: 1.6s; }
.lv:not(.cam-vui):not(.cam-buon) :is(.lv-toan, .lv-dau, .lv-phu, .lv-tay) { animation-duration: var(--t); }
.lv-khung-long .m-mo { animation-duration: 5.1s; animation-delay: -2.1s; } .lv-duoi-bien .m-mo { animation-duration: 4.7s; animation-delay: -3.4s; }
.lv-vu-tru .m-mo { animation-duration: 5.6s; animation-delay: -1.2s; } .lv-bau-troi .m-mo { animation-duration: 4.4s; animation-delay: -3.9s; }
.lv-sa-mac .m-mo { animation-duration: 5.3s; animation-delay: -.4s; }
.lv-khung-long .lv-ngoi { animation-delay: -2s; } .lv-duoi-bien .lv-ngoi { animation-delay: -4s; } .lv-vu-tru .lv-ngoi { animation-delay: -1s; }
.lv-bau-troi .lv-ngoi { animation-delay: -3s; } .lv-sa-mac .lv-ngoi { animation-delay: -5s; }
/* phụ kiện riêng */
.lv-bau-troi .lv-phu { animation: lv-khan .5s ease-in-out infinite alternate; }          /* khăn bay phần phật */
@keyframes lv-khan { from { transform: rotate(-6deg) scaleY(.88); } to { transform: rotate(6deg) scaleY(1.1); } }
.lv .lv-quat { animation: lv-quat .3s linear infinite alternate; }                       /* chân vịt quay */
@keyframes lv-quat { to { transform: scaleY(-1); } }
.lv-duoi-bien .lv-toan { animation: lv-noi 2.4s ease-in-out infinite; }                  /* tàu ngầm bập bềnh thay vì nhún */
@keyframes lv-noi { 0%, 100% { transform: translateY(2px) rotate(1.5deg); } 50% { transform: translateY(-5px) rotate(-1.5deg); } }
.lv .lv-bot circle { transform-box: fill-box; animation: lv-bot 2.4s ease-in infinite; }
.lv .lv-bot circle:nth-child(2) { animation-delay: -.8s; } .lv .lv-bot circle:nth-child(3) { animation-delay: -1.6s; }
@keyframes lv-bot { from { transform: translateY(14px) scale(.6); opacity: 0; } 25% { opacity: 1; } to { transform: translateY(-16px) scale(1.1); opacity: 0; } }
.lv .lv-den { animation: lv-den 1.2s steps(1) infinite; }
@keyframes lv-den { 50% { opacity: .25; } }

/* nhân vật học sinh (nhanvat.js): cánh vỗ lệch nhau hai bên */
.lv .nv-canh { animation: nv-vo .9s ease-in-out infinite alternate; }
.lv .nv-canh.p { animation-name: nv-vo-p; }
@keyframes nv-vo { from { transform: rotate(8deg); } to { transform: rotate(-10deg) scaleX(.9); } }
@keyframes nv-vo-p { from { transform: rotate(-8deg); } to { transform: rotate(10deg) scaleX(.9); } }
.lv .q-nhap { animation: q-nhap .3s steps(1) infinite; }

/* ================= VUI: lấy đà (ngồi xổm) → bật cao duỗi người → rơi bẹp → nảy, rồi nhún phấn khích liên tục, giơ hai tay */
.lv.cam-vui .lv-toan { animation: lv-bat .9s cubic-bezier(.3, .7, .4, 1) both, lv-phan-khich .5s ease-in-out .9s 6 alternate; }   /* ~3 giây rồi đứng yên vui */
@keyframes lv-bat {
  0% { transform: none; } 15% { transform: scale(1.18, .8); } 38% { transform: translateY(-26px) scale(.86, 1.18) rotate(-4deg); }
  55% { transform: translateY(-29px) scale(.95, 1.05) rotate(3deg); } 72% { transform: scale(1.2, .82); } 86% { transform: translateY(-6px) scale(.97, 1.04); } 100% { transform: none; } }
@keyframes lv-phan-khich { from { transform: scale(1.04, .96); } to { transform: translateY(-6px) scale(.97, 1.04); } }
.lv.cam-vui .lv-dau { animation: lv-dau-vui .5s ease-in-out .9s 6 alternate; }
@keyframes lv-dau-vui { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
.lv.cam-vui .lv-tay { transform: rotate(var(--vay)); animation: lv-co-vu .25s ease-in-out 14 alternate; }
@keyframes lv-co-vu { from { transform: rotate(calc(var(--vay) + 10deg)); } to { transform: rotate(calc(var(--vay) - 10deg)); } }
.lv.cam-vui .lv-phu { animation-duration: .5s; }

/* ================= BUỒN: gục xuống (co người), thở dài chậm, lắc đầu nhẹ, tay buông */
.lv.cam-buon .lv-toan { animation: lv-guc .5s cubic-bezier(.4, 0, .2, 1) both, lv-tho-dai 2.8s ease-in-out .5s 2 both; }
@keyframes lv-guc { to { transform: translateY(5px) scale(1.04, .94); } }
@keyframes lv-tho-dai { 0%, 100% { transform: translateY(5px) scale(1.04, .94); } 40% { transform: translateY(3px) scale(1.01, .98); } }
.lv.cam-buon .lv-dau { animation: lv-lac-dau 2.8s ease-in-out .5s 2 both; transform: translateY(5px) rotate(6deg); }
@keyframes lv-lac-dau { 0%, 100% { transform: translateY(5px) rotate(6deg); } 30% { transform: translateY(5px) rotate(-3deg); } 55% { transform: translateY(5px) rotate(5deg); } }
.lv.cam-buon .lv-tay { animation: none; transform: rotate(8deg); }
.lv.cam-buon .lv-phu { animation-duration: 3s; }

/* ================= CHÀO: vẫy tay phải nhanh, đầu nghiêng theo nhịp vẫy, thân nhún nhẹ */
.lv.cam-chao .lv-tay-p { transform: rotate(var(--vay)); animation: lv-vay .32s ease-in-out infinite alternate; }   /* --vay đặt inline theo loài */
@keyframes lv-vay { from { transform: rotate(calc(var(--vay) + 18deg)); } to { transform: rotate(calc(var(--vay) - 18deg)); } }
.lv.cam-chao .lv-dau { animation: lv-dau-chao .64s ease-in-out infinite alternate; }
@keyframes lv-dau-chao { from { transform: rotate(-6deg); } to { transform: rotate(3deg); } }

/* ---- giảm chuyển động: đứng yên (tay vẫn giơ khi chào/vui, mắt vẫn đổi theo cảm xúc) */
body.giam .lv, body.giam .lv * { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .lv, .lv * { animation: none !important; transition: none !important; } }

/* ================= QUÁI (site/js/quai.js) — cùng phong cách linh vật: phẳng, không bóng, sống bằng chuyển động.
   Đứng chờ: thở phồng xẹp + chân bước so le + cánh vỗ + đuôi/râu lắc. Trúng đòn (cha có .trung/.nga hoặc .qv.dau): mắt "> <". */
.qv { position: relative; display: inline-block; width: var(--co, 160px); aspect-ratio: 1; line-height: 0; vertical-align: bottom; flex: none; }
.qv svg { display: block; width: 100%; height: 100%; overflow: visible; }
.qv g { transform-box: view-box; }
.qv .q-dau { display: none; }
:is(.trung, .nga, .dau) > .qv .q-mo, .qv.dau .q-mo { display: none; }
:is(.trung, .nga, .dau) > .qv .q-dau, .qv.dau .q-dau { display: inline; }
.q-toan { animation: q-tho 1.5s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes q-tho { 0%, 100% { transform: scale(1.03, .97); } 50% { transform: translateY(-3px) scale(.97, 1.04); } }
.qv-boss .q-toan { animation-duration: 2.2s; }
.q-canh { animation: q-canh .22s ease-in-out infinite alternate; }
@keyframes q-canh { from { transform: rotate(-14deg) scaleY(1.05); } to { transform: rotate(10deg) scaleY(.8); } }
.q-canh-cham { animation: q-canh 1.1s ease-in-out infinite alternate; }
.q-duoi { animation: q-duoi 1.3s ease-in-out infinite alternate; }
@keyframes q-duoi { from { transform: rotate(-8deg); } to { transform: rotate(9deg); } }
.q-rau { animation: q-rau 1.5s ease-in-out -.4s infinite alternate; }
@keyframes q-rau { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
.q-chan-a, .q-chan-b { animation: q-buoc .75s ease-in-out infinite alternate; }
.q-chan-b { animation-delay: -.75s; }
@keyframes q-buoc { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
.q-nhap { animation: q-nhap 1.2s steps(1) infinite; }                     /* đèn/điện/lửa nhấp nháy */
@keyframes q-nhap { 50% { opacity: .35; } }
.q-xoay { animation: q-xoay 3s linear infinite; }
@keyframes q-xoay { to { transform: rotate(360deg); } }
.q-bay { animation: q-bay 2s ease-in-out infinite; }                       /* loài bay: lơ lửng thay vì nhún */
@keyframes q-bay { 0%, 100% { transform: translateY(4px); } 50% { transform: translateY(-8px); } }
.qv .q-mo { transform-box: fill-box; transform-origin: center; animation: lv-chop 3.7s infinite; }
/* bậc (đi lại vòng 2+): hào quang màu bậc; bậc 3+ đội vương miện */
.qv[data-bac] svg { filter: drop-shadow(0 0 9px var(--bac)); }
.q-vuong { position: absolute; left: 50%; top: -4%; width: 26%; transform: translateX(-50%) rotate(-8deg); }
body.giam .qv *, body.giam .qv { animation: none !important; }
@media (prefers-reduced-motion: reduce) { .qv, .qv * { animation: none !important; } }
