/* Kuru Games kit: the paper pieces every game type, the player, the Game Room and the sticker album share.
   Contract and naming: docs/GAMES.md. Prefix g- (pieces), gt (a paper tile button), gc (a choice), g-pad (number pad).
   Rules: transform and opacity only for motion; 44 px targets at least (64 px for answers a child taps); text on a
   tile uses --ink; feedback is kind (a soft wobble and a coral tint, never red alarm colours); reduced motion keeps
   the colours and drops the movement. Place colours come from --pl-c / --pl-bg / --pl-ink / --pl-accent (places.js). */

:root {
  --g-cut: 16px 19px 15px 18px / 18px 15px 19px 16px;
  --g-cut-sm: 11px 13px 10px 12px / 12px 10px 13px 11px;
  --g-sh: 0 1px 1px rgba(90, 42, 0, .24), 0 6px 12px -7px rgba(90, 42, 0, .42);
  --g-sh-lift: 0 2px 3px rgba(90, 42, 0, .2), 0 16px 26px -14px rgba(90, 42, 0, .45);
  --g-edge: inset 0 1px 0 rgba(255, 255, 255, .8), inset 0 -2px 0 rgba(90, 42, 0, .07);
  --g-right: #3E9A55; --g-right-bg: #D5F3E0;
  --g-wrong: #E5635A; --g-wrong-bg: #FFE3DE;
  --g-spring: var(--m-spring, cubic-bezier(.16, 1, .3, 1));
  --pl-c: var(--blue); --pl-bg: var(--sky); --pl-ink: var(--blue-deep); --pl-accent: var(--coral);
}

/* ---------- art: every motif is a 100 x 100 SVG (js/games/art.js); text inside art uses our display font */
.g-art { display: block; width: 100%; height: auto; overflow: visible; }
.g-art__t { font-family: var(--font-display); }
.g-art--note { aspect-ratio: 160 / 76; }

/* ---------- the board a game draws into */
.g-board { position: relative; width: 100%; max-width: 820px; margin-inline: auto; display: grid; gap: clamp(12px, 2.2vh, 20px);
  justify-items: center; align-content: start; }
.g-q { font: 800 clamp(24px, 3.6vw, 36px)/1.15 var(--font-display); color: var(--ink); text-align: center; letter-spacing: -.005em; text-wrap: balance; }
.g-q small { display: block; font: 700 clamp(16px, 1.6vw, 18px)/1.35 var(--font-body); color: var(--ink-2); margin-top: 4px; letter-spacing: 0; }
.g-sub { font: 700 17px/1.4 var(--font-body); color: var(--ink-2); text-align: center; text-wrap: balance; }
.g-round { display: inline-flex; align-items: center; gap: 6px; font: 800 15px/1 var(--font-body); color: var(--pl-ink); }
.g-round i { width: 10px; height: 10px; border-radius: 50%; background: rgba(30, 42, 90, .14); box-shadow: inset 0 1px 1px rgba(90, 42, 0, .2); }
.g-round i.is-done { background: var(--pl-c); box-shadow: 0 1px 0 rgba(255, 255, 255, .7); }
.g-round i.is-now { background: var(--card); box-shadow: inset 0 0 0 2.5px var(--pl-c); }

/* ---------- a paper tile button: cards, pads, cells, answers */
.gt { appearance: none; border: 0; margin: 0; position: relative; display: grid; place-items: center; min-width: 44px; min-height: 44px;
  padding: 6px; background: var(--card); color: var(--ink); border-radius: var(--g-cut-sm); cursor: pointer;
  font: 800 clamp(22px, 3vw, 30px)/1 var(--font-display); letter-spacing: 0;
  box-shadow: var(--g-edge), var(--g-sh); touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  transition: translate 160ms var(--m-settle, ease), scale 160ms var(--m-settle, ease), background-color 200ms ease; }
