/* ── DSG Gallery Base ──────────────────── */

.dsg-gallery {
	margin: 0 auto;
	width: 100%;
}

.dsg-gallery-item {
	overflow: hidden;
	cursor: pointer;
}

.dsg-gallery-image-wrap {
	line-height: 0;
}

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

.dsg-gallery-meta {
	padding: 8px 10px;
	background: #f9f9f9;
}

.dsg-gallery-title {
	margin: 0 0 4px;
	font-size: 14px;
	line-height: 1.3;
}

.dsg-gallery-caption {
	font-size: 12px;
	color: #666;
	line-height: 1.4;
	margin: 0;
}

/* ── Masonry ──────────────────────────── */

.dsg-gallery-masonry {
	display: flex;
	flex-wrap: wrap;
}

.dsg-gallery-masonry .dsg-gallery-item {
	padding: 5px;
	box-sizing: border-box;
}

.dsg-gallery-masonry .dsg-gallery-image-wrap {
	border-radius: 4px;
	overflow: hidden;
}

/* Default responsive columns fallback (before Isotope init) */
.dsg-gallery-masonry[data-columns="1"] .dsg-gallery-item { width: 100%; }
.dsg-gallery-masonry[data-columns="2"] .dsg-gallery-item { width: 50%; }
.dsg-gallery-masonry[data-columns="3"] .dsg-gallery-item { width: 33.333%; }
.dsg-gallery-masonry[data-columns="4"] .dsg-gallery-item { width: 25%; }
.dsg-gallery-masonry[data-columns="5"] .dsg-gallery-item { width: 20%; }
.dsg-gallery-masonry[data-columns="6"] .dsg-gallery-item { width: 16.666%; }
.dsg-gallery-masonry[data-columns="7"] .dsg-gallery-item { width: 14.285%; }
.dsg-gallery-masonry[data-columns="8"] .dsg-gallery-item { width: 12.5%; }

/* ── Justified ────────────────────────── */

.dsg-gallery-justified .dsg-gallery-item {
	display: inline-block;
}

.dsg-gallery-justified .dsg-gallery-image {
	height: 100%;
	width: auto;
}

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

.dsg-gallery-carousel {
	position: relative;
}

/* Defensive: enforce Swiper container behavior in case theme CSS
   overrides .swiper { overflow: visible } — without overflow:hidden,
   loop-mode duplicated slides leak into view making it look like
   slidesPerView is higher than configured. */
.dsg-gallery-carousel .swiper {
	overflow: hidden;
}

/* Defensive: image inside slide must not overflow and force the slide
   to image's natural width. */
.dsg-gallery-carousel .swiper-slide img {
	max-width: 100%;
	height: auto;
	display: block;
}

.dsg-gallery-carousel .swiper-slide {
	height: auto;
}

.dsg-gallery-carousel .dsg-gallery-image-wrap {
	border-radius: 4px;
	overflow: hidden;
}

/* WCAG 1.4.11 — Swiper arrow defaults have no background, so contrast depends
   entirely on the underlying image. Give them a semi-transparent circle so
   they meet 3:1 against ANY background (light or dark). */
.dsg-gallery-carousel .swiper-button-next,
.dsg-gallery-carousel .swiper-button-prev {
	width: 44px;
	height: 44px;
	background: rgba(0, 0, 0, 0.6);
	color: #fff;
	border-radius: 50%;
	transition: background 0.15s, opacity 0.15s;
}
.dsg-gallery-carousel .swiper-button-next:hover,
.dsg-gallery-carousel .swiper-button-prev:hover,
.dsg-gallery-carousel .swiper-button-next:focus-visible,
.dsg-gallery-carousel .swiper-button-prev:focus-visible {
	background: rgba(0, 0, 0, 0.85);
}
.dsg-gallery-carousel .swiper-button-next::after,
.dsg-gallery-carousel .swiper-button-prev::after {
	font-size: 18px;
	font-weight: 700;
}

/* WCAG 1.4.11 — bump inactive pagination bullet opacity to 0.5 so the dot
   passes 3:1 contrast against typical light backgrounds. Swiper default 0.2
   is invisible for anyone with reduced acuity. Active stays 1.0 (fully opaque). */
.dsg-gallery-carousel .swiper-pagination-bullet {
	width: 12px;
	height: 12px;
	padding: 6px;
	background: #333;
	opacity: 0.5;
	background-clip: content-box;
	box-sizing: content-box;
	margin: 0 2px;
	transition: opacity 0.15s;
}
.dsg-gallery-carousel .swiper-pagination-bullet:hover {
	opacity: 0.85;
}
.dsg-gallery-carousel .swiper-pagination-bullet-active {
	background: #333;
	opacity: 1;
}
.dsg-gallery-carousel .swiper-pagination-bullet:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 3px;
	opacity: 1;
}

