/* Gameplay scene: positioned over the gameplay area. Variables are set by scene.layout() / ui layout. */

.scene {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--area-left);
  width: var(--area-width);
  z-index: 1;
  pointer-events: none;
}

.scene__layer {
  position: absolute;
  inset: 0;
  width: 100%;   /* the sparks canvas has no intrinsic CSS size */
  height: 100%;
}

.scene__catcher,
.scene__object,
.scene__shadow,
.scene__glow,
.scene__popup {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}

.scene__catcher {
  width: var(--catcher-width);
  height: var(--catcher-height);
  transform-origin: 50% 100%;
}

.scene__catcher-sprite {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
}

.scene__object {
  width: var(--object-size);
  height: var(--object-size);
}

/* The sprite may be bigger than the hit box, so it is centred on it. Its rotation is set by scene.js. */
.scene__object-sprite {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--sprite-width) * var(--object-scale) * 1px);
  transform: translate(-50%, -50%);
}

/* A caught object stays put, shrinks to 75 % and fades out, so it looks sucked into the catcher. */
.scene__object.is-sucked-in .scene__object-sprite {
  animation: suck-in var(--suck-in-ms) ease-in forwards;
}

/* Glow on the catcher's opening (same artwork as the victory shine). It is a child of .scene__catcher, so it
   sits on the catcher and follows it. */
.scene__glow {
  left: 50%;
  top: calc(var(--catcher-height) * var(--glow-y));
  width: calc(var(--glow-px) * var(--k) * 1px);
  height: calc(var(--glow-px) * var(--k) * 1px);
  transform: translate(-50%, -50%);
  filter: blur(8px) brightness(1.2);
  animation: glow var(--glow-ms) ease-out forwards;
}

/* Catcher shadows keep the size of their SVG artwork; the extra black copy (drop-shadow without blur) makes the
   soft shadow strong enough to read on the busy backgrounds. */
.scene__shadow--small,
.scene__shadow--large { filter: drop-shadow(0 0 0 #000); }
.scene__shadow--small { width: calc(128px * var(--k)); height: calc(40px * var(--k)); }
.scene__shadow--large { width: calc(224px * var(--k)); height: calc(80px * var(--k)); }

/* Falling-object shadow on the ground line: a dark ellipse with a wide soft edge (box-shadow), easy to spot at any height. */
.scene__shadow--object {
  width: calc(72px * var(--object-scale));
  height: calc(16px * var(--object-scale));
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.525);
  box-shadow: 0 0 calc(14px * var(--object-scale)) calc(6px * var(--object-scale)) rgba(0, 0, 0, 0.34);
}

.scene__popup {
  font: calc(32px * var(--k)) / 1 var(--font-display);
  text-transform: var(--type-display-transform);
  -webkit-text-stroke: 5px #fff;
  paint-order: stroke fill;
  animation: popup-rise 0.8s ease-out forwards;
}
.scene__popup.is-positive { color: var(--color-positive); }
.scene__popup.is-negative { color: var(--color-negative); }

.scene__catcher-sprite.is-bump-positive { animation: bump-positive 0.28s ease-out; }
.scene__catcher-sprite.is-bump-negative { animation: bump-negative 0.32s ease-out; }

@keyframes suck-in {
  to { scale: 0.75; opacity: 0; }
}

@keyframes glow {
  0% { opacity: 0; scale: 0.5; }
  20% { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: 1.2; }
}

@keyframes popup-rise {
  from { opacity: 1; margin-top: 0; }
  to { opacity: 0; margin-top: -48px; }
}

@keyframes bump-positive {
  0% { transform: scale(1); }
  35% { transform: scale(1.1, 0.92); }
  70% { transform: scale(0.97, 1.04); }
  100% { transform: scale(1); }
}

@keyframes bump-negative {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-3deg); }
  40% { transform: translateX(6px) rotate(3deg); }
  60% { transform: translateX(-4px) rotate(-2deg); }
  80% { transform: translateX(3px) rotate(1deg); }
}
