/*
 * Every custom property carries a fallback: this stylesheet ships with the
 * PLUGIN, so it must render under a theme that has never heard of Quartier's
 * tokens (Phase 1's exit gate). Fallbacks are CSS system colours, never hex —
 * TOKENS.md forbids literal colours, and a system colour also respects the
 * reader's forced-colours mode.
 */

/**
 * Quick View — trigger, overlay and dialog panel.
 *
 * Structure only. Every colour, radius and space is a theme.json token, so a
 * demo variation restyles this block by refilling slots and never by touching
 * CSS (TOKENS.md, "patterns reference slugs, never hex").
 */

.anps-quick-view__trigger {
	cursor: pointer;
}

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

/**
 * The overlay is position:fixed so it escapes the product card's overflow. It
 * must NOT sit under an ancestor with transform/filter/perspective, or fixed
 * would resolve against that ancestor instead of the viewport — an integration
 * note for the card pattern that hosts this block.
 */
.anps-quick-view__overlay {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	place-items: center;
	padding: var(--wp--preset--spacing--30, 1rem);
	background-color: color-mix(
		in srgb,
		var(--wp--preset--color--contrast, CanvasText) 55%,
		transparent
	);
	overscroll-behavior: contain;
}

/* Beats the display:grid above so the dialog is closed on first paint and
   whenever the state says so. */
.anps-quick-view__overlay[hidden] {
	display: none;
}

.anps-quick-view__panel {
	position: relative;
	box-sizing: border-box;
	width: min(100%, 46rem);
	max-height: min(90vh, 44rem);
	overflow-y: auto;
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--wp--preset--spacing--40, 1.5rem);
	padding: var(--wp--preset--spacing--50, 2rem);
	background-color: var(--wp--preset--color--paper, Canvas);
	color: var(--wp--preset--color--contrast, CanvasText);
	border-radius: var(--wp--custom--radius--card, 12px);
	box-shadow: 0 1.5rem 3rem color-mix(in srgb, var(--wp--preset--color--contrast, CanvasText) 25%, transparent);
}

@media (min-width: 640px) {
	.anps-quick-view__panel {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		align-items: start;
	}
}

.anps-quick-view__panel:focus {
	outline: none;
}

.anps-quick-view__close {
	position: absolute;
	inset-block-start: var(--wp--preset--spacing--20, 0.75rem);
	inset-inline-end: var(--wp--preset--spacing--20, 0.75rem);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2.25rem;
	height: 2.25rem;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--control, 999px);
	background: none;
	color: inherit;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.anps-quick-view__close:hover {
	background-color: color-mix(in srgb, currentColor 12%, transparent);
}

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

.anps-quick-view__media {
	margin: 0;
	border-radius: var(--wp--custom--radius--card, 12px);
	background-color: var(--wp--custom--product-image--background, Canvas);
	overflow: hidden;
}

.anps-quick-view__image {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
}

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

.anps-quick-view__body {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--20, 0.75rem);
}

.anps-quick-view__title {
	margin: 0;
	/* Padded so a long title never runs under the close button. */
	padding-inline-end: 2.5rem;
}

.anps-quick-view__price {
	margin: 0;
	color: var(--wp--preset--color--primary, LinkText);
	font-weight: 600;
}

.anps-quick-view__description {
	margin: 0;
	color: var(--wp--custom--text--soft, GrayText);
}

.anps-quick-view__loading,
.anps-quick-view__error {
	margin: 0;
}

.anps-quick-view__error {
	color: var(--wp--preset--color--error, Mark);
	font-weight: 600;
}

.anps-quick-view__loading[hidden],
.anps-quick-view__error[hidden],
.anps-quick-view__price[hidden],
.anps-quick-view__description[hidden],
.anps-quick-view__add[hidden] {
	display: none;
}

.anps-quick-view__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--20, 0.75rem);
	margin-block-start: var(--wp--preset--spacing--10, 0.5rem);
}

.anps-quick-view__add {
	cursor: pointer;
}

.anps-quick-view__add:focus-visible,
.anps-quick-view__details:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.anps-quick-view__add[disabled] {
	opacity: 0.6;
	cursor: default;
}

.anps-quick-view__details {
	color: var(--wp--preset--color--primary, LinkText);
	text-underline-offset: 0.2em;
}

/* A live region present at load but empty until there is something to announce;
   collapse it so it costs no space in the meantime. */
.anps-quick-view__message {
	margin: 0;
}

.anps-quick-view__message:empty {
	display: none;
}

/* Forced colours drop custom fills; keep the panel and its overlay legible with
   a system border and ground. */
@media (forced-colors: active) {
	.anps-quick-view__overlay {
		background-color: rgba(0, 0, 0, 0.5);
	}

	.anps-quick-view__panel {
		border: 1px solid CanvasText;
	}
}
