/* IMAGINARIUM — process-games.css
   Shared shell for the three process mini-games (Layer by Layer, Carve to
   Spec, Fill and Set). One UI shell, one score readout, one button language,
   inherited straight from the runner band (rg-*) so the arcade reads as a set.
   Namespaced pg-* so it never collides with the runner. */

.pg-card {
  border: 1.5px solid var(--ink);
  background: var(--white);
  box-shadow: 12px 14px 0 rgba(11,11,12,.10);
  /* Cap the game so it always fits the viewport: width is limited by the
     available height (vh) times this game's aspect ratio (--ar, set per game
     by the core). On tall/narrow screens (phones, iPad portrait) the column
     wins; on short/wide screens (laptops) the height cap wins. Centred. */
  width: min(100%, calc(var(--pg-h, 52vh) * var(--ar, 1.4)));
  max-width: 1080px;
  margin-inline: auto;
}

/* ---- head: title + blurb on the left, score readout on the right ---- */
.pg-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px 26px; flex-wrap: wrap;
  padding: clamp(16px, 2.2vw, 26px) clamp(20px, 2.8vw, 34px) 14px;
}
.pg-kicker { display: flex; flex-direction: column; gap: 6px; max-width: 44ch; }
.pg-name {
  font-family: var(--font-display); font-weight: 900; text-transform: uppercase;
  letter-spacing: -.02em; line-height: .96; font-size: clamp(22px, 2.8vw, 34px);
}
.pg-blurb {
  font-size: clamp(13px, 1.4vw, 15px); line-height: 1.45; opacity: .72;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}
.pg-blurb kbd, .pg-foot kbd, .pg-oi-sub kbd {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em;
  border: 1px solid var(--ink); border-radius: 4px; padding: 2px 6px; margin: 0 1px;
  background: var(--paper); opacity: .9;
}

.pg-score { display: flex; align-items: flex-end; gap: 16px 22px; flex-wrap: wrap; }
.pg-readout { display: flex; flex-direction: column; gap: 5px; }
.pg-rlabel {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .2em;
  text-transform: uppercase; opacity: .55;
}
.pg-rval { font-family: var(--font-display); font-weight: 900; font-size: clamp(20px, 2.3vw, 27px); line-height: 1; }
.pg-rval b { color: var(--blue-deep); font-weight: 900; }
.pg-track { width: clamp(90px, 14vw, 150px); height: 6px; background: rgba(11,11,12,.10); position: relative; overflow: hidden; align-self: center; }
.pg-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--blue); transition: width .25s ease; }

/* ---- stage: bordered canvas with blueprint grid + overlays ---- */
.pg-stage {
  position: relative; border-top: 1.5px solid var(--ink);
  background: rgba(243,239,230,.6);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: pointer; contain: layout paint; overflow: hidden;
}
/* While a game is running the canvas owns the gesture: without this, a
   touch drag scrolls the page and the browser pointercancels the aim. */
.pg-card[data-running] .pg-stage,
.pg-card[data-running] .pg-canvas { touch-action: none; }
.pg-stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: linear-gradient(rgba(11,11,12,.05) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(11,11,12,.05) 1px, transparent 1px);
  background-size: 32px 32px;
}
.pg-canvas { position: relative; z-index: 1; display: block; width: 100%; height: auto; }

/* ---- floating cue / combo toast ---- */
.pg-toast {
  position: absolute; z-index: 3; left: 50%; top: 18%; transform: translate(-50%, -6px);
  font-family: var(--font-marker); font-weight: 700; color: var(--blue);
  font-size: clamp(20px, 3.2vw, 34px); line-height: 1; white-space: nowrap;
  opacity: 0; pointer-events: none; text-shadow: 0 2px 0 rgba(255,255,255,.7);
}
.pg-toast.show { animation: pgPop .72s cubic-bezier(.2,.8,.2,1) both; }
.pg-toast.bad { color: var(--pill-rust); }
.pg-toast.good { color: var(--pill-green); }
@keyframes pgPop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.85); }
  22% { opacity: 1; transform: translate(-50%, -4px) scale(1.05); }
  70% { opacity: 1; transform: translate(-50%, -6px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -22px) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .pg-toast.show { animation: none; opacity: 1; } }

/* ---- overlays (idle / lose-prompt / reward) ---- */
.pg-overlay {
  position: absolute; inset: 0; z-index: 2; display: none;
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: clamp(16px, 3vw, 30px); overflow: auto;
  background: color-mix(in oklab, var(--paper) 92%, transparent);
}
.pg-overlay.show { display: flex; }
/* Whenever an end/reward overlay is showing, let the stage grow so the
   message, buttons and voucher note are never clipped by the card border.
   Applies at ALL widths (phone, iPad, laptop); the canvas keeps its size. */
