/* ═══════════════════════════════════════════
   CART DRAWER — v4
   ═══════════════════════════════════════════ */

/* Backdrop */
.wv-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1099;
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms ease, visibility 300ms ease;
}
.wv-cart-overlay--visible {
  opacity: 1;
  visibility: visible;
}

/* Drawer Shell */
.wv-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 85vw;
  max-width: 400px;
  height: 100vh;
  background: var(--wv-color-background);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 300ms ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  overflow-x: hidden;
}
.wv-cart-drawer--open {
  transform: translateX(0);
}

/* Admin bar offset */
.admin-bar .wv-cart-drawer {
  top: 46px;
  height: calc(100vh - 46px);
}
@media screen and (min-width: 783px) {
  .admin-bar .wv-cart-drawer {
    top: 32px;
    height: calc(100vh - 32px);
  }
}

/* ── Header ── */
.wv-cart-drawer__header {
  flex-shrink: 0;
  padding: 20px 24px 0;
}
.wv-cart-drawer__title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(42, 43, 20, 0.15);
}
.wv-cart-drawer__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--wv-font-primary);
  font-weight: 700;
  font-size: var(--wv-fs-h6);
  color: var(--wv-color-text-primary);
  text-transform: uppercase;
}
.wv-cart-drawer__title svg { width: 19px; height: 19px; }
.wv-cart-drawer__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  background: var(--wv-color-badge-bg);
  color: var(--wv-color-badge-text);
  font-size: var(--wv-fs-label-legal);
  font-weight: 600;
  border-radius: var(--wv-radius-pill);
  padding: 0 6px;
}
.wv-cart-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 0;
  color: var(--wv-color-text-primary);
  cursor: pointer;
}
.wv-cart-drawer__close:hover { color: var(--wv-color-text-link-hover); }

/* ── Milestone tracker (.wv-cart-drawer__nudge) ──
   Carded tracker replacing the prior thin progress bar + $-labels.
   Container box → copy line → bar (track + fill + two milestone dots)
   → labels row.
   2026-06-05 starter values flagged NEEDS DESIGNER REVIEW. */

.wv-cart-drawer__nudge {
  background: var(--wv-color-surface);
  border-radius: var(--wv-radius-sm);
  padding: 16px 18px;                              /* NEEDS DESIGNER REVIEW */
  margin-top: 8px;                                 /* breathing room below title bar */
}

.wv-cart-drawer__nudge-copy {
  /* font-* + color all covered by .wv-body global class on the element.
     Local rule = layout only. */
  margin: 0 0 12px;                                /* NEEDS DESIGNER REVIEW — gap to track */
}

.wv-cart-drawer__nudge-remaining {
  /* Inline emphasis span inside a .wv-body paragraph. The <span>
     itself carries no global typography class, so local color +
     font-weight here are not Rule 3 redeclarations — the parent
     paragraph owns family / size / line-height. */
  color: var(--wv-color-olive-dark);
  font-weight: 600;
}

.wv-cart-drawer__nudge-track {
  position: relative;
  height: 8px;
  background: var(--wv-color-background);
  border-radius: var(--wv-radius-pill);
  margin-bottom: 10px;                             /* NEEDS DESIGNER REVIEW — gap to labels */
}

.wv-cart-drawer__nudge-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--wv-color-accent);
  border-radius: var(--wv-radius-pill);
  transition: width var(--wv-transition-base);
}

.wv-cart-drawer__nudge-dot {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--wv-color-background);
  border: 1px solid var(--wv-color-surface-2);
  color: var(--wv-color-text-secondary);          /* drives glyph SVG via currentColor */
}

.wv-cart-drawer__nudge-dot--shipping {
  left: 60%;
  transform: translate(-50%, -50%);
}

.wv-cart-drawer__nudge-dot--rewards {
  left: 100%;
  transform: translate(-100%, -50%);
}

.wv-cart-drawer__nudge-dot--earned {
  background: var(--wv-color-olive-dark);
  border-color: var(--wv-color-olive-dark);
  color: var(--wv-color-text-inverse);             /* cream check on dark dot */
}

