/* Cart feedback stays clear of the purchase controls and does not intercept taps. */
body {
  --cart-feedback-accent: #18794e;
  --cart-feedback-soft: #18794e1f;
}
body[data-color="dark"] {
  --cart-feedback-accent: #77d6a7;
  --cart-feedback-soft: #77d6a724;
}

body .toast[data-kind="success"] {
  position: fixed;
  top: var(--cart-feedback-top, calc(var(--store-header-height, var(--flow-head, 90px)) + 12px));
  right: max(20px, env(safe-area-inset-right));
  bottom: auto;
  left: auto;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  min-width: 0;
  max-width: min(380px, calc(100vw - 40px));
  margin: 0;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 28px #0000001f, 0 2px 6px #0000000a;
  transform: none;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}
body[data-color="dark"] .toast[data-kind="success"] {
  border-color: color-mix(in srgb, var(--line) 75%, var(--cart-feedback-accent) 25%);
  box-shadow: 0 8px 28px #00000038, 0 2px 6px #00000020;
}
body .toast[data-kind="success"]::before {
  content: "";
  display: block;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  background: var(--cart-feedback-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='m7.5 12 3 3 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='m7.5 12 3 3 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
}
body .toast[data-kind="success"]:not([hidden]) {
  animation: cart-feedback-enter 160ms ease-out both;
}

/* Existing labels, icons, focus treatment and button dimensions stay intact. */
body :is([data-buy], [data-add-product])[aria-busy="true"] {
  cursor: progress;
  opacity: .78;
  filter: saturate(.85);
  transform: none;
}
body :is([data-buy], [data-add-product])[data-cart-added]:not([data-cart-added="false"]):not([aria-busy="true"]) {
  box-shadow: inset 0 0 0 1px var(--cart-feedback-accent), 0 0 0 2px var(--cart-feedback-soft);
}

/* Overlay the existing content so labels/icons keep the button's exact size. */
body button [data-buy-label] {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
}
body button:has([data-buy-label]) > svg { flex-shrink: 0; }
body button[data-cart-feedback] {
  position: relative;
  color: transparent !important;
  transform: none !important;
}
body button[data-cart-feedback] > :not(.cart-button-feedback) { visibility: hidden; }
body button[data-cart-feedback] > .cart-button-feedback {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 4px;
  container: cart-button-feedback / inline-size;
  border-radius: inherit;
  background: inherit;
  color: var(--cart-button-feedback-ink, var(--ink));
  font: inherit;
  line-height: 1.2;
  letter-spacing: normal;
  white-space: nowrap;
  pointer-events: none;
  overflow: hidden;
}
.cart-button-feedback-icon {
  display: block;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
}
.cart-button-feedback .cart-button-feedback-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
}
@container cart-button-feedback (max-width:80px) {
  .cart-button-feedback-label { display:none; }
  .cart-button-feedback-icon { flex-basis:18px;width:18px;height:18px; }
}
body button[data-cart-feedback="pending"] .cart-button-feedback-icon {
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cart-button-spin 700ms linear infinite;
}
body button[data-cart-feedback="success"] {
  border-color: var(--cart-button-feedback-color, #18794e);
}
body button[data-cart-feedback="success"] > .cart-button-feedback {
  background: var(--cart-button-feedback-color, #18794e);
  color: var(--cart-button-feedback-success-ink, #fff);
}
body button[data-cart-feedback="success"] .cart-button-feedback-icon {
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4 4L19 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 4 4L19 6'/%3E%3C/svg%3E") center / contain no-repeat;
}
body button[data-cart-feedback="success"][data-cart-feedback-animation="pulse"] { animation: cart-button-confirm 360ms ease-out; }
body button[data-cart-feedback="success"][data-cart-feedback-animation="pulse"] .cart-button-feedback-icon { animation: cart-check-enter 220ms ease-out; }
body button[data-cart-feedback="success"][data-cart-feedback-animation="bounce"] .cart-button-feedback-icon { animation: cart-check-bounce 550ms ease-out; }
body button[data-cart-feedback="success"][data-cart-feedback-animation="shine"] > .cart-button-feedback::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 45%;
  background: linear-gradient(110deg, transparent, #ffffff75, transparent);
  animation: cart-button-shine 650ms ease-out both;
  pointer-events: none;
}
body [data-open-cart][data-cart-feedback-pulse] :is(svg, .bag-icon, [data-cart-count]) {
  transform-origin: center;
}
body [data-open-cart][data-cart-feedback-pulse="pulse"] :is(svg, .bag-icon, [data-cart-count]) {
  animation: cart-icon-pulse 650ms ease-out;
}
body [data-open-cart][data-cart-feedback-pulse="bounce"] :is(svg, .bag-icon, [data-cart-count]) {
  animation: cart-check-bounce 650ms ease-out;
}
body [data-open-cart][data-cart-feedback-pulse="shine"] :is(svg, .bag-icon, [data-cart-count]) {
  animation: cart-icon-shine 650ms ease-out;
}
body button[data-cart-feedback][data-cart-feedback-animation="none"],
body button[data-cart-feedback][data-cart-feedback-animation="none"] *,
body button[data-cart-feedback][data-cart-feedback-animation="none"] > .cart-button-feedback::after {
  animation: none !important;
  transition: none !important;
}
@keyframes cart-button-spin { to { transform: rotate(360deg); } }
@keyframes cart-button-confirm {
  from { box-shadow: 0 0 0 0 var(--cart-feedback-soft); }
  55% { box-shadow: 0 0 0 6px var(--cart-feedback-soft); }
  to { box-shadow: 0 0 0 0 transparent; }
}
@keyframes cart-check-enter {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes cart-icon-pulse {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.22); }
  70% { transform: scale(.96); }
}
@keyframes cart-check-bounce {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-4px); }
  65% { transform: translateY(2px); }
  82% { transform: translateY(-1px); }
}
@keyframes cart-button-shine {
  from { transform: translateX(-180%) skewX(-18deg); opacity: 0; }
  20%, 80% { opacity: 1; }
  to { transform: translateX(400%) skewX(-18deg); opacity: 0; }
}
@keyframes cart-icon-shine {
  0%, 100% { filter: brightness(1); opacity: 1; }
  40% { filter: brightness(1.8); opacity: .6; }
  70% { filter: brightness(1.25); opacity: 1; }
}

