/* ==========================================================================
   COMPONENT — Wishlist controls, dialog and grid
   --------------------------------------------------------------------------
   Loaded wherever a wishlist control exists: product pages, the homepage hero,
   the account endpoint and a shared list. The controls themselves already have
   their geometry from the page that hosts them — this layer only adds the
   selected state, the shared dialog and the endpoint's own furniture.
   ========================================================================== */

/* --------------------------------------------------------------------------
   CONTROL STATE
   --------------------------------------------------------------------------
   The heart is outlined until it is saved, then filled. The icon set draws
   everything with `fill: none; stroke: currentColor`, so a filled mark is a
   fill/stroke swap rather than a second icon — the same recipe the homepage
   hero already used for its decorative heart.
   -------------------------------------------------------------------------- */

[data-avallone-wishlist] {
	cursor: pointer;
}

[data-avallone-wishlist][aria-pressed='true'] {
	color: var(--color-primary);
}

[data-avallone-wishlist][aria-pressed='true'] svg {
	fill: currentColor;
	stroke: none;
}

/* A request in flight: dimmed and unclickable, but never visually "done" yet. */
[data-avallone-wishlist][aria-busy='true'] {
	opacity: 0.55;
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   CARD HEART
   --------------------------------------------------------------------------
   The product page's heart, on a card's image: the same cream plate, the same
   dark-red outline that fills once saved, so a product saved on one surface
   reads as saved on every other. Top right, because the catalogue card's
   out-of-stock flag already holds the top left.

   One component for the homepage cards, the catalogue card and related
   products. Its parent is the card's image wrapper, which is what makes
   "appears on image hover" expressible without naming any card here.
   -------------------------------------------------------------------------- */

.card-wishlist {
	position: absolute;
	inset-block-start: var(--space-sm);
	inset-inline-end: var(--space-sm);
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-pill);
	background-color: var(--color-cream);
	color: var(--color-primary-dark);
	box-shadow: var(--shadow-sm);
	transition:
		opacity var(--transition-base),
		color var(--transition-base),
		transform var(--transition-base);
}

.card-wishlist:hover {
	color: var(--color-primary);
}

.card-wishlist:active {
	transform: scale(0.94);
}

/*
 * With a pointer that can hover, the heart waits for the image: it appears when
 * the image is hovered, when it takes keyboard focus, and it stays once the
 * product is saved, because a saved state that vanished would be one nobody
 * could find again. It is transparent rather than hidden while it waits, so it
 * is still in the tab order and still the thing a click at that corner lands on
 * — and that click can only come from a pointer already over the image, which
 * has revealed it.
 *
 * A touch screen has no hover to wait for, so there the heart is simply always
 * shown; the rules below never apply.
 */
@media (hover: hover) and (pointer: fine) {

	.card-wishlist {
		opacity: 0;
	}

	:hover > .card-wishlist,
	.card-wishlist:focus-visible,
	.card-wishlist[aria-pressed='true'] {
		opacity: 1;
	}
}

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

	.card-wishlist:active {
		transform: none;
	}
}

.wishlist-status {
	margin: 0;
	font-family: var(--font-ui);
	font-size: 12px;
	line-height: 16px;
	color: var(--color-text);
}

.wishlist-status:empty {
	display: none;
}

.wishlist-status.is-error {
	color: var(--color-error);
}

/* ==========================================================================
   GUEST DIALOG
   --------------------------------------------------------------------------
   State is carried on the `hidden` attribute rather than a class, so a closed
   dialog leaves the accessibility tree and the tab order completely — and so
   the opening frame is never a painted-but-hidden one, which is what made a
   focus move disappear in the catalogue drawer.
   ========================================================================== */

.wishlist-dialog {
	position: fixed;
	inset: 0;
	z-index: 200;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--space-md);
	background-color: color-mix(in srgb, var(--color-ink) 45%, transparent);
	opacity: 1;
	transition: opacity var(--transition-base), display var(--transition-base) allow-discrete;
}

.wishlist-dialog[hidden] {
	display: none;
	opacity: 0;
}

@starting-style {
	.wishlist-dialog:not([hidden]) {
		opacity: 0;
	}
}

.wishlist-dialog__panel {
	width: min(420px, 100%);
	max-height: calc(100vh - var(--space-2xl));
	overflow-y: auto;
	padding: var(--space-lg) var(--space-md);
	border-radius: var(--radius-button);
	background-color: var(--color-cream);
	box-shadow: var(--shadow-xl);
	text-align: center;
}

/* The panel is a scripted focus target, not a control someone tabs to. */
.wishlist-dialog__panel:focus,
.wishlist-dialog__panel:focus-visible {
	outline: none;
}

.wishlist-dialog__icon {
	display: inline-flex;
	margin-bottom: var(--space-sm);
	color: var(--color-primary-dark);
}

.wishlist-dialog__title {
	margin: 0 0 var(--space-xs);
	font-family: var(--font-heading);
	font-style: normal;
	font-weight: 400;
	font-size: 22px;
	line-height: 1.3;
	color: var(--color-ink);
}

