/*
 * Mustafa WP — AJAX Mini Cart Drawer.
 * Site-wide (the header cart button appears everywhere). Docked on the
 * same physical side as the mobile nav drawer (left) for a consistent
 * off-canvas convention across the site — this theme is RTL-only, so the
 * side is fixed rather than computed per-direction.
 */

.mwp-header-cart { position: relative; }
.mwp-header-cart__badge {
  position: absolute; top: -4px; inset-inline-start: -4px;
  min-width: 18px; height: 18px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--primary); color: var(--on-primary);
  font-size: .68rem; font-weight: 800; line-height: 1;
  border: 2px solid var(--surface);
  transition: transform .2s var(--ease), background .2s var(--ease);
}
@media (prefers-reduced-motion: reduce) {
  .mwp-header-cart__badge { transition: none; }
}

.mwp-cart-drawer[hidden] { display: none; }
.mwp-cart-drawer { position: fixed; inset: 0; z-index: 250; }
/* Same reasoning as .mwp-header: WP's own #wpadminbar is fixed at the very
 * top (32px desktop, 46px below its own 782px breakpoint) with a z-index
 * above ours, so without this offset the drawer's header row renders
 * underneath/collides with it instead of starting just below it. */
body.admin-bar .mwp-cart-drawer { top: 32px; }
@media screen and (max-width: 782px) {
  body.admin-bar .mwp-cart-drawer { top: 46px; }
}

/* No backdrop-filter here (deliberately): animating a full-viewport blur
 * every open/close forces the browser to re-blur everything behind it on
 * every frame, which is heavy on real devices — a plain opacity fade is
 * cheap (compositor-only) and reads just as clearly. */
.mwp-cart-drawer__scrim {
  position: absolute; inset: 0; background: rgba(7, 11, 20, .5);
  opacity: 0; transition: opacity .22s var(--ease);
}
.mwp-cart-drawer.is-open .mwp-cart-drawer__scrim { opacity: 1; }

.mwp-cart-drawer__panel {
  position: absolute; inset-block: 0; left: 0;
  width: min(380px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform .28s var(--ease);
}
.mwp-cart-drawer.is-open .mwp-cart-drawer__panel { transform: translateX(0); }
@media (prefers-reduced-motion: reduce) {
  .mwp-cart-drawer__scrim, .mwp-cart-drawer__panel { transition: none; }
}

.mwp-cart-drawer__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-5); flex: none;
  background: var(--surface-sunken); border-block-end: 1px solid var(--border);
}
.mwp-cart-drawer__header h2 { font-size: 1.1rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.mwp-cart-drawer__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--primary-soft); color: var(--primary); border-radius: var(--radius-pill);
  font-size: .74rem; font-weight: 800;
}

.mwp-cart-drawer__status {
  margin: 0; padding: 0 var(--sp-5);
  max-height: 0; overflow: hidden; opacity: 0;
  color: #16a34a; font-weight: 700; font-size: var(--fs-sm);
  transition: max-height .2s var(--ease), opacity .2s var(--ease), padding .2s var(--ease);
}
.mwp-cart-drawer__status.is-visible { max-height: 40px; opacity: 1; padding-block: var(--sp-3); }

.mwp-cart-drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-5); }
.mwp-cart-drawer__loading { padding: var(--sp-8) 0; text-align: center; color: var(--text-secondary); }

.mwp-cart-drawer__item {
  display: grid; grid-template-columns: 72px 1fr; gap: var(--sp-3);
  padding: var(--sp-3); margin-block-end: var(--sp-2); border: 1px solid transparent;
  border-radius: var(--radius-sm); transition: background .16s var(--ease), border-color .16s var(--ease);
}
.mwp-cart-drawer__item:hover { background: var(--surface-sunken); border-color: var(--border); }
.mwp-cart-drawer__item:last-child { margin-block-end: 0; }
.mwp-cart-drawer__item-image {
  width: 72px; height: 72px; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-sunken); border: 1px solid var(--border); flex: none;
}
.mwp-cart-drawer__item-image img { width: 100%; height: 100%; object-fit: cover; }
.mwp-cart-drawer__item-name { font-weight: 700; font-size: var(--font-size-sm); color: var(--text-primary); line-height: 1.5; }
.mwp-cart-drawer__item-meta { color: var(--text-secondary); font-size: var(--font-size-xs); margin-block-start: 2px; }
.mwp-cart-drawer__item-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-block-start: var(--sp-3);
}
.mwp-cart-drawer__item-price { font-weight: 800; color: var(--text-primary); font-size: var(--font-size-md); }