/* WCAG 2.4.7 — Focus Visible on all keyboard-reachable controls. */
.dsg-gallery-carousel .swiper-button-next:focus-visible,
.dsg-gallery-carousel .swiper-button-prev:focus-visible,
.dsg-gallery-carousel .swiper-pagination-bullet:focus-visible,
.dsg-gallery-link:focus-visible,
.dsg-gallery-item:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 3px;
	border-radius: 3px;
}

/* WCAG 2.2.2 — visible pause/play toggle for autoplay carousels.
   Positioned TOP-LEFT to avoid three collision zones:
   - top-right: reserved for the admin-only "Edit Gallery" button
   - bottom-center: Swiper pagination bullets strip
   - vertical middle sides: Swiper prev/next arrows
   Top-left has no collision on any layout / viewport tested. */
.dsg-autoplay-toggle {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 20;
	width: 36px;
	height: 36px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 50%;
	cursor: pointer;
	fill: currentColor;
	transition: background-color 0.15s ease-out, transform 0.1s ease-out;
}
.dsg-autoplay-toggle:hover,
.dsg-autoplay-toggle:focus-visible {
	background: rgba(0, 0, 0, 0.85);
}
.dsg-autoplay-toggle:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}
.dsg-autoplay-toggle:active {
	transform: scale(0.95);
}
.dsg-autoplay-icon {
	display: none;
}
.dsg-autoplay-toggle--playing .dsg-autoplay-icon--pause {
	display: block;
}
.dsg-autoplay-toggle--paused .dsg-autoplay-icon--play {
	display: block;
}

/* ── Video Items ──────────────────────── */

.dsg-gallery-item-video .dsg-gallery-image-wrap {
	position: relative;
}

.dsg-play-overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 60px;
	height: 60px;
	background: rgba(0, 0, 0, 0.6);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	pointer-events: none;
	z-index: 2;
}

.dsg-gallery-item-video:hover .dsg-play-overlay {
	background: rgba(0, 0, 0, 0.8);
}

.dsg-play-icon {
	color: #fff;
	font-size: 24px;
	line-height: 1;
	margin-left: 3px;
}

.dsg-video-placeholder {
	position: relative;
	width: 100%;
	padding-top: 100%;
	background: #f0f0f1;
}
.dsg-video-placeholder-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 48px;
	height: 48px;
	color: #b4b9be;
}

.dsg-video-lightbox {
	max-width: 900px;
	margin: 0 auto;
	background: #000;
}

.dsg-video-lightbox video {
	display: block;
}

/* ── Album ────────────────────────────── */

.dsg-album {
	margin: 0 auto;
	width: 100%;
}

.dsg-album-title {
	margin: 0 0 20px;
	font-size: 24px;
}

.dsg-album-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
	gap: 20px;
}

a.dsg-album-item,
a.dsg-album-item:hover,
a.dsg-album-item:focus {
	text-decoration: none;
	color: inherit;
}

.dsg-album-item {
	display: block;
	border-radius: 6px;
	overflow: hidden;
	background: #f9f9f9;
	transition: transform 0.2s, box-shadow 0.2s;
	cursor: pointer;
}

.dsg-album-item:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dsg-album-thumb {
	position: relative;
	padding-top: 66.666%;
	overflow: hidden;
	background: #e0e0e0;
}

.dsg-album-thumb img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.dsg-album-placeholder-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	font-size: 40px;
	color: #ccc;
}

.dsg-album-info {
	padding: 12px 15px;
}

.dsg-album-gallery-name {
	margin: 0 0 4px;
	font-size: 16px;
	line-height: 1.3;
}

.dsg-album-gallery-count {
	font-size: 13px;
	color: #888;
}

/* ── Album Gallery View ──────────────── */

.dsg-album-back {
	display: inline-block;
	margin-bottom: 20px;
	font-size: 15px;
	color: #0073aa;
	text-decoration: none;
}

.dsg-album-back:hover {
	color: #005a87;
	text-decoration: underline;
}

/* Landing intro block shown above the gallery when the user drills in
   from an album view (WCAG-friendly: proper heading hierarchy, generous
   line-height, comfortable reading measure). */
.dsg-gallery-landing {
	max-width: 780px;
	margin: 0 auto 32px;
	padding: 0 8px;
}
.dsg-gallery-landing-title {
	font-size: clamp(1.6rem, 2.2vw + 0.5rem, 2.4rem);
	line-height: 1.2;
	margin: 0 0 16px;
	font-weight: 700;
}
.dsg-gallery-landing-description {
	font-size: 1.05rem;
	line-height: 1.65;
	color: #333;
}
.dsg-gallery-landing-description p:first-child {
	margin-top: 0;
}
.dsg-gallery-landing-description p:last-child {
	margin-bottom: 0;
}
.dsg-gallery-landing-description img {
	max-width: 100%;
	height: auto;
}
.dsg-gallery-landing-description a:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
	border-radius: 2px;
}

