/* =========================================================
   Tsvetomania · mini-cart drawer · v2
   ========================================================= */

/* ---------- Триггер в шапке ---------- */
.tm-cart-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px 6px 6px;
	background: transparent;
	border: none;
	cursor: pointer;
	font-family: 'Tilda Sans', -apple-system, BlinkMacSystemFont, sans-serif;
	font-size: 14px;
	font-weight: 500;
	color: #A11826;
	position: relative;
	z-index: 2; /* над родительскими обработчиками */
	text-decoration: none;
	line-height: 1.2;
	transition: color .15s ease;
}
.tm-cart-trigger:hover { color: #7a1119; }

.tm-cart-trigger__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: inherit;
	flex-shrink: 0;
	pointer-events: none; /* чтобы target клика был сам <button>, а не <svg> */
	position: relative;   /* якорь для бейджа */
	width: 28px;          /* одинаковый якорь с .intensa-favorite-icon-wrap */
	height: 28px;
}
.tm-cart-trigger__icon svg { pointer-events: none; }

.tm-cart-trigger__label {
	color: inherit;
	font-size: inherit;
	font-weight: inherit;
	margin: 0;
	pointer-events: none;
}

/* Бейдж с количеством — 1:1 с .intensa-favorite-badge из favorite-counter.css */
.tm-cart-trigger__badge {
	position: absolute;
	top: -6px;
	right: -8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	background: #A11826;
	color: #fff;
	font-family: 'Tilda Sans', Arial, sans-serif;
	font-size: 11px;
	font-weight: 600;
	line-height: 1;
	letter-spacing: -0.02em;
	border-radius: 999px;
	border: 2px solid #fff;  /* обводка ВНУТРИ 18×18 (box-sizing: border-box) — как у избранного */
	box-sizing: border-box;
	pointer-events: none;
}
.tm-cart-trigger__badge[hidden] { display: none; }

.header__middle-buttons_mobile .tm-cart-trigger__label { display: none; }

/* ---------- DRAWER ---------- */

.tm-cart {
	--tm-primary: #A11826;
	--tm-primary-dark: #7a1119;
	--tm-accent: #F13A5F;
	--tm-bg: #ffffff;
	--tm-surface: #faf8f3;
	--tm-border: #ece7dd;
	--tm-border-soft: #f4f0e7;
	--tm-text: #1a0d0f;
	--tm-text-muted: #8a857c;
	--tm-danger-bg: #fcebeb;

	font-family: 'Tilda Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	color: var(--tm-text);
}

/* ---------- Overlay: поверх вообще всего на сайте ---------- */
.tm-cart__overlay {
	position: fixed;
	inset: 0;
	background: rgba(20, 10, 12, 0.42);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	opacity: 0;
	z-index: 2147483646;
	transition: opacity .25s ease;
	pointer-events: auto;
	touch-action: none; /* перехватываем touch — ничего не пропускает вниз */
}
.tm-cart__overlay.is-open { opacity: 1; }
.tm-cart__overlay[hidden] { display: none; }

/* ---------- Drawer-панель: самый верхний слой ---------- */
.tm-cart__drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 420px;
	max-width: 100vw;
	background: var(--tm-bg);
	z-index: 2147483647;
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform .32s cubic-bezier(.4, 0, .2, 1);
	box-shadow: -16px 0 48px rgba(0, 0, 0, 0.14);
	will-change: transform;
}
.tm-cart__drawer.is-open { transform: translateX(0); }
.tm-cart__drawer[hidden] { display: none; }

@media (max-width: 480px) {
	.tm-cart__drawer { width: 100vw; }
}

/* ---------- Шапка drawer ---------- */
.tm-cart__head {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px 16px;
	border-bottom: 1px solid var(--tm-border-soft);
}
.tm-cart__title {
	margin: 0;
	font-size: 18px;
	font-weight: 500;
	color: var(--tm-text);
	letter-spacing: -0.2px;
	display: flex;
	align-items: center;
	gap: 8px;
	font-family: inherit;
}
.tm-cart__pill {
	display: inline-flex;
	align-items: center;
	background: #f9ede9;
	color: var(--tm-primary);
	font-size: 11px;
	font-weight: 500;
	padding: 3px 9px;
	border-radius: 12px;
}
.tm-cart__pill:empty { display: none; }

.tm-cart__close {
	width: 34px;
	height: 34px;
	flex-shrink: 0;
	border-radius: 50%;
	border: none;
	background: transparent;
	cursor: pointer;
	color: var(--tm-text);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease, color .15s ease;
}
.tm-cart__close:hover {
	background: var(--tm-surface);
	color: var(--tm-primary);
}
.tm-cart__close svg { pointer-events: none; }

/* ---------- Тело drawer ---------- */
.tm-cart__body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}
.tm-cart__body::-webkit-scrollbar { width: 6px; }
.tm-cart__body::-webkit-scrollbar-thumb {
	background: #e5ded0;
	border-radius: 3px;
}

