/* pn-fx.css — the shared "juice" layer for the 8 PN practice games (load after each game's own styles).
   Star progress track, press feedback, breathing characters that look at the hint, sparkle trails,
   confetti, and the folding parent tip. */

/* ---------- star track (replaces the progress dots) ---------- */
body .dots { gap: 3px; align-items: center; }
body .dots i {
  width: 24px; height: 24px; border: 0; border-radius: 0; background: center / contain no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.1l-5.9 3.2 1.3-6.6-4.9-4.6 6.6-.8z' fill='%23fff' stroke='%232b2347' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E");
  transition: transform .3s; transform: none;
}
body .dots i.now {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.1l-5.9 3.2 1.3-6.6-4.9-4.6 6.6-.8z' fill='%23ffd0dc' stroke='%232b2347' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E");
  animation: pnfx-now 1.4s ease-in-out infinite;
}
body .dots i.on {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.1l-5.9 3.2 1.3-6.6-4.9-4.6 6.6-.8z' fill='%23ffd93b' stroke='%232b2347' stroke-width='2.2' stroke-linejoin='round'/%3E%3Cpath d='M9 8.6l1.2-2.4' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  transform: scale(1.12);
}
body .dots i, body .dots i.now, body .dots i.on, body .dots i.wait { background-color: transparent; border: 0; box-shadow: none; }
body .dots i.fresh { animation: pnfx-fresh .6s cubic-bezier(.3, 1.8, .5, 1); }
body .dots i.wait { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.1l-5.9 3.2 1.3-6.6-4.9-4.6 6.6-.8z' fill='%23fff' stroke='%232b2347' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E"); transform: none; }
/* long sessions (9+ stars) use smaller stars so the track stays on one line on a phone */
body .dots:has(i:nth-child(9)) { gap: 1px; }
body .dots:has(i:nth-child(9)) i { width: 19px; height: 19px; }
@keyframes pnfx-now { 50% { transform: scale(1.18) rotate(8deg); } }
@keyframes pnfx-fresh { 0% { transform: scale(.4); } 60% { transform: scale(1.6) rotate(-12deg); } 100% { transform: scale(1.12); } }
.pnfx-flystar {
  position: fixed; z-index: 9; width: 44px; height: 44px; margin: -22px 0 0 -22px; pointer-events: none;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.1l-5.9 3.2 1.3-6.6-4.9-4.6 6.6-.8z' fill='%23ffd93b' stroke='%232b2347' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M9 8.6l1.2-2.4' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 6px rgba(255, 228, 92, .9));
}

/* ---------- press feedback: things squish under the finger ---------- */
.titem, .check-btn, .again, .big-btn, .icon-btn, .corner { transition: transform .12s ease, filter .12s; }
.titem:active { transform: scale(.88); filter: brightness(.96); }
.icon-btn:active { transform: scale(.9); }

/* ---------- question card entrance ---------- */
.prompt .q.pop { animation: pnfx-qpop .55s cubic-bezier(.3, 1.7, .5, 1); }
@keyframes pnfx-qpop { 0% { transform: scale(.6) rotate(-3deg); opacity: 0; } 70% { transform: scale(1.04) rotate(1deg); opacity: 1; } }

/* ---------- characters breathe, and look at the thing that is glowing ---------- */
:where(svg.ani) .ani-body { animation: pnfx-breathe 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
:where(.titem) :where(svg.ani) .ani-body { animation-duration: 4.2s; }
@keyframes pnfx-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.015, 1.03); } }
svg.ani .a-pupil, svg.ani .a-glint, svg.panda .p-pupil, svg.panda .p-glint { translate: var(--lx, 0px) var(--ly, 0px); transition: translate .35s ease; }
/* drawings without an .ani-body group (Who's Hungry? book animals) breathe as a whole */
:where(svg.ani:not(:has(> .ani-body))) { animation: pnfx-breathe 3.4s ease-in-out infinite; transform-origin: 50% 100%; }
.pnfx-tilt { animation: pnfx-tilt 1.1s ease-in-out; transform-origin: 50% 90%; }
@keyframes pnfx-tilt { 30% { transform: rotate(-6deg); } 70% { transform: rotate(4deg); } }

