/* ==========================================================================
   Rocket mascot (js/mascot.js, art from js/art.js mascotSvg()).
   Only the rocket's painted shapes take pointer input; the empty space
   around it never blocks the page. touch-action: none is on the rocket only,
   so normal touch scrolling keeps working everywhere else.
   Sits under the header so it never covers the nav or the mobile menu.
   ========================================================================== */

.mascot {
  --mascot-line: var(--neon-purple);
  --mascot-pupil: #12061f;
  --mascot-w: 60px;
  --charge: 0; /* 0..1, drag speed; set by js/mascot.js */
}

@media (min-width: 860px) {
  .mascot {
    --mascot-w: 80px;
  }
}

.mascot__rocket,
.mascot__show {
  position: fixed;
  z-index: calc(var(--z-header) - 10);
}

.mascot__rocket {
  top: 0;
  left: 0;
  width: var(--mascot-w);
  aspect-ratio: 92 / 132;
  pointer-events: none;
  will-change: transform;
}

.mascot [hidden] {
  display: none;
}

/* ---- Art ---- */
.mascot__art {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mascot__float {
  pointer-events: visiblePainted;
  cursor: grab;
}

.mascot.is-dragging .mascot__float {
  cursor: grabbing;
}

.mascot__line {
  fill: none;
  stroke: var(--mascot-line);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mascot__fill {
  fill: var(--sky-mid);
}

/* Nose band and belt: the brand petrol */
.mascot__accent {
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linecap: round;
}

.mascot__eye {
  fill: #fff;
  stroke: var(--mascot-line);
  stroke-width: 1.6;
}

.mascot__pupil {
  fill: var(--mascot-pupil);
}

.mascot__glint {
  stroke: #fff;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.mascot__nose {
  fill: var(--fire);
}

.mascot__smile {
  fill: none;
  stroke: var(--mascot-line);
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* Pupils follow the pointer (js sets the transform) */
.mascot__pupils {
  transition: transform var(--dur-fast) var(--ease-out);
}

/* Blink: the eyes squash shut for a moment */
.mascot__eyes {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  transition: transform 80ms ease-in-out;
}

.mascot.is-blinking .mascot__eyes {
  transform: scaleY(0.1);
}

/* Flame only while moving. While dragging it grows with the drag speed
   (--charge), so a fast flick feels "charged". Scales from the nozzle (0, 38). */
.mascot__flame {
  visibility: hidden;
  opacity: 0;
  transform-box: view-box;
  transform-origin: 46px 98px;
  transform: scale(calc(1 + var(--charge) * 0.3), calc(1 + var(--charge) * 1.1));
  transition:
    opacity var(--dur) var(--ease-out),
    visibility 0s linear var(--dur),
    transform var(--dur-fast) var(--ease-out);
}

.mascot__glow {
  opacity: calc(var(--charge) * 0.85);
  pointer-events: none;
}

.mascot__glow-stop {
  stop-color: var(--fire);
}

.mascot.is-flying .mascot__flame,
.mascot.is-dragging .mascot__flame,
.mascot.is-aiming .mascot__flame {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

/* Arms: resting down, up while dragged or flying, waving after a tap */
.mascot__arm {
  transform-box: fill-box;
  transition: transform var(--dur) var(--ease-bounce);
}

.mascot__arm--left {
  transform-origin: 100% 0%;
}

.mascot__arm--right {
  transform-origin: 0% 0%;
}

.mascot.is-dragging .mascot__arm--left,
.mascot.is-aiming .mascot__arm--left,
.mascot.is-flying .mascot__arm--left {
  transform: rotate(100deg);
}

.mascot.is-dragging .mascot__arm--right,
.mascot.is-aiming .mascot__arm--right,
.mascot.is-flying .mascot__arm--right {
  transform: rotate(-100deg);
}

.mascot.is-waving .mascot__arm--right {
  animation: mascot-wave 0.3s ease-in-out 4 alternate;
}

@keyframes mascot-wave {
  from {
    transform: rotate(-80deg);
  }
  to {
    transform: rotate(-125deg);
  }
}

/* Gentle hover in place while resting */
.mascot.is-resting .mascot__float {
  animation: mascot-bob 3.2s ease-in-out infinite;
}

@keyframes mascot-bob {
  50% {
    transform: translateY(-3px);
  }
}

/* ---- Slingshot: elastic band from the anchor, dotted aim arrow ----
   js/mascot.js sets the line coordinates (SVG attributes, in viewport px). */
.mascot__sling {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) - 11);
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  visibility: hidden;
}

.mascot.is-aiming .mascot__sling {
  visibility: visible;
}

.mascot__band {
  stroke: var(--neon-purple);
  stroke-linecap: round;
}

.mascot__anchor {
  fill: var(--sky-mid);
  stroke: var(--neon-purple);
  stroke-width: 2;
}

.mascot__aim,
.mascot__aim-head {
  fill: none;
  stroke: var(--art-bright);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: var(--art-glow);
}

/* Round dots along the aim line */
.mascot__aim {
  stroke-dasharray: 0 9;
}

/* Too short to launch: the arrow fades, so letting go here snaps back */
.mascot:not(.is-armed) :is(.mascot__aim, .mascot__aim-head) {
  opacity: 0.3;
}

/* ---- Flame trail after a launch: embers that shrink and fade ---- */
.mascot__trail {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) - 11);
  overflow: hidden;
  pointer-events: none;
  contain: strict;
}

