/* =====================================================================
   42.2 — Cart Page
   Соответствует макетам:
     WebDesign/desktop-cart.pdf, desktop-cart-1.pdf
     WebDesign/phone-cart.pdf,   phone-cart-1.pdf
   Подключается ТОЛЬКО на странице корзины (см. inc/wc-cart.php).
   ===================================================================== */

:root {
  --cart-brand: #B600BD;
}

.cart-page {
  padding: 40px 0 120px;
}
.cart-page__container { position: relative; }

/* ----- Шапка страницы (desktop) ----- */
.cart-page__head { margin-bottom: 24px; }
.cart-page__head .breadcrumbs { margin-bottom: 12px; }
.cart-page__title {
  font-family: 'Bebas Neue', 'Inter', system-ui, sans-serif;
  font-size: 96px;
  line-height: 1;
  letter-spacing: 0.01em;
  margin: 0;
  text-transform: uppercase;
  color: var(--ink);
}

/* ----- Шапка страницы (mobile, «‹ КОРЗИНА») ----- */
.cart-page__back {
  display: none;
  align-items: center;
  gap: 12px;
  font-family: 'Bebas Neue', 'Inter', system-ui, sans-serif;
  font-size: 28px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 16px;
  padding: 8px 0;
}
.cart-page__back svg { width: 24px; height: 24px; flex: 0 0 24px; }
.cart-page__back:hover { opacity: .7; }

/* ----- Сетка: список + сайдбар ----- */
.cart-page__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 80px;
  align-items: start;
}

/* ============= СПИСОК ПОЗИЦИЙ ============= */
.cart-list {
  border-top: 1px solid var(--line);
}

.cart-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto auto auto;
  align-items: center;
  column-gap: 32px;
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.cart-item__media {
  display: block;
  width: 120px;
  height: 120px;
  background: var(--surface-alt);
  border-radius: 4px;
  overflow: hidden;
}
.cart-item__media img,
.cart-item__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cart-item__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cart-item__name {
  font-family: 'Bebas Neue', 'Inter', system-ui, sans-serif;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.cart-item__name:hover { opacity: .7; }
.cart-item__attrs {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ----- Quantity ----- */
.cart-item__qty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 6px;
  background: var(--bg);
  height: 44px;
}
.cart-item__qty-btn {
  appearance: none;
  background: transparent;
  border: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: background .15s ease, color .15s ease;
}
.cart-item__qty-btn svg { width: 14px; height: 14px; }
.cart-item__qty-btn:hover { background: var(--surface-alt); }
.cart-item__qty-btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; }
.cart-item__qty-input {
  width: 40px;
  border: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  -moz-appearance: textfield;
  appearance: textfield;
  padding: 0;
}
.cart-item__qty-input::-webkit-outer-spin-button,
.cart-item__qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.cart-item__qty-input:focus { outline: none; }

/* ----- Цена позиции ----- */
.cart-item__price {
  font-style: italic;
  font-weight: 800;
  font-size: 20px;
  color: var(--price);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.15;
}
.cart-item__price .woocommerce-Price-amount,
.cart-item__price bdi { font-style: italic; font-weight: 800; }

/* WC оборачивает «акционная + старая» в <ins>/<del>.
   В нашем макете: акционная внизу с розовым подчёркиванием, старая выше. */
.cart-item__price ins {
  text-decoration: none;
  color: var(--price);
  position: relative;
  padding-bottom: 2px;
  background: linear-gradient(var(--cart-brand), var(--cart-brand)) left bottom / 70% 2px no-repeat;
}
.cart-item__price del {
  color: var(--old);
  font-size: 16px;
  font-weight: 700;
  text-decoration: line-through;
  opacity: .9;
}

/* ----- Действия (избранное + удалить) ----- */
.cart-item__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.cart-item__fav,
.cart-item__remove {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 6px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}
.cart-item__fav svg,
.cart-item__remove svg { width: 22px; height: 22px; }
.cart-item__fav:hover,
.cart-item__remove:hover { color: var(--cart-brand); transform: scale(1.05); }

.cart-item__fav-filled { display: none; }
.cart-item__fav.is-active { color: var(--cart-brand); }
.cart-item__fav.is-active .cart-item__fav-outline { display: none; }
.cart-item__fav.is-active .cart-item__fav-filled  { display: block; }

