/*
 * WP Nav Pro — Mini Cart Styles  v0.2.0
 *
 * Desktop: dropdown panel anchored below cart icon (position: absolute on header,
 *          position: fixed when used with sticky header).
 * Mobile:  full-height fixed sheet sliding up from bottom.
 *
 * All colours use --wnp-* custom properties set by the PHP asset class.
 */

/* ════════════════════════════════════════════════════════════════════
   SHARED — items, footer, empty state (used in both desktop + mobile)
════════════════════════════════════════════════════════════════════ */

/* Loading / skeleton state on the wrapper */
.wnp-cart-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Shipping bar ─────────────────────────────────────────────── */
.wnp-cart-ship {
  padding: 9px 12px;
  background: var(--wnp-surface-dim, #F2F4F6);
  border-radius: 10px;
  margin: 10px 16px 0;
  flex-shrink: 0;
}
.wnp-cart-ship__label {
  font-size: 11px;
  color: var(--wnp-on-surface-variant);
  margin-bottom: 5px;
  line-height: 1.4;
}
.wnp-cart-ship__label strong { color: var(--wnp-primary); }
.wnp-cart-ship__track {
  height: 4px;
  background: var(--wnp-outline-variant, #E7E0EC);
  border-radius: 2px;
  overflow: hidden;
}
.wnp-cart-ship__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--wnp-primary), #2A6BAA);
  border-radius: 2px;
  transition: width 600ms var(--wnp-ease);
}

/* ─── Item list ────────────────────────────────────────────────── */
.wnp-cart-items {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--wnp-outline) transparent;
  /* Fade bottom edge — hints scrollability */
  mask-image: linear-gradient(to bottom, black calc(100% - 32px), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 32px), transparent 100%);
}
.wnp-cart-items::-webkit-scrollbar       { width: 3px; }
.wnp-cart-items::-webkit-scrollbar-thumb { background: var(--wnp-outline); border-radius: 2px; }

/* ─── Single item row ──────────────────────────────────────────── */
.wnp-cart-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  position: relative;
  transition: background var(--wnp-dur-md, 280ms) var(--wnp-ease);
}
.wnp-cart-item:hover {
  background: var(--wnp-surface-dim, #F2F4F6);
}

/* Thumbnail */
.wnp-cart-item__img-wrap {
  width: 54px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  display: block;
  background: var(--wnp-surface-dim);
}
.wnp-cart-item__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.wnp-cart-item__img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wnp-on-surface-variant);
}
.wnp-cart-item__img-placeholder svg { width: 22px; height: 22px; }

/* Body */
.wnp-cart-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1px 0;
}
.wnp-cart-item__name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--wnp-on-surface);
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 22px;
  line-height: 1.3;
}
.wnp-cart-item__name:hover { color: var(--wnp-primary); }
.wnp-cart-item__meta {
  font-size: 10.5px;
  color: var(--wnp-on-surface-variant);
  margin-top: 2px;
  display: block;
}
.wnp-cart-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.wnp-cart-item__price {
  font-size: 13px;
  font-weight: 600;
  color: var(--wnp-primary);
}

/* Quantity badge (read-only — edits happen on cart page) */
.wnp-cart-item__qty-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--wnp-on-surface-variant);
  background: var(--wnp-surface-dim, #F2F4F6);
  padding: 2px 8px;
  border-radius: var(--wnp-shape-full);
  white-space: nowrap;
}

/* Remove button */
.wnp-cart-item__remove {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 20px;
  height: 20px;
  border-radius: var(--wnp-shape-full);
  border: none;
  background: var(--wnp-surface-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wnp-on-surface-variant);
  transition:
    background var(--wnp-dur-md) var(--wnp-ease),
    color var(--wnp-dur-md) var(--wnp-ease);
}
.wnp-cart-item__remove:hover {
  background: #FEE2E2;
  color: #DC2626;
}
.wnp-cart-item__remove svg { width: 9px; height: 9px; }

/* Removing animation */
.wnp-cart-item.wnp-removing {
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 300ms var(--wnp-ease), transform 300ms var(--wnp-ease);
  pointer-events: none;
}

