/**
 * Image Menu Grid – pure CSS overlay (no JavaScript)
 * Open/close via #comfy-nav-toggle checkbox in the theme header
 */

.img-menu-grid {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-content: center;
	gap: 10px;
	width: 100%;
	max-width: 70vw;
	margin: 0 auto;
	padding: 0;
	box-sizing: border-box;
	list-style: none;
}

.img-menu-grid__item {
	/* Instant response on tap/click */
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	position: relative;
	display: block;
	flex: 0 0 calc((100% - 40px) / 5);
	max-width: calc((100% - 40px) / 5);
	aspect-ratio: 1 / 1 !important;
	background-color: #e8e8e8;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	border-radius: 2px;
	overflow: hidden;
	text-decoration: none;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	box-sizing: border-box;
}

.img-menu-grid__item:hover,
.img-menu-grid__item:focus {
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14);
	outline: none;
}

.img-menu-grid__label {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	padding: 28px 8px 11px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.3) 55%, transparent 100%);
	display: flex;
	align-items: flex-end;
	justify-content: center;
	text-align: center;
}

.img-menu-grid__title {
	color: #fff;
	font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-size: clamp(0.85rem, 1.4vw, 1.1rem);
	font-weight: 500;
	line-height: 1.25;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
	margin: 0;
}

.img-menu-grid__placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #d0d0d0, #b8b8b8);
}

.img-menu-grid-error {
	padding: 12px 16px;
	background: #fff3cd;
	border: 1px solid #ffc107;
	border-radius: 4px;
	color: #856404;
}

/* Overlay – hidden by default */
.img-menu-grid-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(255, 255, 255, 0.97);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 72px 32px 40px;
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	/* Instant open/close – no fade lag before navigation */
	transition: none !important;
}

/* Open state – pure CSS, no JS */
body:has(#comfy-nav-toggle:checked) .img-menu-grid-overlay {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

body:has(#comfy-nav-toggle:checked) {
	overflow: hidden;
}

.img-menu-grid-overlay__inner {
	width: 100%;
	max-width: 70vw;
	margin: 0 auto;
	display: flex;
	justify-content: center;
}

/* Close is a <label> for the checkbox */
.img-menu-grid-overlay__close {
	position: fixed;
	top: 16px;
	right: 18px;
	z-index: 100002;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	cursor: pointer;
	color: #333;
	border-radius: 50%;
	padding: 0;
	line-height: 1;
}
.img-menu-grid-overlay__close:hover {
	background: rgba(0, 0, 0, 0.06);
}
.img-menu-grid-overlay__close svg {
	pointer-events: none;
	display: block;
}

@media (max-width: 1024px) {
	.img-menu-grid__item {
	/* Instant response on tap/click */
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
		flex: 0 0 calc((100% - 20px) / 3);
		max-width: calc((100% - 20px) / 3);
	}
	.img-menu-grid-overlay {
		padding: 70px 24px 32px;
	}
}

@media (max-width: 768px) {
	.img-menu-grid-overlay {
		padding: 64px 18px 24px;
	}
	.img-menu-grid-overlay__inner {
		max-width: 96vw;
		width: 96vw;
	}
	.img-menu-grid__item {
	/* Instant response on tap/click */
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
		flex: 0 0 calc((100% - 16px) / 3) !important;
		max-width: calc((100% - 16px) / 3) !important;
	}
	.img-menu-grid__label {
		padding: 18px 4px 7px;
	}
	.img-menu-grid__title {
		font-size: 0.82rem;
		font-weight: 600;
	}
	.img-menu-grid-overlay__close {
		top: 10px;
		right: 10px;
		width: 44px;
		height: 44px;
	}
}

@media (max-width: 400px) {
	.img-menu-grid-overlay {
		padding: 60px 14px 20px;
	}
	.img-menu-grid-overlay__inner {
		max-width: 300px;
	}
	.img-menu-grid__title {
		font-size: 0.78rem;
	}
}
