/* The background games layer's look (docs/design/arcade-games.md; ADR 0027; arcade.js owns the
   behaviour). Loaded by index.html only, after kingdomchat.css. It names no theme and no layout:
   it reads the theme's --arcade-ball, --arcade-ball-size, --arcade-candy and --arcade-ghost and the
   layout's --arcade-floor-inset (role-named custom properties, ADR 0027 section 2), and colours
   only through the base variables (no colour literal). Phone first: one set of rules, no width
   query. Nothing here moves, fades or animates; the ball, the candies and the ghosts are moved by
   arcade.js's transform only.

   Stacking (docs/design/arcade-games.md, Stacking): the arena is z-index 10 (arcade.js ARCADE_Z),
   so the ball paints over the page's flow and every content box with a z-index of 1 to 5 (cards,
   a theme's art, the Legacy side bar and its Mentor strip, frozen table headers, a result
   window's close button) and under every bar, row, menu and sheet from 20 up (the site menu 20,
   Retro's sticky row 30, the Codes top bar 40, Pocket's pinned pill rows 45, Nuevo's province
   strip 50, the staff bar 60, the confirm modal 70, every fixed bar, drawer, sheet and result
   window from 2500, the top layer's dialogs). The dock (switcher, menu, streak label) is z-index
   11: over the ball, under all of those. */

/* --- The arena: the court is the window above the layout's bottom chrome; taps pass through --- */
#arcade {
  position: fixed; top: 0; left: 0; right: 0; bottom: var(--arcade-floor-inset, 0px);
  z-index: 10; overflow: visible; pointer-events: none;
}

/* --- The ball: the theme's picture (a bare file name in --arcade-ball resolves against this
   sheet, in static/), else a plain ball in the base accents; opaque, round, the thumb's size --- */
#arcade-ball {
  position: absolute; top: 0; left: 0;
  width: var(--arcade-ball-size, 2.75rem); height: var(--arcade-ball-size, 2.75rem);
  border-radius: 50%; pointer-events: none; will-change: transform;
  background-image: var(--arcade-ball, radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent)));
  background-position: center; background-size: contain; background-repeat: no-repeat;
}

/* --- Candy catch's candies: the theme's sprites, --arcade-candy, one to three comma-separated
   url()s (bare file names resolving against this sheet, in static/), drawn as layers of one
   background; data-kind picks the layer shown (arcade.js counts the url()s and gives each candy one
   it has): that layer centred, the others placed far outside the box, so never painted. Unset: a
   plain disc in the base accents. The thumb's size; moved and popped by arcade.js's transform only --- */
.arcade-candy {
  position: absolute; top: 0; left: 0;
  width: 2.75rem; height: 2.75rem; pointer-events: none; will-change: transform;
  background-image: var(--arcade-candy, radial-gradient(circle closest-side, var(--accent-2), var(--accent) 94%, transparent 96%));
  background-size: contain; background-repeat: no-repeat;
  background-position: center, -99rem 0, -99rem 0;
}
.arcade-candy[data-kind="1"] { background-position: -99rem 0, center, -99rem 0; }
.arcade-candy[data-kind="2"] { background-position: -99rem 0, -99rem 0, center; }

/* --- Whack-a-ghost's ghosts: the theme's picture (--arcade-ghost, a bare file name resolving
   against this sheet, or up to six comma-separated url()s drawn as layers of one background, as
   the candies' are: data-kind picks the layer shown, the ghosts taking turns, arcade.js counting
   the url()s), else a plain rounded shape in the base colours; the thumb's size, the tap target.
   arcade.js places, stretches and shows each one frame by frame (transform and its alpha as inline
   style, never a CSS fade); nothing here moves --- */
