/* Animacje przycisków „dodaj do koszyka” (kafelki, karta produktu), „Przejdź do kasy” i koszyka w nagłówku. */

.xs-tile__cart,
.xs-cart-form__submit,
.xs-drawer__checkout {
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.xs-tile__cart svg,
.xs-cart-form__submit svg,
.xs-drawer__checkout svg {
  transition: opacity 0.15s ease;
}

/* Na karcie produktu ✓ pojawia się w miejscu wózka, obok napisu. */
.xs-cart-form__icon {
  position: relative;
  display: inline-flex;
}

/* WooCommerce dokleja swój link „Zobacz koszyk” po dodaniu — mamy własny przycisk.
   Selektor mocniejszy niż „.woocommerce a.added_to_cart” z arkusza WooCommerce. */
.xs-cart-form a.added_to_cart.wc-forward {
  display: none;
}

/* Najechanie: przycisk się unosi, wózek się kołysze. */
.xs-tile__cart:hover,
.xs-cart-form__submit:hover,
.xs-drawer__checkout:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(255, 74, 0, 0.35);
}

.xs-tile__cart:hover svg,
.xs-cart-form__submit:hover svg,
.xs-drawer__checkout:hover svg {
  animation: xs-cart-wiggle 0.5s ease;
}

/* Kliknięcie: przycisk się wciska. */
.xs-tile__cart:active {
  transform: scale(0.92);
  box-shadow: none;
}

.xs-cart-form__submit:active,
.xs-drawer__checkout:active {
  transform: scale(0.98);
  box-shadow: none;
}

/* Dodawanie: wózek odjeżdża w prawo i wraca z lewej. */
.xs-tile__cart.loading svg,
.xs-cart-form__submit.loading svg,
.xs-drawer__checkout.loading svg {
  animation: xs-cart-ride 0.7s ease-in-out infinite;
}

/* Dodano: wózek znika, na chwilę pojawia się ✓. */
.xs-tile__cart.xs-cart-done svg,
.xs-cart-form__submit.xs-cart-done svg {
  opacity: 0;
}

.xs-tile__cart.xs-cart-done::after,
.xs-cart-form__submit.xs-cart-done .xs-cart-form__icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 13px;
  border: solid var(--xs-text);
  border-width: 0 3px 3px 0;
  transform: translate(-50%, -62%) rotate(45deg);
  animation: xs-check-pop 0.35s ease;
}

/* Koszyk w nagłówku: najechanie — unosi się, ciemnieje (jak górny pasek), wózek się kołysze. */
.xs-cart {
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease, color 0.2s ease;
}

.xs-cart:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(20, 20, 21, 0.25);
  background: var(--xs-dark);
  color: #ffffff;
}

.xs-cart:hover svg {
  color: var(--xs-brand);
  animation: xs-cart-wiggle 0.5s ease;
}

.xs-cart:active {
  transform: scale(0.96);
  box-shadow: none;
}

/* Koszyk w nagłówku podskakuje po dodaniu produktu. */
.xs-cart.xs-cart--bump {
  animation: xs-cart-bump 0.5s ease;
}

@keyframes xs-cart-wiggle {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-12deg);
  }
  60% {
    transform: rotate(10deg);
  }
}

@keyframes xs-cart-ride {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  45% {
    transform: translateX(22px);
    opacity: 0;
  }
  55% {
    transform: translateX(-22px);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes xs-check-pop {
  0% {
    transform: translate(-50%, -62%) rotate(45deg) scale(0.2);
    opacity: 0;
  }
  70% {
    transform: translate(-50%, -62%) rotate(45deg) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -62%) rotate(45deg) scale(1);
  }
}

@keyframes xs-cart-bump {
  0%,
  100% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.97);
  }
}

@media (prefers-reduced-motion: reduce) {
  .xs-tile__cart,
  .xs-tile__cart svg,
  .xs-tile__cart::after,
  .xs-cart-form__submit,
  .xs-cart-form__submit svg,
  .xs-drawer__checkout,
  .xs-drawer__checkout svg,
  .xs-cart-form__icon::after,
  .xs-cart {
    animation: none !important;
    transition: none !important;
  }
}
