/*
 * Wishlist and comparison: card buttons, header counter, the two pages, the
 * comparison tray and the toast. Built on the theme's own tokens so it reads
 * as part of the same design.
 */

/* --- Card buttons ----------------------------------------------------------- */

/*
 * Over the image's top-right corner. z-index above the title link's
 * full-card ::after (z-index 1 in product-card.css), which would otherwise
 * swallow the click.
 */
.pcard__actions {
	position: absolute;
	top: var(--wp--preset--spacing--3);
	right: var(--wp--preset--spacing--3);
	z-index: 3;
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--2);
}

.pcard__action {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--wp--custom--border--on-light);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	box-shadow: var(--wp--custom--shadow--sm);
	cursor: pointer;
	transition:
		background var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		color var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.pcard__action svg {
	width: 20px;
	height: 20px;
	fill: none;
}

.pcard__action:hover {
	transform: scale(1.06);
}

.pcard__action:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

.pcard__action.ef-wishlist-btn.is-active svg {
	fill: currentColor;
}

.pcard__action.ef-compare-btn.is-active {
	border-color: var(--wp--preset--color--contrast);
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

/* --- Header counter --------------------------------------------------------- */

.site-header__wishlist {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	color: var(--ef-header-fg);
	border-radius: var(--wp--custom--radius--md);
	transition: opacity var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.site-header__wishlist:hover {
	opacity: 0.65;
	color: var(--ef-header-fg);
}

.site-header__wishlist-icon {
	width: 20px;
	height: 20px;
	stroke-width: 1.6;
}

/* Same badge as the cart count beside it. */
.site-header__wishlist-count {
	position: absolute;
	top: 4px;
	right: 2px;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--base-darker);
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	font-variant-numeric: tabular-nums;
}

.site-header__wishlist-count[hidden] {
	display: none;
}

/* --- Pages ------------------------------------------------------------------ */

.ef-collection {
	padding-block: var(--wp--preset--spacing--10) var(--wp--custom--section--padding-tight);
	padding-inline: var(--wp--preset--spacing--5);
}

.ef-collection:focus {
	outline: none;
}

.ef-collection__inner {
	max-width: var(--wp--style--global--wide-size, 1320px);
	margin-inline: auto;
}

.ef-collection__head {
	margin-bottom: var(--wp--preset--spacing--8);
}

.ef-collection__title {
	margin: 0;
	font-size: var(--wp--preset--font-size--xl-4);
	letter-spacing: -0.035em;
}

.ef-collection__loading,
.ef-collection__error,
.ef-collection__noscript {
	color: var(--wp--preset--color--contrast-muted);
}

.ef-wishlist-grid .pcard {
	position: relative;
}

/* Remove control on a wishlist card, over the picture like the card buttons. */
.ef-card-remove {
	position: absolute;
	top: var(--wp--preset--spacing--3);
	right: var(--wp--preset--spacing--3);
	z-index: 3;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid var(--wp--custom--border--on-light);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.ef-card-remove:hover,
.ef-card-remove:focus-visible {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.ef-stock {
	margin: 0;
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
}

.ef-stock--instock {
	color: var(--wp--preset--color--success);
}

.ef-stock--onbackorder {
	color: var(--wp--preset--color--warning);
}

.ef-stock--outofstock {
	color: var(--wp--preset--color--contrast-muted);
}

/* --- Empty state ------------------------------------------------------------ */

.ef-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--wp--preset--spacing--3);
	max-width: 440px;
	margin: var(--wp--preset--spacing--10) auto;
	text-align: center;
}

.ef-empty__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 72px;
	height: 72px;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--base-subtle);
	color: var(--wp--preset--color--contrast);
}

.ef-empty__title {
	margin: var(--wp--preset--spacing--2) 0 0;
	font-size: var(--wp--preset--font-size--xl-2);
}

.ef-empty__text {
	margin: 0;
	color: var(--wp--preset--color--contrast-subtle);
}

.ef-empty__cta {
	margin-top: var(--wp--preset--spacing--3);
}

/* --- Comparison -------------------------------------------------------------- */

.ef-notice {
	margin: 0 0 var(--wp--preset--spacing--4);
	padding: var(--wp--preset--spacing--3) var(--wp--preset--spacing--4);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--base-subtle);
	color: var(--wp--preset--color--contrast-subtle);
	font-size: var(--wp--preset--font-size--sm);
}

.ef-compare__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--3);
	margin-bottom: var(--wp--preset--spacing--4);
}

.ef-switch {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--2);
	min-height: 44px;
	cursor: pointer;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
}

