/**
 * Кошик: модальне вікно та сторінка /cart/.
 *
 * Список позицій і підсумок — спільні компоненти, тому геометрія описана один
 * раз, а вікно й сторінка лише задають їм оболонку.
 */

/* ---------- вікно ---------- */

.am-cartmodal {
	position: fixed;
	inset: 0;
	z-index: 3000;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 32px 24px;
	overflow: auto;
	overscroll-behavior: contain;
}

.am-cartmodal[hidden] {
	display: none;
}

/* iOS Safari ігнорує overflow:hidden при свайпі, тому сторінку ще й
   фіксуємо — top і відновлення прокрутки ставить cart.js. */
body.am-cart-open {
	overflow: hidden;
	position: fixed;
	left: 0;
	right: 0;
	width: 100%;
}

.am-cart__backdrop {
	position: fixed;
	inset: 0;
	background: rgba(14, 16, 17, 0.52);
	backdrop-filter: blur(3px);
	animation: amCartFade 0.25s ease both;
}

@keyframes amCartFade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes amCartIn {
	from { opacity: 0; transform: translateY(18px) scale(0.98); }
	to   { opacity: 1; transform: none; }
}

.am-cart__dialog {
	position: relative;
	width: 100%;
	max-width: 720px;
	margin: auto;
	display: flex;
	flex-direction: column;
	max-height: calc(100vh - 64px);
	background: var(--am-surface, #fff);
	border-radius: 26px;
	box-shadow: 0 30px 80px rgba(14, 16, 17, 0.28);
	animation: amCartIn 0.34s cubic-bezier(0.2, 0.7, 0.3, 1) both;
	overflow: hidden;
}

.am-cart__head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 22px 26px 16px;
	border-bottom: 1px solid var(--am-divider, #f2f2ef);
}

.am-cart__h {
	margin: 0;
	font-size: 21px;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: var(--am-text, #111214);
}

.am-cart__badge {
	padding: 4px 10px;
	border-radius: 999px;
	background: var(--am-surface-3, #f4f4f1);
	font-size: 12px;
	font-weight: 700;
	color: var(--am-text-3, #6b6f76);
}

.am-cart__x {
	margin-left: auto;
	width: 36px;
	height: 36px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 50%;
	background: var(--am-surface-3, #f4f4f1);
	color: var(--am-text-2, #43474d);
	cursor: pointer;
	transition: background-color 0.18s ease;
}

.am-cart__x:hover {
	background: var(--am-border, #ececea);
}

.am-cart__flash {
	margin: 12px 26px 0;
	padding: 11px 14px;
	border-radius: 12px;
	background: #e7f4ec;
	color: #0d7c37;
	font-size: 13px;
	font-weight: 600;
}

.am-cart__flash.is-bad {
	background: #fdecec;
	color: #b3261e;
}

.am-cart__scroll {
	flex: 1;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 6px 26px;
}

.am-cart__foot {
	padding: 16px 26px 22px;
	border-top: 1px solid var(--am-divider, #f2f2ef);
	background: var(--am-surface-2, #fafaf8);
}

/* ---------- позиція ---------- */

.am-cart__item {
	display: grid;
	grid-template-columns: 72px 1fr auto auto 32px;
	align-items: center;
	gap: 14px;
	padding: 16px 0;
	border-bottom: 1px solid var(--am-divider, #f2f2ef);
}

.am-cart__item:last-child {
	border-bottom: 0;
}

.am-cart__thumb {
	width: 72px;
	height: 72px;
	display: grid;
	place-items: center;
	border-radius: 14px;
	background: var(--am-surface-3, #f4f4f1);
	overflow: hidden;
}

.am-cart__thumb img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	mix-blend-mode: multiply;
}

.am-cart__info {
	min-width: 0;
}

.am-cart__name {
	display: block;
	font-size: 14.5px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--am-text, #111214);
	text-decoration: none;
}

.am-cart__name:hover {
	color: var(--am-text-2, #43474d);
}

.am-cart__meta,
.am-cart__unit {
	margin-top: 4px;
	font-size: 12.5px;
	color: var(--am-muted, #8b9098);
}

.am-cart__qty {
	display: inline-flex;
	align-items: center;
	height: 38px;
	border: 1px solid var(--am-border-ctl, #e4e4e0);
	border-radius: 11px;
	overflow: hidden;
	background: #fff;
}

.am-cart__qty button {
	width: 34px;
	height: 100%;
	border: 0;
	background: none;
	font-size: 16px;
	line-height: 1;
	color: var(--am-text-2, #43474d);
	cursor: pointer;
	transition: background-color 0.16s ease;
}

.am-cart__qty button:hover {
	background: var(--am-surface-3, #f4f4f1);
}

.am-cart__qty input[data-am-cart-input] {
	width: 34px;
	height: 100%;
	padding: 0;
	border: 0;
	background: none;
	text-align: center;
	font-family: inherit;
	font-size: 13.5px;
	font-weight: 700;
	color: var(--am-text, #111214);
}

.am-cart__qty input[data-am-cart-input]:focus {
	outline: none;
}

.am-cart__sum {
	min-width: 104px;
	text-align: right;
}

.am-cart__total {
	display: block;
	font-size: 15px;
	font-weight: 800;
	letter-spacing: -0.01em;
	color: var(--am-text, #111214);
}

.am-cart__old {
	display: block;
	margin-top: 2px;
	font-size: 12px;
	color: var(--am-muted-2, #9aa0a8);
	text-decoration: line-through;
}

.am-cart__rm {
	width: 32px;
	height: 32px;
	display: grid;
	place-items: center;
	border: 0;
	border-radius: 9px;
	background: none;
	color: var(--am-muted, #8b9098);
	cursor: pointer;
	transition: background-color 0.16s ease, color 0.16s ease;
}

.am-cart__rm:hover {
	background: #fdecec;
	color: #b3261e;
}

/* ---------- підсумок ---------- */

.am-cart__row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 5px 0;
	font-size: 13.5px;
	color: var(--am-text-3, #6b6f76);
}

.am-cart__row b {
	font-weight: 700;
	color: var(--am-text, #111214);
}

.am-cart__row--save b {
	color: #0d7c37;
}

.am-cart__row--ship b {
	font-weight: 600;
	color: var(--am-text-3, #6b6f76);
}

.am-cart__row--total {
	margin-top: 8px;
	padding-top: 12px;
	border-top: 1px solid var(--am-border, #ececea);
	font-size: 15px;
	font-weight: 700;
	color: var(--am-text, #111214);
}

.am-cart__row--total b {
	font-size: 21px;
	font-weight: 800;
	letter-spacing: -0.02em;
}

.am-cart__cta {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 10px;
	margin-top: 14px;
}

.am-cart__cta .am-btn {
	height: 50px;
	border-radius: 14px;
}

.am-btn--ghost {
	background: #fff;
	border-color: var(--am-border-ctl, #e4e4e0);
	color: var(--am-text, #111214);
}

.am-btn--ghost:hover {
	border-color: var(--am-border-hover, #d7d7d2);
}

.am-cart__perks {
	display: flex;
	flex-wrap: wrap;
	gap: 6px 18px;
	margin: 14px 0 0;
	padding: 0;
	list-style: none;
	font-size: 12.5px;
	color: var(--am-muted, #8b9098);
}

.am-cart__perks li {
	display: inline-flex;
	align-items: center;
	gap: 7px;
}

.am-cart__perks svg {
	color: var(--am-text-3, #6b6f76);
}

/* ---------- порожньо ---------- */

.am-cart__blank {
	padding: 46px 10px 52px;
	text-align: center;
}

.am-cart__blank-art {
	display: grid;
	place-items: center;
	width: 68px;
	height: 68px;
	margin: 0 auto 16px;
	border-radius: 50%;
	background: var(--am-surface-3, #f4f4f1);
	color: var(--am-muted, #8b9098);
}

.am-cart__blank-h {
	margin: 0 0 6px;
	font-size: 17px;
	font-weight: 800;
	color: var(--am-text, #111214);
}

.am-cart__blank-sub {
	max-width: 340px;
	margin: 0 auto 20px;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--am-muted, #8b9098);
}

/* ---------- скелет ---------- */

.am-cart__skeleton {
	padding: 12px 0;
}

.am-cart__skeleton span {
	display: block;
	height: 72px;
	margin: 12px 0;
	border-radius: 14px;
	background: linear-gradient(90deg, #f4f4f1 25%, #ececea 37%, #f4f4f1 63%);
	background-size: 400% 100%;
	animation: amCartShine 1.3s ease infinite;
}

@keyframes amCartShine {
	from { background-position: 100% 50%; }
	to   { background-position: 0 50%; }
}

/* ---------- сторінка /cart/ ---------- */

.am-cartpage {
	padding: 8px 0 56px;
}

.am-cartpage__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 372px;
	align-items: start;
	gap: 24px;
}

.am-cartpage__list {
	padding: 4px 26px;
	background: var(--am-surface, #fff);
	border: 1px solid var(--am-border, #ececea);
	border-radius: var(--am-r-2xl, 22px);
}

.am-cartpage__side {
	position: sticky;
	top: 96px;
	padding: 22px 24px 24px;
	background: var(--am-surface, #fff);
	border: 1px solid var(--am-border, #ececea);
	border-radius: var(--am-r-2xl, 22px);
}

.am-cartpage__side h2 {
	margin: 0 0 12px;
	font-size: 17px;
	font-weight: 800;
	color: var(--am-text, #111214);
}

.am-cartpage__side .am-btn {
	width: 100%;
	height: 52px;
	margin-top: 16px;
	border-radius: 14px;
}

.am-cartpage__note {
	margin: 14px 0 0;
	font-size: 12.5px;
	line-height: 1.5;
	color: var(--am-muted, #8b9098);
}

/* Крихти й заголовок сторінки лишаються від теми — прибираємо зайвий відступ. */
.woocommerce-cart .am-cartpage .woocommerce-notices-wrapper:empty {
	display: none;
}

/* ---------- адаптив ---------- */

@media (max-width: 1024px) {
	.am-cartpage__grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.am-cartpage__side {
		position: static;
	}
}

@media (max-width: 720px) {
	/* Нижня шторка: вікно на весь екран із порожнечею під однією позицією
	   виглядало б незавершеним. */
	.am-cartmodal {
		padding: 0;
		align-items: flex-end;
	}

	.am-cart__dialog {
		max-width: none;
		max-height: 92vh;
		margin: 0;
		border-radius: 22px 22px 0 0;
	}

	.am-cart__head,
	.am-cart__scroll,
	.am-cart__foot {
		padding-inline: 16px;
	}

	.am-cart__flash {
		margin-inline: 16px;
	}

	.am-cart__item {
		grid-template-columns: 60px minmax(0, 1fr) auto;
		grid-template-areas:
			"thumb info rm"
			"thumb qty sum";
		gap: 10px 12px;
	}

	.am-cart__sum,
	.am-cart__rm {
		justify-self: end;
	}

	.am-cart__qty {
		justify-self: start;
	}

	.am-cart__thumb {
		grid-area: thumb;
		width: 60px;
		height: 60px;
	}

	.am-cart__info { grid-area: info; }
	.am-cart__qty  { grid-area: qty; height: 34px; }
	.am-cart__sum  { grid-area: sum; min-width: 0; }
	.am-cart__rm   { grid-area: rm; }

	.am-cart__cta {
		grid-template-columns: 1fr;
	}

	/* На телефоні шторка і є кошиком — друга кнопка лише дублює. */
	.am-cart__cta .am-btn--ghost {
		display: none;
	}

	.am-cartpage__list {
		padding-inline: 16px;
	}
}

/* ---------- шапка сторінки ---------- */

.am-cart-page {
	padding-top: 18px;
}

.am-cartpage__title {
	margin: 6px 0 20px;
	font-size: 34px;
	font-weight: 800;
	letter-spacing: -0.02em;
	color: var(--am-text, #111214);
}

/* Тема фарбує посилання й кнопки в контенті у свій акцент — повертаємо свої. */
.am-cart-page .am-cart__name,
.am-cartmodal .am-cart__name {
	color: var(--am-text, #111214);
}

.am-cart-page .am-btn--dark,
.am-cartmodal .am-btn--dark {
	color: #fff;
}

.am-cart-page .am-btn--ghost,
.am-cartmodal .am-btn--ghost {
	color: var(--am-text, #111214);
}

.am-cart-page a,
.am-cartmodal a {
	text-decoration: none;
}

/* Кнопка «Купити» на час запиту. */
.am-btn.is-loading {
	opacity: 0.6;
	pointer-events: none;
}


/* передзамовлення в кошику */
.am-cart__pre {
	margin-top: 4px;
	font-size: 12.5px;
	font-weight: 600;
	color: oklch(0.55 0.14 65);
}

/* === кошик на телефоні: вікно по центру екрана, а не шторка знизу ======= */
@media (max-width: 720px) {
	.am-cartmodal {
		align-items: center;
		padding: 16px;
		padding-top: max(16px, env(safe-area-inset-top));
		padding-bottom: max(16px, env(safe-area-inset-bottom));
	}

	.am-cart__dialog {
		margin: auto;
		max-height: calc(100vh - 32px);
		/* svh — висота без панелі адреси Safari; старі браузери лишаться на vh */
		max-height: calc(100svh - 32px);
		border-radius: 22px;
	}
}
