/* ==========================================================================
   cart.css: the cart page. Load after base.css, page.css and products.css
   (the stepper and .sr-only come from products.css). Flat colour only.
   ========================================================================== */

.cartpage {
  padding-block: clamp(2rem, 4vw, 3rem) var(--section);
  /* Same error colour as auth.css and portal.css. */
  --cart-error: #9b2c1f;
}

/* ---- Heading ---- */

.chead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}

.cart__title {
  margin: 0;
  font-size: clamp(2.2rem, 4.6vw, 3.4rem);
  line-height: 1.05;
}

.cart__title em {
  color: var(--green);
}

.chead__count {
  margin: 0.6rem 0 0;
  color: var(--muted);
}

/* ---- Needs-attention banner ---- */

.cbanner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0 0 var(--s3);
  padding: 1rem 1.25rem;
  border: 1px solid var(--cart-error);
  border-radius: 16px;
  background: #fbefec;
  font-weight: 600;
  color: var(--cart-error);
}

.cbanner svg {
  flex-shrink: 0;
  margin-top: 0.1rem;
}

/* ---- Layout: items, then summary ---- */

.cart__layout {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

@media (min-width: 960px) {
  .cart__layout {
    grid-template-columns: minmax(0, 1fr) 23rem;
  }
  .csum {
    position: sticky;
    top: 6rem;
  }
}

/* ---- Item rows ---- */

.cart__list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.citem {
  display: grid;
  grid-template-columns: clamp(5.5rem, 14vw, 7.5rem) minmax(0, 1fr);
  gap: var(--s2) clamp(1rem, 3vw, 1.75rem);
  align-items: start;
  padding: clamp(1.25rem, 3vw, 1.75rem) 0;
  border-bottom: 1px solid var(--line);
}

.citem.is-problem {
  margin-inline: -1rem;
  padding-inline: 1rem;
  border-radius: 16px;
  background: #fbefec;
}

.citem__media {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: var(--sand);
  overflow: hidden;
}

.citem__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.citem__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s2);
}

.citem__name {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  line-height: 1.25;
}

.citem__name a {
  color: inherit;
  text-decoration: none;
}

.citem__name a:hover {
  color: var(--green);
}

.citem__meta {
  margin: 0.3rem 0 0;
  font-size: 0.95rem;
  color: var(--charcoal);
}

.citem__meta span {
  color: var(--muted);
}

.citem__total {
  flex-shrink: 0;
  margin: 0;
  font-family: var(--font-head);
  font-size: clamp(1.2rem, 2.2vw, 1.45rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--green-ink);
}

.citem__warn {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--cart-error);
}

.citem__hint {
  margin: 0.6rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: #8a5d00;
}

.citem__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}

.citem__qty {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  transition: opacity 0.2s;
}

.citem__qty.is-saving {
  opacity: 0.6;
}

/* A slimmer stepper than the product page, to fit a row. */
.citem .stepper__btn {
  width: 2.4rem;
  height: 2.5rem;
}

.citem .stepper__input {
  width: 2.6rem;
  height: 2.5rem;
}

/* With JavaScript the quantity saves by itself, so the Update button is not needed. */
.js .citem__qty [data-cart-save] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Small actions that look like text links but are real buttons. */
.cart__link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  color: var(--green);
  cursor: pointer;
}

.cart__link:hover {
  color: var(--green-ink);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.cart__remove {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}

.cart__remove:hover {
  color: var(--cart-error);
}

/* ---- Summary ---- */

.csum {
  display: grid;
  gap: var(--s2);
  padding: clamp(var(--s3), 4vw, var(--s4));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--white);
}

.csum__title {
  margin: 0;
  font-size: 1.5rem;
}

.csum__rows {
  display: grid;
  margin: 0;
}

.csum__row {
  display: flex;
  justify-content: space-between;
  gap: var(--s2);
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

.csum__row dt {
  color: var(--muted);
}

.csum__row dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.csum__soft {
  font-weight: 400 !important;
  color: var(--muted);
}

.csum__total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s2);
  margin: 0;
  padding: 1rem 0 0.25rem;
  border-top: 2px solid var(--green-ink);
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--green-ink);
}

.csum__total span:first-child {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
}

.csum__note {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.csum .btn {
  width: 100%;
  justify-content: center;
  cursor: pointer;
}

.csum .btn[disabled] {
  background: var(--sand);
  color: var(--muted);
  cursor: not-allowed;
}

.csum .btn[disabled]:hover {
  transform: none;
}

.csum__more {
  justify-self: center;
  margin-top: 0.25rem;
  font-size: 0.92rem;
}

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

.cempty {
  max-width: 32rem;
  margin: clamp(1rem, 4vw, 3rem) auto;
  text-align: center;
}

.cempty__icon {
  display: inline-grid;
  place-items: center;
  width: 5.5rem;
  height: 5.5rem;
  margin-bottom: 1.5rem;
  border-radius: 50%;
  background: var(--sand);
  color: var(--green);
}

.cempty h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  color: var(--green-ink);
}

.cempty p {
  margin: 0 0 1.75rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ---- Phones ---- */

@media (max-width: 560px) {
  .citem__top {
    flex-direction: column;
    gap: 0.5rem;
  }
  .citem.is-problem {
    margin-inline: -0.75rem;
    padding-inline: 0.75rem;
  }
}
