/* ══════════════════════════════════════════
   cart.css — корзина сайта /Cart (06.11.2026; проект docs/2026-11-05-shop-cart/README.md, §6.2; ui.md §3). Разметка —
   Views/Cart/Index.cshtml и _CartContent.cshtml (тот же фрагмент присылает сервер скрипту после «− / + / Удалить»).

   Requires: shop-product.css — чипы статуса (.shop__status), главная кнопка (.shop__buy), переменные .shop (зелёный «В продаже»,
   тень карточки) и их тёмная тема; корень страницы — .shop .cart, ширина и поля — как у «Магазина» (.shop: 1120 px, 32/16 px).
   Компьютер — две колонки: строки | «Итого» (липкая); телефон — одна, «Итого» под строками.
   Цвета — только токены сайта (тёмная тема работает сама); ниже переопределён лишь мелкий красный текст на тёмном фоне.
   ══════════════════════════════════════════ */

.cart {
  padding-top: 28px;
  padding-bottom: 56px;
}

.cart__head {
  margin: 0 0 20px;
}
.cart__title {
  margin: 0;
  color: var(--text);
  font-family: "Lora", Georgia, serif;
  font-size: 36px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.cart__title:focus {
  outline: none;
}
.cart__title:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Ошибка запроса скрипта (сеть) — над корзиной, пока следующий запрос не пройдёт. */
.cart__error {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary-text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
}

/* Пока сервер пересчитывает (скрипт), строки чуть приглушены — второе нажатие не уйдёт. */
.cart__content[aria-busy="true"] .cart__layout {
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

/* ── Две колонки ── */

.cart__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  align-items: start;
  gap: 28px;
}
.cart__main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

/* ── Плашки над строками: пропавшие книги, недоступные книги ── */

.cart__notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
.cart__main .cart__notice {
  margin: 0;
}

/* ── Строки ── */

.cart__list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cart-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto 36px;
  grid-template-areas: "cover body side remove";
  align-items: start;
  gap: 4px 16px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shop-shadow);
}

.cart-line__cover {
  grid-area: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.cart-line__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.cart-line__placeholder {
  color: var(--text-3);
}

.cart-line__body {
  grid-area: body;
  display: grid;
  gap: 4px;
  min-width: 0;
}
.cart-line__title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.cart-line__title a {
  color: var(--text);
  text-decoration: none;
}
.cart-line__title a:hover {
  color: var(--primary-text);
}
.cart-line__title a:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.cart-line__price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 2px 0 0;
}
.cart-line__unit {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cart-line__old {
  color: var(--text-3);
  font-size: 14px;
  white-space: nowrap;
}
.cart-line__offer {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
}
.cart-line__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.4;
}
.cart-line__chip {
  flex-shrink: 0;
  padding: 2px 10px;
  font-size: 12px;
}
.cart-line__reduced {
  margin: 4px 0 0;
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

/* Количество и сумма строки — справа. */
.cart-line__side {
  grid-area: side;
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 0;
}
.cart-line__total {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Недоступная строка: вместо количества — причина словами карточки. */
.cart-line__blocked {
  max-width: 220px;
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: right;
}

.cart-qty {
  margin: 0;
}
.cart-qty__group {
  display: inline-flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 100px;
}
.cart-qty__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.cart-qty__btn:hover {
  background: var(--bg-hover);
  color: var(--primary-text);
}
.cart-qty__btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* На пределе — неактивна, но остаётся в фокусе (aria-disabled, а не disabled): после пересчёта фокус не падает на страницу. */
.cart-qty__btn[aria-disabled="true"],
.cart-qty__btn[aria-disabled="true"]:hover {
  background: transparent;
  color: var(--text-4);
  cursor: not-allowed;
}
.cart-qty__value {
  min-width: 28px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.cart-qty__hint {
  margin: 0;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
}

/* «Удалить» — крестик в углу строки; подпись — для скринридера и всплывающей подсказкой. */
.cart-line__remove-form {
  grid-area: remove;
  margin: 0;
}
.cart-line__remove {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.cart-line__remove:hover {
  background: var(--bg-hover);
  color: var(--primary-text);
}
.cart-line__remove:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Недоступная книга: строка серая — фото и цена приглушены, «Удалить» по-прежнему в полную силу. */
.cart-line--blocked {
  box-shadow: none;
  border: 1px solid var(--border);
}
.cart-line--blocked .cart-line__img {
  opacity: 0.6;
  filter: grayscale(0.6);
}
.cart-line--blocked .cart-line__title a,
.cart-line--blocked .cart-line__unit {
  color: var(--text-2);
}

/* ── «Итого» ── */

.cart__summary {
  position: sticky;
  top: calc(var(--header-h, 64px) + 16px);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--card);
  border-radius: var(--card-radius);
  box-shadow: var(--shop-shadow);
}
.cart__summary-title {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
}

/* Одна посылка по самому позднему сроку (оферта 1.3, п. 6.1) — крупно и рядом с кнопкой оформления. */
.cart__parcel {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
}
.cart__parcel-icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--primary-text);
}

.cart__totals {
  display: grid;
  gap: 8px;
  margin: 0;
}
.cart__total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.cart__total-row dt {
  color: var(--text-2);
  font-size: 15px;
}
.cart__total-row dd {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.cart__delivery-note {
  margin: -4px 0 0;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.4;
}

.cart__actions {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}
.cart__checkout {
  width: 100%;
}
/* «Продолжить покупки» — обводка, как «Подробнее о книге» в «Магазине»: главное действие одно. */
.cart__continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  padding: 12px 26px;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}
.cart__continue:hover {
  border-color: var(--primary);
  color: var(--primary-text);
}
.cart__continue:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* ── Пусто ── */

.cart__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 56px 24px;
  background: var(--card);
  border-radius: var(--card-radius);
  box-shadow: var(--shop-shadow);
  text-align: center;
}
.cart__empty-icon {
  color: var(--text-3);
}
.cart__empty-text {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
}

