/* Cart + checkout */

.cart-add-control {
  position: relative;
  display: block;
  width: 100%;
}

.purchase-action-group .cart-add-control {
  flex: 1 1 10rem;
  min-width: 0;
}

.purchase-action-group .cart-add-control .btn-add-cart {
  width: 100%;
  flex: 0 0 auto;
}

.cart-add-msg {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 50%;
  z-index: 6;
  margin: 0;
  padding: 0.5rem 0.85rem;
  max-width: min(15rem, 78vw);
  transform: translateX(-50%);
  white-space: nowrap;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  color: #6c5685;
  background: #f6f2f7;
  border: 1px solid rgb(108 86 133 / 0.12);
  border-radius: 1.75rem 1.75rem 1.75rem 1.55rem;
  box-shadow:
    0 1px 0 rgb(255 255 255 / 0.8) inset,
    0 6px 18px rgb(108 86 133 / 0.14);
  pointer-events: none;
  -webkit-font-smoothing: antialiased;
  animation: cart-msg-cloud-in 0.28s ease both;
}

.cart-add-msg[hidden] {
  display: none;
}

.cart-add-msg::before,
.cart-add-msg::after {
  content: "";
  position: absolute;
  background: #f6f2f7;
  border: 1px solid rgb(108 86 133 / 0.12);
  pointer-events: none;
}

.cart-add-msg::before {
  left: 50%;
  bottom: calc(100% - 0.28rem);
  width: 0.7rem;
  height: 0.7rem;
  margin-left: -0.35rem;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgb(108 86 133 / 0.08);
}

.cart-add-msg::after {
  left: 50%;
  bottom: calc(100% + 0.22rem);
  width: 0.42rem;
  height: 0.42rem;
  margin-left: -0.12rem;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgb(108 86 133 / 0.08);
}

@keyframes cart-msg-cloud-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(0.35rem) scale(0.92);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cart-add-msg {
    animation: none;
  }
}

.btn-buy.is-in-cart,
.btn-add-cart.is-in-cart,
.btn-buy:disabled,
.btn-add-cart:disabled {
  cursor: default;
  opacity: 0.72;
  box-shadow: none;
  pointer-events: none;
}

@media (max-width: 767px) {
  .purchase-action-group .cart-add-control {
    flex: 0 0 auto;
    width: 100%;
  }

  .cart-add-msg {
    white-space: normal;
  }
}

.quantity-picker:has(.qty-input:disabled),
.quantity-picker:has(.qty-btn:disabled) {
  opacity: 0.55;
}

.checkout-aside {
  position: static;
}

.checkout-aside .cart-table {
  font-size: var(--fs-sm);
}

.thanks-card {
  max-width: 36rem;
  margin-inline: auto;
  text-align: center;
}

.thanks-card h1 {
  margin-bottom: var(--space-3);
}

@media (min-width: 768px) {
  .checkout-aside {
    position: sticky;
    top: calc(var(--header-h) + var(--safe-top) + var(--space-4));
  }
}

.cart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* —— Cart page: 2-column layout —— */
.cart-page .page-head h1 {
  margin-bottom: var(--space-2);
}

.cart-layout {
  display: grid;
  gap: var(--space-5);
  align-items: start;
}

@media (min-width: 900px) {
  .cart-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(16rem, 0.5fr);
    gap: var(--space-6);
  }
}

.cart-layout__main {
  min-width: 0;
}

/* Список товарів */
.cart-list-card {
  background: var(--c-bg-elevated);
  border: 1px solid rgb(108 86 133 / 0.08);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.05);
  overflow: hidden;
}

.cart-list-card__head {
  display: none;
}

@media (min-width: 768px) {
  .cart-list-card__head {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr) 7.5rem 6.5rem 3.25rem;
    gap: var(--space-3);
    align-items: center;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    color: var(--c-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .cart-list-card__head-qty,
  .cart-list-card__head-price {
    text-align: center;
  }
}

.cart-items {
  display: flex;
  flex-direction: column;
}

.cart-items--embed {
  gap: 0;
}

.cart-items__footer {
  margin: 0;
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-top: 1px solid #f0f0f0;
  font-size: var(--fs-sm);
}

/* Рядок товару */
.cart-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  grid-template-areas:
    "thumb info remove"
    "thumb qty price";
  gap: 0.65rem 0.75rem;
  align-items: center;
  padding: 1rem 1rem;
  border-bottom: 1px solid #f0f0f0;
}

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

@media (min-width: 768px) {
  .cart-item {
    grid-template-columns: 90px minmax(0, 1fr) 7.5rem 6.5rem 3.25rem;
    grid-template-areas: "thumb info qty price remove";
    gap: var(--space-3);
    padding: 1.15rem 1.25rem;
  }
}

.cart-item__thumb {
  grid-area: thumb;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0.35rem;
  background: #f4f6f5;
  border: 1px solid rgb(108 86 133 / 0.08);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cart-item__thumb:hover {
  border-color: rgb(108 86 133 / 0.2);
  box-shadow: 0 2px 10px rgb(108 86 133 / 0.06);
}

@media (min-width: 768px) {
  .cart-item__thumb {
    width: 90px;
    height: 90px;
  }
}

.cart-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cart-item__thumb-placeholder {
  display: block;
  width: 40%;
  height: 40%;
  border-radius: 4px;
  background: rgb(108 86 133 / 0.12);
}

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

.cart-item__name {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--c-brand);
  font-weight: 700;
  font-size: var(--fs-sm);
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.2s ease;
}

.cart-item__name:hover {
  color: #514063;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.cart-item__unit {
  display: none;
  margin: 0.35rem 0 0;
  color: var(--c-muted);
  font-size: var(--fs-xs);
}

@media (max-width: 767px) {
  .cart-item__unit {
    display: block;
  }
}

.cart-item__unit-label {
  margin-left: 0.2rem;
  font-weight: 500;
}

.cart-item__qty {
  grid-area: qty;
  justify-self: start;
}

@media (min-width: 768px) {
  .cart-item__qty {
    justify-self: center;
  }
}

.cart-item__qty-form {
  margin: 0;
}

/* Степер кількості в кошику (компактніший за PDP) */
.cart-qty-picker {
  padding: 0.15rem;
  border-radius: 0.625rem;
}

.cart-qty-picker .qty-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 0.4rem;
  font-size: 1rem;
  line-height: 1;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cart-qty-picker .qty-btn:hover {
  background: rgb(108 86 133 / 0.08);
}

.cart-qty-picker .qty-btn:active {
  transform: scale(0.96);
  background: rgb(108 86 133 / 0.12);
}

.cart-qty-picker .qty-input {
  width: 2.25rem;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--c-brand);
  -moz-appearance: textfield;
}

.cart-qty-picker .qty-input::-webkit-outer-spin-button,
.cart-qty-picker .qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cart-item__price {
  grid-area: price;
  justify-self: end;
  color: var(--c-brand);
  font-size: var(--fs-sm);
  white-space: nowrap;
}

@media (min-width: 768px) {
  .cart-item__price {
    justify-self: center;
    font-size: var(--fs-base);
  }
}

.cart-item__price strong {
  font-weight: 700;
}

.cart-item__remove {
  grid-area: remove;
  margin: 0;
  justify-self: end;
  align-self: start;
}

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

.cart-item__remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: #d64545;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cart-item__remove-icon {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  shape-rendering: geometricPrecision;
}

.cart-item__remove-btn:hover {
  color: #b42323;
  background: rgb(212 69 69 / 0.1);
}

.cart-item__remove-btn:active {
  transform: scale(0.96);
}
