/* ==================================================================
   15 - SIDE CART DRAWER
   Slides in from the right after an add-to-cart.

   Loads after 14-cart-checkout.css but never appears on the cart or
   checkout pages - inc/cart-drawer.php does not render the markup
   there. Every selector below is inside .wo-cart-drawer or its
   overlay, so this file cannot reach any existing component.

   The glass recipe is the header/nav drawer's, so the panel reads as
   part of the same system rather than a bolt-on.
   ================================================================== */


/* ------------------------------------------------------------------
   OVERLAY
   ------------------------------------------------------------------ */

.wo-cart-drawer-overlay {
	position: fixed;
	inset: 0;
	z-index: var(--wo-z-overlay);

	background: rgba(10, 6, 26, 0.68);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);

	opacity: 0;
	transition: opacity var(--wo-transition);
}

.wo-cart-drawer-overlay.is-open {
	opacity: 1;
}

/* [hidden] must beat the block display the rules above imply. */
.wo-cart-drawer-overlay[hidden] {
	display: none;
}


/* ------------------------------------------------------------------
   PANEL
   ------------------------------------------------------------------ */

.wo-cart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: calc(var(--wo-z-overlay) + 1);

	display: flex;
	flex-direction: column;

	/* ~70% of the viewport on mobile, so the site stays visible
	   behind the drawer instead of it reading as a full-screen
	   takeover - the previous 92vw value left almost nothing of the
	   page in view on a phone. Capped at 420px so it does not keep
	   growing past a comfortable reading width once the viewport is
	   wide enough that 70% would exceed that (roughly 600px up).

	   min-width is a deliberate, small departure from a literal 70%,
	   solely for usability: on the narrowest real phones (~320-360px)
	   70vw alone would be ~225-250px, too tight for a product image,
	   name, price and quantity stepper to sit on one row without
	   everything wrapping onto its own line. 260px keeps that layout
	   usable while still reading as a drawer rather than a takeover -
	   at 320px wide that is 81% of the viewport; by ~375px and up it
	   is the full, literal ~70%. */
	width: min(70vw, 420px);
	min-width: 260px;
	max-width: 100%;

	/* Safe-area inset keeps the checkout button clear of the iOS
	   home indicator. */
	padding-bottom: env(safe-area-inset-bottom, 0);

	color: var(--wo-text-muted);

	background: linear-gradient(
		200deg,
		rgba(48, 35, 100, 0.94) 0%,
		rgba(26, 18, 56, 0.96) 55%,
		rgba(20, 14, 42, 0.97) 100%
	);
	border-left: 1px solid rgba(255, 255, 255, 0.16);

	box-shadow:
		-24px 0 64px rgba(6, 3, 20, 0.62),
		inset 1px 0 0 rgba(255, 255, 255, 0.14);

	backdrop-filter: blur(26px) saturate(180%);
	-webkit-backdrop-filter: blur(26px) saturate(180%);

	transform: translateX(100%);
	visibility: hidden;

	transition:
		transform var(--wo-duration-slow) var(--wo-ease-out),
		visibility var(--wo-duration-slow) var(--wo-ease-out);
}

.wo-cart-drawer.is-open {
	transform: translateX(0);
	visibility: visible;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {

	.wo-cart-drawer {
		background: rgba(20, 14, 42, 0.99);
	}
}

@media (prefers-reduced-motion: reduce) {

	.wo-cart-drawer,
	.wo-cart-drawer-overlay {
		transition-duration: 1ms;
	}
}

/* Page behind the panel must not scroll while it is open. */
body.wo-drawer-open {
	overflow: hidden;
}

/* Quiet dim while an AJAX round trip is in flight. */
.wo-cart-drawer.is-busy .wo-cart-drawer__body,
.wo-cart-drawer.is-busy .wo-cart-drawer__foot {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity var(--wo-duration-fast) var(--wo-ease);
}


/* ------------------------------------------------------------------
   HEAD
   ------------------------------------------------------------------ */

.wo-cart-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wo-space-4);
	flex: 0 0 auto;

	padding: var(--wo-space-6) var(--wo-space-6) var(--wo-space-5);
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.wo-cart-drawer__title {
	display: flex;
	align-items: baseline;
	gap: var(--wo-space-2);

	margin: 0;
	font-family: var(--wo-font-display);
	font-size: var(--wo-text-xl);
	font-weight: var(--wo-weight-semibold);
	color: var(--wo-text);
}

