/* app.css
 *
 * The look is borrowed wholesale from the sibling animals game, so the two
 * feel like shelves of the same toybox: a white page, everything outlined in
 * deep plum, hard teal offset-shadows instead of blurred ones (the flat
 * sticker drop), sunshine-yellow fills, hot pink for emphasis, pill shapes
 * and heavy type. The camera view sits in the middle as a rounded,
 * plum-outlined card — the same framing animals gives its habitat board.
 *
 * 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 {
  /* The animals palette, verbatim. */
  --plum: rgb(92, 38, 72);
  --plum-ink: rgba(58, 24, 45, 0.55);
  --teal: #42bdb8;
  --sun: #fbd868;
  --pink: #ff009e;

  /*
   * 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: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Inset from the edges so the camera reads as a card on the white page,
   with headroom left clear for the title and the record pill. */
#show-video-el {
  position: fixed;
  inset: calc(var(--hud-edge) + var(--hud-bar-height) + 2vmin) 3vmin 3vmin;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* The camera picture is the video itself, under the canvas (which carries
   only the overlay), in a frame video.js lays on exactly the canvas's box,
   plum and clipping, its edges snapped to the pixel grid as the canvas's are.
   The video is stretched as the canvas is and mirrored (left on screen is left
   in the room); being transformed, it isn't snapped, so it overhangs the frame
   by a pixel rather than leave a hairline of page. Hidden until it has a
   frame: see .live. */
#show-video-frame-el {
  position: absolute;
  overflow: hidden;
  border-radius: 25px;
  background: var(--plum);
  pointer-events: none;
}

#show-video-video-el {
  position: absolute;
  left: -1px;
  top: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  opacity: 0;
  pointer-events: none;
  object-fit: fill;
  transform: scaleX(-1);
}

/* The habitat-board treatment: rounded, plum-outlined, sitting proud of the
   page on a hard teal drop. Positioned, so it paints above the video. */
#show-video-canvas-el {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  border-radius: 25px;
  outline: 4px solid var(--plum);
  box-shadow: 0 8px 0 var(--teal), 0 14px 22px rgba(92, 38, 72, 0.25);
  background: var(--plum);
}

/* The camera has a frame: show it through the canvas. */
#show-video-el.live #show-video-video-el {
  opacity: 1;
}

#show-video-el.live #show-video-canvas-el {
  background: transparent;
}

#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: 900;
  letter-spacing: -0.02em;
  color: var(--plum);
  text-shadow: 0 0.3vmin 0 #fff, 0 0.6vmin 0 var(--teal);
  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.6vmin;
}

.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: 3px solid var(--plum);
  border-radius: 999px;
  background: var(--sun);
  color: var(--plum);
  font-size: 3vmin;
  line-height: 1;
  font-weight: 900;
  box-shadow: 0 0.7vmin 0 var(--teal), 0 1.2vmin 1.8vmin rgba(92, 38, 72, 0.2);
  pointer-events: none;
}

/* Quietly beside the record: present when there is something to erase, and
   dressed down so the yellow 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: 2px solid var(--plum);
  border-radius: 999px;
  background: #fff;
  color: var(--plum);
  font: inherit;
  font-size: 2.2vmin;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0.5vmin 0 var(--teal);
  cursor: pointer;
  transition: transform 120ms ease-out, box-shadow 120ms ease-out;
}

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

.reset-button:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow: 0 0.8vmin 0 var(--teal), 0 1.2vmin 1.8vmin rgba(92, 38, 72, 0.18);
}

/* The live number, climbing while the player is still in the air. Drawn over
   the video, so it keeps a plum underlay for contrast on any room. */
.height-readout {
  position: fixed;
  top: 38%;
  right: 6vmin;
  display: flex;
  align-items: baseline;
  gap: 0.6vmin;
  color: #fff;
  font-size: 14vmin;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0.5vmin 0 var(--plum), 0 1vmin 2.4vmin rgba(58, 24, 45, 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: 800;
  color: var(--sun);
}

/*
 * 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;
}

/* Three pulses, then still: it ends on scale(1), where it rests, and starts
   again whenever the prompt comes back. A pulse that never ended kept the page
   painting for as long as the game sat armed. */
.go.visible {
  opacity: 1;
  transform: scale(1);
  animation: go-pulse 1.4s ease-in-out 3;
}

.go-headline {
  font-size: 22vmin;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--sun);
  text-shadow: 0 0.7vmin 0 var(--plum), 0 1.4vmin 3vmin rgba(58, 24, 45, 0.55);
}

.go-note {
  padding: 0.8vmin 2.4vmin;
  border: 2px solid var(--plum);
  border-radius: 999px;
  background: #fff;
  color: var(--plum);
  font-size: 2.6vmin;
  font-weight: 700;
  box-shadow: 0 0.5vmin 0 var(--teal);
}

.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: 3px solid var(--plum);
  border-radius: 999px;
  background: #fff;
  color: var(--plum);
  max-width: 80vw;
  font-size: 3.4vmin;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 0.6vmin 0 var(--teal), 0 1vmin 1.6vmin rgba(92, 38, 72, 0.18);
  /* 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: #fff;
  font-size: 26vmin;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0.8vmin 0 var(--plum), 0 1.6vmin 3vmin rgba(58, 24, 45, 0.6);
}

.result-height .unit {
  font-size: 8vmin;
  font-weight: 800;
  color: var(--sun);
}

/* Hot pink is the animals voice for "this bit matters". White underlay keeps
   it legible over the video. */
.result-note {
  color: var(--pink);
  font-size: 5vmin;
  font-weight: 900;
  text-shadow: 0 0.3vmin 0 #fff, 0 0.6vmin 1.4vmin rgba(255, 255, 255, 0.9);
}

#camera-message-el {
  position: fixed;
  inset: auto 0 0 0;
  padding: 4vmin;
  background: #fff;
  border-top: 4px solid var(--plum);
  color: var(--plum);
  font-size: 3.4vmin;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

#camera-message-el button {
  margin-left: 2vmin;
  padding: 1vmin 4vmin;
  border: 0;
  border-radius: 999px;
  background: var(--plum);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

/* Which build this is, small and out of the way — hover for the full story. */
.version-display {
  position: fixed;
  bottom: 0.8vmin;
  left: 1.2vmin;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--plum);
  opacity: 0.55;
  z-index: 1000;
}

#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;
}