.wishlist-dialog__text {
	margin: 0 0 var(--space-lg);
	font-family: var(--font-ui);
	font-size: 15px;
	line-height: 1.55;
	color: var(--color-text);
}

.wishlist-dialog__actions {
	display: flex;
	flex-direction: column;
	gap: var(--space-xs);
}

.wishlist-dialog__actions .btn {
	width: 100%;
	padding: 14px var(--space-md);
	font-size: 14px;
	letter-spacing: 0.1em;
}

.wishlist-dialog__dismiss {
	margin-block-start: var(--space-xs);
	padding: var(--space-xs);
	border: 0;
	background: none;
	font-family: var(--font-ui);
	font-size: 14px;
	color: var(--color-text);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

.wishlist-dialog__dismiss:hover {
	color: var(--color-primary);
}

/* ==========================================================================
   WISHLIST VIEW — the account endpoint and the shared list
   ========================================================================== */

.wishlist-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--space-sm);
	margin-block-end: var(--space-lg);
	padding-block-end: var(--space-md);
	border-block-end: 1px solid var(--color-border);
}

.wishlist-head__count {
	margin: 0;
	font-family: var(--font-meta);
	font-weight: 500;
	font-size: 13px;
	line-height: 18px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--color-text);
}

/* --------------------------------------------------------------------------
   SHARING
   -------------------------------------------------------------------------- */

.wishlist-share {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-xs);
}

.wishlist-share__button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px var(--space-sm);
	border: 1px solid var(--color-rose);
	border-radius: var(--radius-sm);
	background-color: transparent;
	font-family: var(--font-ui);
	font-weight: 500;
	font-size: 13px;
	line-height: 18px;
	text-decoration: none;
	color: var(--color-primary-dark);
	cursor: pointer;
	transition: background-color var(--transition-base), color var(--transition-base);
}

.wishlist-share__button:hover {
	background-color: var(--color-surface-light);
	color: var(--color-primary);
}

.wishlist-share__button--quiet {
	border-color: transparent;
	color: var(--color-text);
}

.wishlist-share__link {
	flex: 1 1 100%;
	min-width: 0;
	margin: 0;
	font-family: var(--font-meta);
	font-size: 13px;
	line-height: 18px;
	word-break: break-all;
	color: var(--color-text);
}

.wishlist-share__status {
	flex: 1 1 100%;
	margin: 0;
	font-family: var(--font-ui);
	font-size: 13px;
	line-height: 18px;
	color: var(--color-text);
}

.wishlist-share__status:empty {
	display: none;
}

.wishlist-share__status.is-error {
	color: var(--color-error);
}

/* --------------------------------------------------------------------------
   GRID
   --------------------------------------------------------------------------
   The catalogue card, reused. Its stylesheet is registered as a dependency
   rather than copied, so the card stays defined in exactly one place.
   -------------------------------------------------------------------------- */

.wishlist-grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space-lg) var(--space-md);
	margin: 0;
	padding: 0;
	list-style: none;
}

.wishlist-grid__item {
	position: relative;
	min-width: 0;
}

/* Remove sits on the card's image plate, mirroring the product page's heart. */
.wishlist-remove {
	position: absolute;
	inset-block-start: var(--space-xs);
	inset-inline-end: var(--space-xs);
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: var(--radius-pill);
	background-color: var(--color-cream);
	color: var(--color-text);
	box-shadow: var(--shadow-sm);
	cursor: pointer;
	transition: color var(--transition-base);
}

.wishlist-remove:hover {
	color: var(--color-primary);
}

.wishlist-remove[aria-busy='true'] {
	opacity: 0.55;
	pointer-events: none;
}

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

.wishlist-empty {
	padding-block: var(--space-2xl);
	text-align: center;
}

.wishlist-empty__title {
	margin: 0 0 var(--space-xs);
	font-family: var(--font-heading);
	font-style: normal;
	font-size: 22px;
	color: var(--color-ink);
}

.wishlist-empty__text {
	margin: 0 0 var(--space-md);
	font-family: var(--font-body);
	font-size: 15px;
	color: var(--color-text);
}

/* ==========================================================================
   < 600px — two cards per row (client 04.11.2026)
   --------------------------------------------------------------------------
   The same two columns as the catalogue on phones; the card's narrow-column
   adaptation (stacked price, full-width 44px LISA) is in catalog.css. The
   remove control already sits 8px from the plate's corner.
   ========================================================================== */

@media (max-width: 599px) {

	.wishlist-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 32px 16px;
	}

	/* The grid item is the <li>, so the card inside did not take the row's
	   height and a two-line name put its LISA 16px below the neighbour's.
	   The card fills its item, and its footer is already pinned to the foot. */
	.wishlist-grid__item {
		display: flex;
		flex-direction: column;
	}

	.wishlist-grid__item > .catalog-card {
		flex: 1 1 auto;
	}
}

/* ==========================================================================
   >= 600px
   ========================================================================== */

@media (min-width: 600px) {

	.wishlist-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.wishlist-dialog__actions {
		flex-direction: row;
	}
}

/* ==========================================================================
   >= 1280px
   ========================================================================== */

@media (min-width: 1280px) {

	.wishlist-grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}