.tm-cart__list {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* ---------- Item ---------- */
.tm-cart__item {
	display: flex;
	gap: 14px;
	padding: 16px 24px;
	border-bottom: 1px solid var(--tm-border-soft);
	position: relative;
	overflow: hidden;
	transition: background .15s ease, opacity .28s ease, height .28s ease, padding .28s ease, margin .28s ease;
}
.tm-cart__item:hover { background: #fdfcf8; }
.tm-cart__item.is-removing {
	opacity: 0;
	pointer-events: none;
}
.tm-cart__item.is-loading {
	opacity: 0.55;
	pointer-events: none;
}

.tm-cart__item-img {
	display: block;
	width: 72px;
	height: 72px;
	flex-shrink: 0;
	border-radius: 8px;
	overflow: hidden;
	background: var(--tm-surface);
	border: 1px solid var(--tm-border);
}
.tm-cart__item-img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.tm-cart__item-body {
	flex: 1 1 auto;
	min-width: 0;
	padding-right: 24px;
}

.tm-cart__item-name {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;

	font-size: 13.5px;
	font-weight: 500;
	color: var(--tm-text);
	line-height: 1.35;
	text-decoration: none;
	margin: 0 0 10px;
	transition: color .15s ease;
}
.tm-cart__item-name:hover { color: var(--tm-primary); }

.tm-cart__item-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 4px;
}

.tm-cart__item-price {
	font-size: 14px;
	font-weight: 500;
	color: var(--tm-primary);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* ---------- Stepper −/+ ---------- */
.tm-cart__stepper {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--tm-border);
	border-radius: 20px;
	overflow: hidden;
	height: 30px;
	background: #fff;
}
.tm-cart__stepper-btn {
	width: 30px;
	height: 30px;
	border: none;
	background: transparent;
	cursor: pointer;
	color: var(--tm-text);
	font-size: 16px;
	font-weight: 400;
	line-height: 1;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease, color .15s ease;
	font-family: inherit;
}
.tm-cart__stepper-btn:not(:disabled):hover {
	background: var(--tm-surface);
	color: var(--tm-primary);
}
.tm-cart__stepper-btn:disabled {
	color: #c9c4b9;
	cursor: not-allowed;
}
.tm-cart__stepper-qty {
	min-width: 24px;
	padding: 0 4px;
	text-align: center;
	font-size: 13px;
	font-weight: 500;
	color: var(--tm-text);
	font-variant-numeric: tabular-nums;
}

/* ---------- Удалить (крестик в углу) ---------- */
.tm-cart__item-remove {
	position: absolute;
	top: 16px;
	right: 20px;
	width: 22px;
	height: 22px;
	border: none;
	background: transparent;
	cursor: pointer;
	color: #b5afa3;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background .15s ease, color .15s ease;
}
.tm-cart__item-remove:hover {
	background: var(--tm-danger-bg);
	color: var(--tm-primary);
}
.tm-cart__item-remove svg { pointer-events: none; }

/* ---------- Пустое состояние ---------- */
.tm-cart__empty {
	padding: 80px 40px;
	text-align: center;
}
.tm-cart__empty-icon {
	width: 72px;
	height: 72px;
	margin: 0 auto 18px;
	border-radius: 50%;
	background: var(--tm-surface);
	color: var(--tm-primary);
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.tm-cart__empty-title {
	margin: 0 0 6px;
	font-size: 16px;
	font-weight: 500;
	color: var(--tm-text);
}
.tm-cart__empty-text {
	margin: 0;
	font-size: 13px;
	color: var(--tm-text-muted);
	line-height: 1.5;
}

/* ---------- Футер drawer ---------- */
.tm-cart__foot {
	flex-shrink: 0;
	padding: 18px 24px 22px;
	border-top: 1px solid var(--tm-border-soft);
	background: #fff;
}
.tm-cart__foot[hidden] { display: none; }

.tm-cart__total {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 14px;
}
.tm-cart__total-label {
	font-size: 15px;
	font-weight: 500;
	color: var(--tm-text);
}
.tm-cart__total-sum {
	font-size: 20px;
	font-weight: 600;
	color: var(--tm-primary);
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.3px;
}

.tm-cart__checkout {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	height: 50px;
	background: var(--tm-primary);
	color: #fff;
	border: none;
	border-radius: 8px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 500;
	cursor: pointer;
	text-decoration: none;
	letter-spacing: 0.2px;
	transition: background .15s ease, transform .1s ease;
}
.tm-cart__checkout:hover {
	background: var(--tm-primary-dark);
	color: #fff;
}
.tm-cart__checkout:active { transform: scale(0.985); }

/* ---------- Блокировка прокрутки фона (iOS-safe) ---------- */
html.tm-cart-locked {
	overflow: hidden;
	height: 100%;
}
html.tm-cart-locked body {
	overflow: hidden;
	position: fixed;
	left: 0;
	right: 0;
	width: 100%;
}

/* ---------- Спиннер ---------- */
.tm-cart__item.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 22px;
	margin-top: -8px;
	width: 16px;
	height: 16px;
	border: 2px solid var(--tm-border);
	border-top-color: var(--tm-primary);
	border-radius: 50%;
	animation: tm-spin .7s linear infinite;
}
@keyframes tm-spin { to { transform: rotate(360deg); } }