/* Divider */
.wnp-cart-divider {
  height: 1px;
  background: var(--wnp-outline-variant, #E7E0EC);
  margin: 0 16px;
}

/* ─── Footer ───────────────────────────────────────────────────── */
.wnp-cart-footer {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--wnp-outline-variant, #E7E0EC);
  flex-shrink: 0;
  background: white;
}
.wnp-cart-subtotal {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 3px;
}
.wnp-cart-subtotal__label  { font-size: 13px; color: var(--wnp-on-surface-variant); }
.wnp-cart-subtotal__amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--wnp-on-surface);
}
.wnp-cart-tax-note { font-size: 10px; color: var(--wnp-on-surface-variant); margin-bottom: 12px; }

.wnp-cart-btn-checkout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 13px 16px;
  background: var(--wnp-primary);
  color: var(--wnp-on-primary);
  border-radius: var(--wnp-btn-radius, var(--wnp-shape-full));
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  margin-bottom: 8px;
  min-height: 50px;
  transition: background var(--wnp-dur-md) var(--wnp-ease);
}
.wnp-cart-btn-checkout:hover {
  background: var(--wnp-checkout-hover-bg, #142e4a);
  color: var(--wnp-checkout-hover-color, var(--wnp-on-primary));
}
.wnp-cart-btn-checkout svg { width: 15px; height: 15px; flex-shrink: 0; }

.wnp-cart-btn-view {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 16px;
  background: transparent;
  color: var(--wnp-primary);
  border-radius: var(--wnp-btn-radius, var(--wnp-shape-full));
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--wnp-primary);
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
  transition: background var(--wnp-dur-md) var(--wnp-ease);
}
.wnp-cart-btn-view:hover { background: var(--wnp-primary-container); }

/* ─── Empty state ──────────────────────────────────────────────── */
.wnp-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  flex: 1;
}
.wnp-cart-empty__icon {
  width: 64px;
  height: 64px;
  background: var(--wnp-surface-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--wnp-on-surface-variant);
}
.wnp-cart-empty__icon svg { width: 28px; height: 28px; }
.wnp-cart-empty__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--wnp-on-surface);
  margin-bottom: 6px;
}
.wnp-cart-empty__text {
  font-size: 13px;
  color: var(--wnp-on-surface-variant);
  line-height: 1.5;
}
.wnp-cart-btn-shop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 10px 22px;
  background: var(--wnp-primary);
  color: var(--wnp-on-primary);
  border-radius: var(--wnp-shape-full);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--wnp-dur-md) var(--wnp-ease);
}
.wnp-cart-btn-shop:hover {
  background: var(--wnp-checkout-hover-bg, var(--wnp-primary-dark, #142e4a));
  color: var(--wnp-checkout-hover-color, var(--wnp-on-primary));
}
.wnp-cart-btn-shop svg { width: 14px; height: 14px; }


/* ════════════════════════════════════════════════════════════════════
   DESKTOP DROPDOWN
════════════════════════════════════════════════════════════════════ */

.wnp-mini-cart--desktop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 380px;
  max-height: 540px;
  background: white;
  border-radius: var(--wnp-shape-large);
  border: 1px solid var(--wnp-outline-variant);
  box-shadow: var(--wnp-elev-3);
  z-index: calc(var(--wnp-z-index) + 5);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Hidden state */
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition:
    opacity var(--wnp-dur-md) var(--wnp-ease),
    transform var(--wnp-dur-md) var(--wnp-ease);
}

/* Arrow pointer */
.wnp-mini-cart--desktop::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: white;
  border-left: 1px solid var(--wnp-outline-variant);
  border-top: 1px solid var(--wnp-outline-variant);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

/* Open state */
.wnp-mini-cart--desktop.wnp-mc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Desktop header bar */
.wnp-mini-cart__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--wnp-outline-variant);
  flex-shrink: 0;
}
.wnp-mini-cart__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--wnp-on-surface);
}
.wnp-mini-cart__close {
  width: 28px;
  height: 28px;
  border-radius: var(--wnp-shape-full);
  border: none;
  background: var(--wnp-surface-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wnp-on-surface-variant);
  transition: background var(--wnp-dur-md) var(--wnp-ease), transform 200ms var(--wnp-ease);
}
.wnp-mini-cart__close:hover { background: var(--wnp-outline-variant); transform: rotate(90deg); }
.wnp-mini-cart__close svg { width: 14px; height: 14px; }