@media (hover: hover) and (pointer: fine) {
  .gt:not([aria-disabled="true"]):hover { translate: 0 -2px; box-shadow: var(--g-edge), var(--g-sh-lift); }
}
.gt:not([aria-disabled="true"]):active { translate: 0 1px; scale: .97; transition-duration: 80ms; }
.gt[aria-disabled="true"] { cursor: default; }
.gt:focus-visible { outline: 3.5px solid var(--blue); outline-offset: 3px; z-index: 2; }
.gt > .g-art { width: 82%; pointer-events: none; }
.gt.is-right { background: var(--g-right-bg); box-shadow: inset 0 0 0 3px var(--g-right), var(--g-sh); }
.gt.is-wrong { background: var(--g-wrong-bg); box-shadow: inset 0 0 0 3px var(--g-wrong), var(--g-sh); }
.gt.is-dim { opacity: .45; }
.gt.is-hint { box-shadow: inset 0 0 0 3px var(--sun-deep), var(--g-sh); }
@media (prefers-reduced-motion: no-preference) {
  html:not(.rm) .gt.is-wrong { animation: g-nope 420ms var(--m-settle, ease); }
  html:not(.rm) .gt.is-right { animation: g-yes 520ms var(--g-spring); }
  html:not(.rm) .gt.is-hint { animation: g-hint 1.2s steps(2, jump-none) 2; }
}
@keyframes g-nope { 0%, 100% { translate: 0 0; } 18% { translate: -7px 0; } 38% { translate: 6px 0; } 58% { translate: -4px 0; } 78% { translate: 2px 0; } }
@keyframes g-yes { 0% { scale: 1; } 35% { scale: 1.1; } 100% { scale: 1; } }
@keyframes g-hint { 0%, 100% { rotate: 0deg; } 50% { rotate: -3deg; } }

/* a small paper tick or cross that lands on a tile */
.g-mark { position: absolute; right: -8px; top: -8px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; z-index: 3;
  background: var(--g-right); box-shadow: 0 1px 1px rgba(90, 42, 0, .3), 0 4px 8px -4px rgba(90, 42, 0, .5); pointer-events: none; }
.g-mark::after { content: ""; width: 62%; height: 62%; background: #fff; -webkit-mask: url(/assets/art/icons/mark-tick.svg) center / contain no-repeat; mask: url(/assets/art/icons/mark-tick.svg) center / contain no-repeat; }
@media (prefers-reduced-motion: no-preference) { html:not(.rm) .g-mark { animation: g-pop 360ms var(--g-spring) both; } }
@keyframes g-pop { from { scale: .2; opacity: 0; } to { scale: 1; opacity: 1; } }

/* ---------- answer choices: a row of big paper buttons (kit.js choices()) */
.gc-row { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: clamp(10px, 2vw, 16px); width: min(100%, var(--gc-w, 560px)); }
.gc-row--wrap { grid-template-columns: repeat(auto-fit, minmax(var(--gc-min, 120px), 1fr)); }
.gc { min-height: clamp(64px, 11vw, 84px); font-size: clamp(26px, 4vw, 38px); }
.gc--text { font: 800 clamp(18px, 2.4vw, 23px)/1.15 var(--font-display); padding: 10px 12px; text-wrap: balance; }
.gc--art { aspect-ratio: 1; min-height: 0; padding: 8%; }
.gc__k { position: absolute; left: 8px; top: 6px; font: 800 13px/1 var(--font-body); color: var(--ink-2); }
@media (hover: none) { .gc__k { display: none; } }

/* ---------- number pad (kit.js pad()) */
.g-pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: min(100%, 300px); }
.g-pad .gt { min-height: clamp(46px, 6.6vh, 58px); font-size: 28px; }
.g-pad__ok { background: var(--blue) !important; color: #fff !important; }
.g-pad__del { font: 800 16px/1 var(--font-body) !important; color: var(--ink-2) !important; }
.g-entry { min-width: 3.4ch; min-height: 64px; padding: 6px 18px; border-radius: var(--g-cut-sm); background: var(--card); text-align: center;
  font: 800 40px/1.35 var(--font-display); color: var(--ink); box-shadow: inset 0 0 0 3px var(--pl-c), var(--g-sh); }
.g-entry:empty::before { content: "?"; color: var(--ink-3); }

/* ---------- a paper strip with a soft pattern, used as a tray or shelf */
.g-tray { position: relative; width: 100%; padding: clamp(12px, 2.4vw, 22px); border-radius: var(--g-cut); background: var(--card);
  box-shadow: var(--g-edge), var(--g-sh); }
.g-tray::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: url(/assets/art/textures/grain-tile.webp) 0 0 / 256px 256px; mix-blend-mode: multiply; opacity: .45; }

/* the "Ready" / "Check" / "Pay" button inside a game */
.g-go { min-height: 56px; padding: 0 30px; font-size: 19px; }
.g-go[aria-disabled="true"] { opacity: .5; cursor: default; }

