/* Tap Pop. Sits on arcade.css, which supplies the shell, the readout and the
   dialogs. The gems are real buttons, absolutely placed in a square board, and
   they move by changing two custom properties (--x, --y) that a CSS transition
   animates: the page never draws a frame itself. */

.tappop-page .tp-shell {
  /* The five colours, from the arcade palette so the themes still own them.
     light-dark() works on a plain CSS property; it was only canvas that could
     not read it. */
  --tp-0: light-dark(var(--ar-hue-1), var(--ar-hue-1-dark));  /* blue   */
  --tp-1: light-dark(var(--ar-hue-2), var(--ar-hue-2-dark));  /* green  */
  --tp-2: light-dark(var(--ar-hue-3), var(--ar-hue-3-dark));  /* gold   */
  --tp-3: light-dark(var(--ar-hue-6), var(--ar-hue-6-dark));  /* red    */
  --tp-4: light-dark(var(--ar-hue-4), var(--ar-hue-4-dark));  /* purple */
  --tp-ink: #7B1828;
  padding-bottom: 20px;
}

.tp-play {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
}

.tp-play .hh-main { width: min(100%, 560px); align-items: stretch; }

/* ---- jobs + taps ------------------------------------------------------ */

.tp-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.tp-goals {
  display: flex;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 8px 12px;
  border: 2px solid var(--tp-ink);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tp-ink) 8%, transparent);
}

.tp-goal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font: 800 18px/1 'Trebuchet MS', sans-serif;
}

