/* The scan: while Pika reads a page the child waits on (main.dang-quet, set by session-screen.js from vision_status), a light
   sweeps over the zoomed photo and the notebook's picture, and a thin bar slides under the caption. Display only.
   The band runs from the top edge to the bottom edge of its box (top 0 -> 100% minus the band), whatever the box's height:
   a fixed distance (420 px / 220 px before 22/10) stopped half way down a tall photo (anh Cường 22/10). */
.lv4.dang-quet .zoom::after, .dang-quet .cam-card .view::after {
  content: ""; position: absolute; left: 14px; right: 14px; top: 14px; height: 70px; pointer-events: none; z-index: 7; border-radius: 12px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--main, #22b8cf) 38%, transparent) 70%, color-mix(in srgb, var(--main, #22b8cf) 85%, transparent) 97%, transparent 100%);
  --quet-le: 14px; animation: quet-quet 1.9s ease-in-out infinite alternate; }
.dang-quet .cam-card .view::after { left: 0; right: 0; top: 0; border-radius: 0; --quet-le: 0px; }
.lv4.dang-quet .zoom img { animation: quet-tho 1.9s ease-in-out infinite alternate; }
.dang-quet .zoom-tag, .dang-quet .cam-badge { position: absolute; overflow: hidden; }
.dang-quet .zoom-tag::after, .dang-quet .cam-badge::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; width: 35%;
  background: var(--main, #22b8cf); animation: quet-thanh 1.4s ease-in-out infinite; }
@keyframes quet-quet { from { top: var(--quet-le); } to { top: calc(100% - 70px - var(--quet-le)); } }
@keyframes quet-thanh { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@keyframes quet-tho { from { filter: brightness(1); } to { filter: brightness(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .lv4.dang-quet .zoom::after, .dang-quet .cam-card .view::after, .lv4.dang-quet .zoom img { animation: none; }
  .dang-quet .zoom-tag::after, .dang-quet .cam-badge::after { animation: none; width: 100%; opacity: .5; }
}

/* "Pika thấy bài rồi" (anh Cường 22/10): the camera's first reading put a problem on the board. The scan above ends in a
   lock: four corners close on the camera's page and turn green, a check pops on the camera and on the stage, the
   problem line glows once. main.thay-bai-on is set for 2.6 s by session-screen.js (phatThayBai); nothing is clickable. */
.thay-bai, .cam-khoa { display: none; pointer-events: none; }
.lv4 .board-card > .thay-bai { grid-row: 2; grid-column: 1 / -1; }   /* over the picture and the scratch paper alike */
.thay-bai { position: relative; z-index: 8; place-self: center; flex-direction: column; align-items: center; gap: 10px;
  padding: 22px 34px 20px; border-radius: 28px; text-align: center; max-width: min(92%, 420px);
  background: color-mix(in srgb, var(--white, #fff) 96%, transparent); border: 3px solid var(--green-400, #2ec47a);
  box-shadow: 0 18px 50px color-mix(in srgb, var(--green-500, #22a866) 30%, transparent); }
.thay-bai-on .thay-bai { display: flex; animation: tb-vao .5s cubic-bezier(.34, 1.56, .64, 1) both, tb-ra .45s ease-in 2.1s forwards; }
.thay-bai .tb-t { display: flex; flex-direction: column; gap: 2px; }
.thay-bai .tb-t b { font-family: "Baloo 2", var(--font, inherit); font-weight: 800; font-size: 26px; line-height: 1.15; color: var(--ink, #0f172a); }
.thay-bai .tb-t span { font-weight: 700; font-size: 15px; color: var(--ink2, #475569); }
/* the check: a green disc pops, the white tick is drawn */
.tb-tick { display: block; width: 76px; height: 76px; flex: none; }
.tb-tick svg { width: 100%; height: 100%; overflow: visible; }
.tb-tick circle { fill: var(--green-400, #2ec47a); transform-origin: 26px 26px; }
.tb-tick path { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; }
.thay-bai-on .tb-tick circle { animation: tb-dia .45s cubic-bezier(.34, 1.56, .64, 1) .12s both; }
.thay-bai-on .tb-tick path { animation: tb-ve .35s ease-out .45s forwards; }
/* a ring and eight sparks around the check */
.tb-ring { position: absolute; left: 50%; top: 60px; width: 0; height: 0; }
.tb-ring::before { content: ""; position: absolute; width: 76px; height: 76px; margin: -38px; border-radius: 50%;
  border: 3px solid var(--green-400, #2ec47a); opacity: 0; }
.thay-bai-on .tb-ring::before { animation: tb-song .8s ease-out .4s; }
.tb-ring i { position: absolute; width: 9px; height: 9px; margin: -4.5px; border-radius: 50%; opacity: 0;
  background: var(--green-400, #2ec47a); transform: rotate(var(--a)) translateY(-40px); }
.tb-ring i:nth-child(even) { background: var(--yellow-400, #ffc93c); width: 7px; height: 7px; margin: -3.5px; }
.tb-ring i:nth-child(1) { --a: 0deg; } .tb-ring i:nth-child(2) { --a: 45deg; } .tb-ring i:nth-child(3) { --a: 90deg; }
.tb-ring i:nth-child(4) { --a: 135deg; } .tb-ring i:nth-child(5) { --a: 180deg; } .tb-ring i:nth-child(6) { --a: 225deg; }
.tb-ring i:nth-child(7) { --a: 270deg; } .tb-ring i:nth-child(8) { --a: 315deg; }
.thay-bai-on .tb-ring i { animation: tb-sao .75s ease-out .45s; }
/* the problem line and Pika's halo answer the same beat */
.thay-bai-on .board-card .nowtop .progbar, .thay-bai-on .board-card .nowtop .now-de { animation: tb-nhan 1.3s ease-out .5s; }
.thay-bai-on .halo-av { animation: tb-nhun .6s cubic-bezier(.34, 1.56, .64, 1) .5s; }
/* the camera: four corners close on the page, a green wash, the check */
.thay-bai-on .cam-khoa { display: block; position: absolute; inset: 0; z-index: 8; border-radius: inherit; overflow: hidden; }
.cam-khoa::after { content: ""; position: absolute; inset: 0; background: var(--green-400, #2ec47a); opacity: 0; }
.thay-bai-on .cam-khoa::after { animation: tb-sang .9s ease-out .35s; }
.cam-khoa i { position: absolute; width: 28px; height: 28px; border: 0 solid var(--green-400, #2ec47a);
  animation: tb-goc .45s cubic-bezier(.34, 1.4, .64, 1) both, tb-ra .4s ease-in 2.1s forwards; }
.cam-khoa .tl { top: 12px; left: 12px; border-width: 5px 0 0 5px; border-top-left-radius: 10px; --dx: -16px; --dy: -16px; }
.cam-khoa .tr { top: 12px; right: 12px; border-width: 5px 5px 0 0; border-top-right-radius: 10px; --dx: 16px; --dy: -16px; }
.cam-khoa .bl { bottom: 12px; left: 12px; border-width: 0 0 5px 5px; border-bottom-left-radius: 10px; --dx: -16px; --dy: 16px; }
.cam-khoa .br { bottom: 12px; right: 12px; border-width: 0 5px 5px 0; border-bottom-right-radius: 10px; --dx: 16px; --dy: 16px; }
.cam-khoa .tb-tick { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px;
  filter: drop-shadow(0 4px 12px rgb(0 0 0 / .3)); animation: tb-ra .4s ease-in 2.1s forwards; }
@keyframes tb-vao { from { opacity: 0; transform: translateY(14px) scale(.7); } to { opacity: 1; transform: none; } }
@keyframes tb-ra { to { opacity: 0; transform: translateY(-8px) scale(.96); } }
@keyframes tb-dia { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes tb-ve { to { stroke-dashoffset: 0; } }
@keyframes tb-song { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(2); } }
@keyframes tb-sao { 0% { opacity: 1; transform: rotate(var(--a)) translateY(-40px) scale(1); }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-84px) scale(.4); } }
@keyframes tb-nhan { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green-400, #2ec47a) 60%, transparent); border-color: var(--green-400, #2ec47a); }
  100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes tb-nhun { 0%, 100% { transform: none; } 40% { transform: translateY(-8px) scale(1.12); } }
@keyframes tb-sang { 0% { opacity: 0; } 30% { opacity: .28; } 100% { opacity: 0; } }
@keyframes tb-goc { from { opacity: 0; transform: translate(calc(var(--dx) * 2), calc(var(--dy) * 2)); border-color: #fff; }
  60% { opacity: 1; border-color: #fff; } to { opacity: 1; transform: none; border-color: var(--green-400, #2ec47a); } }
@media (prefers-reduced-motion: reduce) {
  /* a still check, no motion: shown and hidden with the class */
  .thay-bai-on .thay-bai, .thay-bai-on .tb-tick circle, .thay-bai-on .tb-ring i, .thay-bai-on .tb-ring::before, .cam-khoa i,
  .cam-khoa .tb-tick, .thay-bai-on .cam-khoa::after, .thay-bai-on .halo-av,
  .thay-bai-on .board-card .nowtop .progbar, .thay-bai-on .board-card .nowtop .now-de { animation: none; }
  .thay-bai-on .tb-tick path { animation: none; stroke-dashoffset: 0; }
  .cam-khoa i { opacity: 1; }
}