/* ── Тёмная тема: мелкий красный текст светлее (красный бренда на тёмной карточке ≈ 3:1) ── */

html[data-theme="dark"] .cart__error,
html[data-theme="dark"] .cart-line__reduced,
html[data-theme="dark"] .cart-line__title a:hover,
html[data-theme="dark"] .cart-qty__btn:hover,
html[data-theme="dark"] .cart-line__remove:hover,
html[data-theme="dark"] .cart__parcel-icon,
html[data-theme="dark"] .cart__continue:hover {
  color: #f19a8f;
}
html[data-theme="dark"] .cart__continue:hover {
  border-color: #f19a8f;
}
html[data-theme="dark"] .cart__error,
html[data-theme="dark"] .cart__parcel {
  background: rgba(241, 154, 143, 0.12);
}

/* ── Телефон и узкий планшет: одна колонка, «Итого» под строками ── */

@media (max-width: 900px) {
  .cart__layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .cart__summary {
    position: static;
  }
}

@media (max-width: 600px) {
  .cart {
    padding-top: 20px;
    padding-bottom: 40px;
  }
  .cart__title {
    font-size: 30px;
  }
  /* Строка: обложка | название и цена | крестик; ниже во всю ширину — количество слева, сумма справа. */
  .cart-line {
    grid-template-columns: 64px minmax(0, 1fr) 36px;
    grid-template-areas:
      "cover body remove"
      "side side side";
    gap: 12px 12px;
    padding: 14px;
  }
  .cart-line__side {
    grid-template-columns: auto auto;
    grid-template-areas:
      "qty total"
      "hint hint";
    align-items: center;
    justify-content: space-between;
    justify-items: start;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
  }
  /* В тёмной теме --border-light совпадает с цветом карточки — черта пропала бы. */
  html[data-theme="dark"] .cart-line__side {
    border-top-color: var(--border);
  }
  .cart-line__side .cart-qty {
    grid-area: qty;
  }
  .cart-line__side .cart-qty__hint {
    grid-area: hint;
  }
  .cart-line__side .cart-line__total {
    grid-area: total;
    justify-self: end;
  }
  .cart-line__blocked {
    grid-column: 1 / -1;
    max-width: none;
    text-align: left;
  }
  .cart__summary {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cart__content[aria-busy="true"] .cart__layout {
    transition: none;
  }
}
