/**
 * AJAX cart drawer styles.
 *
 * The drawer's contents reuse the ported theme's own component classes
 * (.line-item, .free-shipping-bar, .tab-pills, .cart-offers, .offer-item,
 * .product-cross-sell, .cart-drawer__footer-*, .quantity-selector--line-item)
 * which are styled by style.css, so this file only styles the drawer chrome:
 * the slide-in panel, header, footer padding, checkboxes, checkout gating,
 * loading state and the bottom-sheet popovers. Everything is scoped under
 * .mabel-cart-* / #cart-drawer so nothing leaks into the ported theme.
 * Colours come from the theme's color-scheme custom properties.
 *
 * @package Mabellife
 */

/* Body scroll lock while the drawer is open. */
html.mabel-cart-open,
html.mabel-cart-open body {
	overflow: hidden;
}

.mabel-cart-drawer {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: block;
	visibility: hidden;
	pointer-events: none;
}

.mabel-cart-drawer[hidden] {
	display: none;
}

.mabel-cart-drawer.is-open {
	visibility: visible;
	pointer-events: auto;
}

.mabel-cart-drawer__overlay {
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0.4);
	opacity: 0;
	transition: opacity 0.3s ease;
}

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

.mabel-cart-drawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	width: min(540px, 100vw);
	max-width: 100%;
	background-color: rgb(var(--background, 255 255 255));
	color: rgb(var(--text-color, 0 0 0));
	box-shadow: -4px 0 24px rgb(0 0 0 / 0.12);
	transform: translateX(100%);
	transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}

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

@media (prefers-reduced-motion: reduce) {
	.mabel-cart-drawer__panel,
	.mabel-cart-drawer__overlay,
	.mabel-cart-popover__panel,
	.mabel-cart-popover__overlay {
		transition: none;
	}
}

/* Header — close (left) · centred title · balancing spacer (right). */
.mabel-cart-drawer__header {
	display: grid;
	grid-template-columns: 2.75rem 1fr 2.75rem;
	align-items: center;
	gap: 0.5rem;
	padding: 1.25rem 1.5rem 0.75rem;
}

.mabel-cart-drawer__title {
	justify-self: center;
	gap: 0.5rem;
}

.mabel-cart-drawer__title h2 {
	margin: 0;
}

.mabel-cart-drawer__close {
	justify-self: start;
}

/* Body (scroll area). */
.mabel-cart-drawer__body {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-height: 0;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	padding: 0.5rem 1.5rem 0;
}

/* Sticky footer within the scroll area. */
.mabel-cart-drawer__footer {
	position: sticky;
	bottom: 0;
	margin-top: auto;
	padding: 1rem 0 calc(0.75rem + env(safe-area-inset-bottom));
	background-color: rgb(var(--background, 255 255 255));
}

.mabel-cart-drawer__footer .cart-drawer__footer-inner {
	padding-top: 1rem;
}

/* Gift-box / Terms checkboxes. */
.mabel-cart-check {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	cursor: pointer;
	line-height: 1.3;
}

