/* app.css
 *
 * The video fills the screen and everything else floats on top of it. Sizes are
 * in vmin so the layout holds on a laptop and on a phone held sideways — this
 * game gets propped up on whatever is to hand.
 */

:root {
  --cream: #fdf3dc;
  --amber: #f0a01e;
  --amber-deep: #d2761a;
  --ink: rgba(0, 0, 0, 0.55);

  /*
   * The title and the record pill are a matched pair at the top of the screen,
   * so they share their inset and their height rather than each carrying its
   * own numbers that drift apart the next time one of them is touched.
   */
  --hud-edge: 3vmin;
  --hud-bar-height: 6vmin;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#show-video-el {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* The video element only feeds the detector; the canvas is what is seen. */
#show-video-video-el {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#show-video-canvas-el {
  max-width: 100%;
  max-height: 100%;
}

#hud-title-el {
  position: fixed;
  top: var(--hud-edge);
  left: var(--hud-edge);
  margin: 0;
  /* Sized to the shared bar height, so it and the pill read as one row. */
  height: var(--hud-bar-height);
  display: flex;
  align-items: center;
  font-size: 5vmin;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--cream);
  text-shadow:
    0 0 1.6vmin var(--amber-deep),
    0 0 0.6vmin var(--amber),
    0 0.3vmin 0 rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

/* The record pill and its reset button travel together, top right. */
.best-wrap {
  position: fixed;
  top: var(--hud-edge);
  right: var(--hud-edge);
  display: flex;
  align-items: center;
  gap: 1.2vmin;
}

.badge {
  /* Height comes from the shared bar rather than from font size plus padding,
     which is what keeps it level with the title at every viewport size. */
  height: var(--hud-bar-height);
  display: inline-flex;
  align-items: center;
  padding: 0 2.4vmin;
  border-radius: calc(var(--hud-bar-height) / 2);
  background: var(--amber);
  color: #fff;
  font-size: 3vmin;
  line-height: 1;
  font-weight: 700;
  box-shadow: 0 0.4vmin 1.6vmin rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

/* Quietly beside the record: present when there is something to erase, and
   dressed down so the amber pill stays the thing the eye lands on. Sized to
   the same bar height, because on a tablet this is a finger target. */
.reset-button {
  display: none;
  height: var(--hud-bar-height);
  align-items: center;
  padding: 0 2vmin;
  border: none;
  border-radius: calc(var(--hud-bar-height) / 2);
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-size: 2.2vmin;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.reset-button.visible {
  display: inline-flex;
}

.reset-button:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* The live number, climbing while the player is still in the air. */
.height-readout {
  position: fixed;
  top: 38%;
  right: 3vmin;
  display: flex;
  align-items: baseline;
  gap: 0.6vmin;
  color: var(--cream);
  font-size: 14vmin;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0.5vmin 2vmin rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 120ms ease-out;
  pointer-events: none;
}

.height-readout.visible {
  opacity: 1;
}

.height-readout .unit {
  font-size: 5vmin;
  font-weight: 700;
}

/*
 * The armed signal. Deliberately the loudest thing on screen after the score:
 * the trigger is "the game is watching and you are standing still", which is
 * invisible unless something says so.
 */
.go {
  position: fixed;
  left: 0;
  right: 0;
  top: 34%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2vmin;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
  pointer-events: none;
}

.go.visible {
  opacity: 1;
  transform: scale(1);
  animation: go-pulse 1.4s ease-in-out infinite;
}

.go-headline {
  font-size: 22vmin;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--cream);
  text-shadow:
    0 0 4vmin var(--amber-deep),
    0 0 1.5vmin var(--amber),
    0 0.5vmin 2vmin rgba(0, 0, 0, 0.5);
}

.go-note {
  padding: 0.8vmin 2vmin;
  border-radius: 1.6vmin;
  background: var(--ink);
  color: var(--cream);
  font-size: 2.6vmin;
  font-weight: 600;
}

.go-note:empty {
  display: none;
}

@keyframes go-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Respect a stated preference for less motion; the prompt still appears. */
@media (prefers-reduced-motion: reduce) {
  .go.visible {
    animation: none;
  }
}

.coach {
  position: fixed;
  left: 50%;
  bottom: 6vmin;
  transform: translateX(-50%);
  padding: 1.6vmin 3.2vmin;
  border-radius: 2vmin;
  background: var(--ink);
  backdrop-filter: blur(6px);
  color: var(--cream);
  max-width: 80vw;
  font-size: 3.4vmin;
  font-weight: 600;
  text-align: center;
  /* Wraps rather than running off the sides. A long message with nowrap set
     stopped being centred the moment it outgrew the screen. */
  white-space: normal;
  opacity: 0;
  transition: opacity 200ms ease-out;
  pointer-events: none;
}

.coach.visible {
  opacity: 1;
}

/* The score, once they are back on the floor. */
.result {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1vmin;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  pointer-events: none;
}

.result.visible {
  opacity: 1;
  transform: scale(1);
}

.result-height {
  display: flex;
  align-items: baseline;
  gap: 1vmin;
  color: var(--cream);
  font-size: 26vmin;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 4vmin var(--amber-deep), 0 0.6vmin 2vmin rgba(0, 0, 0, 0.6);
}

.result-height .unit {
  font-size: 8vmin;
  font-weight: 700;
}

.result-note {
  color: var(--amber);
  font-size: 5vmin;
  font-weight: 700;
  text-shadow: 0 0.3vmin 1vmin rgba(0, 0, 0, 0.6);
}

#camera-message-el {
  position: fixed;
  inset: auto 0 0 0;
  padding: 4vmin;
  background: rgba(20, 20, 20, 0.92);
  color: var(--cream);
  font-size: 3.4vmin;
  line-height: 1.5;
  text-align: center;
}

#debug-info-el {
  position: fixed;
  top: 12vmin;
  left: 2vmin;
  margin: 0;
  padding: 1.5vmin;
  max-height: 70vh;
  overflow: auto;
  border-radius: 1vmin;
  background: rgba(0, 0, 0, 0.7);
  color: #7dffb2;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.7vmin;
  line-height: 1.5;
  white-space: pre;
  pointer-events: none;
}
