/* Minh họa, icon, chuyển động và linh vật · khuôn trang bài học (14/11/2026) */

/* ---------- Icon nét mảnh ---------- */
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; display: block; }
.ic > * { stroke-dasharray: 1; stroke-dashoffset: 0; transition: stroke-dashoffset 1s var(--ease, ease) .15s; }


/* Icon phần: bên phải dải navy */
.pa-b .part-head { align-items: center; }
.pa-b .ph-ic { margin-left: auto; color: var(--gold); opacity: .9; }
.pa-b .ph-ic .ic { width: 30px; height: 30px; stroke-width: 1.4; }
.part-head.reveal .ph-ic .ic > * { stroke-dashoffset: 1; }
.part-head.reveal.in .ph-ic .ic > * { stroke-dashoffset: 0; transition-delay: .3s; }

/* ---------- Ba cấp độ ---------- */
.lv-top { display: flex; align-items: center; justify-content: space-between; color: var(--navy); margin-bottom: 2px; }
.lv-top .ic { width: 28px; height: 28px; }
.lv-meter { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.lv-meter i { width: 6px; border-radius: 2px; background: var(--line); transition: background .4s, transform .5s var(--ease, ease); transform-origin: bottom; }
.lv-meter i.on { background: var(--gold); }
.levels.mh-wait:not(.mh-in) .level { opacity: 0; }
.levels.mh-in .level { --from: translateY(var(--rise, 22px)); animation: rise-in .65s var(--ease, ease) var(--d, 0ms) backwards; }
.levels.mh-wait .level:nth-child(2) { --rise: 34px; } .levels.mh-wait .level:nth-child(3) { --rise: 46px; }
.levels.mh-wait .ic > * { stroke-dashoffset: 1; } .levels.mh-in .ic > * { stroke-dashoffset: 0; }
.levels.mh-wait .lv-meter i { transform: scaleY(0); } .levels.mh-in .lv-meter i { transform: none; transition-delay: calc(var(--d, 0ms) + .4s); }
.pa-b .levels .level:nth-child(3) { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }

/* ---------- RGCCF ---------- */
.rg { position: relative; padding-right: 52px !important; }
.rg-ic { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--gold); }
.rg-ic .ic { width: 22px; height: 22px; }
.rg.mh-wait:not(.mh-in) { opacity: 0; }
.rg.mh-in { --from: translateX(-12px); animation: rise-in .5s var(--ease, ease) var(--d, 0ms) backwards; }
.rg.mh-wait .ic > * { stroke-dashoffset: 1; } .rg.mh-in .ic > * { stroke-dashoffset: 0; }

/* Thẻ hồ sơ bài 04 */
.card-ic { display: block; color: var(--gold); margin-bottom: 10px; }
.card-ic .ic { width: 28px; height: 28px; }
#L04 .cards.mh-wait .ic > * { stroke-dashoffset: 1; } #L04 .cards.mh-in .ic > * { stroke-dashoffset: 0; }