.wv-cart-drawer__nudge-glyph {
  width: 12px;
  height: 12px;
  display: block;
}

.wv-cart-drawer__nudge-labels {
  position: relative;
  min-height: 16px;
}

.wv-cart-drawer__nudge-label {
  /* font-* covered by .wv-label-small global class. Local
     text-transform + position only. Base color comes from the
     global class (--wv-color-text-secondary); --earned modifier
     overrides. */
  position: absolute;
  top: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Both labels right-justified to their respective dots — prevents
   "FREE SHIPPING" and "REWARDS COUPON" from overlapping when the
   text is wider than the gap between 60% and 100%. Labels extend
   leftward from the milestone, reading as "ending at this dot." */
.wv-cart-drawer__nudge-label:first-child {
  left: 60%;
  transform: translateX(-100%);
}

.wv-cart-drawer__nudge-label:last-child {
  left: 100%;
  transform: translateX(-100%);
}

.wv-cart-drawer__nudge-label--earned {
  color: var(--wv-color-olive-dark);
}

/* ── Content ── */
.wv-cart-drawer__content {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px;
  -webkit-overflow-scrolling: touch;
}

/* Empty State */
.wv-cart-drawer__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  text-align: center;
}
.wv-cart-drawer__empty p {
  font-family: var(--wv-font-primary);
  font-size: var(--wv-fs-body-lg);
  color: var(--wv-color-text-secondary);
  margin: 0 0 20px;
}
.wv-cart-drawer__shop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 28px;
  background: var(--wv-color-text-primary);
  color: var(--wv-color-text-inverse);
  font-family: var(--wv-font-primary);
  font-size: var(--wv-fs-body);
  font-weight: 600;
  text-transform: uppercase;
  border-radius: var(--wv-radius-pill);
  transition: background var(--wv-transition-base);
}
.wv-cart-drawer__shop-btn:hover { background: var(--wv-color-accent); }

/* ── Notices ── */
.wv-cart-drawer__notices {
  padding: 12px 0;
}
.wv-cart-drawer__notice-error {
  font-family: var(--wv-font-primary);
  font-size: var(--wv-fs-body-sm);
  line-height: 16px;
  color: var(--wv-color-accent);
  background: rgba(182, 95, 84, 0.08);
  padding: 10px 14px;
  border-radius: 6px;
  margin: 0 0 8px;
}

/* ── Line Item ── */
.wv-cart-drawer__item {
  padding: 20px 0;
  border-bottom: 1px solid rgba(42, 43, 20, 0.1);
}
.wv-cart-drawer__item:last-of-type { border-bottom: 0; }
.wv-cart-drawer__item--adding { opacity: 0.6; animation: wv-fade-in 200ms ease forwards; }
@keyframes wv-fade-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 0.6; transform: translateY(0); } }
.wv-cart-drawer__item--just-added { animation: wv-highlight 1.5s ease forwards; }
@keyframes wv-highlight { 0% { background: rgba(147, 151, 64, 0.15); } 100% { background: transparent; } }

/* Row 1: Info */
.wv-cart-drawer__item-info {
  display: flex;
  gap: 16px;
}
.wv-cart-drawer__item-image {
  position: relative;
  flex-shrink: 0;
  width: 80px;
  height: 90px; /* portrait — fits the full card-image bottle, trims bottom padding */
  background: var(--wv-color-card-bg);
  border-radius: 8px;
  overflow: hidden;
}
/* The WebP mu-plugin wraps wp_get_attachment_image output in
   <picture><source><img></picture>. display: contents on the
   picture wrapper lets the img's percentage sizing + object-fit
   reference the fixed-size container, not the picture. Same fix
   as the PDP hero containers. */
.wv-cart-drawer__item-image picture {
  display: contents;
}