.mabel-cart-check input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.mabel-cart-check__box {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.05rem;
	height: 1.05rem;
	background: #fff;
	border: 1px solid rgb(var(--border-color, 0 0 0) / 1);
	--border-color: 0 0 0;
	border-radius: 3px;
	transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mabel-cart-check input:checked + .mabel-cart-check__box {
	background: rgb(var(--text-color, 0 0 0));
	border-color: rgb(var(--text-color, 0 0 0));
}

.mabel-cart-check input:checked + .mabel-cart-check__box::after {
	content: "";
	width: 0.55rem;
	height: 0.3rem;
	margin-top: -2px;
	border-left: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(-45deg);
}

.mabel-cart-check input:focus-visible + .mabel-cart-check__box {
	box-shadow: 0 0 0 2px rgb(var(--text-color, 0 0 0) / 0.25);
}

.mabel-cart-check__label a {
	text-decoration: underline;
}

.mabel-cart-check.is-required .mabel-cart-check__box {
	border-color: #b42318;
	box-shadow: 0 0 0 2px rgb(180 35 24 / 0.2);
}

/* Checkout gated by Terms — visually muted but still clickable so the
   click handler can prompt for agreement. */
.mabel-cart-drawer [data-cart-checkout][aria-disabled="true"] {
	opacity: 0.45;
}

/* Empty state. */
.mabel-cart-drawer__empty {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	padding: 3rem 1.5rem;
	text-align: center;
}

.mabel-cart-drawer__empty .icon {
	opacity: 0.4;
}

.mabel-cart-drawer__empty p {
	margin: 0;
}

/* Loading overlay while an AJAX call is in flight. */
.mabel-cart-drawer__loading {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgb(var(--background, 255 255 255) / 0.6);
	z-index: 2;
}

.mabel-cart-drawer.is-loading .mabel-cart-drawer__loading {
	display: flex;
}

.mabel-cart-spinner {
	width: 1.75rem;
	height: 1.75rem;
	border-radius: 50%;
	border: 2px solid rgb(var(--text-color, 0 0 0) / 0.2);
	border-top-color: rgb(var(--text-color, 0 0 0));
	animation: mabel-cart-spin 0.7s linear infinite;
}

@keyframes mabel-cart-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Row-level busy state while a qty/remove call runs. */
.line-item.is-busy {
	opacity: 0.5;
	pointer-events: none;
}

/* Add-to-cart button busy state. */
.mabel-atc-busy {
	opacity: 0.7;
	cursor: progress;
}

.mabel-atc-error {
	margin: 0.5rem 0 0;
}

/* -------------------------------------------------- Footer bottom-sheet popovers */
.mabel-cart-popover {
	position: absolute;
	inset: 0;
	z-index: 3;
	display: block;
	visibility: hidden;
}

.mabel-cart-popover[hidden] {
	display: none;
}

.mabel-cart-popover.is-open {
	visibility: visible;
}

.mabel-cart-popover__overlay {
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0.3);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.mabel-cart-popover.is-open .mabel-cart-popover__overlay {
	opacity: 1;
}

.mabel-cart-popover__panel {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	max-height: 85%;
	overflow-y: auto;
	padding: 1.25rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
	background-color: rgb(var(--background, 255 255 255));
	border-top-left-radius: 14px;
	border-top-right-radius: 14px;
	box-shadow: 0 -4px 20px rgb(0 0 0 / 0.15);
	transform: translateY(100%);
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mabel-cart-popover.is-open .mabel-cart-popover__panel {
	transform: translateY(0);
}

.mabel-cart-popover__header {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-bottom: 1rem;
    padding-bottom: 1rem;
    margin-inline: -1.5rem;
    border-bottom: 1px solid rgba(var(--border-color));
    padding-inline: 1.5rem;
    text-align: center;
	position: relative;
}

.mabel-cart-popover__header p {
	margin: 0;
}

.mabel-cart-popover__close {
	background: none;
	border: 0;
	color: inherit;
	cursor: pointer;
	padding: 0.25rem;
	position: absolute;
	left: 1.5rem;
	/* top: 50%; */
	/* transform: translateY(-50%); */
}

.mabel-cart-popover .textarea,
.mabel-cart-popover .input {
	width: 100%;
	padding: 0.7rem 0.85rem;
	color: inherit;
	background: transparent;
	border: 1px solid rgb(var(--border-color, 0 0 0) / 0.3);
	border-radius: 6px;
	font: inherit;
}

/* Gift-box confirmation popup: centred modal variant of the drawer popover. */
.mabel-cart-popover--modal .mabel-cart-popover__panel {
	top: 50%;
	bottom: auto;
	left: 1rem;
	right: 1rem;
	max-height: 85%;
	border-radius: 14px;
	transform: translateY(-50%);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.mabel-cart-popover--modal.is-open .mabel-cart-popover__panel {
	transform: translateY(-50%);
	opacity: 1;
}

.mabel-gift-popup__actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 1.25rem;
	margin-top: 0.5rem;
}

.mabel-gift-popup__remove {
	padding: 0;
	border: 0;
	background: none;
	color: #d0421b;
	font: inherit;
	cursor: pointer;
	text-decoration: none;
}

.mabel-gift-popup__remove:hover {
	text-decoration: underline;
}

.mabel-gift-popup__image-link {
	justify-items: start;
	text-decoration: none;
}

.mabel-gift-popup__image {
	display: block;
	max-width: 180px;
	border-radius: 6px;
}

/* Cross-sell "You may also like" slider: disable mandatory scroll-snap so the
   arrow scroll animation in mabel-cart.js is not cancelled by the browser, and
   size the cells so exactly 2 products are visible per view (arrows advance
   1 item at a time — see scrollCrossSell in mabel-cart.js). */
.cart-drawer__cross-sell-carousel {
	scroll-snap-type: none;
	scroll-behavior: auto;
	/* grid-auto-columns: calc((100% - 1.25rem) / 2) !important; */
}