/* ---------- Minh họa đầu vào → AI → đầu ra ---------- */
.mh-io { margin: 22px 0 8px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); display: grid; gap: 14px; }
.io-row { display: grid; grid-template-columns: 112px 1fr 48px 1fr 124px; grid-template-rows: auto auto; align-items: center; column-gap: 0; row-gap: 6px; }
.io-lab { grid-column: 1 / -1; font: 700 12.5px var(--sans); color: var(--muted); }
.io-row.good .io-lab { color: var(--green); }
.io-row.bad .io-lab { color: var(--red); }
.io-in { display: flex; gap: 5px; }
.io-doc { position: relative; width: 30px; height: 38px; border: 1.5px solid var(--navy); border-radius: 3px; background: var(--card); padding: 7px 5px; display: flex; flex-direction: column; gap: 4px; }
.io-doc i { height: 2px; border-radius: 1px; background: var(--gold-300); }
.io-doc i:nth-child(3) { width: 60%; }
.io-doc em { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 3px; font: 600 10px var(--sans); font-style: normal; color: var(--muted); white-space: nowrap; }
.io-row.bad .io-doc { opacity: .5; border-style: dashed; }
.io-line { height: 2px; margin: 0 6px; background-image: linear-gradient(90deg, var(--gold) 50%, transparent 0); background-size: 10px 2px; }
.io-row.bad .io-line { background-image: linear-gradient(90deg, var(--line) 50%, transparent 0); }
.mh-io.mh-in .io-line { animation: flow .7s linear infinite; }
@keyframes flow { to { background-position: 10px 0; } }
.io-ai { width: 48px; height: 48px; border-radius: 12px; background: var(--navy); color: var(--bg); display: grid; place-items: center; font: 800 16px var(--display, var(--sans)); }
.mh-io.mh-in .io-row.good .io-ai { animation: pulse 2.2s var(--ease, ease) infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(201,148,46,.45); } 50% { box-shadow: 0 0 0 8px rgba(201,148,46,0); } }
.io-out { display: flex; align-items: center; gap: 8px; }
.io-out b { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font: 800 20px var(--display, var(--sans)); flex: none; }
.io-out span { font: 700 13px var(--sans); white-space: nowrap; }
.io-row.bad .io-out b { background: var(--red-50); color: var(--red); }
.io-row.bad .io-out span { color: var(--red); }
.io-row.good .io-out b { background: var(--green-bg); color: var(--green); }
.io-row.good .io-out b .ic { width: 20px; height: 20px; }
.io-row.good .io-out span { color: var(--green); }
.mh-io.mh-wait .io-out { opacity: 0; transform: scale(.7); }
.mh-io.mh-in .io-out { opacity: 1; transform: none; transition: opacity .4s, transform .5s var(--ease, ease); transition-delay: .9s; }
.mh-io.mh-wait .io-doc { transform: translateY(8px); opacity: 0; }
.mh-io.mh-in .io-doc { opacity: 1; transform: none; transition: transform .5s var(--ease, ease), opacity .5s; }
.mh-io.mh-in .io-row.good .io-doc:nth-child(2) { transition-delay: .12s; } .mh-io.mh-in .io-row.good .io-doc:nth-child(3) { transition-delay: .24s; }
.mh-io.mh-in .io-row.bad .io-doc { opacity: .5; }
@media (max-width: 560px) {
  .mh-io { padding: 14px 12px; }
  .io-row { grid-template-columns: auto 1fr 40px 1fr auto; }
  .io-doc { width: 24px; height: 31px; padding: 6px 4px; gap: 3px; }
  .io-doc em { font-size: 9px; }
  .io-row.good .io-doc em { display: none; }
  .io-row.good .io-in, .io-row.good .io-line, .io-row.good .io-ai, .io-row.good .io-out { margin-bottom: 0; padding-bottom: 0; }
  .io-ai { width: 40px; height: 40px; font-size: 14px; }
  .io-out { flex-direction: column; gap: 3px; } .io-out span { font-size: 11px; }
  .io-out b { width: 32px; height: 32px; font-size: 17px; }
}

/* ---------- Linh vật ---------- */
/* Đầu trang */
.hero.has-mascot { display: grid; grid-template-columns: minmax(0, 1fr) 210px; column-gap: 28px; }
.hero.has-mascot > * { grid-column: 1; }
.hero.has-mascot > .hero-mascot { grid-column: 2; grid-row: 1 / span 6; align-self: end; }
.hero-mascot { margin: 0; position: relative; }
.hm-img { display: block; width: 100%; height: auto; }
.hm-bubble {
  position: absolute; bottom: 100%; right: 0; margin-bottom: 4px; width: max-content; max-width: 200px; padding: 8px 12px; border-radius: 12px 12px 12px 2px;
  background: var(--navy); color: var(--bg); font: 600 13px/1.4 var(--sans);
}
@media (prefers-reduced-motion: no-preference) {
  .hero-mascot .hm-img { animation: hm-in .9s var(--ease, ease) both .2s; }
  .hm-bubble { animation: hm-pop .5s var(--ease, ease) both 1s; transform-origin: bottom left; }
  .cq-img { animation: hm-in .7s var(--ease, ease) both; }
}
@keyframes hm-in { from { opacity: 0; transform: translateY(18px); } }
@keyframes hm-pop { from { opacity: 0; transform: scale(.6); } }

/* Câu hỏi coach: chân dung tròn bên trái */
blockquote.coach-q.has-mascot { display: grid; grid-template-columns: 64px 1fr; column-gap: 16px; align-items: start; }
.cq-mascot { grid-row: 1 / span 3; width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: var(--gold-bg); border: 1.5px solid var(--gold-300); }
.cq-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; transform-origin: 50% 0; scale: 1.5; }

