/**
 * Cart drawer — ported from prototype/src/components/CartDrawer.astro's
 * <style> block. Global chrome (see inc/cart-drawer.php), so this loads
 * sitewide rather than through a widget's get_style_depends().
 */

.iclk-drawer-overlay {
	position: fixed;
	inset: 0;
	z-index: 940;
	background: rgb(15 23 42 / 0.5);
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--transition), visibility var(--transition);
}

.iclk-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 950;
	display: flex;
	flex-direction: column;
	width: min(400px, 94vw);
	background: var(--color-surface);
	box-shadow: var(--shadow-lg);
	translate: 100% 0;
	visibility: hidden;
	transition: translate 280ms ease, visibility 280ms;
	outline: none;
}

.iclk-drawer-root.is-open .iclk-drawer-overlay {
	opacity: 1;
	visibility: visible;
}

.iclk-drawer-root.is-open .iclk-drawer {
	translate: 0 0;
	visibility: visible;
}

.iclk-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--color-border);
	flex-shrink: 0;
}

.iclk-drawer__head h2 {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	font-size: 1.05rem;
}

.iclk-drawer__close {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border: 0;
	background: none;
	border-radius: var(--radius-full);
	color: var(--color-text-muted);
	cursor: pointer;
	transition: background var(--transition), color var(--transition);
}

.iclk-drawer__close:hover {
	background: var(--color-accent-soft);
	color: var(--color-accent);
}

.iclk-drawer__content {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

.iclk-drawer__added {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 9px 20px;
	background: var(--color-success-soft);
	color: var(--color-success);
	font-size: 0.86rem;
	font-weight: 600;
	flex-shrink: 0;
}

/* cart-drawer.js flags this line with the [hidden] attribute (shown for 3s
   after an add, hidden when the drawer is opened any other way), but the
   display:flex above outranks the UA `[hidden] { display: none }`, so the
   "Added to your cart" banner stuck on. Re-assert [hidden] — same fix as
   .iclk-wish-row__stock[hidden] and .iclk-tabs__panel[hidden]. */
.iclk-drawer__added[hidden] {
	display: none;
}

.iclk-drawer__items {
	flex: 1;
	overflow-y: auto;
	padding: 8px 20px;
}

.iclk-drawer__empty {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 24px;
	color: var(--color-text-muted);
}

.iclk-drawer__empty-icon {
	color: var(--color-border-strong);
}

.iclk-drawer__foot {
	display: grid;
	gap: 10px;
	padding: 16px 20px;
	border-top: 1px solid var(--color-border);
	background: var(--color-bg);
	flex-shrink: 0;
}

.iclk-drawer__ship {
	margin: 0;
	font-size: 0.82rem;
	color: var(--color-text-muted);
}

.iclk-drawer__ship.is-free {
	color: var(--color-success);
	font-weight: 600;
}

.iclk-drawer__subtotal {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	font-family: var(--font-heading);
	font-weight: 600;
	font-size: 1.15rem;
	color: var(--color-ink);
}

/* Items */
.iclk-d-item {
	display: grid;
	grid-template-columns: 64px minmax(0, 1fr) auto;
	gap: 12px;
	align-items: start;
	padding: 14px 0;
	border-bottom: 1px solid var(--color-border);
}

.iclk-d-item:last-child {
	border-bottom: 0;
}

.iclk-d-item.is-updating {
	opacity: 0.5;
	pointer-events: none;
}

.iclk-d-item__img {
	display: block;
	width: 64px;
	height: 64px;
	padding: 5px;
	background: #fff;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-sm);
}

.iclk-d-item__img img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.iclk-d-item__info {
	display: grid;
	gap: 4px;
	min-width: 0;
}

.iclk-d-item__name {
	font-size: 0.86rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--color-ink);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.iclk-d-item__name:hover {
	color: var(--color-primary);
}

.iclk-d-item__unit {
	font-size: 0.76rem;
	color: var(--color-text-muted);
}

.iclk-d-item__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-top: 2px;
}

.iclk-d-item__qty {
	display: inline-flex;
	align-items: center;
	border: 1.5px solid var(--color-border-strong);
	border-radius: var(--radius-sm);
	overflow: hidden;
	background: var(--color-surface);
}

.iclk-d-item__qty button {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border: 0;
	background: var(--color-bg);
	color: var(--color-text);
	cursor: pointer;
	transition: background var(--transition);
}

.iclk-d-item__qty button:hover {
	background: var(--color-primary-soft);
	color: var(--color-primary);
}

.iclk-d-item__qty span {
	min-width: 30px;
	text-align: center;
	font-size: 0.85rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
}

.iclk-d-item__line {
	font-family: var(--font-heading);
	font-weight: 700;
	font-size: 0.92rem;
	color: var(--color-ink);
}

.iclk-d-item__remove {
	display: grid;
	place-items: center;
	width: 32px;
	height: 32px;
	border: 0;
	background: none;
	border-radius: var(--radius-full);
	color: var(--color-text-muted);
	cursor: pointer;
	transition: background var(--transition), color var(--transition);
}

.iclk-d-item__remove:hover {
	background: var(--color-accent-soft);
	color: var(--color-accent);
}

@media (prefers-reduced-motion: reduce) {
	.iclk-drawer,
	.iclk-drawer-overlay {
		transition: none;
	}
}
