/* ==========================================================================
   Cart page
   Loaded only on Cart/Index. Brand tokens come from front.css.

   The row/flash/swap animations (.cart-row.is-removing, .cart-value-flash,
   #cartContainer.is-swapping) stay in front.css because js/cart.js is a global
   script - this file only owns the layout and skin of the page.
   ========================================================================== */
.cart-page {
  --cart-radius: 14px;
  --cart-line-gap: 1.1rem;
}

/* ==========================================================================
   Progress steps
   ========================================================================== */
.cart-steps {
  display: flex;
  align-items: flex-start;
  list-style: none;
  margin: 0 auto 2.25rem;
  padding: 0;
  max-width: 520px;
  counter-reset: cart-step;
}

.cart-step {
  position: relative;
  flex: 1;
  text-align: center;
  color: var(--brand-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Connector runs from the previous dot to this one. Steps are equal-width, so
   -50% lands on the previous dot's centre; the 20px clears the 17px radius.
   Top is the dot's centre (17px) less half the line's own height. */
.cart-step + .cart-step::before {
  content: "";
  position: absolute;
  top: 16px;
  left: calc(-50% + 20px);
  right: calc(50% + 20px);
  height: 2px;
  background-color: var(--brand-border);
}

.cart-step-dot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0 auto 0.5rem;
  border: 2px solid var(--brand-border);
  border-radius: 50%;
  background-color: var(--brand-surface);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--brand-muted);
}

.cart-step.is-active {
  color: var(--brand-primary);
  font-weight: 600;
}

.cart-step.is-active .cart-step-dot {
  border-color: transparent;
  background-image: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(138, 38, 164, 0.12);
}

/* ==========================================================================
   Items panel
   ========================================================================== */
.cart-panel {
  background-color: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--cart-radius);
  box-shadow: var(--brand-shadow-soft);
  overflow: hidden;
}

.cart-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--brand-border);
  background-color: rgba(138, 38, 164, 0.03);
}

.cart-panel-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.1rem;
}

.cart-panel-count {
  display: inline-block;
  margin-left: 0.45rem;
  padding: 0.1rem 0.55rem;
  border-radius: var(--brand-radius-pill);
  background-color: rgba(138, 38, 164, 0.1);
  color: var(--brand-primary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  vertical-align: middle;
}

.cart-panel-link {
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.cart-panel-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Line item
   Mobile stacks qty/total under the copy; from md up everything sits on one
   row. Grid areas keep both arrangements described in one place.
   ========================================================================== */
.cart-line {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  grid-template-areas:
    "media info remove"
    "media qty  total";
  gap: 0.85rem 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--brand-border);
  transition: background-color var(--brand-transition), opacity 200ms ease, transform 200ms ease;
}

.cart-line:last-child {
  border-bottom: 0;
}

.cart-line:hover {
  background-color: rgba(138, 38, 164, 0.025);
}

@media (min-width: 768px) {
  .cart-line {
    grid-template-columns: 96px minmax(0, 1fr) auto minmax(96px, auto) 36px;
    grid-template-areas: "media info qty total remove";
    align-items: center;
    gap: 1.25rem;
  }
}

.cart-line-media {
  grid-area: media;
  display: block;
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--brand-radius-md);
  overflow: hidden;
  background-color: var(--brand-bg);
  border: 1px solid var(--brand-border);
}

.cart-line-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}

.cart-line:hover .cart-line-media img {
  transform: scale(1.06);
}

.cart-line-info {
  grid-area: info;
  min-width: 0;
}

.cart-line-name {
  display: block;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-fg);
  text-decoration: none;
  line-height: 1.35;
}

.cart-line-name:hover,
.cart-line-name:focus-visible {
  color: var(--brand-primary);
}

.cart-line-unit {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--brand-muted);
}

.cart-line-unit strong {
  color: var(--brand-fg);
  font-weight: 600;
}

/* Stock / availability chips */
.cart-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.45rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--brand-radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.cart-chip svg {
  flex-shrink: 0;
}

.cart-chip-ok {
  background-color: rgba(47, 107, 58, 0.1);
  color: var(--brand-success);
}

.cart-chip-low {
  background-color: rgba(184, 114, 26, 0.12);
  color: #8A5A22;
}

.cart-chip-out {
  background-color: rgba(176, 42, 55, 0.1);
  color: #B02A37;
}

/* Quantity stepper */
.cart-line-qty {
  grid-area: qty;
}

.cart-line .cart-qty-group {
  width: 118px;
  flex-wrap: nowrap;
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-pill);
  background-color: var(--brand-surface);
  overflow: hidden;
  transition: border-color var(--brand-transition), box-shadow var(--brand-transition);
}

