/*
 * The shop, as on Sabad, in Yalda's design system (/ui/yalda.css, loaded first): the cart's
 * controls on the cards, the cart page, and the page after ordering.
 */

/* ---------- «+ n −» once a product is in the cart (/ui/cart.js) ----------
   One size, --q, sets the pill's height and buttons, the icons and the number: 36px in the cart's
   rows, the card's button's height on a card (.card-buy, below). */
.qty-pill {
  --q: var(--qty-size, 36px);
  display: inline-flex;
  align-items: center;
  height: var(--q);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: 0 2px 6px -2px rgb(43 26 29 / 0.2);
}
.qty-pill__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--q);
  height: var(--q);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}
.qty-pill__btn svg {
  width: calc(var(--q) * 0.5);
  height: calc(var(--q) * 0.5);
}
.qty-pill__val {
  min-width: calc(var(--q) * 0.56);
  font-size: calc(var(--q) * 0.42);
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* a finger's reach a little above and below the pill's buttons (not sideways: each keeps its side) */
.qty-pill__btn::after {
  content: "";
  position: absolute;
  inset: -6px 0;
}
.qty-pill__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(227 160 171 / 0.7);
}

/* ---------- on a card: its last line, as wide as the card ----------
   «افزودن به سبد خرید» in the colour of the card's section (the bundles' gold, the nuts'
   pomegranate, the boxes' navy); once the product is in the cart the same line holds «+ n −»:
   + on the right, the number in the middle, − (the bin for the last one) on the left. */
.card-buy {
  --qty-size: 38px;
  container-type: inline-size;
  margin-top: auto;
}
/* under a price that already keeps the card's last lines at its foot */
.n-card__buy + .card-buy,
.m-card__buy + .card-buy {
  margin-top: 0;
}
.qty-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--qty-size);
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: var(--primary-foreground);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgb(43 26 29 / 0.18);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
/* darker on hover only with a mouse: on a phone a tap would leave it stuck on */
@media (hover: hover) and (pointer: fine) {
  .qty-cta:hover {
    background: var(--primary-hover);
  }
}
.qty-cta:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.qty-pill.qty--card {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px var(--border);
}
.qty--card .qty-pill__btn {
  border-radius: var(--radius-lg);
}
.qty--card .qty-pill__val {
  flex: 1;
}
/* the narrowest cards (a gift box's on a phone): the words a little smaller; narrower still,
   «افزودن به سبد» */
@container (max-width: 135px) {
  .qty-cta {
    padding: 0 6px;
    font-size: 12px;
  }
}
@container (max-width: 112px) {
  .qty-cta {
    padding: 0 3px;
  }
}
@container (max-width: 100px) {
  .qty-cta__more {
    display: none;
  }
}

/* a product that is out */
.sold-out {
  font-size: 12px;
}
.is-out .m-card__media img,
.is-out .b-card__media img {
  opacity: 0.55;
  filter: grayscale(0.5);
}

/* =========================================================
   The cart page (/cart)
   ========================================================= */
/* the same width as the shop and the club pages */
.c-shop-main {
  width: min(100% - 32px, 1288px);
  margin: 0 auto;
  padding-top: 16px;
}
@media (min-width: 768px) {
  .c-shop-main {
    padding-top: 28px;
  }
}
.cart-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.cart-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.cart-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
}
.cart-item + .cart-item {
  border-top: 1px solid var(--border);
}
.cart-item__media {
  position: relative;
  flex-shrink: 0;
  align-self: flex-start;
}
/* a product's photo, square or not (a bundle's is wider), whole on white, as on its card */
.cart-item__img {
  display: block;
  box-sizing: border-box;
  width: 76px;
  height: 76px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  object-fit: contain;
}
/* the X on the picture's top right corner: the whole row leaves the cart */
.cart-item__remove {
  position: absolute;
  top: -7px;
  right: -7px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted-foreground);
  box-shadow: 0 2px 6px -2px rgb(43 26 29 / 0.25);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