.mwp-cart-drawer__qty {
  display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden;
}
.mwp-cart-drawer__qty button {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--surface-sunken); color: var(--text-primary); font-size: 1rem; font-weight: 700;
  border: 0; cursor: pointer; transition: background .14s var(--ease), color .14s var(--ease);
}
.mwp-cart-drawer__qty button:hover { background: var(--primary-soft); color: var(--primary); }
.mwp-cart-drawer__qty button:disabled { opacity: .4; cursor: not-allowed; }
.mwp-cart-drawer__qty span {
  min-width: 30px; height: 30px; display: grid; place-items: center;
  font-size: .85rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.mwp-cart-drawer__item-remove {
  color: #dc2626; font-size: .78rem; font-weight: 700; background: none; border: 0; cursor: pointer;
  padding: 4px;
}
.mwp-cart-drawer__item-remove:hover { text-decoration: underline; }
.mwp-cart-drawer__item.is-updating { opacity: .5; pointer-events: none; }

.mwp-cart-drawer__empty { padding: var(--sp-12) var(--sp-4); text-align: center; }
.mwp-cart-drawer__empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; margin-block-end: var(--sp-4);
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
}
.mwp-cart-drawer__empty h3 { font-size: 1.1rem; margin-block-end: var(--sp-2); }
.mwp-cart-drawer__empty p { color: var(--text-secondary); font-size: var(--fs-sm); margin-block-end: var(--sp-5); }

.mwp-cart-drawer__error {
  margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-4);
  background: #fef2f2; color: #b91c1c; border-radius: var(--radius-sm); font-size: var(--fs-sm);
}
:root[data-theme="dark"] .mwp-cart-drawer__error { background: #2a1414; color: #f87171; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mwp-cart-drawer__error { background: #2a1414; color: #f87171; }
}

.mwp-cart-drawer__footer {
  flex: none; padding: var(--sp-4) var(--sp-5) var(--sp-6);
  border-block-start: 1px solid var(--border); display: grid; gap: var(--sp-3);
  background: var(--surface); box-shadow: 0 -8px 20px rgba(11, 18, 32, .05);
}
.mwp-cart-drawer__subtotal {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--font-size-sm); color: var(--text-secondary); margin-block-end: var(--sp-1);
}
.mwp-cart-drawer__subtotal strong { color: var(--text-primary); font-size: var(--font-size-xl); font-weight: 800; }

/* Cart drawer CTAs: same .mwp-btn base as the rest of the site, just a
 * touch taller here since these are the two decisive actions in the
 * drawer, plus a subtle lift on hover/press consistent with the site's
 * "very light motion" rule (no scale, no bounce). */
.mwp-cart-drawer__cta {
  min-height: 44px; padding-block: 10px; font-size: .9rem;
  transition: transform .16s var(--ease), background .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.mwp-cart-drawer__cta:hover { transform: translateY(-1px); }
.mwp-cart-drawer__cta--primary { box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 28%, transparent); }
.mwp-cart-drawer__cta--primary:hover { box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 34%, transparent); }
@media (prefers-reduced-motion: reduce) {
  .mwp-cart-drawer__cta { transition: none; }
  .mwp-cart-drawer__cta:hover { transform: none; }
}

/* Scroll lock without CLS: reserve the scrollbar gutter so the page never
 * jumps when the scrollbar disappears (supported cross-browser; degrades
 * harmlessly to no-op where unsupported). */
html.mwp-cart-drawer-open { overflow: hidden; scrollbar-gutter: stable; }

@media (max-width: 480px) {
  .mwp-cart-drawer__panel { width: min(380px, 100%); }
}