.mascot__ember {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--fire-hot) 0 22%, var(--fire) 50%, transparent 72%);
  animation: mascot-ember 450ms var(--ease-out) forwards;
}

@keyframes mascot-ember {
  from {
    opacity: 0.9;
    scale: 1;
  }
  to {
    opacity: 0;
    scale: 0.25;
  }
}

/* ---- First visit hint: a small HUD callout above the rocket ---- */
.mascot__hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  max-width: 12rem;
  margin: 0;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  border: var(--hairline) solid var(--mascot-line);
  border-radius: var(--radius);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 700;
  font-stretch: var(--stretch-expanded);
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
  pointer-events: none;
  transition:
    opacity var(--dur) var(--ease-out),
    visibility 0s;
  animation: mascot-hint-in var(--dur-slow) var(--ease-bounce) 1.2s backwards;
}

/* Callout line down to the rocket's nose */
.mascot__hint::after {
  content: "";
  position: absolute;
  top: 100%;
  right: calc(var(--mascot-w) / 2);
  width: var(--hairline);
  height: 14px;
  background: var(--mascot-line);
}

/* Rocket on the left half: the bubble opens to the right */
.mascot.is-hint-left .mascot__hint {
  right: auto;
  left: 0;
}

.mascot.is-hint-left .mascot__hint::after {
  right: auto;
  left: calc(var(--mascot-w) / 2);
}

/* Only while resting: out of the way while dragged, flying or hopping */
.mascot:not(.is-resting) .mascot__hint {
  opacity: 0;
  visibility: hidden;
  transition-delay: 0s, var(--dur);
}

@keyframes mascot-hint-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

.mascot__hint-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: var(--hairline) solid var(--glass-border);
  border-radius: 50%;
  background: none;
  color: var(--ink-muted);
  cursor: pointer;
  pointer-events: auto;
}

.mascot__hint-close:hover {
  border-color: var(--neon-pink);
  color: var(--ink);
}

/* ---- Hide and sound buttons (on the rocket), show button (corner) ---- */
.mascot__hide,
.mascot__sound,
.mascot__show {
  display: grid;
  place-items: center;
  padding: 0;
  border: var(--hairline) solid var(--mascot-line);
  border-radius: 50%;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
}

/* Stacked on the rocket's right side: hide on top, sound below */
.mascot__hide,
.mascot__sound {
  position: absolute;
  right: -6px;
  width: 32px;
  height: 32px;
  transition:
    opacity var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}

.mascot__hide {
  top: 0;
}

.mascot__sound {
  top: 36px;
}

/* Phones: 44px buttons stacked BESIDE the rocket, on the side facing the
   screen center, so grabbing the rocket never hits them. is-hint-left
   (set by js/mascot.js when it settles) means the rocket is on the left half. */
@media (max-width: 859.98px) {
  .mascot__hide,
  .mascot__sound {
    right: calc(100% + 4px);
    width: 44px;
    height: 44px;
  }

  .mascot__sound {
    top: 48px;
  }

  .mascot.is-hint-left :is(.mascot__hide, .mascot__sound) {
    right: auto;
    left: calc(100% + 4px);
  }
}

.mascot__hide:hover,
.mascot__sound:hover,
.mascot__show:hover {
  border-color: var(--neon-pink);
  box-shadow: var(--glow-pink);
}

/* Muted: the icon (a crossed speaker, set by JS) is a little quieter too */
.mascot.is-muted .mascot__sound {
  color: var(--ink-muted);
}

/* With a mouse they appear on hover (they stay a moment so they can be reached)
   or when one of them has keyboard focus; on touch screens they are always visible. */
@media (hover: hover) {
  .mascot__hide,
  .mascot__sound {
    opacity: 0;
    transition-delay: 700ms, 0s;
  }

  .mascot__rocket:hover :is(.mascot__hide, .mascot__sound),
  .mascot__hide:focus-visible,
  .mascot__sound:focus-visible {
    opacity: 1;
    transition-delay: 0s;
  }

  /* Separate rule: a browser without :has() drops only this one */
  .mascot__rocket:has(:focus-visible) :is(.mascot__hide, .mascot__sound) {
    opacity: 1;
    transition-delay: 0s;
  }
}

.mascot.is-dragging :is(.mascot__hide, .mascot__sound) {
  opacity: 0;
  pointer-events: none;
}

.mascot__show {
  right: var(--space-4);
  bottom: var(--space-4);
  width: 44px;
  height: 44px;
}

.mascot__icon {
  overflow: visible;
}

.mascot__icon .art-flame {
  animation: none;
}

@media print {
  .mascot {
    display: none;
  }
}

/* ---- Reduced motion: no blinking, waving, bobbing or flame flicker.
   The drag charge only brightens the glow (no growing flame, no trail). ---- */
@media (prefers-reduced-motion: reduce) {
  .mascot.is-resting .mascot__float,
  .mascot.is-waving .mascot__arm--right,
  .mascot .art-flame,
  .mascot__hint {
    animation: none;
  }

  .mascot__flame {
    transform: none;
  }

  .mascot__trail {
    display: none;
  }

  .mascot.is-blinking .mascot__eyes {
    transform: none;
  }
}
