/* ============================================================================
 * cart-feedback.css
 * ----------------------------------------------------------------------------
 * Non-blocking feedback when items are added to cart.
 *
 * Three layers (see manage_cart.js → showCartToast()):
 *   1. Inline button transform — "Add to Cart" briefly shows "✓ Added"
 *   2. Toast — top-right (desktop), top-center (mobile), auto-dismiss
 *   3. Cart badge bounce — visual confirmation that count changed
 *
 * Respects prefers-reduced-motion: instant state changes, no slide/bounce.
 * ============================================================================ */

/* ── 1. Toast container ──────────────────────────────────────────────────── */
#cart-toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none; /* container ignores clicks; individual toasts re-enable */
  max-width: 380px;
}

@media (max-width: 768px) {
  #cart-toast-container {
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
    align-items: center;
  }
}

/* ── 2. Toast card ───────────────────────────────────────────────────────── */
.cart-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  font-size: 0.92rem;
  line-height: 1.4;
  color: #1f2937;
  width: 100%;
  max-width: 360px;
  transform: translateX(110%);
  opacity: 0;
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity   200ms ease-out;
}

.cart-toast.is-visible {
  transform: translateX(0);
  opacity: 1;
}

.cart-toast.is-leaving {
  transform: translateX(110%);
  opacity: 0;
}

@media (max-width: 768px) {
  .cart-toast {
    transform: translateY(-120%);
  }
  .cart-toast.is-visible {
    transform: translateY(0);
  }
  .cart-toast.is-leaving {
    transform: translateY(-120%);
  }
}

/* Type variants */
.cart-toast.success { border-left: 4px solid #10b981; }
.cart-toast.error   { border-left: 4px solid #ef4444; }
.cart-toast.info    { border-left: 4px solid #3b82f6; }

/* Icon */
.cart-toast-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.cart-toast.success .cart-toast-icon { background: #10b981; }
.cart-toast.error   .cart-toast-icon { background: #ef4444; }
.cart-toast.info    .cart-toast-icon { background: #3b82f6; }

/* Body */
.cart-toast-body {
  flex: 1;
  min-width: 0;
}
.cart-toast-message {
  margin: 0;
  font-weight: 500;
  color: #111827;
}
.cart-toast-product {
  font-weight: 600;
}
.cart-toast-action {
  display: inline-block;
  margin-top: 2px;
  font-size: 0.82rem;
  color: #996633;
  text-decoration: none;
  font-weight: 600;
}
.cart-toast-action:hover {
  text-decoration: underline;
  color: #7a4d1a;
}

/* Close button (visible on hover or always on mobile) */
.cart-toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background 120ms ease, color 120ms ease;
}
.cart-toast-close:hover {
  background: #f3f4f6;
  color: #374151;
}

/* ── 3. Inline button transform (when add-to-cart succeeds) ──────────────── */
/*  We add .is-added briefly via JS; remove it ~1.2s later.
    Works on any of our add-to-cart buttons by adding the .cart-btn-feedback
    class (added to existing buttons in JS — no template change needed). */
.cart-btn-feedback {
  position: relative;
  transition: background-color 200ms ease, color 200ms ease, transform 120ms ease;
}
.cart-btn-feedback.is-added {
  background-color: #10b981 !important;
  color: #ffffff !important;
  border-color: #10b981 !important;
}
.cart-btn-feedback.is-failed {
  background-color: #ef4444 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
}
/* Subtle squeeze on click (acknowledges the press) */
.cart-btn-feedback:active {
  transform: scale(0.97);
}

/* ── 4. Cart badge bounce (when count updates) ───────────────────────────── */
@keyframes cart-badge-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}
.cart-badge-bump {
  animation: cart-badge-bounce 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── 5. Reduced-motion: skip slide/bounce, keep colour changes ───────────── */
@media (prefers-reduced-motion: reduce) {
  .cart-toast,
  .cart-toast.is-visible,
  .cart-toast.is-leaving {
    transition: opacity 150ms linear;
    transform: none !important;
  }
  .cart-badge-bump { animation: none; }
  .cart-btn-feedback { transition: none; }
  .cart-btn-feedback:active { transform: none; }
}
