/**
 * Category Grid Shortcode - front-end styles.
 *
 * All colors, sizes and column counts are driven by CSS custom properties
 * injected per-instance from the admin settings.
 */

.cgs-grid-wrap {
	width: 100%;
}

.cgs-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(var(--cgs-cols-mobile, 1), minmax(0, 1fr));
	gap: var(--cgs-gap, 20px);
}

/* Tablet */
@media (min-width: 600px) {
	.cgs-grid {
		grid-template-columns: repeat(var(--cgs-cols-tablet, 2), minmax(0, 1fr));
	}
}

/* Desktop */
@media (min-width: 1024px) {
	.cgs-grid {
		grid-template-columns: repeat(var(--cgs-cols-desktop, 4), minmax(0, 1fr));
	}
}

.cgs-item {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cgs-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	text-decoration: none;
	background: var(--cgs-bg, #ffffff);
	border: var(--cgs-border-width, 1px) solid var(--cgs-border-color, #e2e2e2);
	border-radius: var(--cgs-radius, 8px);
	padding: var(--cgs-card-padding, 12px);
	overflow: hidden;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Keyboard accessibility: visible focus ring. */
.cgs-card:focus-visible {
	outline: 2px solid var(--cgs-title-color, #222222);
	outline-offset: 2px;
}

.cgs-media {
	position: relative;
	display: block;
	width: 100%;
	/* Size by aspect ratio so every card is the same shape and scales with its
	   width. This keeps thumbnails uniform on mobile and desktop and removes the
	   empty letterbox space a fixed pixel height caused on wide mobile cards.
	   Falls back to the fixed height on very old browsers without aspect-ratio. */
	aspect-ratio: var(--cgs-img-ratio, 1 / 1);
	border-radius: calc(var(--cgs-radius, 8px) * 0.6);
	overflow: hidden;
}

/* Progressive enhancement: only browsers that lack aspect-ratio use the
   configured fixed height as a fallback. */
@supports not (aspect-ratio: 1 / 1) {
	.cgs-media {
		height: var(--cgs-img-height, 200px);
	}
}

.cgs-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: var(--cgs-img-fit, cover);
	transition: transform 0.3s ease;
}

.cgs-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #ededed 25%, #f6f6f6 25%, #f6f6f6 50%, #ededed 50%, #ededed 75%, #f6f6f6 75%);
	background-size: 24px 24px;
}

.cgs-overlay {
	position: absolute;
	inset: 0;
	background: var(--cgs-overlay-color, #000000);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.cgs-title {
	display: block;
	margin-top: var(--cgs-card-padding, 12px);
	font-size: var(--cgs-title-size, 16px);
	color: var(--cgs-title-color, #222222);
	font-weight: var(--cgs-title-weight, 600);
	text-align: var(--cgs-title-align, center);
	line-height: 1.3;
}

/* ---- Hover effects ---- */

/* Lift Shadow */
.cgs-hover-lift .cgs-card:hover,
.cgs-hover-lift .cgs-card:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
}

/* Zoom Image */
.cgs-hover-zoom .cgs-card:hover .cgs-img,
.cgs-hover-zoom .cgs-card:focus-visible .cgs-img {
	transform: scale(1.08);
}

/* Color Overlay */
.cgs-hover-overlay .cgs-card:hover .cgs-overlay,
.cgs-hover-overlay .cgs-card:focus-visible .cgs-overlay {
	opacity: var(--cgs-overlay-alpha, 0.4);
}

/* Respect reduced motion preferences. */
@media (prefers-reduced-motion: reduce) {
	.cgs-card,
	.cgs-img,
	.cgs-overlay {
		transition: none;
	}
}

.cgs-empty {
	margin: 1em 0;
}
