/* The Solutions closing panel. Each problem appears in the slot at the top, above the middle
   lane, then drops into its own lane: 116px down (half the slot, the gap, the lane's label and half its well),
   and for the outer lanes one lane across. The problems land at 30%, 54% and 78% of the loop, and each lane's
   outline flashes as its problem lands. The first problem waits 1.2s, so a loop paused off screen as the
   page loads never rests with a card half faded in. */

:root {
  /* One full loop. */
  --sort-cycle: 10s;
  /* One lane across: a third of the row, (100cqw + the 8px gap) / 3. */
  --sort-across: calc((100cqw + 8px) / 3);
}

@layer utilities {
  @media (prefers-reduced-motion: no-preference) {
    .motion-safe\:animate-sort-a {
      animation: sort-a var(--sort-cycle) var(--ease-smooth-out) infinite both;
    }

    .motion-safe\:animate-sort-b {
      animation: sort-b var(--sort-cycle) var(--ease-smooth-out) infinite both;
    }

    .motion-safe\:animate-sort-c {
      animation: sort-c var(--sort-cycle) var(--ease-smooth-out) infinite both;
    }

    .motion-safe\:animate-sort-lane-a {
      animation: sort-lane var(--sort-cycle) var(--ease-smooth-out) calc(var(--sort-cycle) * 0.3) infinite both;
    }

    .motion-safe\:animate-sort-lane-b {
      animation: sort-lane var(--sort-cycle) var(--ease-smooth-out) calc(var(--sort-cycle) * 0.54) infinite both;
    }

    .motion-safe\:animate-sort-lane-c {
      animation: sort-lane var(--sort-cycle) var(--ease-smooth-out) calc(var(--sort-cycle) * 0.78) infinite both;
    }
  }
}

/* into the left lane, from above the middle one, one lane to its right */
@keyframes sort-a {
  0%,
  12% {
    opacity: 0;
    transform: translate(var(--sort-across), -116px) scale(0.92);
  }
  15%,
  20% {
    opacity: 1;
    transform: translate(var(--sort-across), -116px) scale(1);
  }
  30%,
  90% {
    opacity: 1;
    transform: none;
  }
  96%,
  100% {
    opacity: 0;
    transform: none;
  }
}

/* straight down into the middle lane */
@keyframes sort-b {
  0%,
  36% {
    opacity: 0;
    transform: translate(0, -116px) scale(0.92);
  }
  39%,
  44% {
    opacity: 1;
    transform: translate(0, -116px) scale(1);
  }
  54%,
  90% {
    opacity: 1;
    transform: none;
  }
  96%,
  100% {
    opacity: 0;
    transform: none;
  }
}

/* into the right lane, from above the middle one, one lane to its left */
@keyframes sort-c {
  0%,
  60% {
    opacity: 0;
    transform: translate(calc(var(--sort-across) * -1), -116px) scale(0.92);
  }
  63%,
  68% {
    opacity: 1;
    transform: translate(calc(var(--sort-across) * -1), -116px) scale(1);
  }
  78%,
  90% {
    opacity: 1;
    transform: none;
  }
  96%,
  100% {
    opacity: 0;
    transform: none;
  }
}

/* the lane's outline flashes as its problem lands */
@keyframes sort-lane {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  3% {
    opacity: 1;
    transform: scale(1);
  }
  12%,
  100% {
    opacity: 0;
    transform: scale(1.15);
  }
}
