/*
 * w2rr's OWN copy of the shared front gallery CSS (grid + slider over one
 * `.sp-gallery` / `.sp-gallery__item` item contract). w2rr normally reuses the
 * maps engine's `rmaps-gallery` bundle via do_action('rmaps_enqueue_gallery'),
 * but on a STANDALONE w2rr install (no rmaps/w2dc core to answer that action)
 * nothing enqueues it and review thumbs render unstyled (full-width). This
 * bundle is the engine-free fallback, enqueued only when core is absent - see
 * Shortcodes::enqueue_display_assets(). Kept byte-compatible with core's
 * gallery.css so co-installed sites look identical.
 */

.sp-gallery {
	--sp-gallery-size: 200px;
	margin: 0;
}

/* ---- Grid (single-listing look) - FLUID, no breakpoints ----
   Up to `--sp-gallery-cols` columns, each at least `--sp-gallery-min` wide,
   dropping a column smoothly as the container narrows (5→4→3→2→1). */
.sp-gallery--grid {
	--sp-gallery-gap: 10px;
	display: grid;
	gap: var(--sp-gallery-gap);
	grid-template-columns: repeat(
		auto-fill,
		minmax(
			max(
				var(--sp-gallery-min, 150px),
				calc((100% - (var(--sp-gallery-cols, 3) - 1) * var(--sp-gallery-gap)) / var(--sp-gallery-cols, 3))
			),
			1fr
		)
	);
}

/* ---- Slider (tight spots) ---- */
.sp-gallery--slider {
	display: flex;
	gap: 10px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 2px;
}

.sp-gallery--slider .sp-gallery__item {
	flex: 0 0 var(--sp-gallery-min, 200px);
	scroll-snap-align: start;
}

/* ---- Item (shared) ---- */
.sp-gallery__item {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: 6px;
	aspect-ratio: 4 / 3;
	cursor: zoom-in;
	background: #f1f2f4;
	line-height: 0;
}

@supports not (aspect-ratio: 1) {
	.sp-gallery__item { height: 0; padding-top: 75%; }
	.sp-gallery__item > img { position: absolute; inset: 0; }
}

.sp-gallery__item > img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.2s ease;
}

.sp-gallery__item:hover > img {
	transform: scale(1.05);
}

.sp-gallery__item::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 46px;
	height: 46px;
	transform: translate(-50%, -50%) scale(0.7);
	border-radius: 50%;
	background: rgba(17, 24, 39, 0.55) no-repeat center / 22px 22px
		url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23fff%27 stroke-width=%272.2%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Ccircle cx=%2710.5%27 cy=%2710.5%27 r=%276.5%27/%3E%3Cline x1=%2721%27 y1=%2721%27 x2=%2715.4%27 y2=%2715.4%27/%3E%3C/svg%3E");
	opacity: 0;
	transition: opacity 0.18s ease, transform 0.18s ease;
	pointer-events: none;
	z-index: 1;
}
.sp-gallery__item:hover::after {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

.sp-gallery__item:focus-visible {
	outline: 2px solid var(--w2rr-primary, var(--rmaps-primary, var(--w2dc-primary, #2271b1)));
	outline-offset: 2px;
}

.sp-gallery__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 14px 8px 6px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
	color: #fff;
	font-size: 12px;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	pointer-events: none;
}

