/*
 * Mini-Cart Drawer — Minow Mango
 * RTL layout, matches site design tokens from global.css
 */

/* ── OVERLAY ── */
.mm-cart-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 10, 10, 0.45);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mm-cart-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── DRAWER PANEL ── */
.mm-cart-drawer {
  position: fixed;
  top: 0;
  inset-inline-start: 0; /* slides in from the inline start (right in RTL) */

  /* Content-hugging: the drawer is only as tall as header + items + footer,
     capped at the viewport so the items area scrolls and the footer stays
     reachable once the cart is large (issue #9). */
  height: auto;
  max-height: 100vh;
  max-height: 100dvh;
  width: min(420px, 92vw);
  background: var(--clr-surface);
  z-index: 9999;
  display: flex;
  flex-direction: column;

  /* Physical: off-canvas is off the right edge, shadow falls to the left of it */
  transform: translateX(100%) /*rtl:ignore*/;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 40px rgba(2, 10, 10, 0.12) /*rtl:ignore*/;
}

.mm-cart-drawer.is-open {
  transform: translateX(0);
}

/* ── HEADER ── */
.mm-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.mm-cart-drawer__title {
  font-size: var(--text-lg, 18px);
  font-weight: 700;
  color: var(--clr-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mm-cart-drawer__count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--clr-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 11px;
  line-height: 1;
}

.mm-cart-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--clr-neutral-100);
  border-radius: 50%;
  cursor: pointer;
  color: var(--clr-text);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.mm-cart-drawer__close:hover {
  background: var(--clr-neutral-200);
}

/* ── ITEMS LIST ── */
.mm-cart-drawer__items {

  /* Shrink (never grow): min-height 0 lets the list compress past its content
     when the drawer hits max-height, which is what makes it scroll. */
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-neutral-300) transparent;
}

.mm-cart-drawer__items::-webkit-scrollbar { width: 4px; }

.mm-cart-drawer__items::-webkit-scrollbar-track { background: transparent; }

.mm-cart-drawer__items::-webkit-scrollbar-thumb { background: var(--clr-neutral-300); border-radius: 2px; }

/* ── SINGLE ITEM ── */
.mm-cart-drawer__item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--clr-border);
}

.mm-cart-drawer__item:last-child { border-bottom: none; }

.mm-cart-drawer__item-img {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--clr-neutral-100);
  flex-shrink: 0;
  border: 1px solid var(--clr-border);
}

.mm-cart-drawer__item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mm-cart-drawer__item-name {
  font-size: var(--text-sm, 13px);
  font-weight: 600;
  color: var(--clr-text);
  line-height: 1.5;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mm-cart-drawer__item-name:hover { color: var(--clr-primary); }

.mm-cart-drawer__item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.mm-cart-drawer__item-price {
  font-size: var(--text-sm, 13px);
  font-weight: 700;
  color: var(--clr-primary-900);
  display: flex;
  align-items: center;
  gap: 4px;
}

.mm-cart-drawer__item-price .mm-cart-drawer__currency {
  width: 14px;
  height: 14px;
  object-fit: contain;
  vertical-align: middle;
}

/* Qty controls */
.mm-cart-drawer__qty {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--clr-border);
  border-radius: 8px;
  overflow: hidden;
  height: 30px;
}

.mm-cart-drawer__qty-btn {
  width: 28px;
  height: 30px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--clr-text);
  transition: background 0.15s;
  line-height: 1;
}

.mm-cart-drawer__qty-btn:hover { background: var(--clr-neutral-100); }

.mm-cart-drawer__qty-val {
  min-width: 28px;
  text-align: center;
  font-size: var(--text-sm, 13px);
  font-weight: 600;
  color: var(--clr-text);
  padding: 0 4px;
}

/* Remove button */
.mm-cart-drawer__item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--clr-neutral-400);
  padding: 2px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.mm-cart-drawer__item-remove:hover { color: #e53e3e; }

/* ── EMPTY STATE ── */
.mm-cart-drawer__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
  color: var(--clr-neutral-400);
}

.mm-cart-drawer__empty svg {
  opacity: 0.18;
  color: var(--clr-primary);
  margin-bottom: 8px;
}

.mm-cart-drawer__empty p {
  font-size: var(--text-base, 16px);
  font-weight: 700;
  color: var(--clr-text);
  margin: 0;
}