.arcade-ghost {
  position: absolute; top: 0; left: 0; width: 2.75rem; height: 2.75rem; pointer-events: none; will-change: transform;
  background-image: var(--arcade-ghost, radial-gradient(ellipse 42% 48% at 50% 50%, var(--text) 84%, var(--muted) 87% 96%, transparent 100%));
  background-position: center, -99rem 0, -99rem 0, -99rem 0, -99rem 0, -99rem 0;
  background-size: contain; background-repeat: no-repeat;
}
.arcade-ghost[data-kind="1"] { background-position: -99rem 0, center, -99rem 0, -99rem 0, -99rem 0, -99rem 0; }
.arcade-ghost[data-kind="2"] { background-position: -99rem 0, -99rem 0, center, -99rem 0, -99rem 0, -99rem 0; }
.arcade-ghost[data-kind="3"] { background-position: -99rem 0, -99rem 0, -99rem 0, center, -99rem 0, -99rem 0; }
.arcade-ghost[data-kind="4"] { background-position: -99rem 0, -99rem 0, -99rem 0, -99rem 0, center, -99rem 0; }
.arcade-ghost[data-kind="5"] { background-position: -99rem 0, -99rem 0, -99rem 0, -99rem 0, -99rem 0, center; }
.arcade-ghost[hidden] { display: none; }

/* --- The dock: the switcher bottom-left above the floor, the streak label beside it --- */
#arcade-dock {
  position: fixed; z-index: 11;
  left: max(.5rem, env(safe-area-inset-left, 0px));
  bottom: calc(var(--arcade-floor-inset, 0px) + .5rem);
  display: flex; align-items: center; gap: .4rem;
}
#arcade-dock[hidden], #arcade-menu[hidden], #arcade-streak[hidden], #arcade-foot[hidden] { display: none; }
/* --- The foot: room at the page's end, in its flow, while the dock shows: the dock's height and
   its .5rem off the floor, and .5rem more, on top of the bottom padding each layout keeps for its
   own bar (which clears --arcade-floor-inset), so the last control at scroll end is above the dock --- */
#arcade-foot { display: block; flex: none; height: calc(2.75rem + 1rem); margin: 0; padding: 0; pointer-events: none; }
#arcade-switch {
  display: grid; place-items: center; box-sizing: border-box;
  width: 2.75rem; height: 2.75rem; min-width: 2.75rem; min-height: 2.75rem; margin: 0; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--panel); color: var(--text);
  font-size: 1.35rem; line-height: 1; text-transform: none; box-shadow: none; cursor: pointer;
}
#arcade-switch[aria-expanded="true"] { border-color: var(--accent); }
#arcade-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#arcade-streak {
  padding: .2rem .6rem; border: 1px solid var(--border); border-radius: 1rem;
  background: var(--panel); color: var(--text);
  font-size: .9rem; line-height: 1.3; font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* a new best this streak: the accent colour until the next streak starts (owner's call 6) */
#arcade-streak.arcade-new-best { border-color: var(--accent); color: var(--accent); font-weight: bold; }

/* --- The menu: opens above the switcher, in the page (never native); rows of the thumb's height,
   each on one line ("Whack-a-thing · best 12"): the menu grows to its longest row (max-content; the
   dock it hangs from is narrower), never past the window --- */
#arcade-menu {
  position: absolute; left: 0; bottom: calc(100% + .4rem);
  display: grid; gap: .25rem; box-sizing: border-box;
  width: max-content; min-width: 13rem; max-width: calc(100vw - 1rem); padding: .4rem;
  border: 1px solid var(--border); border-radius: .65rem; background: var(--panel); color: var(--text);
}
#arcade-menu button {
  display: flex; align-items: center; gap: .5rem; box-sizing: border-box;
  width: 100%; min-height: 2.75rem; margin: 0; padding: .35rem .7rem;
  border: 1px solid transparent; border-radius: .45rem;
  background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; text-align: left; text-transform: none; box-shadow: none; cursor: pointer;
  white-space: nowrap;
}
/* the playing game (or Off) is marked by a tick and the accent edge */
#arcade-menu button::before { content: ""; flex: 0 0 1rem; text-align: center; }
#arcade-menu button[aria-checked="true"] { border-color: var(--accent); }
#arcade-menu button[aria-checked="true"]::before { content: "✓"; color: var(--accent); }
#arcade-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#arcade-menu .arcade-menu-note { max-width: 15rem; margin: .2rem .3rem .3rem; color: var(--muted); font-size: .85rem; line-height: 1.35; }
