/**
 * NeoWish frontend styles.
 *
 * The --neowish-* custom properties come from the plugin's own Design tab
 * (see NeoWish\Frontend\Assets::get_design_css) and are deliberately not the
 * family's shared --neo-* names: NeoWish paints from its own colours alone,
 * so nothing here changes when another NeoPlugin product is switched on or
 * off. Every use carries a fallback so the styles hold up with none defined.
 */

/* Add to Wishlist button */
.neoplugin-wish-button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	text-decoration: none;
	color: var( --neowish-text, #3c434a );
	font-size: 0.95em;
	line-height: 1;
	margin: 8px 0;
	transition: color 0.2s;
}

.neoplugin-wish-button:hover,
.neoplugin-wish-button:focus {
	color: var( --neowish-primary, #2271b1 );
	text-decoration: none;
}

.neoplugin-wish-button:focus-visible {
	outline: 2px solid var( --neowish-primary, #2271b1 );
	outline-offset: 2px;
	border-radius: var( --neowish-border-radius, 4px );
}

.neoplugin-wish-icon {
	display: inline-flex;
}

.neoplugin-wish-heart {
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	transition: fill 0.2s, stroke 0.2s;
}

/* Saved state: the label takes the brand colour along with the heart, so
   text-only buttons show it too. */
.neoplugin-wish-button.is-saved {
	color: var( --neowish-primary, #2271b1 );
}

.neoplugin-wish-button.is-saved .neoplugin-wish-heart {
	fill: var( --neowish-primary, #2271b1 );
	stroke: var( --neowish-primary, #2271b1 );
}

.neoplugin-wish-button.is-busy {
	opacity: 0.5;
	pointer-events: none;
}

/* Compact loop variant: icon-only over the product card */
.neoplugin-wish-button--loop {
	margin: 4px 0;
}

/* Icon-only buttons (the Heart icon only style, and every shop-loop button).
   The label stays in the button for screen readers and is revealed as a
   tooltip on hover and keyboard focus, so sighted shoppers get the same
   words. It is the node the script relabels, so the tooltip always says
   "Add" or "Remove" correctly. */
.neoplugin-wish-button--icon {
	position: relative;
	justify-content: center;
	min-width: 32px;
	min-height: 32px;
}

.neoplugin-wish-label--hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
	border: 0;
}

.neoplugin-wish-button--icon:hover .neoplugin-wish-label--hidden,
.neoplugin-wish-button--icon:focus-visible .neoplugin-wish-label--hidden {
	bottom: calc( 100% + 6px );
	left: 50%;
	z-index: 10;
	width: auto;
	height: auto;
	padding: 5px 8px;
	margin: 0;
	overflow: visible;
	clip: auto;
	clip-path: none;
	color: #fff;
	font-size: 13px;
	line-height: 1.3;
	background: #1d2327;
	border: 1px solid transparent; /* Visible in forced-colours mode. */
	border-radius: 3px;
	transform: translateX( -50% );
	pointer-events: none;
}

/* The over-the-image heart sits in the card's top corner, where a bubble
   above it would be clipped by the image; put it beside the heart instead. */
.neoplugin-wish-button--overlay:hover .neoplugin-wish-label--hidden,
.neoplugin-wish-button--overlay:focus-visible .neoplugin-wish-label--hidden {
	top: 50%;
	bottom: auto;
	left: auto;
	inset-inline-start: calc( 100% + 6px );
	transform: translateY( -50% );
}

/* On touch screens :hover sticks after a tap; keep the tooltip to focus. */
@media ( hover: none ) {

	.neoplugin-wish-button--icon:hover:not( :focus-visible ) .neoplugin-wish-label--hidden {
		width: 1px;
		height: 1px;
		padding: 0;
		overflow: hidden;
		clip: rect( 0 0 0 0 );
		clip-path: inset( 50% );
		border: 0;
	}
}

/* Wishlist page */
.neoplugin-wishlist-table {
	width: 100%;
	border-collapse: collapse;
	margin-bottom: 24px;
}

.neoplugin-wishlist-table th,
.neoplugin-wishlist-table td {
	padding: 12px;
	text-align: start;
	vertical-align: middle;
	border-bottom: 1px solid var( --neowish-border, rgba( 0, 0, 0, 0.15 ) );
}

.neoplugin-wish-col-thumbnail img {
	max-width: 72px;
	height: auto;
	border-radius: var( --neowish-border-radius, 4px );
}

.neoplugin-wish-col-product a {
	color: var( --neowish-text, #3c434a );
	font-weight: 600;
	text-decoration: none;
}

.neoplugin-wish-col-product a:hover {
	color: var( --neowish-primary, #2271b1 );
}

.neoplugin-wish-instock {
	color: var( --neowish-success, #00a32a );
	font-weight: 600;
}

.neoplugin-wish-outofstock {
	color: #d63638;
	font-weight: 600;
}

.neoplugin-wish-points {
	color: var( --neowish-success, #00a32a );
	font-weight: 600;
	white-space: nowrap;
}

.neoplugin-wish-col-actions {
	white-space: nowrap;
}

.neoplugin-wish-col-quantity {
	white-space: nowrap;
}

/* Two classes: themes size input[type="number"] (0,1,1), often to 100%. */
.neoplugin-wishlist-table .neoplugin-wish-qty {
	width: 4.5em;
	max-width: 4.5em;
	min-height: 36px;
	margin: 0;
	box-sizing: border-box;
	padding: 4px 6px;
	text-align: center;
	border: 1px solid var( --neowish-border, rgba( 0, 0, 0, 0.15 ) );
	border-radius: var( --neowish-border-radius, 4px );
}

/* The visible caption only matters once the header row is hidden (below). */
.neoplugin-wish-qty-caption {
	display: none;
}

.neoplugin-wish-remove {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 6px 10px;
	color: var( --neowish-text, #3c434a );
	border-radius: var( --neowish-border-radius, 4px );
}

.neoplugin-wish-remove:hover,
.neoplugin-wish-remove:focus {
	color: #d63638;
}

.neoplugin-wish-remove:focus-visible {
	outline: 2px solid var( --neowish-primary, #2271b1 );
}

/* Empty state */
.neoplugin-wish-empty {
	text-align: center;
	padding: 40px 20px;
	border: 1px dashed var( --neowish-border, rgba( 0, 0, 0, 0.15 ) );
	border-radius: var( --neowish-border-radius, 4px );
}

/* Sharing and privacy */
.neoplugin-wish-sharing {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px;
	border: 1px solid var( --neowish-border, rgba( 0, 0, 0, 0.15 ) );
	border-radius: var( --neowish-border-radius, 4px );
}

.neoplugin-wish-visibility {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
}

.neoplugin-wish-share-links {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

/* Compact icon buttons. Sharing is a secondary action, so it gets icons
   rather than five full-width theme buttons competing with Add to cart. */
.neoplugin-wish-share {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	min-height: 0;
	padding: 0;
	border: 1px solid var( --neowish-border, rgba( 0, 0, 0, 0.15 ) );
	border-radius: 50%;
	background: transparent;
	color: var( --neowish-text, #3c434a );
	line-height: 1;
	cursor: pointer;
	text-decoration: none;
	transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.neoplugin-wish-share:hover,
.neoplugin-wish-share:focus {
	color: #fff;
	background: var( --neowish-primary, #2271b1 );
	border-color: var( --neowish-primary, #2271b1 );
	text-decoration: none;
}

.neoplugin-wish-share:focus-visible {
	outline: 2px solid var( --neowish-primary, #2271b1 );
	outline-offset: 2px;
}

.neoplugin-wish-svg {
	display: block;
	width: 18px;
	height: 18px;
	fill: currentColor;
}

/* Each network takes its own colour on hover — recognisable at a glance
   without printing the brand name next to every icon. */
.neoplugin-wish-share--whatsapp:hover,
.neoplugin-wish-share--whatsapp:focus {
	background: #25d366;
	border-color: #25d366;
}

.neoplugin-wish-share--x:hover,
.neoplugin-wish-share--x:focus {
	background: #000;
	border-color: #000;
}

.neoplugin-wish-share--facebook:hover,
.neoplugin-wish-share--facebook:focus {
	background: #1877f2;
	border-color: #1877f2;
}

/* Copy confirmation: the icon swaps to a tick instead of the label text
   being replaced, which would wipe the SVG out of the button. */
.neoplugin-wish-icon-copied {
	display: none;
}

.neoplugin-wish-share.is-copied .neoplugin-wish-icon-default {
	display: none;
}

.neoplugin-wish-share.is-copied .neoplugin-wish-icon-copied {
	display: block;
}

.neoplugin-wish-share.is-copied {
	color: #fff;
	background: var( --neowish-success, #00a32a );
	border-color: var( --neowish-success, #00a32a );
}

/* Themes are expected to define .screen-reader-text, but not all do — and an
   unstyled one would print "Share on WhatsApp" beside every icon. */
.neoplugin-wishlist .screen-reader-text,
.neoplugin-wish-button .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
	border: 0;
}

/* Mobile: let the table collapse into cards */
@media ( max-width: 600px ) {
	.neoplugin-wishlist-table thead {
		display: none;
	}

	.neoplugin-wishlist-table tr {
		display: block;
		border-bottom: 1px solid var( --neowish-border, rgba( 0, 0, 0, 0.15 ) );
		padding: 12px 0;
	}

	.neoplugin-wishlist-table td {
		display: inline-block;
		border-bottom: none;
		padding: 4px 8px;
	}

	.neoplugin-wish-qty-caption {
		display: inline;
		margin-inline-end: 6px;
	}

	/* The field is taller than a line of text; without this the next cell
	 * sits on its baseline and drops onto it. */
	.neoplugin-wishlist-table td.neoplugin-wish-col-quantity {
		vertical-align: middle;
	}

	.neoplugin-wish-sharing {
		flex-direction: column;
		align-items: stretch;
	}
}

/* Add-to-wishlist toast.
 *
 * The visible half of the confirmation announce() speaks to screen readers.
 * This is where --neowish-success earns its place in the Design tab: the
 * accent colour is the toast, so changing it changes the one moment every
 * shopper sees.
 */
.neowish-toast-region {
	position: fixed;
	z-index: 999999;
	right: 20px;
	bottom: 20px;
	inset-inline-end: 20px;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;

	/* The region spans the corner but must never swallow clicks on the page
	   behind it; the toasts themselves opt back in. */
	pointer-events: none;
}

.neowish-toast {
	display: flex;
	align-items: center;
	gap: 10px;
	max-width: min( 320px, calc( 100vw - 40px ) );
	padding: 12px 18px;
	background: var( --neowish-success, #00a32a );
	color: #fff;
	font-size: 0.95em;
	line-height: 1.4;
	border-radius: var( --neowish-border-radius, 4px );
	box-shadow: 0 6px 18px rgba( 0, 0, 0, 0.18 );
	cursor: pointer;
	pointer-events: auto;
	opacity: 0;
	transform: translateY( 12px );
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.neowish-toast.is-visible {
	opacity: 1;
	transform: translateY( 0 );
}

.neowish-toast.is-leaving {
	opacity: 0;
	transform: translateY( 12px );
}

.neowish-toast-icon {
	flex-shrink: 0;
	font-size: 1.1em;
	line-height: 1;
}

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

	.neowish-toast {
		transform: none;
		transition: opacity 0.01ms;
	}

	.neowish-toast.is-visible,
	.neowish-toast.is-leaving {
		transform: none;
	}
}

/* Shop-loop title row.
 *
 * The card's title and its wishlist button share a line: the title takes the
 * space it needs, the heart sits at the end of it. Aligned to the top rather
 * than centred so a title that wraps to two lines does not drag the heart
 * into the middle of them.
 */
.neoplugin-wish-title-row {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}

.neoplugin-wish-title-row > :first-child {
	min-width: 0;
	margin-top: 0;
}

.neoplugin-wish-title-row .neoplugin-wish-button {
	flex-shrink: 0;
	margin: 0;
}

/* Shop-loop button, over the product image.
 *
 * The placement that needs nothing from the theme. The button renders at the
 * end of the card — the one loop hook every theme fires — and is lifted onto
 * the image from here. Both card selectors are WooCommerce's own markup,
 * classic and block, so no theme class is relied on.
 *
 * Left, not right: WooCommerce puts the sale badge top-right in both.
 */
.woocommerce ul.products li.product,
ul.products li.product,
.wc-block-product {
	position: relative;
}

.neoplugin-wish-button--overlay {
	position: absolute;
	top: 10px;
	left: 10px;
	inset-inline-start: 10px;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	margin: 0;
	background: rgba( 255, 255, 255, 0.92 );
	border-radius: 50%;
	box-shadow: 0 1px 5px rgba( 0, 0, 0, 0.2 );
	transition: background-color 0.2s, transform 0.2s;
}

.neoplugin-wish-button--overlay:hover,
.neoplugin-wish-button--overlay:focus {
	background: #fff;
	transform: scale( 1.08 );
}

.neoplugin-wish-button--overlay .neoplugin-wish-icon {
	margin: 0;
}

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

	.neoplugin-wish-button--overlay {
		transition: none;
	}

	.neoplugin-wish-button--overlay:hover,
	.neoplugin-wish-button--overlay:focus {
		transform: none;
	}
}