.wo-cart-drawer__count {
	font-family: var(--wo-font-body);
	font-size: var(--wo-text-sm);
	font-weight: var(--wo-weight-normal);
	color: var(--wo-text-dim);
}


/* ------------------------------------------------------------------
   BODY
   The only scrolling region, so the totals and the checkout button
   stay pinned no matter how many lines the cart has.
   ------------------------------------------------------------------ */

.wo-cart-drawer__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;

	padding: var(--wo-space-5) var(--wo-space-6);
}

.wo-cart-drawer__items {
	list-style: none;
	margin: 0;
	padding: 0;

	display: flex;
	flex-direction: column;
	gap: var(--wo-space-4);
}

.wo-cart-drawer__item {
	display: grid;
	grid-template-columns: 68px minmax(0, 1fr);
	gap: var(--wo-space-4);
	align-items: start;

	padding-bottom: var(--wo-space-4);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.wo-cart-drawer__item:last-child {
	padding-bottom: 0;
	border-bottom: none;
}

.wo-cart-drawer__media img {
	width: 100%;
	aspect-ratio: 1 / 1;
	height: auto;
	object-fit: cover;
	border-radius: var(--wo-radius-sm);
	border: 1px solid var(--wo-line);
}

.wo-cart-drawer__info {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: var(--wo-space-2);
}

.wo-cart-drawer__name {
	margin: 0;
	font-size: var(--wo-text-sm);
	font-weight: var(--wo-weight-semibold);
	line-height: 1.35;
	color: var(--wo-text);
	overflow-wrap: anywhere;
}

.wo-cart-drawer__name a {
	color: inherit;
	text-decoration: none;
}

.wo-cart-drawer__name a:hover {
	color: var(--wo-primary-hover);
}

.wo-cart-drawer__meta {
	margin: 0;
	font-size: var(--wo-text-xs);
	color: var(--wo-text-dim);
	overflow-wrap: anywhere;
}

.wo-cart-drawer__row {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--wo-space-2) var(--wo-space-3);
}

.wo-cart-drawer__price {
	font-size: var(--wo-text-sm);
	font-weight: var(--wo-weight-bold);
	color: var(--wo-gold);
	white-space: nowrap;
}

.wo-cart-drawer__price del {
	margin-right: var(--wo-space-1);
	font-size: var(--wo-text-xs);
	font-weight: var(--wo-weight-normal);
	color: var(--wo-text-dim);
}

.wo-cart-drawer__price ins {
	background: none;
	color: inherit;
	text-decoration: none;
}


/* ---- Quantity ---- */

.wo-cart-drawer__qty {
	display: inline-flex;
	align-items: center;

	background: rgba(255, 255, 255, 0.05);
	border: 1px solid var(--wo-line-strong);
	border-radius: var(--wo-radius-pill);
}

.wo-cart-drawer__qty-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;

	width: 28px;
	height: 30px;
	min-height: 0;
	padding: 0;

	font-size: var(--wo-text-base);
	line-height: 1;
	color: var(--wo-text-muted);

	background: transparent;
	border: none;
	border-radius: var(--wo-radius-circle);
	cursor: pointer;

	transition: color var(--wo-transition), background var(--wo-transition);
}

.wo-cart-drawer__qty-btn:hover {
	color: var(--wo-text);
	background: rgba(255, 255, 255, 0.10);
}

.wo-cart-drawer__qty-btn:focus-visible {
	outline: none;
	box-shadow: var(--wo-ring);
}

.wo-cart-drawer__qty-value {
	min-width: 26px;
	text-align: center;
	font-size: var(--wo-text-sm);
	font-weight: var(--wo-weight-semibold);
	color: var(--wo-text);
	font-variant-numeric: tabular-nums;
}

.wo-cart-drawer__remove {
	align-self: flex-start;
	min-height: 0;
	padding: 0;

	font-size: var(--wo-text-xs);
	color: var(--wo-text-dim);
	text-decoration: underline;
	text-underline-offset: 0.2em;

	background: none;
	border: none;
	cursor: pointer;
}