.tp-mini { position: relative; display: block; width: 38px; height: 38px; font-size: 38px; }
.tp-goal.is-done b::before { content: "\2713\00a0"; color: #2f6b4f; }
.tp-goal.is-done { opacity: 0.65; }

.tp-moves {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  padding: 6px 12px;
  border-radius: 14px;
  background: var(--tp-ink);
  color: #fff;
}
.tp-moves small { font: 700 12px 'Trebuchet MS', sans-serif; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.tp-moves b { font: 800 34px/1 'Trebuchet MS', sans-serif; }
.tp-moves.is-low b { color: #ffd2cc; }

/* ---- the board ---------------------------------------------------------- */

.tp-board {
  /* As big as the stage allows, square: the stage is a size container, so
     its width and height are what cqw and cqh measure. */
  --cell: min(calc(100cqw / 9), calc(100cqh / 9));
  position: relative;
  width: calc(var(--cell) * 9);
  height: calc(var(--cell) * 9);
  border-radius: 14px;
  background: color-mix(in srgb, var(--tp-ink) 14%, var(--ar-well, #efeae9));
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--tp-ink) 55%, transparent);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

.tp-gem {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell);
  height: var(--cell);
  margin: 0;
  padding: calc(var(--cell) * 0.045);
  border: 0;
  background: none;
  font-size: var(--cell);
  cursor: pointer;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%));
  -webkit-tap-highlight-color: transparent;
}

/* The gem itself: a bevelled enamel tile with a mark pressed into it. */
.tp-gem > .tp-face, .tp-mini > .tp-face {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 26%;
  background:
    radial-gradient(120% 90% at 30% 15%, color-mix(in srgb, var(--hue) 55%, white) 0%, transparent 55%),
    linear-gradient(165deg, color-mix(in srgb, var(--hue) 82%, white) 0%, var(--hue) 48%, color-mix(in srgb, var(--hue) 78%, black) 100%);
  box-shadow:
    inset 0 0.07em 0 rgba(255, 255, 255, 0.5),
    inset 0 -0.1em 0 rgba(0, 0, 0, 0.25),
    0 0.05em 0.1em rgba(0, 0, 0, 0.35);
}

.tp-face svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* The mark is pressed in: a dark copy above, a light one below. */
.tp-mark-dark { fill: rgba(0, 0, 0, 0.34); stroke: rgba(0, 0, 0, 0.34); }
.tp-mark-lit  { fill: rgba(255, 255, 255, 0.42); stroke: rgba(255, 255, 255, 0.42); }

.tp-c0 { --hue: var(--tp-0); }
.tp-c1 { --hue: var(--tp-1); }
.tp-c2 { --hue: var(--tp-2); }
.tp-c3 { --hue: var(--tp-3); }
.tp-c4 { --hue: var(--tp-4); }

/* A group of five or more shows the booster it will make, faintly, on every
   gem in it. Drawn over the mark, so the mark is still what says the colour. */
.tp-promise {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.tp-gem[data-promise] .tp-promise { opacity: 0.9; }
.tp-gem[data-promise] .tp-mark { opacity: 0.3; }

/* ---- boosters ------------------------------------------------------------ */

:is(.tp-gem, .tp-mini)[data-k] .tp-face {
  background:
    radial-gradient(90% 70% at 30% 20%, rgba(255, 255, 255, 0.7), transparent 60%),
    linear-gradient(165deg, #fff 0%, var(--hue) 40%, color-mix(in srgb, var(--hue) 60%, black) 100%);
  box-shadow:
    inset 0 0 0 0.05em #fff,
    inset 0 -0.1em 0 rgba(0, 0, 0, 0.3),
    0 0 0.35em color-mix(in srgb, var(--hue) 80%, white);
}
:is(.tp-gem, .tp-mini)[data-k="prism"] .tp-face {
  background:
    radial-gradient(90% 70% at 30% 20%, rgba(255, 255, 255, 0.8), transparent 60%),
    conic-gradient(from 20deg, #e0463a, #e9a21c, #52b04e, #2e9fd0, #7a4e9e, #e0463a);
}
.tp-art { fill: #fff; stroke: rgba(0, 0, 0, 0.6); stroke-width: 4; paint-order: stroke; stroke-linejoin: round; }

/* ---- motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .tp-gem { transition: transform 0.32s cubic-bezier(0.3, 0.85, 0.4, 1.12); }
  .tp-gem.is-snap { transition: none; }

  .tp-gem.is-pop .tp-face {
    animation: tp-pop 0.26s ease-in forwards;
    animation-delay: calc(var(--wave, 0) * 90ms);
  }
  .tp-gem.is-made .tp-face { animation: tp-made 0.4s ease-out; }
  .tp-gem.is-refused .tp-face { animation: tp-no 0.28s; }
  .tp-gem.is-hint .tp-face { animation: tp-hint 0.7s ease-in-out 3; }
}

@keyframes tp-pop {
  30%  { transform: scale(1.2); filter: brightness(1.4); }
  100% { transform: scale(0.1); opacity: 0; }
}
@keyframes tp-made { 0% { transform: scale(0.3); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes tp-no { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
@keyframes tp-hint { 50% { transform: scale(1.18); filter: brightness(1.35); } }

/* With motion off a popped gem just goes. */
@media (prefers-reduced-motion: reduce) {
  .tp-gem.is-pop { display: none; }
}

.tp-gem.is-picked .tp-face { box-shadow: 0 0 0 0.07em #fff, 0 0 0 0.14em var(--tp-ink); }
.tp-gem:focus-visible { outline: 3px solid #1a5fb4; outline-offset: -3px; z-index: 3; }
.tp-board.is-aiming, .tp-board.is-aiming .tp-gem { cursor: crosshair; }

/* ---- the stage, the dock, the rest --------------------------------------- */

.tp-stage {
  container-type: size;
  align-self: stretch;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  border: 0;
  background: transparent;
  overflow: visible;
}

.tp-top { flex: none; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: nowrap; }

.hh-dock .tp-power { position: relative; }
.hh-dock .tp-power b {
  position: absolute; top: -7px; right: -5px;
  min-width: 20px; height: 20px; padding: 0 4px;
  border-radius: 10px; background: var(--tp-ink); color: #fff;
  font: 700 12px/20px sans-serif; text-align: center;
}
.hh-dock { gap: 6px; }
.hh-dock button { flex: 1 1 0; min-width: 0; }

.tp-status { min-height: 1.4em; margin: 0; font-weight: 600; text-align: center; color: var(--tp-ink); }

.tp-stars { letter-spacing: 0.1em; color: #c9971b; }
.tp-stars .off { color: rgba(0, 0, 0, 0.22); }

.tp-help-art { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.tp-help-art figure { display: flex; align-items: center; gap: 10px; margin: 0; flex: 1 1 220px; }
.tp-help-art .tp-mini { flex: none; width: 46px; height: 46px; font-size: 46px; }
.tp-help-art figcaption { font-size: 0.95em; }

/* ---- splash: shards, rings, rocket streaks and call-outs, all made by
   main.js and removed when their animation ends. ---------------------------- */

.tp-fx { position: absolute; pointer-events: none; z-index: 5; display: block; }

.tp-shard {
  border-radius: 28%;
  background: var(--hue);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 4px rgba(0, 0, 0, 0.25);
}
.tp-shard.is-star {
  border-radius: 0;
  box-shadow: none;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  transform-origin: center;
  scale: 1.8;
}

.tp-ring {
  border-radius: 50%;
  border: 4px solid var(--hue);
  box-shadow: 0 0 14px var(--hue), inset 0 0 12px var(--hue);
}

.tp-streak {
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #fff 15%, #fff 85%, transparent);
  box-shadow: 0 0 16px 4px rgba(255, 220, 120, 0.9);
}
.tp-streak[style*="width: 100%"] { transform-origin: left center; }

.tp-callout {
  font: 900 clamp(16px, 3.2vw, 26px)/1 'Trebuchet MS', sans-serif;
  color: #fff;
  white-space: nowrap;
  -webkit-text-stroke: 3px var(--tp-ink);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 var(--tp-ink);
}


/* The screens (map, card, results) sit over the board, gems and splash alike,
   and take the status line with them. */
.tp-stage .ar-screen { z-index: 10; }
.hh-app:has(.ar-screen:not([hidden])) .tp-status { display: none; }

/* ---- the shop -------------------------------------------------------------- */

.tp-shop { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tp-shop li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--surface);
}
.tp-shop small { display: block; opacity: 0.8; }
.tp-shop em { display: block; font-style: normal; font-size: 0.85em; color: var(--tp-ink); }
.tp-shop button {
  flex: none; min-width: 6.5rem; min-height: 44px; padding: 6px 12px;
  border: 2px solid var(--tp-ink); border-radius: 10px; background: var(--tp-ink); color: #fff;
  font: 700 14px 'Trebuchet MS', sans-serif; cursor: pointer;
}
.tp-shop button:disabled { background: transparent; color: inherit; opacity: 0.45; cursor: default; }
.tp-shop__coins { font-size: 1.1em; margin: 0; }
.tp-shop__note { font-size: 0.9em; opacity: 0.8; }