.pg-stage:has(.pg-overlay.show:not(.pg-idle)) { min-height: 272px; }
.pg-oi-title {
  font-family: var(--font-display); font-weight: 900; text-transform: uppercase;
  letter-spacing: -.02em; font-size: clamp(22px, 3.4vw, 40px); line-height: .98;
}
.pg-oi-sub {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .18em;
  text-transform: uppercase; opacity: .72; margin-top: 14px; line-height: 1.7;
}
.pg-oe-tag {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .24em;
  text-transform: uppercase; color: var(--blue-deep); margin-bottom: 8px;
}
.pg-oe-head {
  font-family: var(--font-marker); font-weight: 700; color: var(--ink);
  font-size: clamp(18px, 2.5vw, 31px); line-height: 1.12; max-width: 26ch;
}
.pg-oe-head .pg-hl { color: var(--blue); }
.pg-oe-actions {
  margin-top: clamp(14px, 2vw, 22px); display: flex; align-items: center;
  gap: 10px 18px; flex-wrap: wrap; justify-content: center;
}
.pg-overlay .btn { padding: 12px 20px; min-height: 42px; }

/* reward screen: solid blue prize panel, same as the runner reward */
.pg-reward { background: var(--blue); color: var(--white); gap: 0; }
.pg-reward .pg-oe-tag { color: rgba(255,255,255,.85); margin-bottom: 6px; }
.pg-reward .pg-oe-head { color: var(--white); font-size: clamp(16px, 2vw, 24px); max-width: 34ch; }
.pg-reward .pg-oe-head .pg-hl { color: var(--ink); }
.pg-reward .pg-oe-actions { margin-top: clamp(12px, 1.6vw, 18px); }
.pg-coupon-note {
  margin-top: 12px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase; opacity: .6;
}
.pg-reward .pg-coupon-note { color: var(--white); opacity: .8; }
.pg-replay {
  background: none; border: 0; padding: 6px 4px; color: var(--ink);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .2em;
  text-transform: uppercase; opacity: .65; border-bottom: 1.5px solid transparent;
}
.pg-replay:hover { opacity: 1; border-bottom-color: var(--blue); color: var(--blue-deep); }
.pg-reward .pg-replay { color: rgba(255,255,255,.82); }
.pg-reward .pg-replay:hover { color: var(--white); border-bottom-color: var(--white); }
/* touch devices: comfortable tap target on the replay button */
@media (pointer: coarse) {
  .pg-replay { min-height: 44px; padding: 10px 8px; }
}

/* ---- foot: controls left, primary play button + status right ---- */
.pg-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px 18px; flex-wrap: wrap; padding: 14px clamp(20px, 2.8vw, 34px) clamp(18px, 2.4vw, 26px);
}
.pg-controls {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; opacity: .6; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pg-play {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; border: 1.5px solid var(--ink); background: var(--ink); color: var(--white);
  padding: 11px 20px; min-height: 42px; display: inline-flex; align-items: center; gap: 10px;
  transition: background .2s ease, color .2s ease;
}
.pg-play:hover, .pg-play:focus-visible { background: var(--blue); color: var(--ink); }
.pg-play .btn-arrow { width: 22px; height: 12px; }
.pg-play .btn-arrow path { stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 600px) {
  .pg-head { padding: 18px 18px 12px; }
  .pg-foot { padding: 12px 18px 18px; }
  .pg-controls .pg-ctl-2 { display: none; }
  .pg-name { font-size: clamp(22px, 6.4vw, 30px); }
  .pg-blurb { font-size: 13px; }
  /* compact the end-state overlays so they fit a short phone-height canvas */
  .pg-overlay { padding: 12px 14px; overflow-y: auto; }
  .pg-oi-title { font-size: clamp(20px, 6vw, 26px); }
  .pg-oi-sub { margin-top: 9px; font-size: 10.5px; letter-spacing: .12em; line-height: 1.6; }
  .pg-oe-tag { margin-bottom: 6px; }
  .pg-oe-head { font-size: clamp(15px, 4.6vw, 19px); max-width: 24ch; }
  .pg-reward .pg-oe-head { font-size: clamp(14px, 4.3vw, 18px); max-width: 26ch; }
  .pg-oe-actions { margin-top: 12px; gap: 8px 12px; }
  .pg-reward .pg-oe-actions { margin-top: 10px; }
  .pg-overlay .btn { padding: 10px 15px; min-height: 38px; }
  .pg-coupon-note { margin-top: 7px; font-size: 9px; letter-spacing: .12em; }
}
/* short, wide viewports (e.g. phone landscape): give the canvas more height */
@media (max-height: 560px) and (min-width: 601px) {
  .pg-card { --pg-h: 78vh; }
}
