/* The button supplies its own dimensions and foreground, including on outline buttons. */
@keyframes ms-button-sweep {
  from { background-position: -72% center; }
  to { background-position: 172% center; }
}

:where(button, [role="button"]):where(
  [data-ms-initiator][data-ms-wait="true"],
  :has(.ms-pending, .medistaff-loading-button, .ms-local-loading, svg.animate-spin)
) {
  position: relative;
}

:is(body, #root) :is(button, [role="button"]):is(
  [data-ms-initiator][data-ms-wait="true"],
  :has(.ms-pending, .medistaff-loading-button, .ms-local-loading, svg.animate-spin)
) {
  /* Keep the label in layout and in the accessibility tree while the pulse is visible. */
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  opacity: 1 !important;
  filter: none;

  & > * { opacity: 0; }
  & :is(.ms-pending, .medistaff-loading-button, .ms-local-loading) { animation: none; }

  &::after {
    content: "";
    position: absolute;
    inset: 3px clamp(2px, 3%, 8px);
    pointer-events: none;
    background-color: color-mix(in srgb, currentColor 56%, transparent);
    background-image: linear-gradient(90deg, transparent, currentColor 62%, currentColor);
    background-repeat: no-repeat;
    background-size: 42% 100%;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 36' preserveAspectRatio='none'%3E %3Cpath d='M0 21H35L37.5 19.5L40 21H43.5L45.5 16L47.4 25L50 2.5L52.4 33.5L55.2 19L57.5 21H63L67.3 17L70.5 21H100' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' vector-effect='non-scaling-stroke'/%3E %3C/svg%3E") center / 100% 100% no-repeat;
    animation: ms-button-sweep 1.65s linear -0.62s infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    &::after {
      animation: none;
      background: currentColor;
    }
  }

  @media (forced-colors: active) {
    &::after {
      forced-color-adjust: none;
      color: ButtonText;
    }
  }
}
