/* --- Keyframe Definitions --- */
@keyframes slide-in-from-right {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slide-out-to-left {
  from {
    transform: translateX(0);
    filter: brightness(1);
  }
  to {
    transform: translateX(-30%);
    filter: brightness(0.7);
  } /* Slight parallax effect */
}

@keyframes slide-in-from-left {
  from {
    transform: translateX(-30%);
    filter: brightness(0.7);
  }
  to {
    transform: translateX(0);
    filter: brightness(1);
  }
}

@keyframes slide-out-to-right {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  16.7% {
    transform: scale(1.16);
  }
  38.9% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shop-spin {
  from {
    stroke-dashoffset: 136;
  }
  to {
    stroke-dashoffset: -272;
  }
}

@keyframes shop-continuous-fill {
  0% {
    stroke-dashoffset: 204;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@media not (prefers-reduced-motion: reduce) {
  .animate-bump {
    animation: bump 360ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  }

  .animate-shop-spin {
    animation: shop-continuous-fill 1.5s linear infinite;
    stroke-dasharray: 68 136 !important;
  }
}

.shop-spinner-path {
  stroke-dasharray: 136;
  stroke-dashoffset: 0;
}

.shop-spinner-progress {
  stroke-dashoffset: calc(136 - (136 * var(--spinner-progress, 0.54)));
  transition: stroke-dashoffset 0.1s ease-out;
}

/* --- View Transition Animations --- */
@media not (prefers-reduced-motion: reduce) {
  /* FORWARD navigation animation */
  html[data-navigation-type='forward']::view-transition-old(root) {
    animation: 0.4s cubic-bezier(0.4, 0, 0.2, 1) both slide-out-to-left;
    z-index: 1;
  }
  html[data-navigation-type='forward']::view-transition-new(root) {
    animation: 0.4s cubic-bezier(0.4, 0, 0.2, 1) both slide-in-from-right;
    z-index: 2; /* New view slides on top */
  }

  /* BACKWARD navigation animation */
  html[data-navigation-type='backward']::view-transition-old(root) {
    animation: 0.4s cubic-bezier(0.4, 0, 0.2, 1) both slide-out-to-right;
    z-index: 2; /* Old view slides away from on top */
  }
  html[data-navigation-type='backward']::view-transition-new(root) {
    animation: 0.4s cubic-bezier(0.4, 0, 0.2, 1) both slide-in-from-left;
    z-index: 1;
  }

  /* Android backward navigation animation */
  html[data-navigation-type='android-backward']::view-transition-old(root) {
    animation: 0.4s cubic-bezier(0.4, 0, 0.2, 1) both slide-out-to-right;
    z-index: 2; /* Old view slides away from on top */
  }
  html[data-navigation-type='android-backward']::view-transition-new(root) {
    animation: 0.4s cubic-bezier(0.4, 0, 0.2, 1) both slide-in-from-left;
    z-index: 1;
  }

  /* NONE navigation animation */
  html[data-navigation-type='none']::view-transition-group(root),
  html[data-navigation-type='none']::view-transition-old(root),
  html[data-navigation-type='none']::view-transition-new(root) {
    animation: 0 !important;
    opacity: 0 !important;
  }
}
