/**
 * AGS Product Options — front-end switcher.
 * Prefixed with ags-po- to avoid clashing with theme/WooCommerce classes.
 */

.ags-po-switcher {
	margin: 0 0 1.5em;
}

.ags-po-group {
	margin: 0 0 1.1em;
}

.ags-po-group__label {
	margin: 0 0 0.5em;
	font-size: 0.95em;
	font-weight: 600;
	line-height: 1.2;
}

.ags-po-items {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.ags-po-item {
	margin: 0;
	padding: 0;
}

/* The clickable / current element. */
.ags-po-link {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	box-sizing: border-box;
	padding: 2px;
	border: 2px solid rgba( 0, 0, 0, 0.15 );
	border-radius: 6px;
	background: transparent;
	color: inherit;
	text-decoration: none;
	line-height: 1;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.ags-po-link:hover,
a.ags-po-link:focus-visible {
	border-color: rgba( 0, 0, 0, 0.55 );
	outline: none;
}

/* Current option: not a link, visually marked. */
.ags-po-item.is-current .ags-po-link {
	border-color: currentColor;
	box-shadow: inset 0 0 0 1px currentColor;
	cursor: default;
}

.ags-po-item.is-current .ags-po-link::after {
	content: "";
	position: absolute;
	top: -6px;
	right: -6px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: currentColor url( "data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E" ) center / 11px no-repeat;
}

/* Image swatch. */
.ags-po-swatch--image,
.ags-po-swatch--color {
	display: block;
	width: 40px;
	height: 40px;
	border-radius: 4px;
	overflow: hidden;
}

.ags-po-swatch-image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Colour swatch: bordered so white is visible. */
.ags-po-swatch--color {
	border: 1px solid rgba( 0, 0, 0, 0.2 );
}

/* Text tile: rectangular, auto width. */
.ags-po-item--text .ags-po-link {
	min-width: 0;
}

.ags-po-swatch--text {
	display: block;
	padding: 0 12px;
	font-size: 0.85em;
	white-space: nowrap;
}

/* Tooltip — only for image/colour where the label is not visible. */
.ags-po-tooltip {
	position: absolute;
	top: calc( 100% + 6px );
	left: 50%;
	transform: translateX( -50% );
	z-index: 5;
	padding: 4px 8px;
	border-radius: 4px;
	background: #1a1a1a;
	color: #fff;
	font-size: 0.75rem;
	line-height: 1.3;
	white-space: nowrap;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.12s ease;
}

.ags-po-link:hover .ags-po-tooltip,
.ags-po-link:focus-visible .ags-po-tooltip,
.ags-po-link:focus .ags-po-tooltip {
	opacity: 1;
	visibility: visible;
}

@media ( prefers-color-scheme: dark ) {
	.ags-po-link {
		background: transparent;
		border-color: rgba( 255, 255, 255, 0.2 );
	}

	a.ags-po-link:hover,
	a.ags-po-link:focus-visible {
		border-color: rgba( 255, 255, 255, 0.65 );
	}
}