.ef-switch__input {
	width: 18px;
	height: 18px;
	margin: 0;
	accent-color: var(--wp--preset--color--contrast);
}

.ef-compare__share {
	appearance: none;
	min-height: 44px;
	padding: 0 var(--wp--preset--spacing--4);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--base);
	color: var(--wp--preset--color--contrast);
	font: inherit;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	cursor: pointer;
}

.ef-compare__share:hover {
	border-color: var(--wp--preset--color--contrast);
}

/*
 * The table scrolls sideways inside its own box; the page never does. The
 * label column stays put while the products slide under it.
 */
.ef-compare__scroll {
	overflow-x: auto;
	border: 1px solid var(--wp--custom--border--on-light);
	border-radius: var(--wp--custom--radius--lg);
	-webkit-overflow-scrolling: touch;
}

.ef-compare__scroll:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}

.ef-compare__table {
	width: 100%;
	min-width: calc(180px + var(--ef-cols, 2) * 200px);
	border-collapse: separate;
	border-spacing: 0;
	table-layout: fixed;
	font-size: var(--wp--preset--font-size--sm);
}

.ef-compare__table th,
.ef-compare__table td {
	padding: var(--wp--preset--spacing--3) var(--wp--preset--spacing--4);
	border-bottom: 1px solid var(--wp--custom--border--on-light);
	text-align: left;
	vertical-align: top;
	overflow-wrap: anywhere;
}

.ef-compare__table tbody tr:last-child th,
.ef-compare__table tbody tr:last-child td {
	border-bottom: 0;
}

.ef-compare__corner,
.ef-compare__label {
	position: sticky;
	left: 0;
	z-index: 1;
	width: 180px;
	background: var(--wp--preset--color--base-soft);
	box-shadow: 1px 0 0 var(--wp--custom--border--on-light);
}

.ef-compare__label {
	font-weight: 500;
	color: var(--wp--preset--color--contrast-subtle);
}

.ef-compare__table td {
	font-weight: 600;
	color: var(--wp--preset--color--contrast);
}

.ef-compare__table td.is-empty {
	font-weight: 400;
	color: var(--wp--preset--color--contrast-muted);
}

.ef-compare__table.is-diff-only tr[data-differs="0"] {
	display: none;
}

.ef-compare__product {
	position: relative;
	font-weight: 400;
}

.ef-compare__remove {
	position: absolute;
	top: var(--wp--preset--spacing--2);
	right: var(--wp--preset--spacing--2);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--base-subtle);
	color: var(--wp--preset--color--contrast);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.ef-compare__remove:hover,
.ef-compare__remove:focus-visible {
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
}

.ef-compare__link {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--2);
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.ef-compare__img {
	width: 100%;
	max-width: 140px;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--base-soft);
}

.ef-compare__name {
	font-size: var(--wp--preset--font-size--base);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -0.01em;
}

.ef-compare__price {
	display: block;
	margin: var(--wp--preset--spacing--2) 0 var(--wp--preset--spacing--3);
	font-weight: 700;
}

.ef-compare__price .woocommerce-Price-amount {
	font-weight: inherit;
}

.ef-compare__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding-inline: var(--wp--preset--spacing--4);
	font-size: var(--wp--preset--font-size--sm);
}

@media (max-width: 599px) {
	.ef-compare__corner,
	.ef-compare__label {
		width: 120px;
	}

	.ef-compare__table {
		min-width: calc(120px + var(--ef-cols, 2) * 160px);
	}

	.ef-compare__table th,
	.ef-compare__table td {
		padding: var(--wp--preset--spacing--2) var(--wp--preset--spacing--3);
	}
}

/* --- Tray --------------------------------------------------------------------- */

/*
 * --ef-tray-offset is the height of the product page's own fixed purchase
 * bar while it is showing (collections.js), so the two stack instead of one
 * covering the other.
 */
.ef-tray {
	position: fixed;
	left: 0;
	right: 0;
	bottom: var(--ef-tray-offset, 0px);
	z-index: 89;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	background: var(--wp--preset--color--base);
	border-top: 1px solid var(--wp--custom--border--on-light);
	box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.06);
	transition: bottom var(--wp--custom--duration--fast) var(--wp--custom--ease--out);
}

.ef-tray[hidden] {
	display: none;
}

.ef-tray__inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--wp--preset--spacing--3) var(--wp--preset--spacing--5);
	max-width: var(--wp--style--global--wide-size, 1320px);
	margin-inline: auto;
	padding: var(--wp--preset--spacing--3) var(--wp--preset--spacing--5);
}