/* Скрываем разметку YITH — она остаётся в DOM как «прокси» для AJAX-вызова. */
.cart-item__fav-yith { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Удаление: анимация исчезновения */
.cart-item.is-removing {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

/* ============= СВОДКА (sidebar) ============= */
.cart-summary {
  position: sticky;
  top: 110px;
  padding: 4px 0 0;
}
.cart-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 0;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.cart-summary__row:last-of-type { border-bottom: 0; }
.cart-summary__row--total { padding-top: 20px; padding-bottom: 28px; }

.cart-summary__label {
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.06em;
}
.cart-summary__value {
  font-style: italic;
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
  white-space: nowrap;
}
.cart-summary__row--total .cart-summary__value { font-size: 22px; }

.cart-summary__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 72px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.cart-summary__btn:hover {
  background: var(--ink);
  color: var(--bg);
  transform: translateY(-1px);
}
.cart-summary__btn.is-loading { pointer-events: none; opacity: .6; }

.cart-summary__note {
  margin: 16px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.cart-summary__note a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cart-summary__note a:hover { color: var(--cart-brand); }

/* ============= ОБРАБОТКА AJAX-СОСТОЯНИЙ ============= */
.cart-item.is-loading { opacity: .55; }
.cart-item.is-loading .cart-item__qty,
.cart-item.is-loading .cart-item__actions { pointer-events: none; }
.cart-summary.is-loading { opacity: .6; transition: opacity .15s ease; }

/* ============= ТЁМНАЯ ТЕМА (наследуем переменные темы) ============= */
[data-theme="dark"] .cart-page__title  { color: var(--ink); }
[data-theme="dark"] .cart-item__media  { background: var(--surface-alt); }
[data-theme="dark"] .cart-item__qty    { background: transparent; border-color: var(--line-strong); }
[data-theme="dark"] .cart-item__qty-btn:hover { background: var(--surface-alt); }
[data-theme="dark"] .cart-item__price del { color: var(--old); }
[data-theme="dark"] .cart-summary__btn { color: var(--ink); border-color: var(--ink); }
[data-theme="dark"] .cart-summary__btn:hover { background: var(--ink); color: var(--bg); }

/* ============= MOBILE (≤ 768px) ============= */
@media (max-width: 768px) {
  .cart-page { padding: 16px 0 80px; }

  .cart-page__head    { display: none; }
  .cart-page__back    { display: inline-flex; }

  .cart-page__layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .cart-list { border-top: 1px solid var(--line); }

  .cart-item {
    grid-template-columns: 76px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 16px;
    row-gap: 12px;
    padding: 20px 0;
  }
  .cart-item__media {
    width: 76px;
    height: 96px;
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: start;
  }
  .cart-item__info     { grid-column: 2; grid-row: 1; gap: 6px; }
  .cart-item__actions  {
    grid-column: 3;
    grid-row: 1;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    align-self: start;
  }
  .cart-item__qty   { grid-column: 2; grid-row: 2; justify-self: start; }
  .cart-item__price { grid-column: 3; grid-row: 2; justify-self: end; align-self: center; }

  .cart-item__name  { font-size: 18px; }
  .cart-item__attrs { font-size: 13px; }

  .cart-item__qty       { height: 40px; }
  .cart-item__qty-btn   { width: 28px; height: 28px; }
  .cart-item__qty-input { width: 32px; font-size: 14px; }

  .cart-item__price { font-size: 17px; flex-direction: row; align-items: baseline; gap: 8px; }
  .cart-item__price del { font-size: 14px; }

  .cart-item__fav,
  .cart-item__remove { width: 28px; height: 28px; padding: 2px; }
  .cart-item__fav svg,
  .cart-item__remove svg { width: 22px; height: 22px; }

  .cart-summary { position: static; padding-top: 8px; }
  .cart-summary__row       { padding: 14px 0; font-size: 15px; }
  .cart-summary__row--total{ padding-top: 18px; padding-bottom: 24px; }
  .cart-summary__value     { font-size: 18px; }
  .cart-summary__row--total .cart-summary__value { font-size: 20px; }

  .cart-summary__btn  { height: 64px; font-size: 16px; }
  .cart-summary__note { font-size: 12px; }
}

/* Очень узкие экраны: подвинуть колонку количества чуть плотнее */
@media (max-width: 360px) {
  .cart-item { column-gap: 10px; }
  .cart-item__qty { padding: 2px 4px; }
  .cart-item__qty-btn { width: 26px; height: 26px; }
}
