/* ============================================================
   Header cart icon + slide-in mini cart
   ============================================================
   Enqueued only when Appearance → Theme Presets → Header cart is on and
   WooCommerce is active (see wpr_cart_drawer_assets), so it costs nothing by
   default. Token-only, so it follows the active palette and font pair.

   Note this file loads on EVERY page when enabled, unlike woocommerce.css
   which is shop-pages-only — the header is site-wide, so the drawer has to be
   too, and it cannot rely on anything in that stylesheet.
   ============================================================ */

/* ---- header icon ---- */
.wpr-cart{
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  width:42px; height:42px; border-radius:10px;
  border:1px solid var(--line); background:var(--ink2); color:var(--cream);
  cursor:pointer; padding:0; flex-shrink:0;
  transition:border-color .15s ease, color .15s ease;
}
.wpr-cart:hover{ border-color:var(--accent); color:var(--accent-dk); }
.wpr-cart:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.wpr-cart svg{ width:21px; height:21px; }

/* The badge sits on the icon, so it needs a fill that always contrasts with
   its own label rather than with the page. */
.wpr-cart__count{
  position:absolute; top:-5px; right:-5px;
  min-width:19px; height:19px; padding:0 5px; border-radius:999px;
  background:var(--accent2); color:var(--on-accent2);
  font-family:var(--sans); font-size:11px; font-weight:700; line-height:19px;
  text-align:center; box-shadow:0 0 0 2px var(--ink);
}
.wpr-cart__count[hidden]{ display:none; }

/* ---- drawer ---- */
.wpr-cartdrawer{ position:fixed; inset:0; z-index:9999; }
.wpr-cartdrawer[hidden]{ display:none; }
.wpr-cartdrawer__backdrop{
  position:absolute; inset:0; background:rgba(0,0,0,.42);
  opacity:0; transition:opacity .28s ease;
}
.wpr-cartdrawer__panel{
  position:absolute; top:0; right:0; height:100%;
  width:min(420px, 100vw);
  display:flex; flex-direction:column;
  background:var(--ink); border-left:1px solid var(--line);
  box-shadow:-18px 0 44px -20px rgba(0,0,0,.28);
  transform:translateX(100%); transition:transform .28s cubic-bezier(.22,1,.36,1);
}
/* is-open is added a frame after `hidden` is removed, so the panel has a
   position to animate FROM. Toggling both at once renders it already open. */
.wpr-cartdrawer.is-open .wpr-cartdrawer__backdrop{ opacity:1; }
.wpr-cartdrawer.is-open .wpr-cartdrawer__panel{ transform:translateX(0); }

.wpr-cartdrawer__head{
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  padding:20px 22px; border-bottom:1px solid var(--line); flex-shrink:0;
}
.wpr-cartdrawer__title{
  margin:0; font-family:var(--serif); font-weight:400; color:var(--cream);
  font-size:calc(var(--ts,1) * 21px); letter-spacing:-0.01em;
}
.wpr-cartdrawer__close{
  display:inline-flex; align-items:center; justify-content:center;
  width:36px; height:36px; border-radius:10px; flex-shrink:0;
  border:1px solid var(--line); background:var(--ink2); color:var(--cream); cursor:pointer;
}
.wpr-cartdrawer__close:hover{ border-color:var(--accent); color:var(--accent-dk); }
.wpr-cartdrawer__close:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; }
.wpr-cartdrawer__body{ flex:1; overflow-y:auto; padding:20px 22px 26px; }

/* ---- mini cart contents ----
   Woo's mini-cart markup, mapped onto theme tokens. Scoped inside the drawer so
   it cannot affect a mini-cart widget placed elsewhere. */
.wpr-cartdrawer .woocommerce-mini-cart{ list-style:none; margin:0; padding:0; }
/* Woo's row is <a.remove> + <a>(img + name) + <span.quantity>, so the image is
   NOT a child of the row — it is nested inside the product link. Grid placement
   on the img therefore does nothing; the link itself has to be the flex row.
   The remove button stays absolutely positioned (Woo's own default) with the
   row reserving right padding for it. */
/* The row selector carries ul.product_list_widget and li deliberately.
   WooCommerce's own sheet has `.woocommerce ul.cart_list li` at (0,2,2), which
   out-specifies a plain `.wpr-cartdrawer .woocommerce-mini-cart-item` at
   (0,2,0) and reset padding to `4px 0`. That took away the right-hand gutter
   this row reserves for the remove button, so a product name long enough to
   fill the row ran underneath it. (0,3,2) wins it back. */