/* Desktop cart icon wrapper — needs position: relative */
.wnp-cart-btn {
  position: relative;
}

/* Cart icon active bg when dropdown open */
.wnp-cart-btn.wnp-mc-open .wnp-icon-btn {
  background: var(--wnp-primary-container);
}

/* Scroll is handled inside .wnp-cart-items */
.wnp-mini-cart--desktop .wnp-cart-inner {
  overflow: hidden;
  max-height: calc(540px - 52px); /* 540 total - header */
}

/* Desktop shows items on their natural height — no forced scroll mask unless overflow */
.wnp-mini-cart--desktop .wnp-cart-items {
  max-height: 300px;
}

/* ════════════════════════════════════════════════════════════════════
   MOBILE SCRIM
════════════════════════════════════════════════════════════════════ */

.wnp-cart-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: calc(var(--wnp-z-index) + 15);
  pointer-events: none;
  visibility: hidden;
  transition:
    background var(--wnp-dur-md) var(--wnp-ease),
    visibility 0s var(--wnp-dur-md);
}
.wnp-cart-scrim.wnp-cs-open {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: all;
  visibility: visible;
  transition:
    background var(--wnp-dur-md) var(--wnp-ease),
    visibility 0s 0s;
}

/* ════════════════════════════════════════════════════════════════════
   MOBILE FULL-SCREEN SHEET
════════════════════════════════════════════════════════════════════ */

.wnp-cart-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: white;
  z-index: calc(var(--wnp-z-index) + 20);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Default: slide up from bottom (mobile) */
  transform: translateY(100%);
  transition:
    transform var(--wnp-dur-lg) var(--wnp-ease),
    visibility 0s var(--wnp-dur-lg);  /* delay visibility change until slide is done */
  will-change: transform;

  /* Prevents GPU compositing from painting the off-screen sheet
     into the viewport during fast scroll */
  visibility: hidden;
  clip-path: inset(0);  /* creates a stacking context so transform can't bleed */
}

.wnp-cart-sheet.wnp-cs-open {
  transform: translateY(0);
  visibility: visible;
  transition:
    transform var(--wnp-dur-lg) var(--wnp-ease),
    visibility 0s 0s;  /* visibility becomes visible immediately on open */
}

/* Sheet top bar */
.wnp-cart-sheet__topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--wnp-outline-variant);
  flex-shrink: 0;
  background: white;
}

.wnp-cart-sheet__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--wnp-on-surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wnp-cart-sheet__count {
  background: var(--wnp-primary-container);
  color: var(--wnp-primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--wnp-shape-full);
}

.wnp-cart-sheet__close {
  width: 34px;
  height: 34px;
  border-radius: var(--wnp-shape-full);
  border: none;
  background: var(--wnp-surface-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wnp-on-surface);
  transition: background var(--wnp-dur-md) var(--wnp-ease), transform 200ms var(--wnp-ease);
}
.wnp-cart-sheet__close:hover { background: var(--wnp-outline-variant); transform: rotate(90deg); }
.wnp-cart-sheet__close svg { width: 16px; height: 16px; }

/* Sheet cart inner fills remaining height */
.wnp-cart-sheet .wnp-cart-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Mobile items scroll freely, footer always pinned */
.wnp-cart-sheet .wnp-cart-items {
  flex: 1;
}

/* Safe-area padding for home indicator */
.wnp-cart-sheet .wnp-cart-footer {
  padding-bottom: max(18px, env(safe-area-inset-bottom, 18px));
}

/* ─── Responsive: only show desktop on desktop, sheet on mobile ─── */
@media ( min-width: 769px ) {
  .wnp-cart-sheet  { display: none !important; }
  .wnp-cart-scrim  { display: none !important; }
}

@media ( max-width: 768px ) {
  .wnp-mini-cart--desktop { display: none !important; }
}

