/* Chat-Dé Gallery – affichage */

.cdg-gallery {
	--cdg-cols-d: 4;
	--cdg-cols-t: 3;
	--cdg-cols-m: 2;
	--cdg-gap: 12px;
	--cdg-radius: 8px;
	--cdg-accent: #7a1f3d;
	--cdg-overlay: #000;
	--cdg-cols: var(--cdg-cols-d);
	position: relative;
	width: 100%;
	box-sizing: border-box;
}

@media (max-width: 1024px) {
	.cdg-gallery { --cdg-cols: var(--cdg-cols-t); }
}

@media (max-width: 767px) {
	.cdg-gallery { --cdg-cols: var(--cdg-cols-m); }
}

.cdg-gallery *,
.cdg-gallery *::before,
.cdg-gallery *::after {
	box-sizing: border-box;
}

.cdg-empty {
	padding: 14px 16px;
	border: 1px dashed #c3c4c7;
	border-radius: 8px;
	color: #50575e;
	font-size: 14px;
}

/* ---------- Grille ---------- */

.cdg-gallery .cdg-grid {
	display: grid;
	grid-template-columns: repeat(var(--cdg-cols), minmax(0, 1fr));
	gap: var(--cdg-gap);
}

.cdg-gallery .cdg-item {
	margin: 0;
	padding: 0;
	min-width: 0;
}

.cdg-gallery .cdg-item.cdg-hidden {
	display: none;
}

/* ---------- Photo carrée ---------- */

.cdg-gallery .cdg-link {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: var(--cdg-radius);
	color: inherit;
	text-decoration: none;
	line-height: 0;
	box-shadow: none;
}

.cdg-gallery .cdg-square {
	display: block;
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #eceae6;
}

.cdg-gallery .cdg-square .cdg-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	object-fit: cover;
	border-radius: 0;
	transition: transform 0.5s ease;
}

.cdg-gallery .cdg-link::after {
	content: "";
	position: absolute;
	inset: 0;
	background: var(--cdg-overlay);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.cdg-gallery .cdg-link:hover::after,
.cdg-gallery .cdg-link:focus-visible::after {
	opacity: 0.22;
}

.cdg-gallery.cdg-has-lightbox .cdg-link {
	cursor: zoom-in;
}

.cdg-gallery.cdg-has-lightbox .cdg-link:hover .cdg-img,
.cdg-gallery.cdg-has-lightbox .cdg-link:focus-visible .cdg-img {
	transform: scale(1.06);
}

.cdg-gallery .cdg-link:focus-visible {
	outline: 3px solid var(--cdg-accent);
	outline-offset: 2px;
}

/* ---------- Légendes ---------- */

.cdg-gallery .cdg-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2;
	margin: 0;
	padding: 30px 14px 12px;
	color: #fff;
	font-size: 14px;
	line-height: 1.35;
	text-align: left;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
	transition: opacity 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.cdg-gallery.cdg-cap-hover .cdg-caption {
	opacity: 0;
	transform: translateY(8px);
}

.cdg-gallery.cdg-cap-hover .cdg-link:hover .cdg-caption,
.cdg-gallery.cdg-cap-hover .cdg-link:focus-visible .cdg-caption {
	opacity: 1;
	transform: none;
}

@media (hover: none) {
	.cdg-gallery.cdg-cap-hover .cdg-caption {
		opacity: 1;
		transform: none;
	}
}

/* ---------- Pagination ---------- */

.cdg-gallery .cdg-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 24px;
	justify-content: center;
}

.cdg-gallery .cdg-pagination[hidden] {
	display: none;
}

.cdg-gallery.cdg-align-left .cdg-pagination { justify-content: flex-start; }
.cdg-gallery.cdg-align-center .cdg-pagination { justify-content: center; }
.cdg-gallery.cdg-align-right .cdg-pagination { justify-content: flex-end; }