.mm-cart-drawer__empty-hint {
  font-size: var(--text-sm, 13px);
  color: var(--clr-text-muted);
  margin-bottom: 12px;
}

.mm-cart-drawer__empty .mm-cart-drawer__btn {
  width: 100%;
  max-width: 220px;
}

/* ── LOADING SHIMMER ── */

/* ponytail: CSS-only shimmer — pseudo-element gradient sweep */
@keyframes mm-shimmer {

  0%   { transform: translateX(-100%); }

  100% { transform: translateX(100%); }
}

.mm-cart-drawer__items.is-loading,
.mm-cart-drawer--loading .mm-cart-drawer__items {
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

.mm-cart-drawer__items.is-loading > *,
.mm-cart-drawer--loading .mm-cart-drawer__items > * {
  opacity: 0.4;
}

.mm-cart-drawer__items.is-loading::after,
.mm-cart-drawer--loading .mm-cart-drawer__items::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.5) 50%,
    transparent 100%
  );
  animation: mm-shimmer 1.2s ease-in-out infinite;
}

/* ── FOOTER ── */
.mm-cart-drawer__footer {
  padding: 20px 24px;
  border-top: 1px solid var(--clr-border);
  flex-shrink: 0;
  background: var(--clr-neutral-50);
}

.mm-cart-drawer__subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.mm-cart-drawer__subtotal-label {
  font-size: var(--text-sm, 13px);
  color: var(--clr-text-muted);
  font-weight: 500;
}

.mm-cart-drawer__subtotal-value {
  font-size: var(--text-base, 16px);
  font-weight: 700;
  color: var(--clr-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.mm-cart-drawer__subtotal-value .mm-cart-drawer__currency {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.mm-cart-drawer__actions {
  display: flex;
  gap: 10px;
}

.mm-cart-drawer__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 10px;
  font-size: var(--text-sm, 13px);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: var(--font-primary);
  letter-spacing: -0.02em;
}

.mm-cart-drawer__btn:active { transform: scale(0.98); }

.mm-cart-drawer__btn--cart {
  background: transparent;
  border: 1.5px solid var(--clr-border);
  color: var(--clr-text);
}

.mm-cart-drawer__btn--cart:hover {
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

.mm-cart-drawer__btn--checkout {
  background: var(--clr-primary);
  border: 1.5px solid var(--clr-primary);
  color: #fff;
}

.mm-cart-drawer__btn--checkout:hover { background: var(--clr-primary-700); border-color: var(--clr-primary-700); }

/* ── CART BUTTON (header) ── */

/* ponytail: keep existing .mm-header__cart styles, just add cursor:pointer for button mode */
button.mm-header__cart {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* Hide/show drawer cart count badge via WC fragment update */
.mm-header__cart-indicator { transition: opacity 0.2s; }

/* Spin animation for loading state */
@keyframes mm-spin {

  to { transform: rotate(360deg); }
}

/* ponytail: badge pulse on add-to-cart */
@keyframes mm-badge-pulse {

  0%   { transform: scale(1); }

  40%  { transform: scale(1.35); }

  100% { transform: scale(1); }
}

.mm-cart-drawer__count-badge.is-pulsing,
.mm-header__cart-indicator.is-pulsing {
  animation: mm-badge-pulse 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── PHONE TAP TARGETS (issue #11) ── */
@media (max-width: 600px) {

  .mm-cart-drawer__close {
    width: 44px;
    height: 44px;
  }

  .mm-cart-drawer__qty {
    height: 44px;
    border-radius: 10px;
  }

  .mm-cart-drawer__qty-btn {
    width: 44px;
    height: 44px;
  }

  .mm-cart-drawer__item-remove {
    width: 44px;
    height: 44px;
    justify-content: center;
    padding: 0;
  }
}

/* ── COMPACT ROWS BELOW ~400px (issue #11) ──
   At phone widths the drawer is 92vw (~359px at 390): tighten chrome and
   stack price above the quantity control so nothing collides or clips. */
@media (max-width: 400px) {

  .mm-cart-drawer__header { padding: 16px; }

  .mm-cart-drawer__items { padding: 12px 16px; }

  .mm-cart-drawer__footer { padding: 16px; }

  .mm-cart-drawer__item { gap: 10px; }

  .mm-cart-drawer__item-img {
    width: 56px;
    height: 56px;
  }

  .mm-cart-drawer__item-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
