/* ==========================================================================
   ATLETIKA — Page: Cart (bag)
   Loaded after the shared sheets. Every colour, size, duration and easing
   is a token from tokens.css. Page-specific dimensions are declared once
   here as page-scoped properties, derived from the spacing scale.
   ========================================================================== */
.page-cart {
  --cart-thumb:     var(--s-24);                          /* 96  — line-item thumb ≤767 (3:4 → 128 tall) */
  --cart-thumb-lg:  calc(var(--s-24) + var(--s-6));       /* 120 — line-item thumb ≥768 (3:4 → 160 tall) */
  --cart-cta-h:     calc(var(--s-16) + var(--s-2));       /* 72  — fixed mobile checkout bar */
  --cart-split:     62fr 38fr;                            /* items / summary ≥1024 */
  --cart-icon:      var(--s-3);                           /* 12  — stock check glyph */
}

/* Keep the page clear of the fixed bar on mobile while the bag has items. */
@media (max-width: 1023px) {
  .page-cart:not([data-cart-empty="true"]) { padding-block-end: var(--cart-cta-h); }
}
/* The shared toast sits bottom-left; lift it above the bar while the bar is shown. */
.page-cart[data-cart-cta="true"] .toast-region { inset-block-end: calc(var(--cart-cta-h) + var(--s-5)); }
.page-cart .toast-region { max-width: calc(100vw - var(--s-8)); }

/* ==========================================================================
   PAGE HEAD — "Bag · 2 items". No breadcrumb.
   ========================================================================== */
.cart-head { padding-block: var(--s-6) var(--s-5); }
@media (min-width: 768px) { .cart-head { padding-block: var(--s-10) var(--s-6); } }
.cart-head__count {
  display: inline-block;
  margin-inline-start: var(--s-2);
  font-weight: var(--fw-regular);
  letter-spacing: var(--track-normal);
  vertical-align: baseline;
  white-space: nowrap;
}

/* ==========================================================================
   LAYOUT — single column ≤1023; items 62% / sticky summary 38% ≥1024
   ========================================================================== */
.cart-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-10);
}
.cart-items { min-width: 0; }
@media (min-width: 1024px) {
  .cart-wrap {
    display: grid;
    grid-template-columns: var(--cart-split);
    gap: var(--gutter);
    align-items: start;
  }
  .cart-summary {
    position: sticky;
    top: calc(var(--header-h) + var(--s-6));
  }
}

/* ==========================================================================
   LINE ITEMS
   li = one animatable grid row (grid-template-rows 1fr → 0fr on remove);
   __clip clips it; __inner carries the padding, the rule and the columns,
   so the collapse reaches a true zero height.
   ========================================================================== */
.cart-list { border-block-start: var(--bw) solid var(--c-line); }
.cart-item {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--dur-base) var(--ease-exit),
              opacity            var(--dur-base) var(--ease-exit);
}
.cart-item[data-removing="true"] { grid-template-rows: 0fr; opacity: 0; }
.cart-item__clip { overflow: hidden; min-height: 0; }
.cart-item__inner {
  display: grid;
  grid-template-columns: var(--cart-thumb) 1fr auto;
  grid-template-areas:
    "media body    price"
    "media actions actions";
  gap: var(--s-3) var(--s-4);
  align-items: start;
  padding-block: var(--s-6);
  border-block-end: var(--bw) solid var(--c-line);
}
@media (min-width: 768px) {
  .cart-item__inner {
    grid-template-columns: var(--cart-thumb-lg) 1fr auto;
    grid-template-areas:
      "media body    price"
      "media actions price";
    grid-template-rows: auto 1fr;
    column-gap: var(--s-6);
  }
}

.cart-item__media { grid-area: media; width: var(--cart-thumb); }
@media (min-width: 768px) { .cart-item__media { width: var(--cart-thumb-lg); } }
.cart-item__media img,
.cart-item__media picture { width: 100%; height: 100%; }
.cart-item__media img { object-fit: cover; }

.cart-item__body {
  grid-area: body;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.cart-item__title { font-size: var(--t-body); line-height: var(--lh-body); }
.cart-item__title:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.cart-item__meta { font-size: var(--t-sm); line-height: var(--lh-sm); color: var(--c-ink-muted); }
.cart-item__stock {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--t-xs);
  line-height: var(--lh-xs);
  color: var(--c-success);
}
.cart-item__stock svg { width: var(--cart-icon); height: var(--cart-icon); }

.cart-item__actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
}
.cart-item__remove {
  display: inline-flex;
  align-items: center;
  min-height: var(--s-10);      /* 40 — matches the stepper height */
  color: var(--c-ink-secondary);
}
.cart-item__remove:hover { color: var(--c-ink); }

.cart-item__price {
  grid-area: price;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}