.wpr-cartdrawer ul.product_list_widget li.woocommerce-mini-cart-item{
  position:relative; display:block;
  padding:16px 34px 16px 0; margin:0;
  border-bottom:1px solid var(--line);
}
.wpr-cartdrawer .woocommerce-mini-cart-item > a:not(.remove){
  display:flex; align-items:center; gap:12px;
  color:var(--cream); text-decoration:none; font-weight:600; font-size:15px; line-height:1.4;
  /* Belt as well as braces: a flex item will not shrink below its content
     without this, so a long unbroken name would overflow the row even with
     the gutter above restored. */
  min-width:0; overflow-wrap:anywhere;
}
.wpr-cartdrawer .woocommerce-mini-cart-item > a:not(.remove):hover{ color:var(--accent-dk); }
.wpr-cartdrawer .woocommerce-mini-cart-item > a:not(.remove) img{
  width:56px; height:56px; object-fit:cover; border-radius:10px;
  flex-shrink:0; margin:0; float:none;
}
.wpr-cartdrawer .woocommerce-mini-cart-item .quantity{
  display:block; margin:6px 0 0 68px; color:var(--dim); font-size:14px;
}
/* The one place this sheet needs !important: WooCommerce paints a.remove
   `color:var(--wc-red)!important`, and nothing but !important beats that. The
   result was a bare red x on a chip the theme had already styled. */
.wpr-cartdrawer .woocommerce-mini-cart-item .remove_from_cart_button{
  position:absolute; top:16px; right:0; left:auto; margin:0;
  width:26px; height:26px; border-radius:999px;
  display:inline-flex; align-items:center; justify-content:center;
  background:var(--ink3); color:var(--dim)!important; font-size:15px; text-decoration:none;
  line-height:1; font-weight:400;
}
.wpr-cartdrawer .woocommerce-mini-cart-item .remove_from_cart_button:hover{
  background:var(--accent2); color:var(--on-accent2)!important;
}
.wpr-cartdrawer .woocommerce-mini-cart__total{
  display:flex; align-items:baseline; justify-content:space-between; gap:14px;
  margin:20px 0 0; padding-top:18px; border-top:1px solid var(--line);
  font-size:15px; color:var(--dim);
}
.wpr-cartdrawer .woocommerce-mini-cart__total strong{ color:var(--cream); font-weight:600; }
.wpr-cartdrawer .woocommerce-mini-cart__total .amount{
  font-family:var(--serif); font-size:calc(var(--ts,1) * 22px); color:var(--cream);
}
.wpr-cartdrawer .woocommerce-mini-cart__buttons{
  display:flex; flex-direction:column; gap:10px; margin:20px 0 0; padding:0;
}
/* Both mini-cart buttons are <a>; the first is "View cart" (quieter) and the
   checkout one is the primary action. */
.wpr-cartdrawer .woocommerce-mini-cart__buttons a{
  display:inline-flex; align-items:center; justify-content:center;
  padding:14px 24px; border-radius:999px; border:1px solid var(--line);
  background:transparent; color:var(--cream); text-decoration:none;
  font-family:var(--sans); font-weight:600; font-size:calc(var(--ts,1) * 15px); line-height:1;
}
.wpr-cartdrawer .woocommerce-mini-cart__buttons a:hover{ border-color:var(--cream); }
.wpr-cartdrawer .woocommerce-mini-cart__buttons a.checkout{
  background:var(--accent2); color:var(--on-accent2); border-color:transparent;
  box-shadow:0 8px 18px -12px var(--accent2-dk);
}
.wpr-cartdrawer .woocommerce-mini-cart__buttons a.checkout:hover{ background:var(--accent2-dk); }
.wpr-cartdrawer .woocommerce-mini-cart__empty-message{
  color:var(--dim); font-size:15px; margin:0;
}

@media (max-width:520px){
  .wpr-cartdrawer__panel{ width:100vw; }
}

/* The panel is a large moving surface; honour the same opt-out the rest of the
   theme's motion respects. */
@media (prefers-reduced-motion: reduce){
  .wpr-cartdrawer__panel, .wpr-cartdrawer__backdrop{ transition:none; }
}
