/**
 * Shared icon card component (front-end + admin product preview).
 *
 * Mobile: max 2 per row | Desktop: max 4 per row
 * Cards are capped at 160px and centered — not stretched to full width.
 * Exact counts use :has() so 5→3+2, 6→3+3, 7→4+3 instead of a lonely leftover.
 */

.wri-icons {
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 1.5rem 0;
}

.wri-icons *,
.wri-icons *::before,
.wri-icons *::after {
	box-sizing: border-box;
}

.wri-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 160px));
	justify-content: center;
	justify-items: center;
	gap: 10px;
	width: 100%;
	margin: 0;
	padding: 0;
}

/* Single card on mobile: center alone */
.wri-grid:has(> .wri-card:only-child) {
	grid-template-columns: minmax(0, 160px);
}

.wri-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	width: 100%;
	max-width: 160px;
	min-width: 0;
	padding: 10px;
	background: #eee;
	border-radius: 5px;
}

.wri-card__image {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 1 / 1;
	max-width: 96px;
}

.wri-card__image img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	object-fit: contain;
	border-radius: 50%;
}

.wri-card__label {
	margin-top: 0.5rem;
	font-size: 12px;
	line-height: 1.3;
	word-break: break-word;
}

@media (min-width: 782px) {
	.wri-grid {
		/* Default / 4 / 7 / 8+: max 4 columns, cards ≤ 160px, centered */
		grid-template-columns: repeat(4, minmax(0, 160px));
		gap: 10px;
	}

	.wri-grid:has(> .wri-card:nth-child(1):last-child) {
		grid-template-columns: minmax(0, 160px);
	}

	.wri-grid:has(> .wri-card:nth-child(2):last-child) {
		grid-template-columns: repeat(2, minmax(0, 160px));
	}

	.wri-grid:has(> .wri-card:nth-child(3):last-child) {
		grid-template-columns: repeat(3, minmax(0, 160px));
	}

	/* 5 → 3+2 | 6 → 3+3 */
	.wri-grid:has(> .wri-card:nth-child(5):last-child),
	.wri-grid:has(> .wri-card:nth-child(6):last-child) {
		grid-template-columns: repeat(3, minmax(0, 160px));
	}

	.wri-card__image {
		max-width: 112px;
	}
}

/* Narrow phones: keep cards from forcing horizontal scroll */
@media (max-width: 360px) {
	.wri-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.wri-grid:has(> .wri-card:only-child) {
		grid-template-columns: minmax(0, 160px);
	}
}
