/* The profile characters (critter.ts). Pivots are in view-box units: the viewBox starts at (-2, 6). */
.critter {
  display: block;
  overflow: visible;
  flex: none;
}
.critter .tri {
  fill: var(--body);
  stroke: var(--body);
  stroke-width: 13;
  stroke-linejoin: round;
}
.critter .feathers {
  fill: none;
  stroke: var(--wing);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.critter .ground {
  fill: none;
  stroke: var(--body);
  stroke-width: 9;
  stroke-linecap: round;
}
.critter .zz {
  font:
    600 16px 'IBM Plex Mono',
    monospace;
  fill: var(--wing);
  opacity: 0;
}

.critter .all,
.critter .body,
.critter .wing,
.critter .eyes,
.critter .zz {
  transform-box: view-box;
}
.critter .all {
  transform-origin: 59px 78px;
}
.critter .body {
  transform-origin: 59px 72px;
  animation: cr-breathe 3s ease-in-out infinite;
}
.critter .wing {
  transform-origin: 31px 32px;
  animation: cr-drift 3s ease-in-out infinite;
}
.critter .eyes {
  transform-origin: 64.7px 50px;
  transition: transform 0.4s ease;
}
.critter .lid {
  transform-box: fill-box;
  transform-origin: 50% 72%;
  transition: transform 0.3s ease;
}

/* idle life, switched on by script at random moments */
.critter.blink .lid {
  animation: cr-blink 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.critter.look-l .eyes {
  transform: translateX(-2.4px);
}
.critter.look-r .eyes {
  transform: translateX(2px);
}
.critter.flap .wing {
  animation: cr-flap 0.7s ease-in-out;
}
.critter.flap .all {
  animation: cr-hop 0.7s ease-in-out;
}

/* thinking: a turn is running. Wings beat, it bobs, eyes look up. */
.critter.st-thinking .wing {
  animation: cr-beat 0.32s ease-in-out infinite alternate;
}
.critter.st-thinking .all {
  animation: cr-bob 0.64s ease-in-out infinite;
}
.critter.st-thinking .eyes {
  transform: translate(1px, -2.2px);
}

/* waiting for you: a permission request. Eyes wide, wings up, small hops. */
.critter.st-waiting .eyes {
  transform: scale(1.22);
}
.critter.st-waiting .wing {
  animation: none;
  transform: rotate(-14deg);
}
.critter.st-waiting .all {
  animation: cr-hop 1.1s ease-in-out infinite;
}

/* asleep: the session is cold. Eyes shut, slow breath, wings down, a z. */
.critter.st-asleep .lid {
  transform: scaleY(0.06);
}
.critter.st-asleep .body {
  animation-duration: 5.5s;
}
.critter.st-asleep .wing {
  animation: none;
  transform: rotate(9deg);
}
.critter.st-asleep .zz {
  animation: cr-zz 3.2s ease-in-out infinite;
}

/* a failure: one droop */
.critter.st-error .all {
  animation: cr-droop 1.4s ease-in-out;
}
.critter.st-error .wing {
  animation: none;
  transform: rotate(16deg);
}

@keyframes cr-breathe {
  50% {
    transform: scale(1.025, 0.975);
  }
}
@keyframes cr-drift {
  50% {
    transform: rotate(-5deg);
  }
}
@keyframes cr-blink {
  0% {
    transform: scaleY(1);
  }
  42% {
    transform: scaleY(0.06);
  }
  54% {
    transform: scaleY(0.06);
  }
  100% {
    transform: scaleY(1);
  }
}
@keyframes cr-flap {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-16deg);
  }
  50% {
    transform: rotate(5deg);
  }
  75% {
    transform: rotate(-12deg);
  }
}
@keyframes cr-hop {
  0%,
  100% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-5px);
  }
  65% {
    transform: translateY(0);
  }
}
@keyframes cr-beat {
  from {
    transform: rotate(6deg);
  }
  to {
    transform: rotate(-20deg);
  }
}
@keyframes cr-bob {
  50% {
    transform: translateY(-3px);
  }
}
@keyframes cr-zz {
  0% {
    opacity: 0;
    transform: translate(0, 4px);
  }
  40% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(6px, -8px);
  }
}
@keyframes cr-droop {
  30%,
  70% {
    transform: rotate(-10deg) translateY(3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .critter .all,
  .critter .body,
  .critter .wing,
  .critter .zz,
  .critter .lid,
  .critter .eyes {
    animation: none !important;
    transition: none !important;
  }
}