.wv-cart-drawer__item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top; /* card images have bottom padding — lock top, clip bottom */
}
.wv-cart-drawer__first5-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-family: var(--wv-font-mono);
  font-size: 8px;
  font-weight: var(--wv-weight-regular);
  color: var(--wv-color-accent);
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 6px;
  border-radius: 4px;
}
.wv-cart-drawer__item-details {
  flex: 1;
  min-width: 0;
}
.wv-cart-drawer__item-name {
  font-family: var(--wv-font-primary);
  font-weight: 600;
  font-size: var(--wv-fs-body);
  line-height: 18px;
  color: var(--wv-color-text-primary);
  margin: 0 0 4px;
}
.wv-cart-drawer__item-variant {
  display: block;
  font-family: var(--wv-font-mono);
  font-size: var(--wv-fs-label-legal);
  color: var(--wv-color-text-secondary);
  margin-bottom: 4px;
}
.wv-cart-drawer__item-benefit {
  display: block;
  font-family: var(--wv-font-primary);
  font-size: var(--wv-fs-label-legal);
  color: var(--wv-color-text-secondary);
  text-transform: uppercase;
}

/* Subscribe & Save pill — mirrors the cart-page .wv-cart__practice-pill.
   Typography comes from .wv-label-small on the element. */
.wv-cart-drawer__practice-pill {
  display: inline-flex;
  align-items: center;
  background: var(--wv-color-accent);
  color: var(--wv-color-text-inverse);
  padding: 4px 10px;
  border-radius: var(--wv-radius-pill);
  margin-top: 2px;
  width: max-content;
  max-width: 100%;
}

/* Delivery cadence — plain text below the subscribe pill (no pill).
   Fixed monthly until the frequency selector ships. */
.wv-cart-drawer__delivery-meta {
  display: block;
  color: var(--wv-color-text-secondary);
  margin-top: 4px;
}

/* Row 2: Qty + Price */
.wv-cart-drawer__item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.wv-cart-drawer__qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(42, 43, 20, 0.2);
  border-radius: var(--wv-radius-pill);
  overflow: hidden;
}
.wv-cart-drawer__qty-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  font-size: var(--wv-fs-h6);
  color: var(--wv-color-text-primary);
  cursor: pointer;
}
.wv-cart-drawer__qty-btn:hover { background: rgba(42, 43, 20, 0.05); }
.wv-cart-drawer__qty-trash { color: var(--wv-color-text-secondary); }
.wv-cart-drawer__qty-trash:hover { color: var(--wv-color-accent); }
.wv-cart-drawer__qty-val {
  min-width: 28px;
  text-align: center;
  font-family: var(--wv-font-primary);
  font-size: var(--wv-fs-body);
  font-weight: 600;
  color: var(--wv-color-text-primary);
}
.wv-cart-drawer__item-price {
  font-family: var(--wv-font-primary);
  font-weight: 700;
  font-size: var(--wv-fs-body);
  color: var(--wv-color-text-primary);
  text-align: right;
}
.wv-cart-drawer__item-price-original {
  display: block;
  font-weight: 400;
  font-size: var(--wv-fs-body-sm);
  color: var(--wv-color-text-secondary);
  text-decoration: line-through;
}

/* ── You May Also Like ── */
.wv-cart-drawer__recs {
  padding: 24px 0;
  border-top: 1px solid rgba(42, 43, 20, 0.15);
}
.wv-cart-drawer__recs-title {
  font-family: var(--wv-font-primary);
  font-weight: 600;
  font-size: var(--wv-fs-body);
  color: var(--wv-color-text-primary);
  margin: 0 0 16px;
  text-transform: uppercase;
}
.wv-cart-drawer__recs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  overflow: hidden;
}
.wv-cart-drawer__rec-card {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--wv-color-card-bg);
  border: 1px solid rgba(42, 43, 20, 0.1);
  border-radius: 12px;
  overflow: hidden;
  padding: 8px;
}
/* Picture wrapper from the WebP mu-plugin — flatten so the rec-img's
   width: 100% references the rec-card flex column, not the picture. */
.wv-cart-drawer__rec-card picture {
  display: contents;
}

