@property --gategoat-graze {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

.cta-goat-scene {
  position: relative;
  width: 144px;
  margin: 0 16px 0 auto;
  color: var(--inspection-ink);
  --loop: 9s;
}

.cta-goat-scene .art {
  position: relative;
  width: 128px;
  height: 48px;
}

.cta-goat-scene .art :is(.grass, .gate, .goat) {
  position: absolute;
}

.cta-goat-scene .grass {
  inset: auto 0 0;
  height: 9px;
  background: currentColor;
  clip-path: polygon(
    0 9px, 0 6px, 2px 6px, 2px 8px, 4px 8px, 4px 4px, 6px 4px, 6px 8px, 9px 8px, 9px 9px,
    48px 9px, 48px 1px, 50px 1px, 50px 6px, 53px 6px, 53px 3px, 55px 3px, 55px 9px,
    118px 9px, 118px 8px, 121px 8px, 121px 5px, 123px 5px, 123px 8px, 125px 8px,
    125px 6px, 127px 6px, 127px 9px
  );
}

.cta-goat-scene .gate {
  bottom: 0;
  left: 80px;
  width: 28px;
  height: 17px;
  background: currentColor;
  /* Two posts, two narrow rails and a stepped timber brace. */
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 17'%3E%3Cpath d='M0 0h4v17H0z M24 0h4v17h-4z M4 3h20v3H4z M4 11h20v3H4z M4 10h4v3H4z M7 9h4v3H7z M10 8h4v3h-4z M13 7h4v3h-4z M16 6h4v3h-4z M19 5h5v3h-5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.cta-goat-scene .goat {
  bottom: -1px;
  left: 10px;
  width: 48px;
  height: 40px;
  /* Extend a solid band from inside the chest to inside the moving neck. */
  background: linear-gradient(currentColor, currentColor)
    23px 17px / calc(5px + 5px * var(--gategoat-graze)) 6px no-repeat;
  animation: cta-goat-graze var(--loop) ease-in-out infinite;
}

/* Split the upright sprite at the shoulder so the hooves stay planted. */
.cta-goat-scene .tail,
.cta-goat-scene .goat::before,
.cta-goat-scene .goat::after {
  position: absolute;
  inset: 0;
  background: currentColor;
  mask: url("/cta-goat-sprites.png") -192px 0 / 240px 40px no-repeat;
  image-rendering: pixelated;
  content: "";
}

.cta-goat-scene .goat::before {
  clip-path: polygon(6px 10px, 15px 10px, 15px 18px, 21px 18px, 24px 16px, 30px 16px, 30px 100%, 0 100%, 0 24px, 6px 24px);
}

.cta-goat-scene .goat::after {
  clip-path: polygon(15px 0, 100% 0, 100% 25px, 32px 25px, 32px 20px, 24px 20px, 22px 16px, 22px 11px, 15px 11px);
  transform-origin: 26px 18px;
  transform: translateX(calc(5px * var(--gategoat-graze))) rotate(calc(60deg * var(--gategoat-graze)));
}

/* Reach, angle and shoulder length all follow the same eased progress. */
@keyframes cta-goat-graze {
  0%, 8%, 20%, 32%, 46%, 94%, 100% { --gategoat-graze: 1; }
  14%, 26% { --gategoat-graze: .92; }
  59%, 81% { --gategoat-graze: 0; }
}

.cta-goat-scene .tail {
  clip-path: inset(10px 42px 16px 0);
  transform-origin: 6px 23px;
  animation: cta-goat-wag calc(2 * var(--loop)) ease-in-out infinite;
}

@keyframes cta-goat-wag {
  0%, 19%, 24%, 69%, 74%, 100% { transform: rotate(0deg); }
  20%, 23%, 70%, 73% { transform: rotate(14deg); }
  21.5%, 71.5% { transform: rotate(-9deg); }
}

.cta-goat-scene .thought {
  position: absolute;
  left: 46px;
  top: 0;
  width: 13px;
  height: 11px;
}

.cta-goat-scene .thought::before,
.cta-goat-scene .thought::after {
  position: absolute;
  content: "";
  background: currentColor;
  opacity: 0;
}

.cta-goat-scene .thought::before {
  top: 4px;
  width: 3px;
  height: 3px;
  animation: cta-goat-ponder calc(2 * var(--loop)) step-end infinite;
}

.cta-goat-scene .thought::after {
  inset: 0;
  clip-path: polygon(0 4px, 2px 4px, 4px 6px, 9px 1px, 11px 1px, 11px 3px, 5px 9px, 3px 9px, 0 6px);
  animation: cta-goat-check calc(2 * var(--loop)) ease-out infinite;
}

@keyframes cta-goat-ponder {
  0%, 42%, 100% { opacity: 0; box-shadow: none; }
  29%, 35% { opacity: 1; box-shadow: none; }
  31%, 37% { opacity: 1; box-shadow: 5px 0 currentColor; }
  33%, 39% { opacity: 1; box-shadow: 5px 0 currentColor, 10px 0 currentColor; }
}

@keyframes cta-goat-check {
  0%, 78%, 92%, 100% { opacity: 0; transform: translateY(2px); }
  80%, 90% { opacity: 1; transform: translateY(0); }
}

.cta-goat-scene .toggle {
  position: absolute;
  inset: 1px 0 auto auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
}

.cta-goat-scene .toggle:hover { background: rgb(0 0 0 / 8%); }

.cta-goat-scene .toggle::before {
  box-sizing: border-box;
  width: 6px;
  height: 7px;
  border-inline: 2px solid currentColor;
  content: "";
}

.cta-goat-scene[data-paused="true"] .toggle::before {
  width: 0;
  height: 0;
  border: 4px solid transparent;
  border-right: 0;
  border-left: 6px solid currentColor;
}

.cta-goat-scene[data-paused="true"] .goat,
.cta-goat-scene[data-paused="true"] .tail,
.cta-goat-scene[data-paused="true"] .thought::before,
.cta-goat-scene[data-paused="true"] .thought::after { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .cta-goat-scene .goat,
  .cta-goat-scene .tail,
  .cta-goat-scene .thought::before,
  .cta-goat-scene .thought::after { animation: none; }
  .cta-goat-scene .toggle { display: none; }
}

.cta-goat-scene .toggle[hidden] { display: none; }