.cart-line .cart-qty-group:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.2rem rgba(138, 38, 164, 0.15);
}

.cart-line .cart-qty-group .btn {
  flex: 0 0 34px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  color: var(--brand-primary);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.cart-line .cart-qty-group .btn:hover:not(:disabled) {
  background-color: rgba(138, 38, 164, 0.08);
}

.cart-line .cart-qty-group .btn:focus {
  box-shadow: none;
}

.cart-line .cart-qty-group .form-control {
  border: 0;
  border-radius: 0;
  background-color: transparent;
  box-shadow: none;
  font-weight: 600;
  color: var(--brand-fg);
  padding-left: 0;
  padding-right: 0;
}

/* Bootstrap overlaps input-group children by 1px to collapse adjacent borders;
   with the borders removed that overlap just nudges the control off-centre. */
.cart-line .cart-qty-group > :not(:first-child) {
  margin-left: 0;
}

/* Number spinners fight the pill shape and duplicate the +/- buttons. */
.cart-line .cart-qty-group input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.cart-line .cart-qty-group input[type="number"]::-webkit-outer-spin-button,
.cart-line .cart-qty-group input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Line total */
.cart-line-total {
  grid-area: total;
  text-align: right;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--brand-fg);
  white-space: nowrap;
}

/* Remove */
.cart-line-remove {
  grid-area: remove;
  justify-self: end;
  align-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: transparent;
  color: var(--brand-muted);
  transition: background-color var(--brand-transition), color var(--brand-transition);
}

@media (min-width: 768px) {
  .cart-line-remove {
    align-self: center;
  }
}

.cart-line-remove:hover:not(:disabled),
.cart-line-remove:focus-visible {
  background-color: rgba(176, 42, 55, 0.1);
  color: #B02A37;
}

/* ==========================================================================
   Order summary
   ========================================================================== */
@media (min-width: 992px) {
  .cart-summary-wrap {
    position: sticky;
    /* Clears the sticky site header. */
    top: 96px;
  }
}

.cart-summary {
  background-color: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--cart-radius);
  box-shadow: var(--brand-shadow-soft);
  overflow: hidden;
}

.cart-summary-head {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 1.15rem 1.5rem;
  background-image: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
  color: #fff;
}

/* Same mandala motif as the hero, kept faint so the heading stays legible.
   Like .page-hero, the motif sits in normal flow and the heading is lifted over
   it - a negative z-index would drop it behind the gradient and vanish. */
.cart-summary-head::after {
  content: "";
  position: absolute;
  top: -3.5rem;
  right: -3.5rem;
  width: 11rem;
  aspect-ratio: 1;
  background-image: url("../images/site/mandala-outer.svg");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.16;
  pointer-events: none;
}

.cart-summary-head h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
}

.cart-summary-body {
  padding: 1.35rem 1.5rem 1.5rem;
}

.cart-sum-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
  font-size: 0.92rem;
  color: var(--brand-muted);
}

.cart-sum-row > span:last-child {
  color: var(--brand-fg);
  font-weight: 600;
  white-space: nowrap;
}

.cart-sum-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--brand-border);
}

.cart-sum-total-label {
  font-weight: 600;
  font-size: 1rem;
}

.cart-sum-total-value {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand-primary-dark);
  white-space: nowrap;
}

.cart-sum-note {
  margin: 0.65rem 0 0;
  font-size: 0.78rem;
  color: var(--brand-muted);
}

/* Coupon
   js/cart.js only toggles .d-none on #cartCouponForm, so the dashed box folds
   itself away when a coupon is applied rather than the script knowing about it.
   Without :has() support the box stays put showing just its label - cosmetic,
   and the applied-coupon row above still reads correctly. */
.cart-coupon:has(> #cartCouponForm.d-none) {
  display: none;
}

.cart-coupon {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--brand-border);
  border-radius: var(--brand-radius-md);
  background-color: var(--brand-bg);
}

.cart-coupon-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-fg);
}

.cart-coupon-label svg {
  color: var(--brand-accent);
}

.cart-coupon .form-control {
  border-color: var(--brand-border);
  background-color: var(--brand-surface);
  letter-spacing: 0.06em;
  font-weight: 600;
}

.cart-coupon .btn {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  font-weight: 600;
}

.cart-coupon .btn:hover:not(:disabled) {
  background-color: var(--brand-primary);
  color: #fff;
}

/* Applied-coupon row, shown in place of the form. */
.cart-coupon-applied {
  align-items: center;
  margin-bottom: 0.7rem;
  font-size: 0.92rem;
}

