/* Footer: a game of fetch. Replaces the doormat and tiles. The footer slides up to reveal the dog
   sitting in a grey box; the ball drops in, her tail wags, and the ball can be pulled back like a
   slingshot and let go. She runs after it, brings it back and sits again. Positions and sizes are
   set by fetch.js in pixels of the box (--dog-w, --dog-h, --ball-d). */
.doormat-reveal { background: #e3e3e3; }
.fetch-scene {
  position: fixed;
  inset: auto 0 0;
  aspect-ratio: 1514 / 415.5;
  overflow: hidden;
  background: #e3e3e3;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.fetch-scene img { display: block; max-width: none; pointer-events: none; -webkit-user-drag: none; }

/* The dog: a box the size of one sprite canvas (340 × 375, feet 24 px above its bottom edge). */
.fetch-dog {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--dog-w, 200px);
  height: var(--dog-h, 220px);
  will-change: transform;
}
.fetch-flip { position: absolute; inset: 0; }
.fetch-dog-shadow {
  position: absolute;
  left: 18%;
  width: 64%;
  bottom: 4.5%;
  height: 5%;
  border-radius: 50%;
  background: #0000001a;
  filter: blur(2px);
}
.fetch-pose {
  position: absolute;
  bottom: 0;
  left: 50%;
  height: 100%;
  width: auto;
  transform: translateX(-50%);
  visibility: hidden;
}
.pose-sit { aspect-ratio: 325 / 375; isolation: isolate; }
.pose-sit .fetch-sit { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.fetch-dog[data-pose="sit"] .pose-sit,
.fetch-dog[data-pose="run-1"] .pose-run-1,
.fetch-dog[data-pose="run-2"] .pose-run-2,
.fetch-dog[data-pose="run-3"] .pose-run-3,
.fetch-dog[data-pose="run-4"] .pose-run-4,
.fetch-dog[data-pose="fetch"] .pose-fetch { visibility: visible; }

/* Her tail peeks out behind her right hip and wags from its base. */
.fetch-tail {
  position: absolute;
  left: 64%;
  top: 50%;
  width: 27%;
  z-index: 0;
  transform-origin: 14% 88%;
  transform: rotate(-6deg);
}
.fetch-wag {
  position: absolute;
  left: 86%;
  top: 41%;
  width: 12%;
  z-index: 2;
  opacity: 0;
}
.fetch-scene.is-wagging .fetch-tail { animation: fetch-wag .34s ease-in-out infinite; }
.fetch-scene.is-wagging .fetch-wag { animation: fetch-wag-marks .68s steps(1) infinite; }
.fetch-scene.is-excited .fetch-tail { animation-duration: .2s; }
.fetch-scene.is-excited .fetch-wag { animation-duration: .4s; }
@keyframes fetch-wag { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(16deg); } }
@keyframes fetch-wag-marks { 0% { opacity: 1; } 50% { opacity: 0; } }

/* The ball she carries back, placed at her mouth on each running frame by fetch.js. */
.fetch-held {
  position: absolute;
  width: var(--ball-d, 36px);
  transform: translate(-50%, -50%);
  visibility: hidden;
}
.fetch-dog[data-carrying] .fetch-held { visibility: visible; }

/* The ball, and its shadow on the floor. */
.fetch-ball {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--ball-d, 36px);
  height: var(--ball-d, 36px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: grab;
  touch-action: none;
  z-index: 3;
  will-change: transform;
}
.fetch-ball img { width: 100%; height: 100%; }
.fetch-ball:focus-visible { outline: 2px solid #111; outline-offset: 3px; }
.fetch-scene[data-state="aim"] .fetch-ball { cursor: grabbing; }
.fetch-scene:not([data-state="ready"]):not([data-state="aim"]) .fetch-ball { cursor: default; }
.fetch-ball[hidden], .fetch-ball-shadow[hidden] { display: none; }
.fetch-ball-shadow {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--ball-d, 36px);
  height: calc(var(--ball-d, 36px) * .22);
  border-radius: 50%;
  background: #00000024;
  filter: blur(1.5px);
  z-index: 2;
}

/* The pulled-back band and the dotted aim line. */
.fetch-band { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 2; }
.fetch-band line { stroke: #9a9a9a; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 1 6; }
.fetch-band circle { fill: #00000030; }

.fetch-hint {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  color: #8a8a8a;
  font: italic 400 clamp(12px, 1vw, 15px)/1.2 "Footer Montreal", Arial, sans-serif;
  letter-spacing: -.01em;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .4s;
}
.fetch-hint[hidden] { display: block; opacity: 0; }

/* Phones: a taller box, so there is room to throw. */
@media (max-width: 600px) {
  .doormat-reveal, .fetch-scene { aspect-ratio: 4 / 3; }
}
@media (prefers-reduced-motion: reduce) {
  .fetch-scene { position: absolute; inset: 0; }
  .fetch-scene.is-wagging .fetch-tail, .fetch-scene.is-wagging .fetch-wag { animation: none; }
}

