/* =============================================================
   CART DRAWER — Phase 3A
   Apple-style slide-in mini-cart from right
   ============================================================= */

/* Backdrop */
.wcr-cart-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 9998;
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1);  /* 5.18.0 */
}
.wcr-cart-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer shell */
.wcr-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 400px;
  background: var(--wc-bg);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);  /* 5.18.0: 0.3s → 0.32s Apple easeOutExpo */
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
}
.wcr-cart-drawer[hidden] {
  display: none;
}
.wcr-cart-drawer.is-open {
  transform: translateX(0);
}

/* Header */
.wcr-cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--wc-border);
  flex-shrink: 0;
}
.wcr-cart-drawer-title {
  font-size: var(--wc-fs-lg);
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wcr-cart-drawer-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--wc-fg);
  color: var(--wc-bg);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
}
.wcr-cart-drawer-close {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  color: var(--wc-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.18s cubic-bezier(0.16, 1, 0.3, 1);  /* 5.18.0 */
}
.wcr-cart-drawer-close:hover {
  background: var(--wc-surface-2);
}

/* Body (scrollable) */
.wcr-cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  -webkit-overflow-scrolling: touch;
}

/* Empty state */
.wcr-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60vh;
  color: var(--wc-muted);
}
.wcr-cart-empty p {
  font-size: var(--wc-fs-lg);
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--wc-fg);
}
.wcr-cart-empty small {
  font-size: var(--wc-fs-sm);
}

/* List */
.wcr-cart-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.wcr-cart-item {
  display: grid;
  grid-template-columns: 64px 1fr 24px;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--wc-border);
  align-items: flex-start;
}
.wcr-cart-item:last-child {
  border-bottom: 0;
}

/* Image */
.wcr-cart-item-img {
  width: 64px;
  height: 64px;
  background: var(--wc-surface-2);
  border-radius: var(--wc-radius-sm);
  overflow: hidden;
}
.wcr-cart-item-img a {
  display: block;
  width: 100%;
  height: 100%;
}
.wcr-cart-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Item body */
.wcr-cart-item-body {
  min-width: 0;
}
.wcr-cart-item-title {
  font-size: var(--wc-fs-sm);
  font-weight: 500;
  color: var(--wc-fg);
  text-decoration: none;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.wcr-cart-item-title:hover {
  color: var(--wc-link);
}
.wcr-cart-item-price {
  font-size: var(--wc-fs-sm);
  color: var(--wc-fg-2);
  font-weight: 500;
  margin-bottom: 8px;
}

.wcr-cart-item-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--wc-border);
  border-radius: 6px;
  overflow: hidden;
}
.wcr-cart-qty-btn {
  width: 28px;
  height: 28px;
  background: var(--wc-bg);
  border: 0;
  font-size: 16px;
  cursor: pointer;
  color: var(--wc-fg);
}
.wcr-cart-qty-btn:hover {
  background: var(--wc-surface-2);
}
.wcr-cart-qty-value {
  min-width: 32px;
  text-align: center;
  font-size: var(--wc-fs-sm);
  font-weight: 500;
}

/* Remove button */
.wcr-cart-item-remove {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--wc-muted);
  border-radius: 4px;
  transition: color 0.18s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.18s cubic-bezier(0.16, 1, 0.3, 1);  /* 5.18.0 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wcr-cart-item-remove:hover {
  color: #c5221f;
  background: rgba(255, 59, 48, 0.1);
}

/* Footer */
.wcr-cart-drawer-footer {
  flex-shrink: 0;
  padding: 20px 24px;
  border-top: 1px solid var(--wc-border);
  background: var(--wc-bg);
}
.wcr-cart-drawer-footer[hidden] {
  display: none;
}
.wcr-cart-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.wcr-cart-subtotal span {
  font-size: var(--wc-fs-base);
  color: var(--wc-fg);
}
.wcr-cart-subtotal strong {
  font-size: var(--wc-fs-xl);
  font-weight: 600;
  color: var(--wc-fg);
  letter-spacing: -0.01em;
}
.wcr-cart-note {
  font-size: 12px;
  color: var(--wc-muted);
  margin: 0 0 16px;
}
.wcr-cart-checkout {
  display: block;
  width: 100%;
  height: 48px;
  line-height: 48px;
  text-align: center;
  background: var(--wc-fg);
  color: var(--wc-bg);
  font-size: var(--wc-fs-base);
  font-weight: 500;
  border-radius: 999px;
  text-decoration: none;
  margin-bottom: 8px;
  transition: background-color 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.12s cubic-bezier(0.16, 1, 0.3, 1);  /* 5.18.0 */
}
.wcr-cart-checkout:hover {
  background: #000;
  transform: translateY(-1px);
  color: var(--wc-bg);
}
.wcr-cart-view {
  display: block;
  width: 100%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: var(--wc-link);
  font-size: var(--wc-fs-sm);
  text-decoration: none;
}
.wcr-cart-view:hover {
  text-decoration: underline;
}

/* Cart icon in header (for nav trigger) */
.wcr-cart-trigger {
  position: relative;
  background: transparent;
  border: 0;
  padding: 8px;
  cursor: pointer;
  color: inherit;
  border-radius: 8px;
  transition: background-color 0.18s cubic-bezier(0.16, 1, 0.3, 1);  /* 5.18.0 */
}
.wcr-cart-trigger:hover {
  background: rgba(0, 0, 0, 0.05);
}
.wcr-cart-trigger .count {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--wc-fg);
  color: var(--wc-bg);
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Loading state */
.wcr-cart-drawer.is-loading .wcr-cart-drawer-body {
  opacity: 0.5;
  pointer-events: none;
}

/* Animations */
@keyframes wcr-cart-item-add {
  0% {
    opacity: 0;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}
.wcr-cart-item.is-new {
  animation: wcr-cart-item-add 0.32s cubic-bezier(0.16, 1, 0.3, 1) forwards;  /* 5.18.0 */
}

/* Mobile */
@media (max-width: 480px) {
  .wcr-cart-drawer {
    max-width: 100%;
  }
}

/* Prevent body scroll when open */
body.wcr-cart-open {
  overflow: hidden;
}