/* Universal WooCommerce feedback toast for cart and checkout. */
@keyframes canuto-site-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Keep a processed WooCommerce notice available to assistive technology
   without displaying it beside its visual toast copy. */
.woocommerce .canuto-toast-source-notice {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Fallback for checkout validation errors that some WooCommerce flows keep
   as a native notice instead of passing through the toast event. */
body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) {
  position: fixed !important;
  top: 24px !important;
  right: 32px !important;
  bottom: auto !important;
  left: auto !important;
  z-index: 999998 !important;
  width: min(420px, calc(100vw - 32px)) !important;
  max-width: 420px !important;
  margin: 0 !important;
}

body.woocommerce-checkout .woocommerce-NoticeGroup-checkout.is-canuto-dismissed {
  display: none !important;
}

body.woocommerce-checkout .canuto-checkout-notice-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-light);
  background: transparent;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

body.woocommerce-checkout .canuto-checkout-notice-close:hover,
body.woocommerce-checkout .canuto-checkout-notice-close:focus {
  color: var(--text-medium);
  background: transparent;
  box-shadow: none;
  transform: none;
}

body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) > .woocommerce-error,
body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) > [role="alert"] {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
}

body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) a,
body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) a:hover,
body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) a:focus {
  text-decoration: none !important;
}

@media (max-width: 600px) {
  body.woocommerce-checkout .woocommerce-NoticeGroup-checkout:not(.canuto-toast-source-notice) {
    top: 16px !important;
    right: 16px !important;
    left: auto !important;
  }
}

/* Prevent the native product notice from flashing before its toast is built.
   Interactive notices remain fully visible and usable. */
body.single-product .woocommerce-message:not(:has(form, iframe, input, select, textarea, button, [contenteditable="true"], [role="button"])),
body.single-product .woocommerce-error:not(:has(form, iframe, input, select, textarea, button, [contenteditable="true"], [role="button"])),
body.woocommerce-cart .woocommerce-message:not(:has(form, iframe, input, select, textarea, button, [contenteditable="true"], [role="button"])),
body.woocommerce-cart .woocommerce-error:not(:has(form, iframe, input, select, textarea, button, [contenteditable="true"], [role="button"])),
body.woocommerce-cart .coupon-error-notice:not(:has(form, iframe, input, select, textarea, button, [contenteditable="true"], [role="button"])) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

body.single-product .woocommerce .blockUI.blockOverlay::before,
body.woocommerce-cart .woocommerce .blockUI.blockOverlay::before,
body.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce .blockUI.blockOverlay::before {
  position: absolute;
  top: 50%;
  right: auto;
  left: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  box-sizing: border-box;
  content: "";
  background: transparent !important;
  background-image: none !important;
  background-size: 0 0 !important;
  border: 5px solid color-mix(in srgb, var(--success-color) 14%, transparent);
  border-top-color: var(--success-color);
  border-radius: 50%;
  color: transparent;
  font-size: 0;
  animation: canuto-site-spinner .8s linear infinite;
}

.canuto-cart-toast {
  position: fixed;
  top: 24px;
  right: 32px;
  left: auto;
  z-index: 999999;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 16px;
  width: min(420px, calc(100vw - 32px));
  max-width: 420px;
  min-height: 88px;
  padding: 16px 18px;
  box-sizing: border-box;
  background: var(--white);
  border: 1px solid color-mix(in srgb, var(--text-light) 28%, transparent);
  border-radius: 16px;
  color: var(--text-dark);
  box-shadow: 0 18px 45px color-mix(in srgb, var(--text-dark) 16%, transparent);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity .25s ease, transform .25s ease;
}

.canuto-cart-toast.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.canuto-cart-toast__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--success-color) 12%, var(--white));
  color: var(--success-color);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.canuto-cart-toast--error .canuto-cart-toast__icon {
  background: color-mix(in srgb, var(--error-color) 10%, var(--white));
  color: var(--error-color);
}

.canuto-cart-toast__content {
  min-width: 0;
}

.canuto-cart-toast__title {
  display: block;
  margin: 0 0 3px;
  color: var(--text-dark);
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.25;
}

.canuto-cart-toast__message {
  margin: 0;
  color: var(--text-light);
  font-size: .88rem;
  font-weight: 400;
  line-height: 1.35;
}

.canuto-cart-toast__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-light);
  box-shadow: none;
  font-size: 1.65rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.canuto-cart-toast__close:hover {
  background: color-mix(in srgb, var(--text-light) 10%, transparent);
  color: var(--text-medium);
}

.canuto-cart-toast__action {
  display: inline-block;
  margin-top: 6px;
  color: var(--button-background-color);
  font-size: .78rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 599px) {
  .canuto-cart-toast {
    top: 12px;
    right: 16px;
    left: auto;
    grid-template-columns: 40px minmax(0, 1fr) 24px;
    gap: 12px;
    width: calc(100% - 32px);
    min-height: 78px;
    padding: 14px;
    border-radius: 14px;
  }

  .canuto-cart-toast__icon {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
  }

  .canuto-cart-toast__title {
    font-size: .92rem;
  }

  .canuto-cart-toast__message {
    font-size: .8rem;
  }
}
