/**
 * ELBIN Redesign 2 — Cart Drawer (бічна панель кошика)
 *
 * Off-canvas панель справа замість hover-дропдауна. Каркас: backdrop + panel.
 * Вміст — WC mini-cart (.widget_shopping_cart_content): товари скроляться,
 * рядок «Разом» (темний) + CTA закріплені знизу панелі.
 */

/* 07.07.2026: ховалку дропдауна видалено — рендер вимкнено в
   panel-builder/header/cart/view.php ($has_cart_dropdown = false),
   вузлів .ct-cart-content/.ct-dropdown-content більше не існує. */

/* ── Каркас ─────────────────────────────────────────────────────────────── */
.elbin-cartdrawer {
	position: fixed;
	inset: 0;
	z-index: 100000; /* вище мобільного нижнього меню (200) і хедера (300) */
	font-family: var(--elbin-r2-font-ui);
}
.elbin-cartdrawer[hidden] {
	display: none;
}

.elbin-cartdrawer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(14, 18, 20, 0.5);
	opacity: 0;
	transition: opacity 0.28s ease;
}
.elbin-cartdrawer.is-open .elbin-cartdrawer__backdrop {
	opacity: 1;
}

/* ── Панель ─────────────────────────────────────────────────────────────── */
.elbin-cartdrawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 400px;
	max-width: 92vw;
	display: flex;
	flex-direction: column;
	/* Темна панель у колір футера/хедера: тіло #0D0D0D, шапка #1A1A1A нижче. */
	background: #0D0D0D;
	box-shadow: -16px 0 48px rgba(14, 18, 20, 0.45);
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}
.elbin-cartdrawer.is-open .elbin-cartdrawer__panel {
	transform: translateX(0);
}

