/**
 * Novalink Variation Swatches — front-end styles.
 *
 * Palette is overridable via CSS variables on .nvs-swatches.
 *
 * NOTE: selectors are deliberately specific and include hard resets so theme
 * (OceanWP) `button`/`li` styling — large border-radius, min-height, padding,
 * uppercase, list bullets — cannot bleed into the swatches.
 */

.nvs-swatches {
	--nvs-accent: #2563eb;
	--nvs-accent-soft: #eff4ff;
	--nvs-border: #d9dee6;
	--nvs-text: #1f2733;
	--nvs-muted: #6b7280;
	--nvs-save: #16a34a;
	--nvs-radius: 12px;

	margin: 0 0 18px;
}

/* Keep the native select in the DOM & functional, just out of sight. */
.nvs-swatches .nvs-native {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Grid container — 1fr tracks keep every item inside its cell (no overflow). */
.nvs-swatches .nvs-options {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	display: grid;
	gap: 10px;
}

.nvs-swatches .nvs-options .nvs-option-wrap {
	margin: 0 !important;
	padding: 0 !important;
	list-style: none !important;
	border: 0;
}

.nvs-swatches .nvs-options .nvs-option-wrap::before,
.nvs-swatches .nvs-options .nvs-option-wrap::marker {
	content: none !important;
	display: none !important;
}

/* Hard reset the button against theme defaults, then apply our own styling. */
.nvs-swatches .nvs-options .nvs-option {
	-webkit-appearance: none;
	appearance: none;
	box-sizing: border-box;
	display: flex;
	width: 100%;
	min-width: 0;
	max-width: 100%;
	min-height: 0;
	height: auto;
	margin: 0;
	background: #fff;
	border: 2px solid var(--nvs-border);
	border-radius: var(--nvs-radius);
	box-shadow: none;
	color: var(--nvs-text);
	font: inherit;
	font-weight: 400;
	line-height: 1.3;
	text-align: center;
	text-transform: none;
	letter-spacing: normal;
	white-space: normal;
	overflow-wrap: break-word;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.nvs-swatches .nvs-options .nvs-option:hover {
	border-color: var(--nvs-accent);
	background: #fff;
}

.nvs-swatches .nvs-options .nvs-option:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--nvs-accent-soft);
	border-color: var(--nvs-accent);
}

.nvs-swatches .nvs-options .nvs-option.is-selected {
	border-color: var(--nvs-accent);
	background: var(--nvs-accent-soft);
	box-shadow: inset 0 0 0 1px var(--nvs-accent);
}

.nvs-swatches .nvs-options .nvs-option.is-disabled {
	opacity: 0.4;
	cursor: not-allowed;
	position: relative;
}

.nvs-swatches .nvs-options .nvs-option.is-disabled::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to top left,
		transparent calc(50% - 1px),
		var(--nvs-border) 50%,
		transparent calc(50% + 1px)
	);
	border-radius: inherit;
	pointer-events: none;
}

/* ---------------------------------------------------------------------
 * Image swatches (e.g. Scent)
 * ------------------------------------------------------------------- */

.nvs-type-image .nvs-options {
	/* Auto-fit small tiles; they wrap on their own and never overflow. */
	grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
	max-width: 420px; /* Stops tiles stretching too wide on desktop. */
}

.nvs-type-image .nvs-options .nvs-option {
	flex-direction: column;
	align-items: center;
	justify-content: flex-start;
	gap: 6px;
	padding: 8px;
}

.nvs-swatch-img {
	display: block;
	width: 100%;
	max-width: 64px;
	aspect-ratio: 1 / 1;
	margin: 0 auto;
	border-radius: 8px;
	overflow: hidden;
	background: #f3f4f6;
}

/* aspect-ratio fallback for very old browsers. */
@supports not ( aspect-ratio: 1 / 1 ) {
	.nvs-swatch-img {
		height: 64px;
	}
}

.nvs-swatch-img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.nvs-swatch-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	font-size: 22px;
	font-weight: 700;
	color: var(--nvs-muted);
	text-transform: uppercase;
}

.nvs-swatch-label {
	display: block;
	width: 100%;
	font-size: 12.5px;
	line-height: 1.25;
	font-weight: 500;
	hyphens: none;
}

/* ---------------------------------------------------------------------
 * Text mode for image-swatch attributes (global toggle)
 * Content-sized pills; selected/hover/focus reuse the shared treatment.
 * ------------------------------------------------------------------- */

.nvs-type-image.nvs-mode-text .nvs-options {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	max-width: none;
}

.nvs-type-image.nvs-mode-text .nvs-options .nvs-option {
	width: auto;
	min-width: 54px;
	min-height: 42px;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	padding: 9px 18px;
}

.nvs-type-image.nvs-mode-text .nvs-swatch-label {
	width: auto;
	font-size: 14px;
	line-height: 1.25;
	font-weight: 500;
	text-align: center;
	white-space: normal;
}

@media ( max-width: 480px ) {
	.nvs-type-image.nvs-mode-text .nvs-options .nvs-option {
		padding: 8px 14px;
		min-height: 40px;
	}

	.nvs-type-image.nvs-mode-text .nvs-swatch-label {
		font-size: 13.5px;
	}
}

/* ---------------------------------------------------------------------
 * Radio cards (e.g. Sheets / Size)
 * ------------------------------------------------------------------- */

.nvs-type-cards .nvs-options {
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
	gap: 12px;
	max-width: 520px;
}

.nvs-type-cards .nvs-options .nvs-option {
	position: relative;
	flex-direction: column;
	align-items: flex-start;
	text-align: left;
	gap: 3px;
	padding: 14px 16px;
	margin-top: 6px; /* Room for the badge that overhangs the top edge. */
}

.nvs-card-badge {
	position: absolute;
	top: -10px;
	right: 10px;
	max-width: calc(100% - 20px);
	background: var(--nvs-save);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.02em;
	padding: 4px 8px;
	border-radius: 999px;
	text-transform: uppercase;
	white-space: nowrap;
}

.nvs-card-title {
	font-size: 16px;
	font-weight: 700;
}

.nvs-card-sub {
	font-size: 13px;
	color: var(--nvs-muted);
}

.nvs-card-price {
	font-size: 15px;
	font-weight: 600;
	margin-top: 2px;
}

.nvs-card-price .amount {
	font-weight: 600;
}

.nvs-card-ppu {
	font-size: 12px;
	color: var(--nvs-muted);
}

/* ---------------------------------------------------------------------
 * Tablet
 * ------------------------------------------------------------------- */

@media ( max-width: 1024px ) {
	.nvs-type-image .nvs-options {
		grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
		max-width: none;
	}

	.nvs-type-cards .nvs-options {
		grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
		max-width: none;
	}
}

/* ---------------------------------------------------------------------
 * Mobile — fixed column counts so tiles stay comfortably sized.
 * ------------------------------------------------------------------- */

@media ( max-width: 600px ) {
	.nvs-type-image .nvs-options {
		grid-template-columns: repeat(3, 1fr);
	}

	.nvs-type-cards .nvs-options {
		grid-template-columns: repeat(2, 1fr);
	}

	.nvs-swatch-img {
		max-width: 72px;
	}
}

@media ( max-width: 360px ) {
	.nvs-type-cards .nvs-options {
		grid-template-columns: 1fr;
	}

	.nvs-type-cards .nvs-options .nvs-option {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: baseline;
		gap: 4px 10px;
	}
}
