/* The Analytics closing panel. Three questions take a third of the loop each, in their
   ask-step-* order. In its third, a question appears under a cover that slides off it in steps, like
   typing, then its answer rises in, and both clear before the next question. */

:root {
  /* One full loop. */
  --ask-cycle: 12s;
}

@layer utilities {
  @media (prefers-reduced-motion: no-preference) {
    .motion-safe\:animate-ask-first {
      animation: ask-first var(--ask-cycle) linear infinite both;
    }

    .motion-safe\:animate-ask-phase {
      animation: ask-phase var(--ask-cycle) linear calc(var(--ask-step, 0) * var(--ask-cycle) / 3) infinite both;
    }

    .motion-safe\:animate-ask-type {
      animation: ask-type var(--ask-cycle) linear calc(var(--ask-step, 0) * var(--ask-cycle) / 3) infinite both;
    }

    .motion-safe\:animate-ask-answer {
      animation: ask-answer var(--ask-cycle) var(--ease-smooth-out) calc(var(--ask-step, 0) * var(--ask-cycle) / 3) infinite both;
    }
  }

  /* A question's place in the order, for it and its answer. */
  .ask-step-0 {
    --ask-step: 0;
  }

  .ask-step-1 {
    --ask-step: 1;
  }

  .ask-step-2 {
    --ask-step: 2;
  }
}

/* The first question is already in place at the start, under its cover, so it never fades in where a
   loop paused off screen as the page loads could catch it half there. */
@keyframes ask-first {
  0%,
  30% {
    opacity: 1;
  }
  32%,
  100% {
    opacity: 0;
  }
}

/* the others wait out their delay hidden */
@keyframes ask-phase {
  0% {
    opacity: 0;
  }
  1%,
  30% {
    opacity: 1;
  }
  32%,
  100% {
    opacity: 0;
  }
}

@keyframes ask-type {
  0%,
  2% {
    opacity: 1;
    transform: translateX(0);
    animation-timing-function: steps(18, end);
  }
  13%,
  100% {
    opacity: 1;
    transform: translateX(101%);
  }
}

@keyframes ask-answer {
  0%,
  14% {
    opacity: 0;
    transform: translateY(8px);
  }
  18%,
  30% {
    opacity: 1;
    transform: none;
  }
  32%,
  100% {
    opacity: 0;
    transform: none;
  }
}
