/*
 * PlayPuzzle Science Lab kit — the shared look of the Science Lab (planner-web kids.css + lab.css), for the
 * static games under /public. Link it after /shared/game-header.css and before the game's own styles.css,
 * and load Fredoka + Nunito from Google Fonts in the page head.
 *
 * Contents: tokens, base, chunky "pressed" buttons (.k-btn, .k-round), glass cards and pills, gold stars,
 * Professor Ollie's coach bubble, the Build → Test step strip, rank bar, level ring, badge shelf, confetti,
 * toasts, the ghost hand, and the kids.css keyframes. Every target is at least 48 px, and every animation
 * stops under reduced motion.
 *
 * Used by Bridge Builder Challenge and Physics Playground.
 */

:root {
  color-scheme: light;
  --k-ink: #1d2742;
  --k-ink-soft: #4a5775;
  --k-card: #ffffff;
  --k-gold: #fbbf24;
  --k-gold-deep: #b45309;
  --k-radius: 24px;
  --k-shadow: 0 10px 30px rgba(29, 39, 66, .12), 0 2px 6px rgba(29, 39, 66, .08);
  --k-spring: cubic-bezier(.34, 1.56, .64, 1);
  --k-sky-top: #c9f2ee;
  --k-sky-bottom: #eef3ff;
  --k-accent: #0c8599;
  --k-accent-deep: #0b7285;
  --k-accent-soft: #e3fafc;
  --k-go-top: #ff7a59;
  --k-go-bottom: #e8430f;
  --k-success: #2f9e44;
  --k-retry: #e8590c;
  --k-hint: #fff9db;
  font-family: Nunito, ui-rounded, system-ui, sans-serif;
  color: var(--k-ink);
  background: var(--k-sky-bottom);
}