/* ── Шапка ──────────────────────────────────────────────────────────────── */
.elbin-cartdrawer__head {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 20px;
	background: #1A1A1A; /* = топбенд футера */
	border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.elbin-cartdrawer__title {
	font: 800 18px/1 var(--elbin-r2-font-ui);
	letter-spacing: -0.01em;
	color: var(--elbin-r2-header-text, #F4F4F5);
}
.elbin-cartdrawer__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	margin: -6px -8px -6px 0;
	border: none;
	background: transparent;
	border-radius: 10px;
	color: var(--elbin-r2-header-text-3, #A1A1A6);
	cursor: pointer;
	transition: color 0.15s ease, background 0.15s ease;
}
.elbin-cartdrawer__close:hover {
	color: var(--elbin-r2-header-text, #F4F4F5);
	background: rgba(255, 255, 255, 0.1);
}

/* ── Тіло (mini-cart) ───────────────────────────────────────────────────── */
.elbin-cartdrawer__body {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
}
.elbin-cartdrawer .widget_shopping_cart_content {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
}

/* Список товарів — скрол */
.elbin-cartdrawer ul.woocommerce-mini-cart {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	list-style: none;
	margin: 0;
	padding: 8px;
}
.elbin-cartdrawer .woocommerce-mini-cart-item {
	position: relative;
	display: grid;
	grid-template-columns: 64px 1fr;
	gap: 14px;
	align-items: center;
	padding: 14px 40px 14px 8px;
	margin: 0 !important;
	border: none !important;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
	border-radius: 0;
}
.elbin-cartdrawer .woocommerce-mini-cart-item:last-child {
	border-bottom: none !important;
}
.elbin-cartdrawer .woocommerce-mini-cart-item:hover {
	background: rgba(255, 255, 255, 0.04);
}
.elbin-cartdrawer .ct-media-container {
	width: 64px;
	height: 64px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 10px;
	background: #fff;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}
.elbin-cartdrawer .ct-media-container img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}
.elbin-cartdrawer .product-data {
	min-width: 0;
}
.elbin-cartdrawer .product-title {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--elbin-r2-header-text, #F4F4F5);
	text-decoration: none;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.elbin-cartdrawer .product-title:hover {
	color: var(--elbin-r2-accent, #1AD0CA);
}
.elbin-cartdrawer .quantity {
	display: block;
	margin-top: 6px;
	font: 600 14px/1 var(--elbin-r2-font-mono);
	color: var(--elbin-r2-header-text-3, #A1A1A6);
}

/* Видалити (🗑) — праворуч */
.elbin-cartdrawer .woocommerce-mini-cart-item .remove {
	position: absolute !important;
	top: 50% !important;
	right: 8px !important;
	left: auto !important;
	transform: translateY(-50%) !important;
	width: 30px;
	height: 30px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--elbin-r2-header-text-3, #A1A1A6) !important;
	background: transparent !important;
	border-radius: 8px;
	font-size: 0;
}
.elbin-cartdrawer .woocommerce-mini-cart-item .remove:hover {
	color: #FF6B6B !important;
	background: rgba(255, 107, 107, 0.12) !important;
}
.elbin-cartdrawer .woocommerce-mini-cart-item .remove svg {
	width: 17px;
	height: 17px;
}

/* ── Порожній кошик ──────────────────────────────────────────────────────
 * Рендериться той самий блок, що й на сторінці кошика (cart.php →
 * .elbin-r2-cart-empty + .return-to-shop), але cart.css фарбує його під
 * СВІТЛУ сторінку. Тут перефарбовуємо під ТЕМНУ панель і центруємо.
 */
.elbin-cartdrawer .elbin-r2-cart-empty {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	max-width: none;
	margin: 0;
	padding: 40px 28px 20px;
	text-align: center;
	background: transparent;
	border: none;
	border-radius: 0;
}
.elbin-cartdrawer .elbin-r2-cart-empty__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 64px;
	height: 64px;
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.12);
	border-radius: 50%;
	color: var(--elbin-r2-header-text-3, #A1A1A6);
}
.elbin-cartdrawer .elbin-r2-cart-empty__icon svg {
	width: 26px;
	height: 26px;
}
.elbin-cartdrawer .elbin-r2-cart-empty__title {
	margin: 18px 0 8px;
	font: 800 19px/1.2 var(--elbin-r2-font-ui);
	color: var(--elbin-r2-header-text, #F4F4F5);
}
.elbin-cartdrawer .elbin-r2-cart-empty__text {
	max-width: 300px;
	font-size: 14px;
	line-height: 1.55;
	color: var(--elbin-r2-header-text-3, #A1A1A6);
}

/* CTA «Перейти до каталогу» — бірюзова кнопка по центру панелі */
.elbin-cartdrawer .return-to-shop {
	flex-shrink: 0;
	max-width: none;
	margin: 0;
	padding: 4px 28px calc(28px + env(safe-area-inset-bottom, 0px));
	text-align: center;
	background: transparent;
	border: none;
	border-radius: 0;
}
.elbin-cartdrawer .return-to-shop a.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 50px;
	padding: 0 26px;
	background: var(--elbin-r2-accent, #1AD0CA) !important;
	color: var(--elbin-r2-ink-on-accent, #063D2E) !important;
	border: none !important;
	border-radius: var(--elbin-r2-r-control, 6px);
	font: 700 14px/1 var(--elbin-r2-font-ui);
	letter-spacing: 0.02em;
	text-transform: uppercase;
	text-decoration: none;
}
.elbin-cartdrawer .return-to-shop a.button:hover {
	background: var(--elbin-r2-accent-hover, #16B8B2) !important;
}

/* Рядок «Разом» — темна смуга */
.elbin-cartdrawer .woocommerce-mini-cart__total {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 !important;
	padding: 18px 20px !important;
	background: #0D0D0D !important;
	color: var(--elbin-r2-header-text, #F4F4F5) !important;
	border: none !important;
	/* Панель уже темна — відмежовуємо тотал тонкою лінією зверху. */
	border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}
.elbin-cartdrawer .woocommerce-mini-cart__total strong {
	font: 700 12px/1 var(--elbin-r2-font-ui);
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--elbin-r2-header-text-3, #A1A1A6);
}
.elbin-cartdrawer .woocommerce-mini-cart__total .amount {
	font: 800 20px/1 var(--elbin-r2-font-ui);
	color: var(--elbin-r2-header-text, #F4F4F5);
}

/* Кнопки: CTA «Оформлення» (бірюза) зверху + «Переглянути кошик» (лінк) знизу */
.elbin-cartdrawer .woocommerce-mini-cart__buttons {
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0 !important;
	padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
}
.elbin-cartdrawer .woocommerce-mini-cart__buttons .button {
	margin: 0 !important;
	min-width: 0;
}
.elbin-cartdrawer .woocommerce-mini-cart__buttons .button.checkout {
	order: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 50px;
	background: var(--elbin-r2-accent, #1AD0CA) !important;
	color: var(--elbin-r2-ink-on-accent, #063D2E) !important;
	border: none !important;
	border-radius: var(--elbin-r2-r-control, 6px);
	font: 700 14px/1 var(--elbin-r2-font-ui);
	letter-spacing: 0.02em;
	text-transform: uppercase;
	text-decoration: none;
}
.elbin-cartdrawer .woocommerce-mini-cart__buttons .button.checkout:hover {
	background: var(--elbin-r2-accent-hover, #16B8B2) !important;
}
.elbin-cartdrawer .woocommerce-mini-cart__buttons .button:not(.checkout) {
	order: 1;
	height: auto;
	padding: 0 !important;
	background: transparent !important;
	border: none !important;
	color: var(--elbin-r2-header-text-3, #A1A1A6) !important;
	text-align: center;
	font: 600 13px/1 var(--elbin-r2-font-ui);
	text-decoration: underline;
	text-underline-offset: 2px;
}
.elbin-cartdrawer .woocommerce-mini-cart__buttons .button:not(.checkout):hover {
	color: var(--elbin-r2-accent, #1AD0CA) !important;
}

/* Блокування скролу body, поки панель відкрита */
body.elbin-cartdrawer-open {
	overflow: hidden;
}

/* ── Мобільний (<1000px): панель виїжджає ЗНИЗУ, як каталог-drawer ──────
 * Спільний каркас → стосується всіх трьох панелей (кошик/обране/акаунт).
 * Глобальне .is-open правило скидає transform (translateX(0) == identity),
 * тож анімація зі стартового translateY(100%) їде вгору сама. */
@media (max-width: 999.98px) {
	/* Контейнер закінчується НАД нижнім меню: меню видиме й клікабельне,
	   панелі перемикаються тапом по пунктах без закриття (02.07).
	   overflow:hidden — стартова позиція панелі translateY(100%) стирчить
	   нижче контейнера і без кліпу проїжджала ПОВЕРХ меню при анімації
	   («меню ще раз виїжджає», фото 02.07). */
	.elbin-cartdrawer {
		/* прямий env() без var — див. mobile-nav.css (iOS-фікс 02.07);
		   другий рядок = компактна safe-зона, фолбек-ланцюжок */
		bottom: calc(60px + env(safe-area-inset-bottom, 0px));
		bottom: calc(60px + max(env(safe-area-inset-bottom, 0px) - 14px, 0px));
		overflow: hidden;
	}

	.elbin-cartdrawer__panel {
		top: auto;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-width: 100%;
		/* Висота керована ручкою __handle (спільна змінна, mobile-nav.js). */
		height: var(--elbin-sheet-h, 55vh);
		min-height: 30vh;
		max-height: 92vh;
		border-radius: 20px 20px 0 0;
		box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
		transform: translateY(100%);
	}

	/* Відкритий стан МУСИТЬ бути тією ж transform-функцією, що й закритий:
	   глобальне translateX(0) проти translateY(100%) браузер НЕ інтерполює
	   (різні функції з відсотками) → панель телепортувалась без анімації
	   («багано відкривається», кадрова діагностика 02.07). */
	.elbin-cartdrawer.is-open .elbin-cartdrawer__panel {
		transform: translateY(0);
	}

	/* Ручка = ресайз висоти шторки (спільна для всіх), як у каталога:
	   широка хіт-зона, видима смужка через ::after. Показуємо лише на моб —
	   на десктопі кошик/акаунт це бічні панелі повної висоти. */
	.elbin-cartdrawer__handle {
		display: flex;
		flex-shrink: 0;
		width: 100%;
		height: 24px;
		align-items: center;
		justify-content: center;
		cursor: ns-resize;
		touch-action: none;
	}
	.elbin-cartdrawer__handle::after {
		content: "";
		width: 40px;
		height: 4px;
		border-radius: 999px;
		background: rgba(255, 255, 255, 0.25);
	}
}

/* Десктоп: бічна панель — ручка не потрібна. */
@media (min-width: 1000px) {
	.elbin-cartdrawer__handle {
		display: none;
	}
}
