/* assets/style.css — Baby-Mart Stroller Bash catalog-fit stylesheet.
 * Overlay-fit discipline (SPEC §10/§11): HUD, menus, results, About and touch
 * clusters read inside a short landscape iframe (innerHeight<=440) — panels stay
 * compact, buttons never below 40 px there, every overlay fits ~560 px embedded
 * heights without scroll. touch-action:none everywhere interactive. */
:root {
  --btn: 56px;
  --btn-short: 44px;
  --accent: #ff5a7a;
  --ink: #2e3440;
  --card: rgba(255, 252, 242, 0.94);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #1d232b;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif; color: var(--ink);
  overscroll-behavior: none; touch-action: none; user-select: none; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* off-screen goal cue (T11 G-01): fixed full-viewport, above the 3D canvas but
   BELOW the HUD chrome (z 5) so panels win where they overlap; pointer-events none
   so it never intercepts steering/input. Draws a clamping edge chevron + distance. */
.goal-cue { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

/* T11 G-10 impact flash: a full-viewport white VIGNETTE (transparent center,
   bright edge) that pops for ~1 frame on a shelf slam / player knockdown and
   fades back to 0 over ~0.3 s. ui.js drives the opacity every running frame
   (no CSS animation to fight); pointer-events none so it never blocks input;
   z-index 3 sits above the 3D canvas but BELOW the goal-cue (4) and the HUD (5)
   so HUD text always stays readable. Visual only — it never touches the sim. */
.impact-flash { position: fixed; inset: 0; z-index: 3; pointer-events: none;
  opacity: 0; background: radial-gradient(ellipse at center,
    rgba(255,255,255,0) 36%, rgba(255,255,255,0.95) 92%); }

.hidden { display: none !important; }

/* ---- HUD ---- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.goal-card { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--card); border-radius: 14px; padding: 5px 12px; display: flex; gap: 9px; align-items: center;
  font-weight: 700; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.25); white-space: nowrap; max-width: min(86vw, 460px); }
/* P4 shared-clock ring: a conic countdown around the ONE errand timer (SPEC §11;
   the ring's sweep = errands.clock / clockClass, set live from ui.js). */
.clock-ring { width: 44px; height: 44px; border-radius: 50%; position: relative; flex: none;
  background: conic-gradient(#ffd45a calc(var(--frac, 1) * 360deg), rgba(255,255,255,0.25) 0);
  display: flex; align-items: center; justify-content: center; }
.clock-ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: #fff; }
.clock-ring.warn { background: conic-gradient(#e5484d calc(var(--frac, 1) * 360deg), rgba(255,255,255,0.25) 0); }
/* T11 G-08 last-10s urgency: ONE pulse animation on the countdown ring while
   the shared errand clock is under 10 s (ui.js adds .urgent from the ring's
   urgencySignal). Skip under prefers-reduced-motion — the JS gate and this
   media query both disable it (audio ticks still play: reduced motion is a
   motion preference, not a sound-off). */
@keyframes ring-urgent-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); }
  50% { transform: scale(1.07); box-shadow: 0 0 9px 2px rgba(229, 72, 77, 0.5); }
}
.clock-ring.urgent { animation: ring-urgent-pulse 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .clock-ring.urgent { animation: none; }
}
#clock { position: relative; font-size: 15px; font-variant-numeric: tabular-nums; color: #33475c; }
/* procedural item picture (canvas glyph — same item shapes as the world) */
.goal-pic { width: 46px; height: 46px; border-radius: 10px; background: #f6f1e6; flex: none; border: 2px solid #fff; }
#goal-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
#goal-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.goal-dept { font-size: 10px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase;
  color: #fff; background: #8fa3b8; border-radius: 8px; padding: 1px 7px; align-self: flex-start; margin-top: 2px; }
.items-chip { font-size: 11px; font-weight: 800; color: #33475c; background: #f0ead8;
  border-radius: 20px; padding: 3px 9px; flex: none; }
/* score + combo (SPEC §11 score/combo) */
.score-box { position: absolute; top: calc(88px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  display: flex; align-items: center; gap: 6px; }
.score { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff;
  background: rgba(20, 26, 36, 0.55); border-radius: 20px; padding: 3px 12px; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.combo-pill { font-size: 14px; font-weight: 800; color: #fff; background: var(--accent);
  border-radius: 20px; padding: 4px 10px; box-shadow: 0 2px 8px rgba(255,90,122,0.5); }
.energy-box { position: absolute; top: calc(64px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  width: 150px; height: 16px; border-radius: 8px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.4); overflow: hidden; }
.energy-box::after { content: "⚡"; position: absolute; left: -22px; top: -6px; font-size: 20px; }
#energy-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffd45a, #ff8c5a); transition: width 0.1s linear; }
/* GFX-02 full-meter brush ack: a 0.6 s brightness/glow pulse on the (full)
   energy meter fired by ui.pulseEnergy() when a candy is brushed at full
   energy — the meter itself says "no room". CSS owns the timing; duration
   driven from ui.js via --cs-energy-pulse-dur. Killed by the global
   prefers-reduced-motion rule below + the ui.js reduce-motion gate. */
#energy-fill.cs-energy-pulse { animation: cs-energy-pulse var(--cs-energy-pulse-dur, 0.6s) ease-out; }
@keyframes cs-energy-pulse {
  0% { filter: brightness(1); box-shadow: none; }
  30% { filter: brightness(1.5); box-shadow: 0 0 14px 3px rgba(255, 214, 90, 0.85); }
  100% { filter: brightness(1); box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  #energy-fill.cs-energy-pulse { animation: none; }
}
/* mini-radar corner (SPEC §11: goal direction blips + errand items + spawn) */
.radar { position: absolute; left: calc(12px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  width: 148px; height: 148px; border-radius: 14px; background: rgba(20, 26, 36, 0.45);
  box-shadow: 0 2px 12px rgba(0,0,0,0.35); }
.hint { position: absolute; bottom: calc(10px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.85); background: rgba(0,0,0,0.35); padding: 4px 10px; border-radius: 20px; font-size: 12px; }
/* one-shot mechanic discovery toasts (T11 G-09): a 2.5s caption card bottom-center,
   above the hint line, driven (shown/hidden, text set) by ui.js's toast queue.
   Informational only — pointer-events none so it never blocks steering. The
   pop-in is ONE animation; the global prefers-reduced-motion rule kills it. */
.toast { position: absolute; left: 50%; bottom: calc(52px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 6; pointer-events: none; white-space: nowrap; letter-spacing: 0.2px;
  color: #fff; font-size: 14px; font-weight: 800;
  background: rgba(20, 26, 36, 0.88); border: 1px solid rgba(255, 214, 90, 0.5);
  border-radius: 12px; padding: 7px 14px; box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35); }
.toast.show { animation: toast-pop 0.22s ease-out; }
@keyframes toast-pop {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---- overlays + panels ---- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 24, 32, 0.45); z-index: 20; padding: 14px; }
.overlay.map-wrap { pointer-events: auto; }
/* About floats above every other overlay (it can be requested from menu, pause
   AND results — the results overlay is a later DOM sibling, so About needs its
   own tier to never hide behind it). */
.about-overlay { z-index: 25; }
.panel { background: var(--card); border-radius: 18px; padding: 20px 24px; max-width: 92vw; width: 440px;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.4); max-height: calc(100dvh - 28px); overflow: auto; }
.panel h1 { margin: 0 0 2px; font-size: 26px; color: var(--accent); letter-spacing: -0.5px; }
.panel h1 .accent-word { color: var(--ink); }
.panel h2 { margin: 0 0 8px; font-size: 22px; }
.panel p { margin: 8px 0; line-height: 1.4; font-size: 13px; }
.panel .tag { color: #7a8291; font-style: italic; }
.panel .tiny { font-size: 12px; color: #6a7180; }
.panel.about { max-width: 640px; text-align: left; }
.panel.about h2 { text-align: center; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; padding: 12px 18px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; margin: 4px 6px;
  touch-action: manipulation; }
button.big { min-width: 200px; }
button.ghost { background: #e7e3d8; color: var(--ink); }
button.danger { color: #b32c34; }
button.small { font-size: 14px; padding: 10px 14px; min-height: 40px; }
button.tb:active, button.big:active { transform: scale(0.96); }
.btn-col { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 10px; }
.row { display: flex; align-items: center; justify-content: center; gap: 2px; flex-wrap: wrap; }
.mute-ico { font-size: 15px; }

/* ---- results (SPEC §11) ---- */
.results-panel { width: 440px; }
.stars { font-size: 40px; letter-spacing: 8px; line-height: 1; margin-top: 2px; }
.star { color: rgba(0,0,0,0.16); }
.star.lit { color: #ffb020; text-shadow: 0 2px 6px rgba(255,176,32,0.5); }
.best-badge { color: var(--accent); font-weight: 800; font-size: 15px; margin: 6px 0 0 !important; }
.results-stats { display: flex; justify-content: center; gap: 10px; margin: 6px 0 2px; }
.stat { background: #f0ead8; border-radius: 12px; padding: 8px 14px; min-width: 86px; display: flex; flex-direction: column; }
.stat .num { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: #33475c; }
.stat .lab { font-size: 11px; color: #7a8291; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- About controls infographic (pure HTML/CSS, no bitmaps) ---- */
.infographic { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 6px 0 4px; }
.ig-col h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: #7a8291; }
.keygrid { display: flex; flex-direction: column; gap: 6px; }
.keyrow { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 12px; color: #4a5361; }
.key { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 6px; background: #fff; border: 1px solid #c9c2b0; box-shadow: 0 2px 0 #c9c2b0;
  font-size: 12px; font-weight: 800; color: #2e3440; }
.key.wide { min-width: 64px; }
.keylab { margin-left: 2px; }
.touch-diagram { display: grid; grid-template-columns: 1.1fr 1fr; gap: 8px; }
.t-half { border-radius: 10px; padding: 10px 8px; text-align: center; font-size: 12px; font-weight: 700; }
.t-left { background: #e3edf4; color: #33506b; }
.t-right { background: #fde5ec; color: #a03352; }
.t-glyph { display: block; font-size: 22px; margin-bottom: 2px; }
.t-sub { display: block; font-weight: 500; font-size: 11px; opacity: 0.8; margin-top: 2px; }

/* ---- full-screen map ---- */
.map-box { position: relative; }
.map-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 50%;
  padding: 0; font-size: 18px; font-weight: 800; background: #33475c; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
#map { background: #f4f1e8; border-radius: 10px; box-shadow: 0 6px 30px rgba(0,0,0,0.35); display: block; }
.map-cap { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0,0,0,0.5); padding: 3px 10px; border-radius: 12px; font-size: 11px; white-space: nowrap; }

/* ---- touch controls (SPEC §7) ---- */
.touch-zone { position: fixed; left: 0; top: 0; bottom: 0; width: 50%; z-index: 10; touch-action: none; }
.touch-zone.joy-active { background: radial-gradient(circle at var(--jx, 50%) var(--jy, 50%), rgba(255,255,255,0.08), transparent 70%); }
.touch-cluster { position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; z-index: 11; }
.tb { width: var(--btn); height: var(--btn); border-radius: 50%; font-size: 13px; font-weight: 800;
  background: rgba(255, 255, 255, 0.85); color: var(--ink); box-shadow: 0 3px 12px rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center; touch-action: none; margin: 0; }
.tb.held { background: var(--accent); color: #fff; transform: scale(0.93); }
.touch-utility { position: fixed; right: calc(12px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top));
  display: flex; gap: 8px; z-index: 11; }
.touch-utility .tb { width: 44px; height: 44px; font-size: 18px; }

/* screenshot mode: hide chrome so evidence shots show the pure world */
body.shot .hud, body.shot .touch-zone, body.shot .touch-cluster, body.shot .touch-utility { display: none !important; }

/* ---- short-iframe fit (SPEC §10: innerHeight<=440 → compact panels/menus) ---- */
@media (max-height: 440px) and (min-aspect-ratio: 5/4) {
  :root { --btn: var(--btn-short); }
  .panel { width: 340px; padding: 10px 16px; }
  .panel h1 { font-size: 19px; }
  .panel h2 { font-size: 17px; margin-bottom: 4px; }
  .panel p { margin: 5px 0; }
  .panel.about { width: 560px; max-width: 94vw; }
  button { padding: 9px 12px; font-size: 14px; min-height: 40px; }
  button.big { min-width: 150px; }
  button.small { font-size: 13px; padding: 8px 10px; min-height: 40px; }
  .btn-col { margin-top: 4px; gap: 2px; }
  .goal-card { font-size: 12px; padding: 4px 8px; }
  .goal-pic { width: 40px; height: 40px; }
  .clock-ring { width: 38px; height: 38px; }
  #clock { font-size: 13px; }
  .goal-dept { font-size: 9px; }
  .items-chip { font-size: 10px; padding: 2px 7px; }
  .score { font-size: 16px; padding: 2px 9px; }
  .energy-box { width: 120px; height: 14px; }
  .radar { width: 104px; height: 104px; border-radius: 10px; }
  .star { font-size: 30px; }
  .stat .num { font-size: 18px; }
  .infographic { gap: 8px; }
  .t-half { padding: 6px 4px; }
  .key { min-width: 22px; height: 22px; font-size: 11px; }
  .hint { display: none; }
  .toast { bottom: calc(14px + env(safe-area-inset-bottom)); font-size: 12px; padding: 5px 11px; }
  .tb { font-size: 11px; }
  .touch-cluster { bottom: calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
}

/* ---- portrait still playable (SPEC §7: landscape-first gameplay, portrait menu fine) ---- */
@media (max-aspect-ratio: 4/5) {
  .touch-zone { width: 55%; }
  /* F1 (T9 QA): the centered goal-card ran 74vw wide and its items chip slid under
     the pause/mute utility buttons at 390x844 (chip x263-327 vs buttons x282+).
     Portrait now LEFT-ANCHORS the card, caps its width short of the button zone,
     and stacks it TWO ROWS: ring + item pic + items chip on line 1, then the goal
     name + dept tag on their own full-width line 2 — so the goal name always fits
     AND the counter never reaches the utility buttons. Energy/score move down so
     the taller card clears the right column. */
  .goal-card { left: calc(10px + env(safe-area-inset-left)); transform: none;
    max-width: min(calc(100vw - 120px), 320px); flex-wrap: wrap; gap: 4px 8px;
    padding: 5px 10px; font-size: 13px; }
  .goal-card .clock-ring { width: 36px; height: 36px; }
  .goal-card .goal-pic { width: 38px; height: 38px; }
  .goal-card .items-chip { font-size: 9px; padding: 2px 6px; order: 2; }
  .goal-card #goal-text { order: 3; flex: 1 1 100%; }
  .radar { width: 104px; height: 104px; }
  .energy-box { width: 120px; top: calc(96px + env(safe-area-inset-top)); }
  .score-box { top: calc(120px + env(safe-area-inset-top)); }
}

/* ---- Reduce Motion (SPEC §1: no flashes/animations; arcade blink stays in the sim) ---- */
@media (prefers-reduced-motion: reduce) {
  .star { transition: none; animation: none; }
  .combo-pill { transition: none; }
  * { animation: none !important; transition-duration: 0.01ms !important; }
}
