/**
 * Frontend styles for Eynakchi Product Model Links.
 *
 * @package EynakchiProductModelLinks
 */

.epm-model-options {
	--epm-border-color: color-mix(in srgb, currentColor 20%, transparent);
	--epm-active-border-color: currentColor;
	--epm-text-color: inherit;
	--epm-muted-color: color-mix(in srgb, currentColor 55%, transparent);
	--epm-gap: 8px;
	--epm-radius: 0.375rem;
	--epm-columns: 4;
	--epm-card-padding: 0.25rem;
	--epm-label-size: 12px;

	box-sizing: border-box;
	color: var(--epm-text-color);
	margin-block: 1.5rem;
	max-width: 100%;
	overflow-x: hidden;
}

.epm-model-options__title {
	font-size: 1.125rem;
	font-weight: 600;
	line-height: 1.4;
	margin: 0 0 0.875rem;
}

.epm-model-options__items {
	box-sizing: border-box;
	display: grid;
	grid-template-columns: repeat(var(--epm-columns), minmax(0, 1fr));
	gap: var(--epm-gap);
	max-width: 100%;
	width: 100%;
}

.epm-model-option {
	position: relative;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: stretch;
	height: 100%;
	min-width: 0;
	padding: var(--epm-card-padding);
	text-decoration: none;
	color: inherit;
	border: 2px solid var(--epm-border-color);
	border-radius: var(--epm-radius);
	background: transparent;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.epm-model-option:hover,
.epm-model-option:focus-visible {
	border-color: var(--epm-active-border-color);
	box-shadow: 0 0 0 1px var(--epm-active-border-color);
	outline: none;
	transform: translateY(-1px);
}

.epm-model-option--active {
	border-color: var(--epm-active-border-color);
	border-width: 2px;
	box-shadow: 0 0 0 2px var(--epm-active-border-color);
}

.epm-model-option--active::after {
	content: "";
	position: absolute;
	top: 4px;
	inset-inline-end: 4px;
	z-index: 2;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background-color: var(--epm-active-border-color);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 6.2L5 8.7L9.5 3.8' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 10px 10px;
	pointer-events: none;
}

.epm-model-option--out-of-stock {
	opacity: 0.55;
}

.epm-model-option--active.epm-model-option--out-of-stock {
	opacity: 1;
}

.epm-model-option--active.epm-model-option--out-of-stock .epm-model-option__image,
.epm-model-option--active.epm-model-option--out-of-stock .epm-model-option__label {
	opacity: 0.55;
}

.epm-model-option__image {
	position: relative;
	display: block;
	flex: 1 1 auto;
	aspect-ratio: 1 / 1;
	min-height: 0;
	overflow: hidden;
	border-radius: calc(var(--epm-radius) - 2px);
	background: color-mix(in srgb, currentColor 6%, transparent);
}

.epm-model-option__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.epm-model-option__badge {
	position: absolute;
	bottom: 4px;
	left: 50%;
	z-index: 1;
	transform: translateX(-50%);
	padding: 1px 5px;
	font-size: 10px;
	line-height: 1.4;
	font-weight: 600;
	white-space: nowrap;
	color: var(--epm-text-color);
	background: color-mix(in srgb, currentColor 8%, transparent);
	border: 1px solid var(--epm-border-color);
	border-radius: 3px;
	pointer-events: none;
}

.epm-model-option__label {
	display: -webkit-box;
	flex: 0 0 auto;
	margin-top: 0.375rem;
	overflow: hidden;
	font-size: var(--epm-label-size);
	font-weight: 500;
	line-height: 1.35;
	text-align: center;
	word-break: break-word;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	min-height: calc(var(--epm-label-size) * 1.35 * 2);
}

.epm-model-option__stock {
	display: block;
	flex: 0 0 auto;
	margin-top: 0.25rem;
	font-size: 10px;
	line-height: 1.3;
	text-align: center;
	color: var(--epm-muted-color);
}

/* Tablet: max 4 columns */
@media (max-width: 1024px) {
	.epm-model-options__items {
		grid-template-columns: repeat(min(var(--epm-columns), 4), minmax(0, 1fr));
	}
}

/* Mobile: fixed 3 columns */
@media (max-width: 599px) {
	.epm-model-options {
		--epm-card-padding: 0.1875rem;
		--epm-label-size: 11px;
	}

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

[dir="rtl"] .epm-model-option__label,
[dir="rtl"] .epm-model-option__stock {
	text-align: center;
}
