/* Cart drawer (markup is injected by js/cart.js on every page).
   Also defines the quantity stepper (.qty), which the shop page reuses. */

/* ---------- Quantity stepper ----------
   Each button is a full 44 x 44 px touch target. Negative margins keep the pill as
   slim as it looks (--bleed is how far the target reaches past the drawn circle),
   and the hover circle is drawn by ::before at the visible size. */
.qty {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  height: 48px; padding: 0 4px;
  --bleed: 2px;
}
.qty button {
  position: relative; z-index: 0; flex: none;
  width: 44px; height: 44px; margin: calc(var(--bleed) * -1); padding: 0;
  font-size: 18px; font-weight: 300; line-height: 1; color: var(--text);
  transition: color 0.3s;
}
.qty button::before {
  content: ""; position: absolute; inset: var(--bleed); z-index: -1;
  border-radius: 50%; transition: background 0.3s;
}
.qty button:hover:not(:disabled) { color: var(--gold-light); }
.qty button:hover:not(:disabled)::before { background: var(--bg-raised-2); }
.qty button:disabled { color: var(--text-dim); cursor: not-allowed; }
.qty button:focus-visible { outline: none; }   /* the ring goes round the drawn circle, not the larger target */
.qty button:focus-visible::before { outline: 1px solid var(--pop); outline-offset: 1px; }
.qty output { min-width: 28px; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; pointer-events: none; }
.qty-sm { height: 36px; padding: 0 2px; --bleed: 7px; }
.qty-sm button { font-size: 16px; }
.qty-sm output { min-width: 22px; font-size: 14px; }

/* ---------- Drawer ---------- */
html.cart-open { overflow: hidden; }
/* With the page locked, <body> must not turn into a scroll box of its own (base.css
   gives it overflow-x: hidden): that would un-stick every position: sticky element
   behind the drawer, so the disassembly would vanish and the shop gallery jump. */
html.cart-open body { overflow: visible; padding-right: var(--cart-scrollbar, 0px); }
html.cart-open .nav { right: var(--cart-scrollbar, 0px); --nav-width: calc(100% - var(--cart-scrollbar, 0px)); }

.cart {
  position: fixed; inset: 0; z-index: 100;
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear 0.5s;
}
.cart.is-open { visibility: visible; pointer-events: auto; transition-delay: 0s; }
.cart-backdrop {
  position: absolute; inset: 0; background: rgba(4, 4, 5, 0.7);
  opacity: 0; transition: opacity 0.5s var(--ease-out);
}
.cart.is-open .cart-backdrop { opacity: 1; }
.cart-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(440px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg-raised); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform 0.5s var(--ease-out);
  outline: none; overscroll-behavior: contain;
}
.cart.is-open .cart-panel { transform: none; }

.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 20px 22px 28px; border-bottom: 1px solid var(--line);
}
.cart-title {
  margin: 0; font-size: 12px; font-weight: 500; letter-spacing: var(--tracking-wide); text-transform: uppercase;
}
.cart-title-count { color: var(--text-muted); letter-spacing: 0.08em; margin-left: 4px; }
.cart-close {
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: color 0.3s, background 0.3s;
}
.cart-close:hover { color: var(--text); background: var(--bg-raised-2); }

.cart-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 28px; }
.cart-lines { list-style: none; margin: 0; padding: 0; }
/* Picture | name and colour | line total, with the controls on their own row under
   the name. That row may run under the total, so it also fits a narrow phone. */
.cart-line {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; column-gap: 16px; align-items: start;
  padding: 24px 0; border-bottom: 1px solid var(--line);
}
.cart-line-main { display: contents; }
.cart-line-img { grid-column: 1; grid-row: 1 / span 4; width: 96px; height: auto; aspect-ratio: 4 / 3; object-fit: contain; }
.cart-line-name { grid-column: 2; grid-row: 1; margin: 0; font-size: 16px; font-weight: 400; line-height: 1.3; }
.cart-line-variant { grid-column: 2; grid-row: 2; margin: 2px 0 0; font-size: 13px; color: var(--text-muted); letter-spacing: 0.04em; }
.cart-line-controls { grid-column: 2 / -1; grid-row: 3; display: flex; align-items: center; gap: 14px; margin-top: 14px; }
/* "Remove" is a 44 px high target; the margins keep the row as slim as the stepper. */
.cart-line-remove {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; margin: -4px -10px;
  font-size: 13px; color: var(--text-muted); letter-spacing: 0.04em;
  text-decoration-line: underline; text-decoration-color: transparent; text-decoration-thickness: 1px; text-underline-offset: 6px;
  transition: color 0.3s, text-decoration-color 0.3s;
}
.cart-line-remove:hover { color: var(--text); text-decoration-color: var(--line-strong); }
.cart-line-note { grid-column: 2 / -1; grid-row: 4; margin: 12px 0 0; font-size: 12px; letter-spacing: 0.04em; color: var(--text-muted); }
.cart-line-total { grid-column: 3; grid-row: 1 / span 2; margin: 0; font-size: 15px; line-height: 1.3; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cart-line.is-new .cart-line-img { animation: cart-line-in 1.4s var(--ease-out) both; }
@keyframes cart-line-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cart-empty { padding: 72px 0; text-align: center; }
.cart-empty-title { margin: 0 0 28px; font-size: 22px; font-weight: 300; color: var(--text-muted); }

.cart-foot {
  padding: 22px 28px calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.cart-total { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.cart-subtotal { margin-left: auto; font-size: 22px; font-weight: 350; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cart-checkout { width: 100%; }
/* Checkout is not connected yet: the button is visibly held back and the note says why. */
.cart-checkout[aria-disabled="true"] { color: var(--text-dim); border-color: var(--line); cursor: not-allowed; }
.cart-checkout[aria-disabled="true"]:hover { color: var(--text-dim); border-color: var(--line-strong); }
.cart-checkout[aria-disabled="true"]:active { transform: none; }
.cart-note {
  margin: 14px 0 0; text-align: center; font-size: 13px; letter-spacing: 0.02em;
  color: var(--text-muted); transition: color 0.6s;
}
.cart-note.is-nudged { color: var(--gold-light); }

.cart [hidden] { display: none !important; }

/* The narrowest phones: the currency toggle moves under "Subtotal", so a four-figure
   amount still fits on the line. */
@media (max-width: 380px) {
  .cart-total { flex-wrap: wrap; row-gap: 10px; }
  .cart-total .currency-toggle { order: 3; }
}
@media (max-width: 480px) {
  .cart-panel { border-left: 0; }
  .cart-head { padding: 16px 12px 16px 20px; }
  .cart-body { padding: 0 20px; }
  .cart-foot { padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .cart-line { grid-template-columns: 80px minmax(0, 1fr) auto; column-gap: 14px; }
  .cart-line-img { width: 80px; }
}