* { box-sizing: border-box; }
.lab-body { margin: 0; min-height: 100dvh; background: linear-gradient(180deg, var(--k-sky-top) 0%, var(--k-sky-bottom) 62%, #f4f9ff 100%) fixed; overflow-x: hidden; overflow-x: clip; -webkit-tap-highlight-color: transparent; }
:where(.lab-body) :where(h1, h2, h3), .k-display { font-family: Fredoka, ui-rounded, system-ui, sans-serif; letter-spacing: .01em; line-height: 1.1; }
:where(.lab-body) :where(button, input, select) { font: inherit; color: inherit; }
:where(.lab-body) button { touch-action: manipulation; }
[hidden] { display: none !important; }
:focus-visible { outline: 4px solid #4f46e5; outline-offset: 3px; border-radius: 16px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.ui-icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.eyebrow { margin: 0 0 4px; color: var(--k-accent-deep); font-size: .82rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }

/* ── Header pills (Science Lab player header) ─────────────────────────────────────────────────────────── */
.ppgh-pills { display: flex; gap: 6px; margin-inline: auto 8px; }
.k-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 14px; border-radius: 999px; background: rgba(255, 255, 255, .92); font-weight: 900; box-shadow: 0 3px 0 rgba(29, 39, 66, .1); white-space: nowrap; }
.ppgh-btn[aria-pressed="false"] { opacity: .6; }

/* ── Buttons: chunky, pressable, never smaller than a thumb ───────────────────────────────────────────── */
.k-btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 8px 24px; border: 0; border-radius: 999px; font-family: Fredoka, ui-rounded, sans-serif; font-weight: 600; font-size: 1.15rem; line-height: 1.15; color: var(--k-ink); background: var(--k-card); cursor: pointer; text-decoration: none; text-align: center; box-shadow: 0 5px 0 rgba(29, 39, 66, .16), 0 8px 18px rgba(29, 39, 66, .12); transition: transform .12s, box-shadow .12s, filter .12s; user-select: none; -webkit-user-select: none; }
.k-btn:hover:not([disabled]) { filter: brightness(1.04); }
.k-btn:active:not([disabled]) { transform: translateY(4px); box-shadow: 0 1px 0 rgba(29, 39, 66, .16), 0 3px 8px rgba(29, 39, 66, .1); }
.k-btn-go { color: #fff; background: linear-gradient(180deg, var(--k-go-top), var(--k-go-bottom)); box-shadow: 0 5px 0 #a6300a, 0 10px 22px rgba(232, 67, 15, .35); text-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.k-btn-go:active:not([disabled]) { box-shadow: 0 1px 0 #a6300a, 0 4px 10px rgba(232, 67, 15, .3); }
.k-btn-gold { color: #7c2d12; background: linear-gradient(180deg, #ffe066, var(--k-gold)); box-shadow: 0 5px 0 #d97706, 0 10px 22px rgba(217, 119, 6, .3); }
.k-btn-gold:active:not([disabled]) { box-shadow: 0 1px 0 #d97706; }
.k-btn-accent { color: #fff; background: linear-gradient(180deg, #22b8cf, var(--k-accent)); box-shadow: 0 5px 0 var(--k-accent-deep), 0 10px 22px rgba(12, 133, 153, .3); }
.k-btn-accent:active:not([disabled]) { box-shadow: 0 1px 0 var(--k-accent-deep); }
.k-btn-big { min-height: 72px; padding: 10px 36px; font-size: 1.45rem; }
.k-btn-sm { min-height: 48px; padding: 6px 18px; font-size: 1rem; gap: 8px; }
.k-btn[disabled] { opacity: .45; cursor: default; transform: none; filter: grayscale(.3); }
.k-round { display: inline-grid; place-items: center; width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .95); color: var(--k-ink); font-size: 1.25rem; cursor: pointer; box-shadow: 0 4px 0 rgba(29, 39, 66, .14), 0 6px 14px rgba(29, 39, 66, .1); transition: transform .12s, background .15s; }
.k-round:active:not([disabled]) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(29, 39, 66, .14); }
.k-round[disabled] { opacity: .35; cursor: default; }
.k-round[aria-pressed="true"] { background: var(--k-accent); color: #fff; box-shadow: 0 4px 0 var(--k-accent-deep), 0 6px 14px rgba(12, 133, 153, .3); }
.k-glass { background: rgba(255, 255, 255, .82); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: var(--k-radius); box-shadow: var(--k-shadow); }
.k-card { padding: 18px; border-radius: var(--k-radius); background: var(--k-card); box-shadow: var(--k-shadow); }

/* ── Stars ────────────────────────────────────────────────────────────────────────────────────────────── */
.k-star { display: inline-block; color: #d7dde8; line-height: 1; }
.k-star.on { color: var(--k-gold); text-shadow: 0 2px 0 var(--k-gold-deep); }
.k-star.pop { animation: k-star-pop .55s var(--k-spring) both; animation-delay: calc(.35s + var(--i, 0) * .22s); }
.star-row { display: inline-flex; gap: 2px; font-size: 1.35rem; }

/* ── Professor Ollie ──────────────────────────────────────────────────────────────────────────────────── */
.coach { display: flex; align-items: flex-end; gap: 10px; }
.coach .ollie { flex: none; filter: drop-shadow(0 4px 6px rgba(29, 39, 66, .12)); }
.ollie-idle, .ollie-think { animation: k-bob 2.6s ease-in-out infinite; }
.ollie-wave .ollie-wing { transform-origin: 38px 92px; animation: k-wave 1.4s ease-in-out infinite; }
.ollie-cheer { animation: k-bounce 1s var(--k-spring) 2; }
.ollie-eyes { transform-origin: 80px 64px; animation: k-blink 4.5s infinite; }
.coach-bubble { position: relative; flex: 1; min-width: 0; padding: 12px 16px; border-radius: 22px 22px 22px 6px; background: #fff; box-shadow: 0 4px 0 rgba(29, 39, 66, .08), 0 10px 24px rgba(29, 39, 66, .08); animation: k-rise .35s var(--k-spring); }
.coach-bubble p { margin: 0; font-weight: 800; line-height: 1.35; text-wrap: pretty; }
.coach-success .coach-bubble { background: #ebfbee; box-shadow: 0 4px 0 #b2f2bb; }
.coach-retry .coach-bubble { background: #fff4e6; box-shadow: 0 4px 0 #ffd8a8; }
.coach-hint .coach-bubble { background: var(--k-hint); box-shadow: 0 4px 0 #ffec99; }

/* ── Progress: step strip, rank bar, level ring ───────────────────────────────────────────────────────── */
.step-strip { display: flex; gap: 8px; margin: 0; padding: 4px 2px; list-style: none; overflow-x: auto; scrollbar-width: none; }
.step-strip li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: rgba(255, 255, 255, .7); font-weight: 900; color: var(--k-ink-soft); white-space: nowrap; transition: background .3s, transform .3s var(--k-spring); }
.step-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #e3e9f2; font-family: Fredoka, sans-serif; }
.step-strip li.done { color: var(--k-success); }
.step-strip li.done .step-num { background: #d3f9d8; }
.step-strip li.current { background: #fff; color: var(--k-ink); transform: scale(1.05); box-shadow: 0 4px 0 rgba(29, 39, 66, .1); }
.step-strip li.current .step-num { background: var(--k-accent); color: #fff; animation: k-pulse 1.6s ease-in-out infinite; }
.rank-bar { height: 12px; margin: 6px 0 4px; border-radius: 999px; background: #e3e9f2; overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3bc9db, var(--k-accent)); transition: width .8s var(--k-spring); }
.level-ring { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: conic-gradient(var(--k-accent) calc(var(--pct) * 1%), #dfe7ef 0); flex: none; }
.level-ring span { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 50%; background: #fff; font-size: 1.6rem; }

/* ── Badge shelf ──────────────────────────────────────────────────────────────────────────────────────── */
.badge-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 0; padding: 18px; list-style: none; border-radius: var(--k-radius); background: linear-gradient(180deg, #fff, #fff8e6); box-shadow: var(--k-shadow); }
.badge-medal { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 12px 8px; border-radius: 18px; text-align: center; }
.badge-medal .medal { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; font-size: 1.8rem; background: radial-gradient(circle at 35% 30%, #fff9db, #ffd43b 70%, #f59f00); box-shadow: 0 4px 0 #e67700, 0 8px 16px rgba(230, 119, 0, .25); }
.badge-medal.locked .medal { background: #e9edf3; box-shadow: 0 4px 0 #cfd6e1; filter: grayscale(1); opacity: .7; }
.badge-medal strong { font-size: .92rem; }
.badge-medal small { color: var(--k-ink-soft); font-weight: 700; font-size: .78rem; line-height: 1.25; }
.badge-medal.earned { animation: k-rise .4s var(--k-spring) both; }

/* ── Effects ──────────────────────────────────────────────────────────────────────────────────────────── */
.confetti-canvas { position: fixed; inset: 0; z-index: 200; width: 100%; height: 100%; pointer-events: none; }
.toast-host { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(76px + env(safe-area-inset-top, 0px)); z-index: 210; display: grid; gap: 8px; width: min(360px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 20px; background: var(--k-ink); color: #fff; font-weight: 800; box-shadow: 0 12px 30px rgba(29, 39, 66, .35); animation: toast-in .45s var(--k-spring) both; }
.toast strong { display: block; color: #ffd43b; }
.toast-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff9db, #ffd43b 70%, #f59f00); font-size: 1.5rem; flex: none; }
.toast.leaving { animation: toast-out .35s ease-in both; }
.ghost-hand { position: absolute; z-index: 120; width: 52px; height: 52px; margin: -6px 0 0 -14px; pointer-events: none; animation: ghost-hand 2.6s ease-in-out 2 both; filter: drop-shadow(0 6px 8px rgba(29, 39, 66, .3)); }
.ghost-hand svg { width: 100%; height: 100%; }
.k-nudge { animation: k-glow 1.4s ease-in-out infinite, k-wiggle .9s ease-in-out 2; }

/* ── Keyframes (Science Lab kids.css) ─────────────────────────────────────────────────────────────────── */
@keyframes k-pop { 0% { transform: scale(.9); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes k-wiggle { 0%, 100% { translate: 0; } 20% { translate: -8px 0; rotate: -2deg; } 40% { translate: 8px 0; rotate: 2deg; } 60% { translate: -5px 0; rotate: 0deg; } 80% { translate: 5px 0; } }
@keyframes k-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, .7), 0 6px 0 rgba(29, 39, 66, .13); } 50% { box-shadow: 0 0 0 12px rgba(251, 191, 36, 0), 0 6px 0 rgba(29, 39, 66, .13); } }
@keyframes k-pulse { 0%, 100% { scale: 1; } 50% { scale: 1.08; } }
@keyframes k-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } 60% { transform: translateY(-5px); } }
@keyframes k-star-pop { 0% { transform: scale(0) rotate(-40deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes k-rise { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes k-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes k-wave { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-18deg); } 75% { transform: rotate(12deg); } }
@keyframes k-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes k-spin { to { transform: rotate(360deg); } }
@keyframes k-fade-in { from { opacity: 0; } }
@keyframes toast-in { from { transform: translateX(40px) scale(.9); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(40px); opacity: 0; } }
@keyframes ghost-hand { 0% { translate: 0 0; opacity: 0; } 12% { opacity: 1; } 55% { translate: calc(var(--dx) * .5) calc(var(--dy) * .5 - 60px); } 85% { translate: var(--dx) var(--dy); opacity: 1; scale: 1; } 92% { scale: .85; } 100% { translate: var(--dx) var(--dy); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ghost-hand, .confetti-canvas { display: none; }
}

@media (forced-colors: active) {
  .k-btn, .k-round, .k-pill, .coach-bubble, .toast { border: 2px solid ButtonText; }
  .k-star.on { color: Highlight; }
}
