/* Cart: the "Added to cart" line on book pages, the /cart/ page, and the buttons and
   money styles that /checkout/ shares. Unlayered, like the .static-page rules in listing.css.
   Colours are the site's existing ones: --tmme-* tokens (tmme-base.css), the static-page CTA
   greys, the newsletter error red and the book page's pre-order brown. */

:root {
  --cart-ink: var(--tmme-ink, #1a1a1a);
  --cart-muted: var(--tmme-ink-muted, #6b6b6b);
  --cart-rule: var(--tmme-border, #e0e0e0);
  --cart-field-edge: rgb(133, 134, 135);   /* tokens.css --color-secondary; 3.7:1 on white */
  --cart-surface-alt: var(--tmme-surface-alt, #f6f5f3);
  --cart-hover: rgb(70, 70, 70);           /* .static-page__cta:hover */
  --cart-disabled: rgb(160, 160, 160);     /* .buy-from__main--sold-out */
  --cart-error: #c0392b;                   /* .newsletter__msg--error */
  --cart-preorder: rgb(140, 100, 50);      /* .book-status--pre-order */
}

/* ---------- Book page: confirmation under the Add to Cart button ---------- */

.cart-added {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cart-muted);
}
.cart-added:empty { margin: 0; }
.cart-added a {
  color: var(--cart-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cart-added--error { color: var(--cart-error); }

@media (max-width: 767px) {
  /* The mobile hero orders its children with flex `order`; the button is 7. */
  .cart-added { order: 8; margin: 16px auto 0; }
  .cart-added:empty { margin: 0; }
}

/* ---------- Buttons ---------- */

.cart-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 14px 32px;
  border: 1px solid var(--cart-ink);
  background: var(--cart-ink);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.cart-btn:hover { background: var(--cart-hover); border-color: var(--cart-hover); }
.cart-btn:active { transform: translateY(1px); }
.cart-btn:disabled,
.cart-btn:disabled:hover {
  background: var(--cart-disabled);
  border-color: var(--cart-disabled);
  cursor: progress;
  transform: none;
}
.cart-btn--ghost { background: transparent; color: var(--cart-ink); }
.cart-btn--ghost:hover { background: var(--cart-surface-alt); border-color: var(--cart-ink); }

.cart-btn:focus-visible,
.cart-page a:focus-visible,
.cart-page button:focus-visible,
.cart-page input:focus-visible {
  outline: 2px solid var(--cart-ink);
  outline-offset: 3px;
}

.cart__money { white-space: nowrap; font-feature-settings: "tnum" 1, "lnum" 1; }
.cart__currency {
  font-size: 0.75em;
  font-weight: 500;
  letter-spacing: 1.5px;
}

/* ---------- /cart/ ---------- */

.cart__lines { border-top: 1px solid var(--cart-rule); }

.cart-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto 104px;
  grid-template-areas: "cover info qty total";
  column-gap: 24px;
  align-items: start;
  padding: 24px 0;
  border-bottom: 1px solid var(--cart-rule);
}

.cart-line__cover { grid-area: cover; display: block; }
.cart-line__cover img { display: block; width: 100%; height: auto; }
.cart-line__cover--missing {
  aspect-ratio: 2 / 3;
  background: var(--cart-surface-alt);
}

.cart-line__info { grid-area: info; min-width: 0; }
.cart-line__title {
  display: inline-block;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--cart-ink);
}
.cart-line__title:hover { text-decoration: underline; text-underline-offset: 2px; }
.cart-line__meta,
.cart-line__unit {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cart-muted);
}
.cart-line__flag {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--cart-preorder);
}
.cart-line__remove {
  margin-top: 8px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--cart-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.cart-line__remove:hover { color: var(--cart-ink); }

.cart-qty {
  grid-area: qty;
  justify-self: start;
  display: inline-flex;
  align-items: stretch;
  height: 40px;
  border: 1px solid var(--cart-field-edge);
}
.cart-qty__btn {
  width: 36px;
  font-size: 18px;
  line-height: 1;
  color: var(--cart-ink);
  cursor: pointer;
}
.cart-qty__btn:hover { background: var(--cart-surface-alt); }
.cart-qty__btn:disabled { color: var(--cart-disabled); cursor: default; background: none; }
.cart-qty__input {
  width: 44px;
  border: 0;
  border-left: 1px solid var(--cart-rule);
  border-right: 1px solid var(--cart-rule);
  background: #fff;
  font-size: 16px;
  text-align: center;
  color: var(--cart-ink);
  cursor: text;
  -moz-appearance: textfield;
  appearance: textfield;
}
.cart-qty__input::-webkit-inner-spin-button,
.cart-qty__input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.cart-line__total {
  grid-area: total;
  font-size: 16px;
  line-height: 40px;
  text-align: right;
  color: var(--cart-ink);
  font-feature-settings: "tnum" 1, "lnum" 1;
  white-space: nowrap;
}

/* Book with no price yet */
.cart-line__total--tbc {
  font-size: 13px;
  line-height: 1.4;
  padding-top: 11px;
  color: var(--cart-muted);
  white-space: normal;
}

.cart__summary { margin-top: 32px; }
.cart__tbc {
  margin-top: 4px;
  font-size: 14px;
  text-align: right;
  color: var(--cart-ink);
}
.cart__subtotal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 18px;
  font-weight: 500;
  color: var(--cart-ink);
}
.cart__note {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--cart-muted);
}
.cart__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
}

.cart-empty { text-align: center; }

@media (max-width: 767px) {
  /* The quantity column is sized to its buttons; the total takes what is left and may wrap,
     so nothing overlaps even at 320px wide. */
  .cart-line {
    grid-template-columns: 56px auto minmax(0, 1fr);
    grid-template-areas:
      "cover info info"
      "cover qty total";
    column-gap: 14px;
    row-gap: 14px;
    padding: 20px 0;
  }
  .cart-line__total {
    align-self: center;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .cart-line__total--tbc { padding-top: 0; }
  .cart__actions { flex-direction: column; }
  .cart__actions .cart-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .cart-btn:active { transform: none; }
}
