/**
 * Pixel-dust light/dark theme wipe (top-left → bottom-right).
 * Mask image is generated once in theme.js as --cx-dust-mask.
 * Driven by document.startViewTransition.
 */

html.cx-theme-wiping,
html.cx-theme-wiping body {
  transition: none;
}

::view-transition-group(root) {
  animation-duration: 0.1s;
  animation-timing-function: steps(9, end);
}

::view-transition-old(root) {
  animation: none;
  z-index: 1;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  animation: cx-theme-dust-in 0.1s steps(9, end) both;
  z-index: 2;
  mix-blend-mode: normal;
  image-rendering: pixelated;
  mask-image: var(--cx-dust-mask);
  mask-mode: alpha;
  mask-repeat: no-repeat;
  mask-size: 200% 200%;
  -webkit-mask-image: var(--cx-dust-mask);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: 200% 200%;
}

@keyframes cx-theme-dust-in {
  from {
    mask-position: 100% 100%;
    -webkit-mask-position: 100% 100%;
  }
  to {
    mask-position: 0% 0%;
    -webkit-mask-position: 0% 0%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.cx-theme-wiping,
  html.cx-theme-wiping body {
    transition: background-color 0.3s ease, color 0.3s ease;
  }

  ::view-transition-group(root),
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
    mask-image: none !important;
    -webkit-mask-image: none !important;
  }
}