/* Cuối trang */
.end-mascot { margin: 34px 0 0; display: grid; grid-template-columns: 150px 1fr; gap: 22px; align-items: end; padding: 22px 24px 0; border-radius: 8px; background: var(--gold-bg); border: 1px solid var(--gold-300); overflow: hidden; }
.em-img { width: 100%; height: auto; display: block; }
.end-mascot figcaption { padding-bottom: 22px; }
.em-k { font: 700 12.5px var(--sans); color: var(--gold-text); }
.end-mascot p { margin: 4px 0 10px; font: 800 22px/1.35 var(--display, var(--sans)); color: var(--navy); }
.em-q { display: block; font: 500 15px/1.5 var(--sans); color: var(--muted); font-style: italic; }

/* Chúc mừng đọc xong */
.cele {
  position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(460px, calc(100vw - 32px));
  display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: end; padding: 14px 40px 14px 14px;
  background: var(--card); border: 1px solid var(--gold); border-radius: 10px; box-shadow: 0 18px 50px -18px rgba(11,10,31,.45);
  animation: hm-pop .45s var(--ease, ease) both;
}
.cele-img { width: 96px; height: auto; display: block; }
.cele-t { display: grid; gap: 4px; padding-bottom: 4px; font-size: 14px; color: var(--muted); }
.cele-t b { font: 800 18px var(--display, var(--sans)); color: var(--navy); }
.cele-t .btn { justify-self: start; margin-top: 6px; padding: 8px 14px; font-size: 14px; }
.cele-x { position: absolute; top: 6px; right: 8px; width: 28px; height: 28px; border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 89; overflow: hidden; }
.confetti i { position: absolute; top: -12px; left: var(--x); width: 8px; height: 12px; background: var(--c); border-radius: 2px; animation: fall 2.2s cubic-bezier(.3,.6,.5,1) var(--dl) forwards; transform: rotate(var(--r)); }
@keyframes fall { to { transform: translateY(105vh) rotate(calc(var(--r) + 540deg)); opacity: .2; } }

/* Ảnh linh vật nền trắng (nếu Codex không tạo được nền trong suốt): hòa vào nền sáng */
.mascot-white .hm-img, .mascot-white .em-img, .mascot-white .cele-img { mix-blend-mode: multiply; }

/* Màn hình hẹp */
@media (max-width: 1020px) {
  .pa-b .lesson-head { min-height: 0; }
  .hero.has-mascot { grid-template-columns: minmax(0, 1fr) 132px; column-gap: 12px; }
  .hero.has-mascot > .hero-mascot { grid-row: 1 / span 2; align-self: start; }
  .hm-bubble { display: none; }
}
@media (max-width: 560px) {
  .hero.has-mascot { grid-template-columns: minmax(0, 1fr) 96px; }
  .end-mascot { grid-template-columns: 96px 1fr; gap: 14px; padding: 16px 16px 0; }
  .end-mascot p { font-size: 18px; }
  .rg { padding-right: 44px !important; }
  .rg-ic { right: 12px; }
}

