/* ── Smart Gallery — WooCommerce Product Gallery ── */

.dsg-wc-gallery {
	margin-bottom: 20px;
	max-width: 100%;
	position: relative; /* anchor for absolutely-positioned SR announcer */
}

.dsg-wc-gallery img {
	display: block;
	width: 100%;
	height: auto;
}

.dsg-wc-gallery-link {
	display: block;
	cursor: zoom-in;
}

.dsg-wc-main-image {
	border-radius: 4px;
	overflow: hidden;
}

/* ── Bottom Thumbnails ────────────────── */

.dsg-wc-gallery--bottom-thumbs .dsg-wc-main-image {
	margin-bottom: 10px;
}

.dsg-wc-thumbs-strip {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	cursor: grab;
}

.dsg-wc-thumbs-strip::-webkit-scrollbar {
	display: none;
}

.dsg-wc-thumbs-strip.dsg-dragging {
	cursor: grabbing;
	scroll-behavior: auto;
}

.dsg-wc-thumb {
	flex-shrink: 0;
	width: 72px;
	height: 72px;
	border-radius: 4px;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.5;
	border: 2px solid transparent;
	transition: opacity 0.2s, border-color 0.2s;
	box-sizing: border-box;
	/* Native <button> reset — thumbs were <div> pre-1.72; switched to real
	   buttons for keyboard focus + Enter/Space activation (WCAG). Themes
	   ship a huge variety of button styling, so zero it all out here. */
	background: transparent;
	padding: 0;
	margin: 0;
	font: inherit;
	color: inherit;
	appearance: none;
	-webkit-appearance: none;
}

.dsg-wc-thumb:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 2px;
	opacity: 1;
}

/* Visually hidden live region for image swap announcements (WCAG 4.1.3). */
.dsg-wc-sr-announcer {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.dsg-wc-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.dsg-wc-thumb:hover,
.dsg-wc-thumb--active {
	opacity: 1;
	border-color: #333;
}

/* ── Left Sidebar ─────────────────────── */

.dsg-wc-gallery--left-sidebar {
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

.dsg-wc-sidebar-thumbs {
	flex-shrink: 0;
	width: 80px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	overflow-y: auto;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	cursor: grab;
	max-height: 500px;
}

.dsg-wc-sidebar-thumbs::-webkit-scrollbar {
	display: none;
}

.dsg-wc-sidebar-thumbs.dsg-dragging {
	cursor: grabbing;
	scroll-behavior: auto;
}

.dsg-wc-gallery--left-sidebar .dsg-wc-thumb {
	width: 80px;
	height: 80px;
}

.dsg-wc-gallery--left-sidebar .dsg-wc-main-image {
	flex: 1;
	min-width: 0;
}

/* ── Grid ─────────────────────────────── */

.dsg-wc-gallery--grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 6px;
}

.dsg-wc-grid-item {
	border-radius: 4px;
	overflow: hidden;
}

.dsg-wc-grid-item:first-child {
	grid-column: 1 / -1;
}

.dsg-wc-grid-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s;
}

.dsg-wc-grid-item:hover img {
	transform: scale(1.03);
}

/* ── Carousel ─────────────────────────── */

.dsg-wc-gallery--carousel {
	position: relative;
	border-radius: 4px;
	overflow: hidden;
}

.dsg-wc-carousel-swiper {
	width: 100%;
}

.dsg-wc-carousel-swiper .swiper-slide {
	overflow: hidden;
}

.dsg-wc-carousel-swiper .swiper-slide img {
	width: 100%;
	height: auto;
	display: block;
}

.dsg-wc-carousel-swiper .swiper-button-next,
.dsg-wc-carousel-swiper .swiper-button-prev {
	color: #fff;
	text-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.dsg-wc-carousel-swiper .swiper-pagination-bullet-active {
	background: #333;
}

/* ── Stacked ──────────────────────────── */

.dsg-wc-gallery--stacked {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.dsg-wc-gallery--stacked .dsg-wc-gallery-link {
	border-radius: 4px;
	overflow: hidden;
}

/* GLightbox theme-override defense is shared with the main shortcode CSS. */

/* ── Responsive ───────────────────────── */

@media (max-width: 768px) {
	.dsg-wc-gallery--left-sidebar {
		flex-direction: column;
	}
	.dsg-wc-sidebar-thumbs {
		flex-direction: row;
		width: 100%;
		overflow-x: auto;
		overflow-y: hidden;
		max-height: none !important;
		scrollbar-width: none;
	}
	.dsg-wc-sidebar-thumbs::-webkit-scrollbar {
		display: none;
	}
	.dsg-wc-gallery--left-sidebar .dsg-wc-thumb {
		width: 60px;
		height: 60px;
	}
	.dsg-wc-thumb {
		width: 60px;
		height: 60px;
	}
	.dsg-wc-gallery--grid {
		grid-template-columns: 1fr;
	}
}

/* === Mobile arrows + touch swipe (since 1.47) === */
.dsg-wc-main-image { position: relative; }

.dsg-wc-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	/* WCAG 2.5.7 — Dragging Movements: arrows are the single-pointer
	   alternative to swipe. They MUST be visible and operable at all
	   viewport sizes, not just desktop. WCAG 2.5.8 — 40×40 target. */
	width: 40px;
	height: 40px;
	background: rgba(255, 255, 255, 0.92);
	border: 0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 10;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	color: #c73986;
	padding: 0;
	transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.dsg-wc-arrow:hover,
.dsg-wc-arrow:focus {
	background: #c73986;
	color: #fff;
	transform: translateY(-50%) scale(1.05);
	opacity: 1;
}
.dsg-wc-arrow:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}
.dsg-wc-arrow-prev { left: 10px; }
.dsg-wc-arrow-next { right: 10px; }
.dsg-wc-arrow svg { display: block; }

/* On mobile the arrows sit on top of the image so make them subtler
   by default (opacity 0.7) — still visible for anyone who needs them
   but not visually dominating the photo. Full opacity on hover/focus. */
@media (max-width: 860px) {
	.dsg-wc-arrow {
		opacity: 0.7;
	}
	.dsg-wc-main-image {
		touch-action: pan-y pinch-zoom;
		-webkit-touch-callout: none;
		user-select: none;
	}
}
