/* ===================== Cart page ===================== */

/* фон */
body {
  background: #f3f3f3;
}

/* змінні висот для липкої панелі */
:root {
  --cartbar-h-mob: 2.6rem; /* приблизна висота панелі на мобі */
  --cartbar-h-desk: 10.4rem; /* приблизна висота панелі на десктопі */
}

/* заголовок */
.cart__title {
  margin: calc(var(--header-h, 6.4rem) + 0.6rem) 0 0.5rem;
  color: #000;
  display: inline-flex;
  align-items: flex-start;
  gap: 0.6rem;
  white-space: nowrap;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.7rem;
}
.cart__count {
  color: #000;
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.7rem;
  position: relative;
  top: -0.35em;
  display: inline-block;
}

/* контейнер сторінки */
.cart.container {
  --cart-max: 100rem; /* макс. ширина області контенту */
  --cart-pad: 1.6rem; /* внутрішні поля контейнера */

  max-width: var(--cart-max);
  margin: 0 auto;
  padding: 0 var(--cart-pad);
  box-sizing: border-box;
}

/* список позицій */
.cart__list {
  display: grid;
  gap: 2.6rem;
  /* запас під липку панель (оновлюється в медіа нижче) */
  padding-bottom: var(--cartbar-h-mob);
}

/* картка позиції */
.citem {
  background: #fff;
  overflow: hidden;
  box-shadow: 0 0 0 0.1rem rgba(0, 0, 0, 0.06);
  border-radius: 0.8rem;
}
.citem__head {
  display: grid;
  grid-template-columns: 16rem 1fr auto;
  align-items: center;
  gap: 0;
  padding: 1.6rem;
  color: inherit;
  text-decoration: none;
}
.citem__img {
  width: 15.8rem;
  height: 13.1rem;
  aspect-ratio: 1/1;
  background: #f7e1e1;
  overflow: hidden;
}
.citem__img > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.citem__title {
  color: #111;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  margin: 0 0 0 2rem;
}
.citem__chev {
  font-size: 2rem;
  padding-left: 0.4rem;
  color: #222;
}
.citem__hr {
  height: 0.1rem;
  background: rgba(0, 0, 0, 0.08);
  margin: 0;
  border: 0;
}

.citem__row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: 'label size' 'qty price';
  align-items: center;
  gap: 1.6rem 1rem;
  padding: 1.2rem 1.6rem;
}
.citem__label {
  grid-area: label;
  margin: 0;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  color: #111;
}
.citem__qtywrap {
  grid-area: qty;
}
.citem__right {
  display: contents;
}
.citem__size {
  grid-area: size;
  justify-self: end;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  color: #111;
}
.citem__price {
  grid-area: price;
  justify-self: end;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  color: #111;
}

.citem__remove {
  display: block;
  width: 100%;
  text-align: center;
  padding: 1.2rem 1.6rem;
  background: transparent;
  border: 0;
  color: #222;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  cursor: pointer;
}

/* порожній кошик */
.cart__empty {
  margin: 3.2rem 0;
  text-align: center;
  color: #666;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.7rem;
}

/* ===================== Quantity ===================== */
.citem__qty {
  width: 5.3rem;
  height: 3.8rem;
  padding: 0 0.8rem;
  border: 0;
  outline: none;
  background: transparent;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  color: #111;
}
.qty {
  display: inline-flex !important;
  align-items: center;
  column-gap: 1rem;
}
.qty__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 3.2rem;
  margin: 0 !important;
  padding: 0 !important;
  border: 0;
  background: transparent;
  outline: none;
  font-weight: 700;
  font-size: 1.6rem;
  line-height: 1;
  color: #111;
  appearance: none;
  cursor: pointer;
}
.qty__btn:focus {
  outline: none;
}
.qty__val {
  min-width: 1.8rem;
  text-align: center;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.7rem;
  color: #111;
  margin: 0 !important;
}

/* ===================== Select size ===================== */
.citem__size-select {
  border: 0;
  outline: none;
  background: transparent;
  padding: 0.2rem 2.2rem 0.2rem 0.2rem;
  border-radius: 0.4rem;
  font: inherit;
  color: #111;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
  box-shadow: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23111" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.2rem center;
  background-size: 1.25rem;
}
.citem__size-select:focus {
  outline: none;
}
.citem__size-select::-ms-expand {
  display: none;
}

/* ===================== Checkoutbar: спільні стилі ===================== */
.checkoutbar {
  /* ВАЖЛИВО: sticky, не fixed! — щоб зупинятися перед футером */
  position: sticky;
  bottom: 0;
  z-index: 60;
  box-sizing: border-box;
  background: transparent; /* фон у внутрішньому блоці */
  /* тінь і фон дає внутрішній контейнер, щоб не чіпати edge-пади */
}
.checkoutbar__inner {
  /* ширина по контейнеру */
  width: calc(min(100%, var(--cart-max)));
  margin: 0 auto;
  padding: 1.2rem var(--cart-pad) calc(1.2rem + env(safe-area-inset-bottom));
  background: #f3f3f3;
  box-shadow: 0 -0.1rem 0 rgba(0, 0, 0, 0.06);
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
}
.checkoutbar__sum {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.checkoutbar__sum > :first-child {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.7rem;
}
.checkoutbar__sum strong {
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.7rem;
}
.checkoutbar__btn {
  font-size: 1.7rem;
  line-height: 1.7rem;
  width: 100%;
  height: 5.4rem;
  border-radius: 6.7rem;
  border: 0;
  background: #2c2c2c;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* фолбек для дуже вузьких екранів */
@media (max-width: 360px) {
  .checkoutbar__inner {
    grid-template-columns: 1fr;
  }
}

/* ===================== Desktop ===================== */
@media (min-width: 1024px) {
  .cart__title {
    margin: calc(var(--header-h, 6.4rem) + 2rem) 0 1.6rem;
    font-size: 4.8rem;
    line-height: 1.05;
  }
  .cart__count {
    font-size: 2rem;
    top: -0.4em;
  }

  /* відступ під більшу десктопну панель */
  .cart__list {
    padding-bottom: var(--cartbar-h-desk);
  }

  /* зручно керувати шириною карток */
  .cart.container {
    --cart-card-max: 50rem;
  }

  .cart__list {
    grid-template-columns: minmax(0, var(--cart-card-max));
    justify-content: start;
  }
  .citem {
    width: 100%;
    margin: 0 23rem;
  }

  /* внутрішній блок панелі трохи вищий на десктопі */
  .checkoutbar__inner {
    padding-top: 1.4rem;
    padding-bottom: calc(1.4rem + env(safe-area-inset-bottom));
  }
}

/* коли кошик порожній — блок вузький як картка */
#cartEmpty {
  max-width: var(--cart-card-max, 100%);
  margin-left: auto;
  margin-right: auto;
}

/* === Mobile: checkoutbar на всю ширину экрана === */
@media (max-width: 1023px) {
  .checkoutbar__inner {
    /* растянуть на 100vw и «вынести» из контейнера */
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);

    /* безопасные отступы по краям (iPhone notch и т.п.) */
    padding-left: max(var(--cart-pad, 1.6rem), env(safe-area-inset-left));
    padding-right: max(var(--cart-pad, 1.6rem), env(safe-area-inset-right));

    border-radius: 0; /* без скруглений у краёв экрана */
  }
}