.wv-cart-drawer__rec-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  background: var(--wv-color-card-bg);
}
.wv-cart-drawer__rec-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0 0;
}
.wv-cart-drawer__rec-name {
  display: block;
  font-family: var(--wv-font-primary);
  font-weight: 600;
  font-size: var(--wv-fs-body-sm);
  line-height: 15px;
  color: var(--wv-color-text-primary);
  margin-bottom: 2px;
}
.wv-cart-drawer__rec-benefit {
  display: block;
  font-family: var(--wv-font-primary);
  font-size: 10px;
  color: var(--wv-color-text-secondary);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.wv-cart-drawer__rec-price {
  font-family: var(--wv-font-primary);
  font-weight: 600;
  font-size: var(--wv-fs-body-sm);
  color: var(--wv-color-text-primary);
  margin-top: auto;
}
.wv-cart-drawer__rec-add {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wv-color-accent);
  color: var(--wv-color-card-bg);
  font-size: var(--wv-fs-body-lg);
  font-weight: 700;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--wv-transition-base);
}
.wv-cart-drawer__rec-add:hover {
  background: var(--wv-color-text-primary);
}

/* ── Footer ── */
.wv-cart-drawer__footer {
  flex-shrink: 0;
  padding: 16px 24px 24px;
  border-top: 1px solid rgba(42, 43, 20, 0.15);
  background: var(--wv-color-background);
}
.wv-cart-drawer__totals { margin-bottom: 16px; }
.wv-cart-drawer__subtotal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--wv-font-primary);
  font-weight: 400;
  font-size: var(--wv-fs-body);
  color: var(--wv-color-text-primary);
  margin-bottom: 6px;
}
.wv-cart-drawer__total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(42, 43, 20, 0.15);
  margin-top: 6px;
}
.wv-cart-drawer__total-label {
  font-family: var(--wv-font-primary);
  font-weight: 700;
  font-size: var(--wv-fs-body);
  color: var(--wv-color-text-primary);
  text-transform: uppercase;
}
.wv-cart-drawer__total-value {
  font-family: var(--wv-font-primary);
  font-weight: 700;
  font-size: var(--wv-fs-body-lg);
  color: var(--wv-color-text-primary);
}
.wv-cart-drawer__checkout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 48px;
  background: var(--wv-color-text-primary);
  color: var(--wv-color-text-inverse);
  font-family: var(--wv-font-primary);
  font-weight: 700;
  font-size: var(--wv-fs-body);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-decoration: none;
  border: 0;
  transition: background var(--wv-transition-base);
}
.wv-cart-drawer__checkout:hover {
  background: var(--wv-color-accent);
  color: var(--wv-color-text-inverse);
}

/* ── Responsive — tablet+ ── */
@media (min-width: 768px) {
  .wv-cart-drawer { width: 400px; }
  .wv-cart-drawer__qty-btn { width: 36px; height: 36px; }
}

/* ── Stale-cart validation (Phase A) — chips + summary ──────────
   Chip typography comes from .wv-label-small in the markup; these rules
   set layout + the tokenized colors only. */
.wv-cart-drawer__stale-chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: var(--wv-radius-sm);
}
.wv-cart-drawer__stale-chip--gone,
.wv-cart-drawer__stale-chip--oos {
  background: var(--wv-color-warning);
  color: var(--wv-color-text-inverse);
}
.wv-cart-drawer__stale-chip--low_stock {
  background: var(--wv-color-amber);
  color: var(--wv-color-text-primary);
}
.wv-cart-drawer__stale-chip--price_up {
  background: var(--wv-color-surface);
  color: var(--wv-color-text-secondary);
}

/* gone/OOS lines stay visible but dimmed, with their existing Remove CTA. */
.wv-cart-drawer__item--stale-remove {
  opacity: 0.6;
}

/* Sticky "X items need attention" banner at the top of the drawer body. */
.wv-cart-drawer__stale-summary {
  position: sticky;
  top: 0;
  z-index: 2;
  display: block;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--wv-radius-sm);
  background: var(--wv-color-amber);
  color: var(--wv-color-text-primary);
}
.wv-cart-drawer__stale-summary a {
  color: inherit;
  text-decoration: underline;
}