/* ─── Reduced motion ──────────────────────────────────────────── */
@media ( prefers-reduced-motion: reduce ) {
  .wnp-mini-cart--desktop,
  .wnp-cart-sheet,
  .wnp-cart-scrim {
    transition-duration: 10ms !important;
  }
  .wnp-cart-item.wnp-removing {
    transition-duration: 10ms !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   OFF-CANVAS CART PANEL
   Activated by body.wnp-cart-offcanvas (set via JS from cfg.cartStyle).
   Desktop: 400px right-side slide-in panel.
   Mobile:  unchanged full-screen sheet.
════════════════════════════════════════════════════════════════════ */

/* Show sheet on desktop in off-canvas mode (overrides display:none) */
@media ( min-width: 769px ) {

  .wnp-cart-offcanvas .wnp-cart-sheet {
    display: flex !important;

    /* Right-side panel geometry */
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 400px;
    max-width: 90vw;

    /* Slide from right instead of bottom */
    transform: translateX(100%) !important;
    transition: transform var(--wnp-dur-lg) var(--wnp-ease) !important;

    border-radius: 0;
    box-shadow: -8px 0 40px rgba(0,0,0,.15);
  }

  .wnp-cart-offcanvas .wnp-cart-sheet.wnp-cs-open {
    transform: translateX(0) !important;
  }

  /* Show scrim on desktop too */
  .wnp-cart-offcanvas .wnp-cart-scrim {
    display: block !important;
  }

  /* Hide dropdown — off-canvas replaces it */
  .wnp-cart-offcanvas .wnp-mini-cart--desktop {
    display: none !important;
  }
}

/* ════════════════════════════════════════════════════════════════════
   RTL — Mini Cart
════════════════════════════════════════════════════════════════════ */

/* Item layout: flip row for RTL */
[dir="rtl"] .wnp-cart-item,
.wnp-rtl    .wnp-cart-item {
  flex-direction: row-reverse;
}

/* Remove button: move to left side in RTL */
[dir="rtl"] .wnp-cart-item__remove,
.wnp-rtl    .wnp-cart-item__remove {
  right: auto;
  left: 12px;
}

/* Item name: padding flips */
[dir="rtl"] .wnp-cart-item__name,
.wnp-rtl    .wnp-cart-item__name {
  padding-right: 0;
  padding-left: 22px;
}

/* Checkout button icon */
[dir="rtl"] .wnp-cart-btn-checkout svg,
.wnp-rtl    .wnp-cart-btn-checkout svg {
  order: 1;
}

/* Shop button arrow */
[dir="rtl"] .wnp-cart-btn-shop svg,
.wnp-rtl    .wnp-cart-btn-shop svg {
  transform: scaleX(-1);
}

/* Off-canvas sheet: slide from left in RTL */
@media ( min-width: 769px ) {
  [dir="rtl"] .wnp-cart-offcanvas .wnp-cart-sheet,
  .wnp-rtl    .wnp-cart-offcanvas .wnp-cart-sheet {
    right: auto;
    left: 0;
    transform: translateX(-100%) !important;
    box-shadow: 8px 0 40px rgba(0,0,0,.15);
  }

  [dir="rtl"] .wnp-cart-offcanvas .wnp-cart-sheet.wnp-cs-open,
  .wnp-rtl    .wnp-cart-offcanvas .wnp-cart-sheet.wnp-cs-open {
    transform: translateX(0) !important;
  }
}

/* Mobile full-screen sheet: slide from right in RTL (opposite of LTR bottom) */
/* Full-screen sheet direction doesn't apply — it covers full viewport */

/* ─── ACSS 3 & 4 isolation ──────────────────────────────────────────────── */
/* Checkout / view cart: full width, undo ACSS overrides */
.wnp-cart-footer .wnp-cart-btn-checkout,
.wnp-cart-footer .wnp-cart-btn-view {
  min-inline-size: unset;
  inline-size: 100%;
  border-radius: var(--wnp-btn-radius, var(--wnp-shape-full));
  border-width: 0;
  text-transform: none;
  letter-spacing: normal;
}

/* Browse Products (empty cart): auto width, centred */
.wnp-cart-empty .wnp-cart-btn-shop {
  min-inline-size: unset;
  inline-size: auto;
  border-radius: var(--wnp-btn-radius, var(--wnp-shape-full));
  border-width: 0;
  text-transform: none;
  letter-spacing: normal;
}
