/**
 * Maxt Offroad — cart drawer (template-parts/cart-drawer.php +
 * assets/js/cart-drawer.js). Loaded sitewide with the drawer shell.
 *
 * Side is a modifier on the root: --left (shipped default) / --right.
 * Flip it in template-parts/cart-drawer.php (one class change).
 */

body.mxo-cart-drawer-open {
	overflow: hidden;
}

.mxo-cart-drawer {
	position: fixed;
	inset: 0;
	z-index: 1200;
}

.mxo-cart-drawer[hidden] {
	display: none !important;
}

.mxo-cart-drawer__overlay {
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0.6);
	opacity: 0;
	transition: opacity 0.25s ease;
}

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

/* Panel — slides in from the side set by the root modifier. */
.mxo-cart-drawer__panel {
	position: absolute;
	top: 0;
	bottom: 0;
	width: min(400px, 100%);
	display: flex;
	flex-direction: column;
	background: var(--background);
	box-shadow: var(--shadow-lg);
	transition: transform 0.25s ease;
}

.mxo-cart-drawer--left .mxo-cart-drawer__panel {
	left: 0;
	border-right: 1px solid var(--border);
	transform: translateX(-100%);
}

.mxo-cart-drawer--right .mxo-cart-drawer__panel {
	right: 0;
	border-left: 1px solid var(--border);
	transform: translateX(100%);
}

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

.mxo-cart-drawer__panel:focus {
	outline: none;
}

/* Sit below the WP admin bar when it is present (logged-in view) so the
   panel header is not clipped by the toolbar. 32px desktop / 46px mobile,
   matching WordPress's own admin-bar heights. Customers see no admin bar, so
   this only affects the authored/preview view. */
.admin-bar .mxo-cart-drawer__panel {
	top: 32px;
}

@media screen and (max-width: 782px) {
	.admin-bar .mxo-cart-drawer__panel {
		top: 46px;
	}
}

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

/* Header */
.mxo-cart-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--border);
}

.mxo-cart-drawer__title {
	margin: 0;
	font-family: var(--font-display);
	font-size: 1.125rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.025em;
}

.mxo-cart-drawer__title-count {
	color: var(--muted-foreground);
	font-weight: 500;
}

.mxo-cart-drawer__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	flex-shrink: 0;
	background: none;
	border: 0;
	border-radius: var(--radius);
	color: var(--muted-foreground);
	cursor: pointer;
}

.mxo-cart-drawer__close:hover {
	color: var(--foreground);
	background: var(--muted);
}

.mxo-cart-drawer__close:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 1px;
}

/* Body */
.mxo-cart-drawer__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 0 1.25rem;
}

.mxo-cart-drawer__loading,
.mxo-cart-drawer__error {
	padding: 2rem 0;
	text-align: center;
	color: var(--muted-foreground);
	font-size: 0.9rem;
}

.mxo-cart-drawer__error {
	color: var(--destructive);
}

.mxo-cart-drawer__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1rem;
	padding: 3rem 0;
	text-align: center;
}

.mxo-cart-drawer__empty p {
	margin: 0;
	font-size: 1rem;
	color: var(--muted-foreground);
}

/* The state blocks above set `display` (e.g. .empty is display:flex), which
   would otherwise override the UA `[hidden]` rule and leave the empty state
   visible alongside rendered items. Re-assert [hidden] with higher
   specificity so cart-drawer.js can toggle these cleanly. */
.mxo-cart-drawer__loading[hidden],
.mxo-cart-drawer__empty[hidden],
.mxo-cart-drawer__error[hidden],
.mxo-cart-drawer__items[hidden],
.mxo-cart-drawer__footer[hidden] {
	display: none;
}

/* Item rows */
.mxo-cart-drawer__items {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mxo-cart-drawer__items--busy {
	opacity: 0.5;
	pointer-events: none;
}

.mxo-cart-drawer__item {
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	padding: 1rem 0;
	border-bottom: 1px solid var(--border);
}

.mxo-cart-drawer__item-thumb {
	width: 64px;
	height: 64px;
	flex-shrink: 0;
	object-fit: contain;
	background: #ffffff;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.mxo-cart-drawer__item-info {
	flex: 1 1 auto;
	min-width: 0;
}

.mxo-cart-drawer__item-name {
	display: block;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--foreground);
	text-decoration: none;
}

.mxo-cart-drawer__item-name:hover {
	color: var(--primary);
}

.mxo-cart-drawer__item-controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-top: 0.625rem;
}

.mxo-cart-drawer__qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--input);
	border-radius: var(--radius);
}

.mxo-cart-drawer__qty-btn {
	width: 1.75rem;
	height: 1.75rem;
	background: none;
	border: 0;
	font-size: 1rem;
	line-height: 1;
	color: var(--foreground);
	cursor: pointer;
}

.mxo-cart-drawer__qty-btn:hover:not(:disabled) {
	background: var(--muted);
}

.mxo-cart-drawer__qty-btn:disabled {
	opacity: 0.35;
	cursor: default;
}

.mxo-cart-drawer__qty-btn:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: -2px;
}

.mxo-cart-drawer__qty-value {
	min-width: 1.75rem;
	text-align: center;
	font-size: 0.85rem;
	font-weight: 600;
}

.mxo-cart-drawer__item-total {
	font-size: 0.875rem;
	font-weight: 700;
}

.mxo-cart-drawer__item-remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	flex-shrink: 0;
	background: none;
	border: 0;
	border-radius: var(--radius);
	color: var(--muted-foreground);
	cursor: pointer;
}

.mxo-cart-drawer__item-remove:hover {
	color: var(--destructive);
	background: var(--muted);
}

.mxo-cart-drawer__item-remove:focus-visible {
	outline: 2px solid var(--ring);
	outline-offset: 1px;
}

/* Footer */
.mxo-cart-drawer__footer {
	padding: 1rem 1.25rem 1.25rem;
	border-top: 1px solid var(--border);
}

.mxo-cart-drawer__subtotal {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 0 0 0.875rem;
	font-size: 0.95rem;
	font-weight: 700;
}

.mxo-cart-drawer__actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.75rem;
}