.cart-coupon-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: var(--brand-radius-pill);
  background-color: rgba(47, 107, 58, 0.1);
  color: var(--brand-success);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* "Offers for you" - the admin-curated coupons advertised under the coupon box. Locked offers stay
   in the list on purpose: "add a little more and save" is most of the reason it's there. */
.cart-offers {
  margin: 0 0 1rem;
}

.cart-offers-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand-fg);
}

.cart-offers-title svg {
  color: var(--brand-accent);
}

/* Capped and scrollable: the list grows with however many coupons admin advertises, and an
   uncapped one pushes Tax and Total below the fold - the two numbers the shopper came here for.
   The height lands mid-card so there is a visibly cut-off offer hinting there is more to scroll. */
.cart-offer-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 19rem;
  overflow-y: auto;
  /* Stops a flick past the last offer from scrolling the page behind it. */
  overscroll-behavior: contain;
  /* Keeps the thumb off the cards' right border. padding-right pairs with the negative margin so
     the list still lines up with the summary rows above when there is nothing to scroll. */
  padding-right: 0.4rem;
  margin-right: -0.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--brand-border) transparent;
}

.cart-offer-list::-webkit-scrollbar {
  width: 6px;
}

.cart-offer-list::-webkit-scrollbar-track {
  background: transparent;
}

.cart-offer-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background-color: var(--brand-border);
}

.cart-offer-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--brand-accent);
}

.cart-offer {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--brand-border);
  border-left: 3px solid var(--brand-accent);
  border-radius: var(--brand-radius-md);
  background-color: var(--brand-surface);
}

.cart-offer.is-locked {
  border-left-color: var(--brand-border);
  opacity: 0.75;
}

.cart-offer.is-applied {
  border-left-color: var(--brand-success);
  background-color: rgba(47, 107, 58, 0.06);
}

.cart-offer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.cart-offer-code {
  padding: 0.1rem 0.5rem;
  border: 1px dashed var(--brand-accent);
  border-radius: var(--brand-radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brand-primary);
}

.cart-offer-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-accent);
  white-space: nowrap;
}

.cart-offer-name {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-fg);
}

.cart-offer-desc {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--brand-muted);
}

.cart-offer-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.cart-offer-save {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-success);
}

.cart-offer-apply {
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--brand-primary);
  border-radius: var(--brand-radius-pill);
  background-color: transparent;
  color: var(--brand-primary);
  font-size: 0.78rem;
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.cart-offer-apply:hover:not(:disabled) {
  background-color: var(--brand-primary);
  color: #fff;
}

.cart-offer-apply:disabled {
  opacity: 0.6;
}

.cart-offer-note {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--brand-muted);
}

.cart-offer-note-ok {
  font-weight: 600;
  color: var(--brand-success);
}

.cart-offer-expiry {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: var(--brand-muted);
}

.cart-checkout-btn {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
}

.cart-continue-link {
  display: block;
  margin-top: 0.6rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.cart-continue-link:hover {
  text-decoration: underline;
}

/* Reassurance list under the CTA */
.cart-assurance {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--brand-border);
}

.cart-assurance li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
  font-size: 0.82rem;
  color: var(--brand-muted);
}

.cart-assurance li:last-child {
  margin-bottom: 0;
}

.cart-assurance svg {
  flex-shrink: 0;
  color: var(--brand-accent);
}

/* ==========================================================================
   Empty state
   The markup here is duplicated in #cartEmptyTemplate, which js/cart.js clones
   when the last item is removed - change both together.
   ========================================================================== */
.cart-empty {
  max-width: 520px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  text-align: center;
  background-color: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--cart-radius);
  box-shadow: var(--brand-shadow-soft);
}

.cart-empty-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background-image: linear-gradient(135deg, rgba(138, 38, 164, 0.12) 0%, rgba(255, 185, 85, 0.22) 100%);
  color: var(--brand-primary);
}

.cart-empty-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.cart-empty-suggestions a {
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius-pill);
  background-color: var(--brand-surface);
  color: var(--brand-fg);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: border-color var(--brand-transition), color var(--brand-transition), background-color var(--brand-transition);
}

.cart-empty-suggestions a:hover,
.cart-empty-suggestions a:focus-visible {
  border-color: var(--brand-primary);
  background-color: rgba(138, 38, 164, 0.06);
  color: var(--brand-primary);
}

/* ==========================================================================
   Motion
   Every animation here is decorative - the page reads the same without it.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .cart-line,
  .cart-line-media img,
  .cart-line-remove,
  .cart-empty-suggestions a {
    transition: none;
  }

  .cart-line:hover .cart-line-media img {
    transform: none;
  }
}