/* ---------- tiny helpers */
.g-hide { visibility: hidden; }
.g-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; }
.g-eq { display: inline-flex; align-items: center; gap: .3em; font: 800 clamp(30px, 5vw, 50px)/1 var(--font-display); color: var(--ink); white-space: nowrap; }
.g-eq b { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.4em; padding: 0 .2em; border-radius: .25em; background: var(--card);
  box-shadow: inset 0 0 0 3px var(--pl-c), var(--g-sh); color: var(--pl-ink); }
.g-eq b.is-right { box-shadow: inset 0 0 0 3px var(--g-right), var(--g-sh); background: var(--g-right-bg); color: #1F6B3A; }

/* paper stopwatch for the speed games (counts up, never down) */
.g-watch { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 8px; border-radius: 999px; background: var(--card);
  font: 800 18px/1 var(--font-display); color: var(--ink); box-shadow: var(--g-edge), var(--g-sh); font-variant-numeric: tabular-nums; }
.g-watch::before { content: ""; width: 24px; height: 24px; border-radius: 50%; background: conic-gradient(var(--pl-c) calc(var(--t, 0) * 1turn), rgba(30, 42, 90, .12) 0);
  box-shadow: inset 0 0 0 3px var(--card); }
.g-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 6px; border: 0; background: none; font: 800 15px/1 var(--font-body); color: var(--ink-2); cursor: pointer; }
.g-switch i { position: relative; width: 44px; height: 26px; border-radius: 99px; background: rgba(30, 42, 90, .18); transition: background-color 200ms ease; }
.g-switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: translate 300ms var(--g-spring); }
.g-switch[aria-checked="true"] i { background: var(--pl-c); }
.g-switch[aria-checked="true"] i::after { translate: 18px 0; }

@media (prefers-contrast: more) {
  .gt, .g-tray, .g-entry { box-shadow: inset 0 0 0 2px var(--ink); }
}
@media (forced-colors: active) {
  .gt, .g-tray, .g-entry, .g-watch { border: 2px solid CanvasText; }
  .gt.is-right, .gt.is-wrong { outline: 3px solid Highlight; }
}

/* ---------- phase 2 additions: Kuru's tip button, the in-board round card, the info pill (kit.js) */
.g-tip { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px 0 12px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--lemon); color: var(--ink); font: 800 16px/1 var(--font-body); box-shadow: var(--g-edge), var(--g-sh); touch-action: manipulation;
  transition: translate 160ms var(--m-settle, ease); }
.g-tip svg { width: 24px; height: 24px; flex: none; }
.g-tip:active { translate: 0 1px; }
@media (hover: hover) and (pointer: fine) { .g-tip:hover { translate: 0 -2px; } }
.g-tip[aria-disabled="true"] { opacity: .5; cursor: default; translate: none; }
.g-banner { display: grid; justify-items: center; gap: 6px; width: min(100%, 470px); padding: 16px clamp(16px, 3vw, 24px) 18px; border-radius: var(--g-cut);
  background: var(--card); text-align: center; box-shadow: inset 0 0 0 3px var(--pl-c), var(--g-edge), var(--g-sh-lift); }
.g-banner--draw { box-shadow: inset 0 0 0 3px var(--sun-deep), var(--g-edge), var(--g-sh-lift); }
.g-banner__t { font: 800 clamp(22px, 3vw, 28px)/1.15 var(--font-display); color: var(--ink); text-wrap: balance; }
.g-banner__l { font: 700 17px/1.4 var(--font-body); color: var(--ink-2); text-wrap: balance; max-width: 34ch; }
.g-banner__go { margin-top: 6px; }
@media (prefers-reduced-motion: no-preference) { html:not(.rm) .g-banner { animation: g-pop 380ms var(--g-spring) both; } }
.g-info { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 14px; border-radius: 999px; background: rgba(255, 253, 248, .9);
  color: var(--ink); font: 800 16px/1.2 var(--font-body); box-shadow: inset 0 0 0 1.5px rgba(30, 42, 90, .1); font-variant-numeric: tabular-nums; }
.g-info b { color: var(--pl-ink); }
@media (forced-colors: active) { .g-tip, .g-banner, .g-info { border: 2px solid CanvasText; } }

/* ---------- phase 4: the how-to demo of a question-and-answers type (js/games/quiz.js), small enough for the demo board */
.qz-demo { width: 100%; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; justify-items: center; align-content: center; }
.qz-demo > .g-q { display: none; }
.qz-demo .g-tray { padding: 8px; width: min(100%, 300px); }
.qz-demo .gc-row { gap: 6px; width: min(100%, 320px); }
.qz-demo .gc { min-height: 40px; min-width: 40px; padding: 4px 6px; font-size: 17px; }
