@layer utilities {
  /* While the AI works (Niklas, 3.12.: the user should see that something is happening), the same everywhere: the
     running review, Ask AI and "Check against source", "Draft with AI" and "Suggest paraphrase". A span of its own, or
     a button with aria-busy, where it takes the place of the button's icon. */
  .spinner,
  .btn[aria-busy="true"]::before {
    display: inline-block;
    flex-shrink: 0;
    inline-size: 1em;
    block-size: 1em;
    border: var(--border-width-2) solid var(--color-border);
    border-block-start-color: var(--color-link);
    border-radius: 50%;
    animation: spinner 1s linear infinite;
  }

  .btn[aria-busy="true"]::before {
    content: "";
  }

  .btn[aria-busy="true"] > .icon {
    display: none;
  }

  @keyframes spinner {
    to { transform: rotate(360deg); }
  }

  @media (prefers-reduced-motion: reduce) {
    .spinner,
    .btn[aria-busy="true"]::before {
      animation-duration: 3s;
    }
  }

  .shake {
    animation: shake 400ms both;
  }

  @keyframes highlight-fade {
    0% {
      box-shadow: var(--shadow-none);
    }
    15%,
    70% {
      border-color: var(--color-blue-accent);
      background-color: var(--color-selected);
      box-shadow: var(--shadow-focus);
    }
    100% {
      box-shadow: var(--shadow-none);
    }
  }

  .animate-highlight {
    animation: highlight-fade 1.5s ease-out;
  }

  @keyframes appear-then-fade {
    0%,
    100% {
      opacity: 0;
    }
    5%,
    60% {
      opacity: 1;
    }
  }

  @keyframes shake {
    0% {
      transform: translateX(-2rem);
    }
    25% {
      transform: translateX(2rem);
    }
    50% {
      transform: translateX(-1rem);
    }
    75% {
      transform: translateX(1rem);
    }
  }

  @keyframes slide-up {
    from {
      transform: translateY(2rem);
    }
    to {
      transform: translateY(0);
    }
  }

  @keyframes slide-up-fade-in {
    from {
      transform: translateY(2rem);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  @keyframes slide-down {
    from {
      transform: translateY(0);
    }
    to {
      transform: translateY(2rem);
    }
  }
}