/* ── GLightbox — theme override defense ────
   Themes sometimes inject overflow:visible or transparent overlays on
   .goverlay / .gcontainer. Enforce the essentials so the lightbox stays
   usable across Divi/Elementor/custom themes. Target sizes ≥40px (WCAG 2.5.8). */

.goverlay {
	background: rgba(0, 0, 0, 0.92) !important;
}

.gnext, .gprev, .gclose {
	width: 44px !important;
	height: 44px !important;
	background: rgba(0, 0, 0, 0.6) !important;
	color: #fff !important;
	border-radius: 50% !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	opacity: 0.9;
	transition: opacity 0.15s, background 0.15s;
}

.gnext:hover, .gprev:hover, .gclose:hover,
.gnext:focus-visible, .gprev:focus-visible, .gclose:focus-visible {
	opacity: 1;
	background: rgba(0, 0, 0, 0.85) !important;
}

.gnext:focus-visible, .gprev:focus-visible, .gclose:focus-visible {
	outline: 2px solid #fff !important;
	outline-offset: 2px !important;
}

.gnext svg, .gprev svg, .gclose svg {
	width: 24px;
	height: 24px;
}

/* ── YouTube Gallery ──────────────────── */

.dsg-yt-gallery {
	display: grid;
	gap: 10px;
	margin: 0 auto;
}

.dsg-yt-gallery-item {
	position: relative;
	overflow: hidden;
	border-radius: 4px;
	cursor: pointer;
	background: #000;
	aspect-ratio: 16 / 9;
}

.dsg-yt-gallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s;
}

.dsg-yt-gallery-item:hover img {
	transform: scale(1.05);
}

.dsg-yt-gallery-item .dsg-play-overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 60px;
	height: 60px;
	background: rgba(255, 0, 0, 0.85);
	border-radius: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	pointer-events: none;
	z-index: 2;
}

.dsg-yt-gallery-item:hover .dsg-play-overlay {
	background: rgba(255, 0, 0, 1);
}

.dsg-yt-gallery-item .dsg-play-icon {
	color: #fff;
	font-size: 24px;
	margin-left: 3px;
}

.dsg-yt-gallery-item-title {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 8px 10px;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
	color: #fff;
	font-size: 13px;
	line-height: 1.3;
	z-index: 2;
}

/* ── YouTube Featured Layout ─────────── */

.dsg-yt-gallery-featured .dsg-yt-featured-item {
	aspect-ratio: 16 / 9;
	border-radius: 6px;
}

/* ── YouTube List Layout ─────────────── */

.dsg-yt-layout-list {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.dsg-yt-list-item {
	display: flex;
	align-items: center;
	gap: 15px;
	background: #f9f9f9;
	border-radius: 6px;
	overflow: hidden;
	cursor: pointer;
	transition: background 0.2s;
	aspect-ratio: auto;
}

.dsg-yt-list-item:hover {
	background: #f0f0f0;
}

.dsg-yt-list-thumb {
	position: relative;
	flex-shrink: 0;
	width: 240px;
	aspect-ratio: 16 / 9;
	overflow: hidden;
}

.dsg-yt-list-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.dsg-yt-list-title {
	flex: 1;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.4;
	padding: 10px 15px 10px 0;
	color: #333;
}

/* ── YouTube Carousel Layout ─────────── */

.dsg-yt-layout-carousel {
	position: relative;
}

.dsg-yt-layout-carousel .swiper-slide .dsg-yt-gallery-item {
	border-radius: 6px;
}

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

/* ── YouTube Playlist Embed ──────────── */

.dsg-yt-playlist-wrap {
	position: relative;
	padding-bottom: 56.25%;
	height: 0;
	overflow: hidden;
	max-width: 100%;
	border-radius: 4px;
}

.dsg-yt-playlist-wrap iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

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

@media (max-width: 768px) {
	.dsg-yt-gallery {
		grid-template-columns: repeat(2, 1fr) !important;
	}
	.dsg-yt-list-thumb {
		width: 160px;
	}
	.dsg-gallery-masonry[data-columns] .dsg-gallery-item {
		width: 50%;
	}
	.dsg-gallery-masonry[data-columns="1"] .dsg-gallery-item {
		width: 100%;
	}
	.dsg-album-grid {
		grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
		gap: 12px;
	}
}

@media (max-width: 480px) {
	.dsg-yt-gallery {
		grid-template-columns: 1fr !important;
	}
	.dsg-yt-list-item {
		flex-direction: column;
	}
	.dsg-yt-list-thumb {
		width: 100%;
	}
	.dsg-yt-list-title {
		padding: 8px 12px;
	}
	.dsg-gallery-masonry[data-columns] .dsg-gallery-item {
		width: 100%;
	}
	.dsg-album-grid {
		grid-template-columns: 1fr;
	}
}
