/*
 * Wishlist Drawer — front-end only (block.json `viewStyle`).
 *
 * `viewStyle`, not `style`: a position:fixed overlay and a slide-out panel would
 * float over the post in the editor canvas. The editor gets the block's flat
 * placeholder preview instead; these rules only ship where the block rendered.
 *
 * Structure and state only — every colour, radius and space is a theme.json
 * token so a demo variation restyles by refilling slots (TOKENS.md). Each custom
 * property carries a fallback because the plugin can activate under a non-Quartier
 * theme (Phase 1 exit gate); the fallbacks are CSS system colours, not hexes, so
 * an unknown theme's light/dark preference still decides.
 */

.anps-wishlist {
	position: relative;
	display: inline-flex;
}

/* ---- Header toggle + count ---- */

.anps-wishlist__toggle {
	position: relative;
	display: inline-grid;
	place-items: center;
	inline-size: 48px;
	block-size: 48px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var( --wp--preset--color--contrast, CanvasText );
	border-radius: var( --wp--custom--radius--pill, 999px );
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.anps-wishlist__toggle:hover {
	color: var( --wp--preset--color--primary, LinkText );
}

.anps-wishlist__toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.anps-wishlist__toggle .anps-wishlist__heart {
	inline-size: 24px;
	block-size: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.6;
	/* Path reaches the viewBox edges; keep the stroke from clipping flat. */
	overflow: visible;
}

.anps-wishlist__count {
	position: absolute;
	inset-block-start: 2px;
	inset-inline-end: 2px;
	display: grid;
	place-items: center;
	min-inline-size: 18px;
	block-size: 18px;
	padding-inline: 5px;
	border-radius: var( --wp--custom--radius--pill, 999px );
	background-color: var( --wp--preset--color--primary, LinkText );
	color: var( --wp--preset--color--on-primary, Canvas );
	font-size: var( --wp--preset--font-size--small, 0.75rem );
	font-weight: 600;
	line-height: 1;
}

.anps-wishlist__count[hidden] {
	display: none;
}

/* ---- Overlay ---- */

.anps-wishlist__overlay {
	position: fixed;
	inset: 0;
	z-index: 120;
	/* Plain rgba first as the fallback; color-mix off the token where supported,
	   so the scrim tracks the demo's own ink. */
	background: rgba( 0, 0, 0, 0.5 );
	background: color-mix( in srgb, var( --wp--preset--color--contrast, CanvasText ) 50%, transparent );
}

.anps-wishlist__overlay[hidden] {
	display: none;
}

/* ---- Panel ---- */

.anps-wishlist__panel {
	position: fixed;
	inset-block: 0;
	inset-inline-end: 0;
	z-index: 121;
	display: flex;
	flex-direction: column;
	gap: var( --wp--preset--spacing--30, 1rem );
	inline-size: min( 400px, 100% );
	padding: var( --wp--preset--spacing--40, 1.5rem );
	background-color: var( --wp--preset--color--base, Canvas );
	color: var( --wp--preset--color--contrast, CanvasText );
	box-shadow: -8px 0 40px rgba( 0, 0, 0, 0.15 );
	overflow-y: auto;
	overscroll-behavior: contain;
	/* Off-canvas + hidden when closed. visibility:hidden keeps the off-screen
	   panel from being a tab stop or a source of horizontal scroll; it is delayed
	   on close so the slide-out can finish first. */
	visibility: hidden;
	transform: translateX( 100% );
	transition: transform 240ms ease, visibility 0s linear 240ms;
}

.anps-wishlist__panel.is-open {
	visibility: visible;
	transform: translateX( 0 );
	transition: transform 240ms ease;
}

/* Right-anchored panel mirrors to the left in RTL. */
[dir="rtl"] .anps-wishlist__panel {
	transform: translateX( -100% );
}

[dir="rtl"] .anps-wishlist__panel.is-open {
	transform: translateX( 0 );
}

@media ( prefers-reduced-motion: reduce ) {
	.anps-wishlist__panel {
		transition: visibility 0s linear 240ms;
	}

	.anps-wishlist__panel.is-open {
		transition: none;
	}
}

.anps-wishlist__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var( --wp--preset--spacing--20, 0.75rem );
}

.anps-wishlist__title {
	margin: 0;
	font-size: var( --wp--preset--font-size--large, 1.25rem );
}

.anps-wishlist__close {
	display: grid;
	place-items: center;
	inline-size: 40px;
	block-size: 40px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	border-radius: var( --wp--custom--radius--pill, 999px );
	cursor: pointer;
}

.anps-wishlist__close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.anps-wishlist__empty,
.anps-wishlist__loading {
	margin: 0;
	color: var( --wp--preset--color--muted, GrayText );
}

.anps-wishlist__empty[hidden],
.anps-wishlist__loading[hidden] {
	display: none;
}

/* ---- Items ---- */

.anps-wishlist__items {
	display: flex;
	flex-direction: column;
	gap: var( --wp--preset--spacing--20, 0.75rem );
	margin: 0;
	padding: 0;
	list-style: none;
}

.anps-wishlist__items[hidden] {
	display: none;
}

.anps-wishlist__item {
	display: flex;
	align-items: center;
	gap: var( --wp--preset--spacing--20, 0.75rem );
}

.anps-wishlist__item-link {
	display: flex;
	flex: 1 1 auto;
	align-items: center;
	gap: var( --wp--preset--spacing--20, 0.75rem );
	min-inline-size: 0;
	color: inherit;
	text-decoration: none;
}

.anps-wishlist__item-img {
	flex: 0 0 auto;
	inline-size: 56px;
	block-size: 56px;
	object-fit: cover;
	border-radius: var( --wp--custom--radius--card, 4px );
	background-color: var( --wp--custom--product-image--background, Canvas );
}

.anps-wishlist__item-img[hidden] {
	display: none;
}

.anps-wishlist__item-name {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.anps-wishlist__item-price {
	flex: 0 0 auto;
	font-weight: 600;
	color: var( --wp--preset--color--primary, LinkText );
}

.anps-wishlist__item-remove {
	display: grid;
	flex: 0 0 auto;
	place-items: center;
	inline-size: 32px;
	block-size: 32px;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var( --wp--preset--color--muted, GrayText );
	border-radius: var( --wp--custom--radius--pill, 999px );
	cursor: pointer;
}

.anps-wishlist__item-remove:hover {
	color: var( --wp--preset--color--contrast, CanvasText );
}

.anps-wishlist__item-remove:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.anps-wishlist__x {
	inline-size: 20px;
	block-size: 20px;
}