.wo-cart-drawer__remove:hover {
	color: var(--wo-error);
	background: none;
}


/* ------------------------------------------------------------------
   EMPTY STATE
   ------------------------------------------------------------------ */

.wo-cart-drawer__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: var(--wo-space-3);

	padding: var(--wo-space-10) var(--wo-space-4);
	color: var(--wo-text-muted);
}

.wo-cart-drawer__empty svg {
	color: var(--wo-text-dim);
}

.wo-cart-drawer__empty-title {
	margin: var(--wo-space-2) 0 0;
	font-family: var(--wo-font-display);
	font-size: var(--wo-text-lg);
	font-weight: var(--wo-weight-semibold);
	color: var(--wo-text);
}

.wo-cart-drawer__empty-text {
	margin: 0 0 var(--wo-space-4);
	font-size: var(--wo-text-sm);
	color: var(--wo-text-dim);
}


/* ------------------------------------------------------------------
   FOOT
   ------------------------------------------------------------------ */

.wo-cart-drawer__foot {
	flex: 0 0 auto;
}

.wo-cart-drawer__foot:empty {
	display: none;
}

.wo-cart-drawer__totals {
	padding: var(--wo-space-5) var(--wo-space-6) 0;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.wo-cart-drawer__total-row {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--wo-space-4);

	font-size: var(--wo-text-base);
	color: var(--wo-text-muted);
}

.wo-cart-drawer__total-row strong {
	font-size: var(--wo-text-lg);
	font-weight: var(--wo-weight-bold);
	color: var(--wo-gold);
	white-space: nowrap;
}

.wo-cart-drawer__note {
	margin: var(--wo-space-2) 0 0;
	font-size: var(--wo-text-xs);
	color: var(--wo-text-dim);
}

.wo-cart-drawer__actions {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: var(--wo-space-3);

	padding: var(--wo-space-5) var(--wo-space-6) var(--wo-space-6);
}

.wo-cart-drawer__actions .wo-btn {
	width: 100%;
}

.wo-cart-drawer__full {
	display: block;
	text-align: center;

	font-size: var(--wo-text-sm);
	font-weight: var(--wo-weight-medium);
	color: var(--wo-text-muted);
	text-decoration: underline;
	text-underline-offset: 0.2em;

	padding: var(--wo-space-2);
	border-radius: var(--wo-radius-sm);
}

.wo-cart-drawer__full:hover {
	color: var(--wo-text);
}

.wo-cart-drawer__full:focus-visible {
	outline: none;
	box-shadow: var(--wo-ring);
}


/* ------------------------------------------------------------------
   SMALL SCREENS
   Full-bleed panel below 480px; the 92vw cap already handles the
   range above it.
   ------------------------------------------------------------------ */

@media (max-width: 479.98px) {

	/* No width/border-left override here on purpose - the base rule's
	   min(70vw, 420px) with its 260px floor already applies down to
	   the smallest real phone widths, and border-left stays so the
	   glass edge - the visual cue that this is a drawer over the
	   page, not the page itself - is never lost. Only the internal
	   padding and grid tighten up at this size. */

	.wo-cart-drawer__head {
		padding: var(--wo-space-5) var(--wo-space-5) var(--wo-space-4);
	}

	.wo-cart-drawer__body {
		padding: var(--wo-space-4) var(--wo-space-5);
	}

	.wo-cart-drawer__totals {
		padding: var(--wo-space-4) var(--wo-space-5) 0;
	}

	.wo-cart-drawer__actions {
		padding: var(--wo-space-4) var(--wo-space-5) var(--wo-space-5);
	}

	.wo-cart-drawer__item {
		grid-template-columns: 58px minmax(0, 1fr);
		gap: var(--wo-space-3);
	}
}

/* Short viewports (landscape phones): the item list must still be
   able to scroll, so the head and foot give up their extra padding
   rather than the body losing its height. */
@media (max-height: 560px) {

	.wo-cart-drawer__head {
		padding-block: var(--wo-space-4);
	}

	.wo-cart-drawer__actions {
		padding-block: var(--wo-space-4);
	}

	.wo-cart-drawer__note {
		display: none;
	}
}