/* a bigger target than the circle, for a finger */
.cart-item__remove::before {
  content: "";
  position: absolute;
  inset: -8px;
}
.cart-item__remove svg {
  width: 14px;
  height: 14px;
}
@media (hover: hover) and (pointer: fine) {
  .cart-item__remove:hover {
    border-color: var(--destructive);
    background: var(--destructive);
    color: #fff;
  }
}
.cart-item__remove:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(227 160 171 / 0.7);
}
.cart-item__info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.cart-item__name {
  margin: 0;
  color: var(--foreground);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.7;
}
.cart-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.cart-item__total {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.5;
  color: var(--foreground);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cart-item__total small {
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 500;
}
.cart-item .qty-pill {
  box-shadow: none;
}

/* the items on one side, the total and «ادامه ثبت سفارش» on the other (under them on a phone) */
.cart-layout {
  display: grid;
  gap: 12px;
  align-items: start;
}
@media (min-width: 992px) {
  .cart-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
  }
  .cart-summary {
    position: sticky;
    top: 84px;
  }
}
.cart-summary__card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}
.cart-summary__card .cart-note {
  margin: 0;
}
.cart-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
/* as on Sabad: the VAT the total includes, under it; a tinted row of its own, so it is seen */
.cart-vat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--accent-foreground);
  font-size: 13px;
  line-height: 1.6;
}
.cart-vat[hidden] {
  display: none;
}
.cart-vat strong {
  flex-shrink: 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cart-vat small {
  font-size: 11.5px;
  font-weight: 500;
}
.cart-total span {
  color: var(--muted-foreground);
  font-size: 14px;
}
.cart-total strong {
  color: var(--foreground);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.cart-total small {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
}

.cart-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid rgb(143 107 12 / 0.25);
  border-radius: var(--radius-xl);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
  line-height: 1.9;
}
.cart-note svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 3px;
}
.cart-note--error {
  border-color: rgb(180 35 24 / 0.25);
  background: var(--destructive-soft);
  color: var(--destructive);
}


/* the empty cart */
.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 20px;
  text-align: center;
}
.cart-empty__img {
  display: block;
  width: 112px;
  height: 112px;
  margin-bottom: 4px;
}
@media (min-width: 768px) {
  .cart-empty__img {
    width: 128px;
    height: 128px;
  }
}
/* «مشاهده محصولات»: a red link back to the shop, the arrow after it in proportion to the words
   (sized by the text, its line as heavy as the bold letters); the same under the mouse, no
   underline, no change of colour */
.cart-empty__link,
.cart-empty__link:hover {
  color: var(--primary);
  text-decoration: none;
}
.cart-empty__link {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 4px;
  padding: 6px 4px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
}
.cart-empty__link svg {
  flex-shrink: 0;
  width: 1.3em;
  height: 1.3em;
  stroke-width: 2;
}
.cart-empty__link:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 6px;
}

/* =========================================================
   After ordering (/orders/…/success)
   ========================================================= */
.done-card {
  max-width: 640px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px 24px;
  text-align: center;
}
/* the success tick: the one icon in a circle, a soft green one, as a seal on the order */
.done-card .ui-head-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}
.done-card .ui-head-icon svg {
  width: 28px;
  height: 28px;
}
/* an error page (resources/views/errors): the same card, its sign in gold */
.done-card--note .ui-head-icon {
  background: var(--warning-soft);
  color: var(--warning);
}
.done-card h1 {
  margin: 0;
  color: var(--foreground);
  font-size: 22px;
  font-weight: 800;
}
.done-card p {
  margin: 0;
  max-width: 420px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.9;
}
.done-code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 12px 0 4px;
  padding: 12px 28px;
  border: 1px dashed rgb(155 27 48 / 0.4);
  border-radius: var(--radius-xl);
  background: var(--primary-soft);
}
.done-code span {
  color: var(--muted-foreground);
  font-size: 12px;
}
.done-code strong {
  color: var(--primary);
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.done-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin-top: 12px;
}
@media (min-width: 576px) {
  .done-actions {
    flex-direction: row;
    justify-content: center;
    max-width: none;
  }
}

/* =========================================================
   The pages of their own: the cart and the page after ordering
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}
body.shop {
  --page-max: 1288px; /* the glass top bar as wide as on the shop page */
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
body.shop img {
  max-width: 100%;
}
