/**
 * Mosaic grid layout for [tgg_random_games].
 *
 * Featured tile spans `featured_size × featured_size` slots; small tiles fill
 * the rest. Mobile breakpoints fall back to a simple 3-col grid (then 2-col
 * <380px) where the featured spans 2×2 (or 2×1 on very narrow screens).
 *
 * Depends on `tgg-frontend` + `tgg-badges`; load AFTER both.
 */

.tgg-mosaic {
	display: grid;
	grid-template-columns: repeat(var(--tgg-cols, 9), 1fr);
	grid-template-rows: repeat(var(--tgg-rows, 3), 1fr);
	gap: 8px;
	margin: 24px 0;
	aspect-ratio: var(--tgg-cols, 9) / var(--tgg-rows, 3);
}

.tgg-mosaic-item {
	position: relative;
	overflow: hidden;
	border-radius: 12px;
	background: #f0f0f0;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	text-decoration: none;
	display: block;
	color: #fff;
}

.tgg-mosaic-item:hover,
.tgg-mosaic-item:focus-visible {
	transform: translateY(-3px);
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
	z-index: 2;
}

.tgg-mosaic-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* ===== Featured (hero tile) ===== */

.tgg-mosaic-featured {
	border-radius: 16px;
}

.tgg-mosaic-overlay-featured {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 16px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.4) 60%, transparent);
	color: #fff;
}

.tgg-mosaic-title {
	font-size: 18px;
	font-weight: 700;
	margin: 0 0 8px;
	text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
	line-height: 1.3;
	color: #fff;
}

.tgg-mosaic-badges {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

/* ===== Small (filler tile) — title overlay on hover ===== */

.tgg-mosaic-overlay-small {
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, transparent 50%);
	opacity: 0;
	transition: opacity 0.2s ease;
	display: flex;
	align-items: flex-end;
	padding: 8px;
	color: #fff;
}

.tgg-mosaic-small:hover .tgg-mosaic-overlay-small,
.tgg-mosaic-small:focus-visible .tgg-mosaic-overlay-small {
	opacity: 1;
}

.tgg-mosaic-title-small {
	font-size: 12px;
	font-weight: 600;
	line-height: 1.3;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	color: #fff;
}

/* ===== Mini badges on small tiles ===== */

.tgg-badge.tgg-badge-mini {
	position: absolute;
	top: 4px;
	left: 4px;
	font-size: 9px;
	padding: 2px 6px;
	border-radius: 6px;
	line-height: 1;
	z-index: 1;
}

/* HOT mini sits top-right so it can coexist with MỚI mini top-left. */
.tgg-badge.tgg-badge-hot.tgg-badge-mini {
	left: auto;
	right: 4px;
	top: 4px;
}

/* ===== Empty state ===== */

.tgg-empty {
	text-align: center;
	padding: 40px;
	color: #666;
	font-style: italic;
}

/* ===== Responsive ===== */

/* Tablet: shrink to 6×4 to keep tiles tappable. */
@media (max-width: 1024px) {
	.tgg-mosaic {
		--tgg-cols: 6;
		--tgg-rows: 4;
		aspect-ratio: 6 / 4;
	}
}

/* Mobile: simple grid, featured spans 2×2 — drop the explicit grid placement
   from the inline style by overriding to `auto`. */
@media (max-width: 600px) {
	.tgg-mosaic {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		grid-template-rows: auto;
		aspect-ratio: unset;
		gap: 6px;
	}

	.tgg-mosaic-item {
		aspect-ratio: 1 / 1;
		grid-column: auto !important;
		grid-row: auto !important;
	}

	.tgg-mosaic-featured {
		grid-column: span 2 !important;
		grid-row: span 2 !important;
	}

	.tgg-mosaic-title {
		font-size: 14px;
	}

	/* Touch devices: keep title visible (no hover signal). */
	.tgg-mosaic-overlay-small {
		opacity: 1;
		background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 70%);
	}

	.tgg-mosaic-title-small {
		font-size: 11px;
	}
}

@media (max-width: 380px) {
	.tgg-mosaic {
		grid-template-columns: repeat(2, 1fr);
	}

	.tgg-mosaic-featured {
		grid-column: span 2 !important;
		grid-row: span 1 !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tgg-mosaic-item,
	.tgg-mosaic-overlay-small {
		transition: none;
	}
}