/* ---------- sparkle trail and landing puff ---------- */
.pnfx-spark {
  position: fixed; z-index: 8; width: 14px; height: 14px; margin: -7px 0 0 -7px; pointer-events: none; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 30%, #ffe45c 31% 60%, transparent 62%);
  animation: pnfx-spark .6s ease-out forwards;
}
@keyframes pnfx-spark { from { transform: scale(1.2); opacity: 1; } to { transform: scale(.2) translateY(10px); opacity: 0; } }
.pnfx-puff {
  position: fixed; z-index: 8; width: 70px; height: 70px; margin: -35px 0 0 -35px; pointer-events: none; border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .9); box-shadow: 0 0 0 3px rgba(255, 228, 92, .6);
  animation: pnfx-puff .45s ease-out forwards;
}
@keyframes pnfx-puff { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* ---------- confetti rain (all stars collected) ---------- */
.pnfx-confetti { position: fixed; z-index: 9; top: -24px; width: 12px; height: 18px; pointer-events: none; border: 2px solid #2b2347; border-radius: 3px; animation: pnfx-fall linear forwards; }
@keyframes pnfx-fall { to { transform: translate(var(--dx, 0px), calc(100vh + 60px)) rotate(var(--rot, 540deg)); } }

/* ---------- parent tip folds into a small chip ---------- */
body .ptip { cursor: pointer; pointer-events: auto; border-radius: 14px; transition: background .2s; padding: 2px 8px; box-sizing: border-box; }
body .ptip:not(.open) { font-size: 0; min-height: 0; line-height: 0; width: auto; display: flex; justify-content: center; background: none; }
body .ptip:not(.open)::before {
  content: "💡 家長提示"; font-size: 13px; line-height: 1.6; font-weight: 800; color: var(--ink-soft, #5c5480);
  background: rgba(255, 255, 255, .75); border: 2px solid rgba(43, 35, 71, .25); border-radius: 999px; padding: 0 10px;
}
body .ptip.open { background: rgba(255, 255, 255, .7); }
body .ptip:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  :where(svg.ani) .ani-body, :where(svg.ani:not(:has(> .ani-body))), body .dots i.now { animation: none; }
  .pnfx-spark, .pnfx-confetti { display: none; }
}

/* ---------- "她講了！" bonus button (for the grown-up; over the star track in the top bar, away from her tap targets) ---------- */
.pnfx-talk {
  position: fixed; z-index: 12; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100vw - 150px); top: max(10px, env(safe-area-inset-top));
  display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 52px; padding: 0 16px 0 10px; white-space: nowrap; overflow: hidden;
  border-radius: 999px; border: 3.5px solid #2b2347; background: #ff9f1c; color: #fff; cursor: pointer;
  font-family: "Noto Sans HK", system-ui, sans-serif; font-weight: 900; font-size: 19px; box-shadow: 0 5px 0 #2b2347;
  animation: pnfx-talk-in .45s cubic-bezier(.3, 1.7, .5, 1), pnfx-talk-wig 1.6s ease-in-out .6s infinite;
}
.pnfx-talk-ico { font-size: 24px; }
.pnfx-talk:active { transform: translateY(4px); box-shadow: 0 1px 0 #2b2347; }
.pnfx-talk-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: rgba(255, 255, 255, .85); transform-origin: left; animation: pnfx-talk-bar linear forwards; }
.pnfx-talk.out { animation: pnfx-talk-out .28s ease-in forwards; pointer-events: none; }
@keyframes pnfx-talk-in { from { transform: scale(0) rotate(-10deg); } }
@keyframes pnfx-talk-wig { 0%, 70%, 100% { rotate: 0deg; } 80% { rotate: -4deg; } 90% { rotate: 4deg; } }
@keyframes pnfx-talk-bar { to { transform: scaleX(0); } }
@keyframes pnfx-talk-out { to { transform: scale(0); opacity: 0; } }
.pnfx-bigstar {
  position: fixed; z-index: 11; left: 50%; top: 45%; width: 150px; height: 150px; margin: -75px 0 0 -75px; pointer-events: none;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.2l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.1l-5.9 3.2 1.3-6.6-4.9-4.6 6.6-.8z' fill='%23ffd93b' stroke='%232b2347' stroke-width='1.6' stroke-linejoin='round'/%3E%3Cpath d='M9 8.6l1.2-2.4' stroke='%23fff' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 18px rgba(255, 228, 92, .95));
  animation: pnfx-bigstar 1.25s cubic-bezier(.3, 1.6, .5, 1) forwards;
}
@keyframes pnfx-bigstar { 0% { transform: scale(0) rotate(-90deg); opacity: 0; } 30% { transform: scale(1.15) rotate(10deg); opacity: 1; } 75% { transform: scale(1) rotate(0); opacity: 1; } 100% { transform: scale(.4) translateY(-120px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pnfx-talk { animation: none; } .pnfx-bigstar { animation-duration: .01s; } }

/* ---------- "用真玩具再玩" chip (top bar, over the finished star track) and card (pn-real.js), for the grown-up at the end of a round ---------- */
.pnreal-chip {
  position: fixed; z-index: 12; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100vw - 150px); top: max(12px, env(safe-area-inset-top)); white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 3px solid #2b2347; background: #fff; color: #2b2347; box-shadow: 0 4px 0 #2b2347;
  font-family: "Noto Sans HK", system-ui, sans-serif; font-weight: 900; font-size: 16px;
  animation: pnfx-talk-in .45s cubic-bezier(.3, 1.7, .5, 1) .6s backwards, pnfx-talk-wig 2.4s ease-in-out 2s infinite;
}
.pnreal-chip span { font-size: 22px; }
.pnreal-chip:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b2347; }
.pnreal-wrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)); background: rgba(43, 35, 71, .45); animation: pnreal-fade .2s ease-out; }
.pnreal-wrap.out { animation: pnreal-fade .2s ease-in reverse forwards; }
@keyframes pnreal-fade { from { opacity: 0; } }
.pnreal {
  position: relative; width: min(560px, 100%); max-height: 100%; overflow-y: auto; box-sizing: border-box; padding: 18px 18px 16px;
  background: #fffaf0; color: #2b2347; border: 4px solid #2b2347; border-radius: 26px; box-shadow: 0 7px 0 #2b2347;
  font-family: "Nunito", "Noto Sans HK", system-ui, sans-serif; animation: pnfx-talk-in .35s cubic-bezier(.3, 1.6, .5, 1);
}
.pnreal h2 { margin: 2px 40px 6px 0; font-family: "Noto Sans HK", system-ui, sans-serif; font-weight: 900; font-size: 24px; line-height: 1.2; }
.pnreal h3 { margin: 12px 0 6px; font-family: "Noto Sans HK", system-ui, sans-serif; font-size: 15px; font-weight: 900; color: #5c5480; }
.pnreal-seg { display: inline-block; font-size: 12px; font-weight: 800; color: #fff; background: #8a6cff; border: 2px solid #2b2347; border-radius: 999px; padding: 1px 10px; font-family: "Noto Sans HK", system-ui, sans-serif; }
.pnreal-x { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #2b2347; background: #fff; font-size: 18px; font-weight: 900; cursor: pointer; color: #2b2347; }
.pnreal-props { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pnreal-props li { display: flex; align-items: center; gap: 10px; background: #fff; border: 2.5px solid #2b2347; border-radius: 14px; padding: 6px 10px; font-family: "Noto Sans HK", system-ui, sans-serif; font-weight: 700; font-size: 15px; }
.pnreal-props li span { font-size: 28px; line-height: 1; }
.pnreal-lines { margin: 0; padding: 0 0 0 1.4em; display: grid; gap: 8px; }
.pnreal-lines li { font-size: 19px; line-height: 1.25; }
.pnreal-lines b { display: block; font-family: "Baloo 2", "Nunito", system-ui, sans-serif; font-weight: 800; font-size: 21px; }
.pnreal-lines span { display: block; font-family: "Noto Sans HK", system-ui, sans-serif; font-weight: 700; color: #5c5480; font-size: 18px; }
.pnreal-tip { margin: 12px 0 0; padding: 8px 12px; background: #fff3c4; border-radius: 14px; font-family: "Noto Sans HK", system-ui, sans-serif; font-size: 14px; line-height: 1.5; }
.pnreal-foot { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.pnreal-foot a { color: #5c5480; font-weight: 800; font-family: "Noto Sans HK", system-ui, sans-serif; font-size: 14px; }
.pnreal-ok { min-height: 50px; padding: 0 20px; border-radius: 999px; border: 3.5px solid #2b2347; background: #2fc86b; color: #fff; font-family: "Noto Sans HK", system-ui, sans-serif; font-weight: 900; font-size: 17px; box-shadow: 0 4px 0 #2b2347; cursor: pointer; }
.pnreal-ok:active { transform: translateY(3px); box-shadow: 0 1px 0 #2b2347; }
@media (prefers-reduced-motion: reduce) { .pnreal-chip, .pnreal, .pnreal-wrap { animation: none; } }