/* Trình chiếu: không hiện linh vật và minh họa phụ */
.stage .end-mascot, .stage .cq-mascot { display: none; }
@media print { .cele, .confetti, .hero-mascot { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .ic > *, .levels .level, .rg, .mh-io * { transition: none !important; animation: none !important; }
}

/* Trình chiếu chép slide lúc bấm: phần chưa kịp chạy chuyển động vẫn phải hiện đủ */
.stage .mh-wait, .stage .mh-wait .level, .stage .mh-wait .io-out, .stage .mh-wait .io-doc { opacity: 1 !important; transform: none !important; }
.stage .mh-wait .ic > *, .stage .reveal .ic > * { stroke-dashoffset: 0 !important; }
.stage .mh-wait .lv-meter i { transform: none !important; }
.stage .mh-io .io-row.bad .io-doc { opacity: .5 !important; }
@media (max-width: 1020px) {
  /* Hình chỉ đứng cạnh nhãn và tiêu đề; đoạn dẫn, nhãn, nút trải hết bề ngang */
  .hero.has-mascot > :not(.hero-mascot):not(.eyebrow):not(h1) { grid-column: 1 / -1; }
}

/* ---------- Nhóm khối hiện lần lượt (thẻ, bước, checklist, phòng, thẻ ôn) ---------- */
/* Dùng animation chạy một lần (chỉ giữ trạng thái đầu trong lúc chờ), để transition còn trống cho hiệu ứng di chuột */
@keyframes rise-in { from { opacity: 0; transform: var(--from, translateY(20px)); } }
.stg:not(.stg-in) > * { opacity: 0; }
.stg.stg-in > * { animation: rise-in .6s var(--ease, ease) calc(var(--i, 0) * 90ms) backwards; }
.cards.stg > *, .rooms.stg > *, .flash.stg > * { --from: translateY(26px) scale(.97); }
.steps.stg > *, .klist.stg > *, .todo.stg > * { --from: translateX(-14px); }
.formula.stg > * { --from: translateY(26px) scale(.97); }
/* Thanh lô hàng: từng đoạn Basic, Pro, Max đầy dần từ trái sang */
.lot-bar.stg > * { --from: scaleX(0); transform-origin: left center; }
.lot-bar.stg.stg-in > * { animation-duration: .5s; animation-delay: calc(var(--i, 0) * 260ms); }

/* Di chuột qua: thẻ nhô lên nhẹ, viền vàng, bóng mềm (chỉ trên máy có chuột) */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .pa-b :is(.card, .level, .room, .rg, .fc, .mh-io, .formula > div) {
    transition: transform .25s var(--ease, ease), box-shadow .25s var(--ease, ease), border-color .25s;
  }
  .pa-b :is(.card, .level, .room, .fc, .mh-io, .formula > div):hover {
    transform: translateY(-4px); border-color: var(--gold);
    box-shadow: 0 14px 28px -16px rgba(26, 23, 67, .35);
  }
  .pa-b .rg:hover { transform: translateX(4px); border-color: var(--gold); box-shadow: 0 10px 22px -16px rgba(26, 23, 67, .35); }
  .pa-b :is(.card, .level, .rg):hover .ic { color: var(--red); }
  .pa-b .klist > li, .pa-b .todo > li { transition: transform .2s var(--ease, ease); }
  .pa-b .klist > li:hover, .pa-b .todo > li:hover { transform: translateX(4px); }
}
/* Khung prompt: vạch đỏ chạy dọc mép trái rồi mờ đi */
.prompt.pr-wait { position: relative; }
.prompt.pr-wait::after { content: ""; position: absolute; left: -3px; top: 0; bottom: 0; width: 3px; background: var(--red); transform-origin: top; transform: scaleY(0); pointer-events: none; }
.prompt.pr-in::after { animation: pr-line 1.1s var(--ease, ease) .15s both; }
@keyframes pr-line { 0% { transform: scaleY(0); opacity: 1; } 70% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.stage .stg > *:not(.pop), .stage .levels .level:not(.pop), .stage .rg:not(.pop) { opacity: 1 !important; animation: none !important; }
.stage .prompt::after { display: none; }
@media (prefers-reduced-motion: reduce) { .stg > *, .levels .level, .rg { opacity: 1 !important; animation: none !important; } }

/* Giao diện tối (14/11/2026): ô kết của công thức phải nổi như ở giao diện sáng; bóng khi di chuột đậm hơn để thấy được trên nền tối */
:root[data-theme="dark"] .pa-b .formula > div:last-child { background: var(--gold-bg); border-color: var(--gold-300); }
:root[data-theme="dark"] .pa-b .formula > div:last-child::before { color: var(--gold-text); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :root[data-theme="dark"] .pa-b :is(.card, .level, .room, .fc, .mh-io, .formula > div):hover,
  :root[data-theme="dark"] .pa-b .rg:hover { box-shadow: 0 16px 32px -14px rgba(0, 0, 0, .75), 0 0 0 1px var(--gold-300); }
}

/* Trình chiếu: chân trang và nhãn bài dùng phông thân bài, chữ thường (bỏ kiểu chữ hoa mono) */
.pa-b .stage-foot { font: 500 15px var(--sans); letter-spacing: 0; text-transform: none; }
.pa-b .stage .s-eyebrow { font: 700 20px var(--sans); letter-spacing: 0; text-transform: none; }
.stage .pop { animation: pop .55s var(--spring) both !important; }

/* Tiêu đề: không để một chữ lẻ rơi xuống dòng (minh-hoa.js mục 5) */
.hero h1, .lesson-head .lt, .part-head h2, .slide h3, .het-han-o h1, .signup h3, .end-mascot p { text-wrap: balance; }
.hero h1.mot-dong { white-space: nowrap; }
.lien { white-space: nowrap; }