.ef-tray__title {
	margin: 0;
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 700;
}

.ef-tray__count {
	font-weight: 500;
	color: var(--wp--preset--color--contrast-muted);
	font-variant-numeric: tabular-nums;
}

.ef-tray__items {
	display: flex;
	flex: 1 1 auto;
	gap: var(--wp--preset--spacing--2);
	min-width: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ef-tray__item {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--2);
	min-width: 0;
	max-width: 220px;
	padding: 4px 4px 4px 4px;
	border: 1px solid var(--wp--custom--border--on-light);
	border-radius: var(--wp--custom--radius--md);
}

.ef-tray__img {
	flex: 0 0 auto;
	width: 40px;
	height: 40px;
	object-fit: contain;
	border-radius: var(--wp--custom--radius--sm);
	background: var(--wp--preset--color--base-soft);
}

.ef-tray__name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 600;
}

.ef-tray__remove {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: var(--wp--custom--radius--pill);
	background: none;
	color: var(--wp--preset--color--contrast-muted);
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
}

.ef-tray__remove:hover,
.ef-tray__remove:focus-visible {
	background: var(--wp--preset--color--base-subtle);
	color: var(--wp--preset--color--contrast);
}

.ef-tray__warn {
	flex: 1 1 100%;
	order: 5;
	margin: 0;
	font-size: var(--wp--preset--font-size--xs);
	color: var(--wp--preset--color--warning);
}

.ef-tray__actions {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--2);
}

.ef-tray__go {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 var(--wp--preset--spacing--5);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--contrast);
	color: var(--wp--preset--color--base);
	font-size: var(--wp--preset--font-size--sm);
	font-weight: 600;
	text-decoration: none;
}

.ef-tray__go:hover {
	background: var(--wp--preset--color--primary-hover);
	color: var(--wp--preset--color--base);
}

.ef-tray__clear {
	appearance: none;
	min-height: 44px;
	padding: 0 var(--wp--preset--spacing--3);
	border: 0;
	background: none;
	color: var(--wp--preset--color--contrast-subtle);
	font: inherit;
	font-size: var(--wp--preset--font-size--sm);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* The page owes the tray the height it covers, so the footer is reachable. */
body.ef-has-tray .wp-site-blocks {
	padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

body.single-product.ef-has-tray .wp-site-blocks {
	padding-bottom: calc(172px + env(safe-area-inset-bottom, 0px));
}

/* Phones: names give way to thumbnails, so the tray stays one short row. */
@media (max-width: 599px) {
	.ef-tray__inner {
		gap: var(--wp--preset--spacing--2) var(--wp--preset--spacing--3);
		padding: var(--wp--preset--spacing--2) var(--wp--preset--spacing--4);
	}

	.ef-tray__title {
		flex: 1 1 auto;
	}

	.ef-tray__items {
		order: 3;
		flex: 1 1 100%;
	}

	.ef-tray__name {
		display: none;
	}

	.ef-tray__item {
		max-width: none;
	}

	/* The mixed-category note already appears in the toast and on the
	   comparison page; on a phone the tray's height is worth more. */
	.ef-tray__warn {
		display: none;
	}
}

/* --- Toast -------------------------------------------------------------------- */

.ef-toast {
	position: fixed;
	left: 50%;
	bottom: calc(var(--wp--preset--spacing--6) + env(safe-area-inset-bottom, 0px));
	z-index: 100;
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--3);
	max-width: min(92vw, 520px);
	padding: var(--wp--preset--spacing--3) var(--wp--preset--spacing--4);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--base-dark);
	color: var(--wp--preset--color--base);
	box-shadow: var(--wp--custom--shadow--lg);
	font-size: var(--wp--preset--font-size--sm);
	opacity: 0;
	visibility: hidden;
	transform: translate(-50%, 8px);
	transition:
		opacity var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		visibility 0s linear var(--wp--custom--duration--fast);
}

.ef-toast.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translate(-50%, 0);
	transition:
		opacity var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		transform var(--wp--custom--duration--fast) var(--wp--custom--ease--out),
		visibility 0s linear 0s;
}

/* Clear of the tray when it is open. */
body.ef-has-tray .ef-toast {
	bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}

.ef-toast__action {
	flex: 0 0 auto;
	color: var(--wp--preset--color--base);
	font-weight: 700;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ef-toast__action:hover {
	color: var(--wp--preset--color--on-dark-muted);
}

@media (prefers-reduced-motion: reduce) {
	.pcard__action,
	.ef-tray,
	.ef-toast {
		transition: none;
	}
}
