/* ==========================================================================
   Блок: Мини-корзина (.b-cart-drawer)
   Scoped-стили: все селекторы под .b-cart-drawer.
   Класс .is-open и атрибуты hidden ставит assets/js/app.js.
   ========================================================================== */

.b-cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 300;
  visibility: hidden;
  transition: visibility 0s 0.4s;
}

.b-cart-drawer.is-open {
  visibility: visible;
  transition-delay: 0s;
}

/* Затемнение фона */
.b-cart-drawer__overlay {
  position: absolute;
  inset: 0;
  background: rgba(59, 52, 55, 0.4);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.b-cart-drawer.is-open .b-cart-drawer__overlay {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Панель справа
   -------------------------------------------------------------------------- */
.b-cart-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 94vw);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.4s ease;
  box-shadow: -12px 0 40px rgba(59, 52, 55, 0.12);
}

.b-cart-drawer.is-open .b-cart-drawer__panel {
  transform: translateX(0);
}

/* Шапка панели */
.b-cart-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.b-cart-drawer__title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
}

.b-cart-drawer__close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--muted);
  transition: color var(--transition), background-color var(--transition);
}

.b-cart-drawer__close:hover {
  color: var(--accent);
  background: var(--lavender-soft);
}

.b-cart-drawer__close svg {
  width: 20px;
  height: 20px;
}

/* --------------------------------------------------------------------------
   Пустое состояние
   -------------------------------------------------------------------------- */
.b-cart-drawer__empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 32px;
  text-align: center;
}

.b-cart-drawer__empty-icon {
  width: 56px;
  height: 56px;
  color: var(--lavender);
  margin-bottom: 8px;
}

.b-cart-drawer__empty-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

.b-cart-drawer__empty-text {
  font-size: 14px;
  color: var(--muted);
  max-width: 280px;
  margin-bottom: 14px;
}

/* --------------------------------------------------------------------------
   Список товаров
   -------------------------------------------------------------------------- */
.b-cart-drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 24px;
}

.b-cart-drawer__items {
  display: flex;
  flex-direction: column;
}

/* Одна позиция (разметка генерируется в app.js) */
.b-cart-drawer__item {
  display: flex;
  gap: 14px;
  padding-block: 18px;
  border-bottom: 1px solid var(--line);
}

.b-cart-drawer__item-img {
  flex: 0 0 76px;
  width: 76px;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--muted);
}

.b-cart-drawer__item-img svg {
  width: 28px;
  height: 28px;
  opacity: 0.6;
}

.b-cart-drawer__item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.b-cart-drawer__item-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.b-cart-drawer__item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.b-cart-drawer__item-meta {
  font-size: 12px;
  color: var(--muted);
}

/* Переключатель количества */
.b-cart-drawer__qty {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  align-self: flex-start;
}

.b-cart-drawer__qty button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-size: 16px;
  color: var(--muted);
  transition: color var(--transition);
}

.b-cart-drawer__qty button:hover {
  color: var(--accent);
}

.b-cart-drawer__qty span {
  min-width: 26px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
}

/* Правая колонка позиции: цена и удаление */
.b-cart-drawer__item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.b-cart-drawer__item-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.b-cart-drawer__item-remove {
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  transition: color var(--transition), border-color var(--transition);
}

.b-cart-drawer__item-remove:hover {
  color: var(--error, #B4553F);
  border-color: currentColor;
}

/* --------------------------------------------------------------------------
   Подвал: подытог и кнопки
   -------------------------------------------------------------------------- */
.b-cart-drawer__foot {
  padding: 20px 24px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.b-cart-drawer__subtotal {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.b-cart-drawer__subtotal-value {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.b-cart-drawer__note {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.b-cart-drawer__foot .btn + .btn {
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   Адаптив
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .b-cart-drawer__panel {
    width: 100vw;
  }

  .b-cart-drawer__head {
    padding: 18px 20px;
  }

  .b-cart-drawer__body {
    padding: 8px 20px;
  }

  .b-cart-drawer__foot {
    padding: 16px 20px 20px;
  }
}