@media (max-width: 760px) {
  body .toast[data-kind="success"] {
    top: var(--cart-feedback-top, calc(var(--store-header-height, var(--flow-head, 70px)) + 10px));
    right: max(12px, env(safe-area-inset-right));
    max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
  }
}
@keyframes cart-feedback-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  body .toast[data-kind="success"]:not([hidden]) { animation: none; }
  body :is([data-buy], [data-add-product])[aria-busy="true"],
  body :is([data-buy], [data-add-product])[data-cart-added] { transition: none; }
  body button[data-cart-feedback],
  body button[data-cart-feedback] .cart-button-feedback-icon,
  body button[data-cart-feedback] > .cart-button-feedback::after,
  body [data-open-cart][data-cart-feedback-pulse] :is(svg, .bag-icon, [data-cart-count]) {
    animation: none !important;
    transition: none !important;
  }
  body button[data-cart-feedback] > .cart-button-feedback::after { display:none; }
}
@media (forced-colors: active) {
  body .toast[data-kind="success"] { border: 1px solid CanvasText; background: Canvas; color: CanvasText; box-shadow: none; }
  body .toast[data-kind="success"]::before { background: CanvasText; forced-color-adjust: none; }
  body :is([data-buy], [data-add-product])[aria-busy="true"] { filter: none; }
  body button[data-cart-feedback] > .cart-button-feedback { background: Canvas; color: CanvasText; }
  body button[data-cart-feedback="success"] { border-color:CanvasText; }
  body button[data-cart-feedback] > .cart-button-feedback::after { display:none; }
  body button[data-cart-feedback="success"] .cart-button-feedback-icon { forced-color-adjust: none; }
}