.cart-item__price .price { justify-content: flex-end; }
.cart-item__price .price__now { font-size: var(--t-body); line-height: var(--lh-body); }
.cart-item__unit { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--c-ink-muted); white-space: nowrap; }

/* ==========================================================================
   SUMMARY — sunken surface, 24px padding
   ========================================================================== */
.cart-summary {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding: var(--s-6);
  background: var(--c-surface-sunken);
}

/* Delivery radios */
.cart-ship { display: flex; flex-direction: column; gap: var(--s-3); }
.cart-ship > legend { padding-block-end: var(--s-3); }
.cart-ship__opt { min-height: var(--s-10); }
.cart-ship__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cart-ship__row { display: flex; justify-content: space-between; gap: var(--s-3); }
.cart-ship__price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-ship__note { font-size: var(--t-xs); line-height: var(--lh-xs); color: var(--c-ink-muted); }

/* Discount code — deferred apply is correct for codes */
.cart-code { display: flex; flex-direction: column; gap: var(--s-3); }
.cart-code__toggle {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  min-height: var(--s-6);
  color: var(--c-ink);
}
.cart-code__row { display: flex; gap: var(--s-2); }
.cart-code__row .input { flex: 1; min-width: 0; }
.cart-code__row .btn { flex: none; }
/* Ghost hover is sunken-on-sunken here; use the page surface so it stays visible. */
.cart-summary .btn--ghost:hover:not(:disabled) { background: var(--c-surface); }
.field__error:empty { display: none; }
.field__error { animation: cart-fade var(--dur-fast) var(--ease-standard); }
@keyframes cart-fade { from { opacity: 0; } }
.cart-code__applied { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.cart-code__applied b { font-weight: var(--fw-medium); }

/* Totals */
.cart-totals {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  font-size: var(--t-base);
  line-height: var(--lh-base);
}
.cart-totals__row { display: flex; justify-content: space-between; gap: var(--s-4); }
.cart-totals__row dt { color: var(--c-ink-secondary); }
.cart-totals__row dd { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.cart-totals__total {
  align-items: baseline;
  margin-block-start: var(--s-2);
  padding-block-start: var(--s-3);
  border-block-start: var(--bw) solid var(--c-line-strong);
}
.cart-totals__total dt { color: var(--c-ink); font-weight: var(--fw-medium); }
.cart-totals__total dd { display: flex; flex-direction: column; align-items: flex-end; }
.cart-totals__grand { font-weight: var(--fw-medium); }
.cart-totals__vat-label { font-weight: var(--fw-regular); }

/* Express (capability-gated; the block is removed when unavailable) */
.cart-express { display: flex; flex-direction: column; gap: var(--s-4); }
.cart-express .express__btn:only-child { grid-column: 1 / -1; }
.cart-express .express__mark { font-weight: var(--fw-bold); }
.cart-express .express__btn:hover { background: var(--c-ink-secondary); }

/* Payment marks + shipping statement (CRD 8(3)) */
.cart-summary__legal { display: flex; flex-direction: column; gap: var(--s-2); }

/* ==========================================================================
   CROSS-SELL / NEW IN RAILS
   ========================================================================== */
.cart-xsell,
.cart-newin { margin-block-start: var(--section-gap-sm); }
.cart-xsell .section-head,
.cart-newin .section-head { align-items: center; }
.cart-empty { padding-block-start: var(--s-6); }

/* ==========================================================================
   UNDO TOAST — the shared .toast with a focusable Undo control
   ========================================================================== */
.cart-toast { flex-wrap: wrap; }
.cart-toast__undo {
  display: inline-flex;
  align-items: center;
  min-height: var(--s-6);
  padding-inline: var(--s-1);
  font-weight: var(--fw-medium);
}

/* ==========================================================================
   FIXED MOBILE CHECKOUT BAR (≤1023) — 72px, white, 1px top rule.
   Shown only while the summary is out of view; aria-hidden + inert toggled
   by cart.js.
   ========================================================================== */
.cart-cta {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  height: var(--cart-cta-h);
  padding: var(--s-2) var(--gutter);
  background: var(--c-surface);
  border-block-start: var(--bw) solid var(--c-line);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform var(--dur-exit) var(--ease-exit),
              visibility 0s linear var(--dur-exit);
}
.cart-cta[data-visible="true"] {
  transform: none;
  visibility: visible;
  transition: transform var(--dur-enter) var(--ease-enter);
}
.cart-cta__total { display: flex; flex-direction: column; line-height: var(--lh-xs); }
.cart-cta__total b { font-size: var(--t-lg); line-height: var(--lh-lg); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.cart-cta .btn { flex: none; }
@media (min-width: 1024px) { .cart-cta { display: none; } }