.cdg-gallery .cdg-pagination .cdg-page {
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 15px;
	line-height: 1;
	text-transform: none;
	letter-spacing: 0;
	box-shadow: none;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cdg-gallery .cdg-pagination .cdg-page:hover:not(:disabled) {
	border-color: var(--cdg-accent);
	color: var(--cdg-accent);
	background: transparent;
}

.cdg-gallery .cdg-pagination .cdg-page.is-active {
	background: var(--cdg-accent);
	border-color: var(--cdg-accent);
	color: #fff;
}

.cdg-gallery .cdg-pagination .cdg-page:disabled {
	opacity: 0.4;
	cursor: default;
}

.cdg-gallery .cdg-pagination .cdg-page:focus-visible {
	outline: 3px solid var(--cdg-accent);
	outline-offset: 2px;
}

.cdg-gallery .cdg-pagination .cdg-ellipsis {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 4px;
	opacity: 0.6;
}

/* ---------- Slider ---------- */

.cdg-gallery .cdg-slider {
	position: relative;
}

.cdg-gallery .cdg-track {
	display: flex;
	gap: var(--cdg-gap);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
}

.cdg-gallery .cdg-track::-webkit-scrollbar {
	display: none;
}

.cdg-gallery .cdg-track:focus-visible {
	outline: 3px solid var(--cdg-accent);
	outline-offset: 2px;
}

.cdg-gallery .cdg-slider .cdg-item {
	flex: 0 0 calc((100% - (var(--cdg-cols) - 1) * var(--cdg-gap)) / var(--cdg-cols));
	scroll-snap-align: start;
}

.cdg-gallery .cdg-arrow {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: var(--cdg-accent);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
	cursor: pointer;
	transform: translateY(-50%);
	transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.cdg-gallery .cdg-arrow:hover {
	background: var(--cdg-accent);
	color: #fff;
	transform: translateY(-50%) scale(1.06);
}

.cdg-gallery .cdg-arrow:focus-visible {
	outline: 3px solid var(--cdg-accent);
	outline-offset: 2px;
}

.cdg-gallery .cdg-prev { left: 10px; }
.cdg-gallery .cdg-next { right: 10px; }

.cdg-gallery.cdg-no-scroll .cdg-arrow {
	display: none;
}

@media (max-width: 767px) {
	.cdg-gallery .cdg-arrow {
		width: 36px;
		height: 36px;
	}
	.cdg-gallery .cdg-prev { left: 6px; }
	.cdg-gallery .cdg-next { right: 6px; }
}

.cdg-gallery .cdg-dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-top: 16px;
}

.cdg-gallery .cdg-dots[hidden] {
	display: none;
}

.cdg-gallery .cdg-dot {
	width: 9px;
	height: 9px;
	min-width: 0;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(0, 0, 0, 0.22);
	box-shadow: none;
	cursor: pointer;
	transition: width 0.25s ease, background 0.25s ease;
}

.cdg-gallery .cdg-dot:hover {
	background: rgba(0, 0, 0, 0.4);
}

.cdg-gallery .cdg-dot.is-active {
	width: 24px;
	background: var(--cdg-accent);
}

/* ---------- Fenêtre d'agrandissement ---------- */

html.cdg-lb-open {
	overflow: hidden;
}

.cdg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 10, 12, 0.92);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.cdg-lb[hidden] {
	display: none;
}

.cdg-lb.is-open {
	opacity: 1;
}

.cdg-lb .cdg-lb-stage {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	padding: 56px 72px;
}

.cdg-lb .cdg-lb-figure {
	margin: 0;
	text-align: center;
}

.cdg-lb .cdg-lb-img {
	display: block;
	margin: 0 auto;
	max-width: min(92vw, 1400px);
	max-height: 78vh;
	width: auto;
	height: auto;
	border-radius: 6px;
	box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
	transition: opacity 0.25s ease;
}

.cdg-lb.is-loading .cdg-lb-img {
	opacity: 0;
}

.cdg-lb.is-loading .cdg-lb-stage::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: cdg-spin 0.8s linear infinite;
}

@keyframes cdg-spin {
	to { transform: rotate(360deg); }
}

.cdg-lb .cdg-lb-caption {
	max-width: 760px;
	margin: 14px auto 0;
	color: #f3f1ee;
	font-size: 15px;
	line-height: 1.5;
}

.cdg-lb .cdg-lb-caption[hidden] {
	display: none;
}

.cdg-lb .cdg-lb-count {
	position: absolute;
	top: 18px;
	left: 22px;
	color: rgba(255, 255, 255, 0.8);
	font-size: 14px;
	letter-spacing: 0.04em;
}

.cdg-lb .cdg-lb-btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	box-shadow: none;
	cursor: pointer;
	transition: background 0.2s ease;
}

.cdg-lb .cdg-lb-btn:hover {
	background: rgba(255, 255, 255, 0.3);
}

.cdg-lb .cdg-lb-btn:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.cdg-lb .cdg-lb-btn[hidden] {
	display: none;
}

.cdg-lb .cdg-lb-close { top: 14px; right: 16px; }
.cdg-lb .cdg-lb-prev { left: 16px; top: 50%; margin-top: -23px; }
.cdg-lb .cdg-lb-next { right: 16px; top: 50%; margin-top: -23px; }

@media (max-width: 767px) {
	.cdg-lb .cdg-lb-stage {
		padding: 64px 12px 24px;
	}
	.cdg-lb .cdg-lb-prev,
	.cdg-lb .cdg-lb-next {
		top: auto;
		bottom: 18px;
		margin-top: 0;
	}
	.cdg-lb .cdg-lb-prev { left: 18px; }
	.cdg-lb .cdg-lb-next { right: 18px; }
	.cdg-lb .cdg-lb-img { max-height: 64vh; }
}

@media (prefers-reduced-motion: reduce) {
	.cdg-gallery .cdg-square .cdg-img,
	.cdg-gallery .cdg-caption,
	.cdg-gallery .cdg-arrow,
	.cdg-lb,
	.cdg-lb .cdg-lb-img {
		transition: none;
	}
}
