/* hud.css — the one HUD vocabulary.
 *
 * Distilled from the ~20 bespoke copies (playdough-letter-factory `.hud`,
 * sound-painting `.round-button`, coach-timer `.qk-coach-img-btn`, …) that all
 * describe the same control: a round glossy button whose PNG *is* the button.
 * There is no pill background, no border, no fill — drop them if you had them.
 *
 * Pairs with shared/js/hud.js, which builds these elements and wires the press
 * path through tap.js. Background-image urls resolve relative to THIS FILE
 * (shared/css/ -> ../assets/ui/), never to the page that links it.
 *
 * Navigation rule this vocabulary encodes (docs/interaction-patterns.md §8):
 * `home` lives ONLY on a game's splash and goes to the catalog (`../../`);
 * every deeper screen uses `back`, which returns to the splash in-page.
 *
 * Requires shared/css/base.css for the --qk-safe-* props; the var() fallbacks
 * below mean it still degrades correctly if it is linked on its own.
 */

.qk-hud-btn {
  --qk-hud-size: 96px;
  --qk-hud-gap: 16px;

  position: relative;
  display: block;
  width: var(--qk-hud-size);
  height: var(--qk-hud-size);
  min-width: var(--qk-hud-size);
  min-height: var(--qk-hud-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  background-image: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  filter: drop-shadow(0 5px 5px rgba(23, 81, 126, .22));
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
  transition: transform .12s ease, filter .12s ease;
}

/* The artwork may step down on small screens (below), but the *press target*
   never drops under the platform's 96px floor. This pseudo-element is the
   thing a finger actually hits. */
.qk-hud-btn::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(96px, 100%);
  height: max(96px, 100%);
  transform: translate(-50%, -50%);
  content: '';
}

.qk-hud-btn:active {
  transform: translateY(4px) scale(.96);
  filter: drop-shadow(0 2px 2px rgba(23, 81, 126, .16));
}

.qk-hud-btn:focus-visible {
  outline: 6px solid #fff;
  outline-offset: 5px;
  box-shadow: 0 0 0 11px #176fa5;
}

.qk-hud-btn[disabled],
.qk-hud-btn.is-disabled {
  opacity: .45;
  pointer-events: none;
}

/* --------------------------------------------------------------- variants */

.qk-hud-home { background-image: url('../assets/ui/btn-home.png'); }
.qk-hud-back { background-image: url('../assets/ui/btn-back.png'); }
.qk-hud-sound { background-image: url('../assets/ui/btn-sound.png'); }

/* ------------------------------------------------------------- placement */

/* Corner helpers. Absolute, so they pin to the game root (`#game`, or any
   positioned ancestor) rather than the document — a screen that transforms or
   scrolls takes its HUD with it. Offsets are max(gap, safe-inset) so the
   buttons clear an iPad's rounded corners and camera housing without wasting
   space on a device that has neither. */

.qk-hud-top-left,
.qk-hud-top-right,
.qk-hud-bottom-left,
.qk-hud-bottom-right {
  position: absolute;
  z-index: 70;
}

.qk-hud-top-left,
.qk-hud-top-right {
  top: max(var(--qk-hud-gap), var(--qk-safe-top, env(safe-area-inset-top, 0px)));
}

.qk-hud-bottom-left,
.qk-hud-bottom-right {
  bottom: max(var(--qk-hud-gap), var(--qk-safe-bottom, env(safe-area-inset-bottom, 0px)));
}

.qk-hud-top-left,
.qk-hud-bottom-left {
  left: max(var(--qk-hud-gap), var(--qk-safe-left, env(safe-area-inset-left, 0px)));
}

.qk-hud-top-right,
.qk-hud-bottom-right {
  right: max(var(--qk-hud-gap), var(--qk-safe-right, env(safe-area-inset-right, 0px)));
}

/* A top strip that holds a left control, centred furniture (progress dots, a
   prompt pill) and a right control. `pointer-events: none` on the bar so its
   dead middle can't swallow a tap meant for the playfield underneath. */
.qk-hud-bar {
  position: absolute;
  z-index: 70;
  inset:
    max(14px, var(--qk-safe-top, env(safe-area-inset-top, 0px)))
    max(14px, var(--qk-safe-right, env(safe-area-inset-right, 0px)))
    auto
    max(14px, var(--qk-safe-left, env(safe-area-inset-left, 0px)));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 96px;
  pointer-events: none;
}

.qk-hud-bar > * {
  pointer-events: auto;
}

/* --------------------------------------------------------- progress dots */

.qk-dots {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
}

.qk-dot {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 3px 0 rgba(23, 81, 126, .13);
  transition: transform .18s ease, background-color .18s ease;
}

.qk-dot.is-done { background: #58a945; }
.qk-dot.is-now { background: #ffd166; transform: scale(1.14); }

/* ------------------------------------------------------- small screens */

/* The artwork steps down so a phone-sized viewport keeps its playfield; the
   96px press target established above does not move. Matches the range games
   already use by hand (68–88px). */

@media (max-width: 700px) {
  .qk-hud-btn { --qk-hud-size: 84px; --qk-hud-gap: 14px; }
  .qk-hud-bar { min-height: 84px; }
  .qk-dot { width: 18px; height: 18px; border-width: 3px; }
}

@media (max-width: 480px) {
  .qk-hud-btn { --qk-hud-size: 76px; --qk-hud-gap: 12px; }
  .qk-hud-bar { min-height: 76px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .qk-hud-btn { --qk-hud-size: 76px; }
  .qk-hud-bar { min-height: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .qk-hud-btn,
  .qk-dot { transition: none; }
}
