/* SDMN - Galerie de projet (voir assets/scripts/galerie.js) */

.sdmn-gallery-link {
	cursor: zoom-in;
}

html.sdmn-gallery-open {
	overflow: hidden;
}

.sdmn-gallery {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: #fff;
	color: #000;
	font-family: 'Source Sans Pro', sans-serif;
	opacity: 0;
	transition: opacity .25s ease;
}

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

.sdmn-gallery.is-visible {
	opacity: 1;
}

/* :where() garde cette remise à zéro facile à surcharger */
:where(.sdmn-gallery) button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

:where(.sdmn-gallery) button:focus {
	outline: none;
}

:where(.sdmn-gallery) button:focus-visible {
	outline: 2px solid #000;
	outline-offset: 2px;
}

/* Barre du haut : titre, compteur, fermeture */
.sdmn-gallery-bar {
	display: flex;
	align-items: center;
	flex: none;
	padding: 22px 30px 18px;
}

.sdmn-gallery-heading {
	flex: 1;
	min-width: 0;
}

.sdmn-gallery-title {
	margin: 0;
	font-family: 'Amiri', serif;
	font-size: 28px;
	font-weight: 400;
	line-height: 1.2;
	color: #000;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sdmn-gallery-cat {
	margin: 2px 0 0;
	font-size: 14px;
	line-height: 1.4;
	color: #555;
}

.sdmn-gallery-counter {
	margin: 0 24px;
	font-size: 15px;
	color: #555;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.sdmn-gallery-close {
	position: relative;
	flex: none;
	width: 44px;
	height: 44px;
}

.sdmn-gallery-close span::before,
.sdmn-gallery-close span::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 24px;
	height: 1.5px;
	margin: -.75px 0 0 -12px;
	background: #000;
	transition: transform .2s ease;
}

.sdmn-gallery-close span::before {
	transform: rotate(45deg);
}

.sdmn-gallery-close span::after {
	transform: rotate(-45deg);
}

.sdmn-gallery-close:hover span::before {
	transform: rotate(135deg);
}

.sdmn-gallery-close:hover span::after {
	transform: rotate(45deg);
}

/* Zone centrale : image ou vidéo */
.sdmn-gallery-main {
	position: relative;
	display: flex;
	flex: 1;
	min-height: 0;
	padding: 0 90px;
}

.sdmn-gallery-figure {
	display: flex;
	flex: 1;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 0;
	margin: 0;
}

.sdmn-gallery-stage {
	display: flex;
	flex: 1;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 0;
}

.sdmn-gallery-slide {
	opacity: 0;
	transition: opacity .3s ease;
}

.sdmn-gallery-slide.is-in {
	opacity: 1;
}

.sdmn-gallery-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	-webkit-user-select: none;
	user-select: none;
}

.sdmn-gallery-video {
	position: relative;
	width: 100%;
	max-width: calc((100vh - 230px) * 16 / 9);
	background: #000;
}

.sdmn-gallery-video::before {
	content: '';
	display: block;
	padding-top: 56.25%;
}

.sdmn-gallery-video iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.sdmn-gallery-caption {
	flex: none;
	max-width: 60ch;
	padding-top: 12px;
	font-size: 15px;
	line-height: 1.5;
	color: #555;
	text-align: center;
}

.sdmn-gallery-caption[hidden] {
	display: none;
}

/* Flèches précédent / suivant */
.sdmn-gallery-nav {
	position: absolute;
	top: 50%;
	width: 56px;
	height: 56px;
	margin-top: -28px;
	border-radius: 50%;
	transition: background-color .2s ease;
}

.sdmn-gallery-nav:hover {
	background-color: #f5f5f5;
}

.sdmn-gallery-prev {
	left: 18px;
}

.sdmn-gallery-next {
	right: 18px;
}

.sdmn-gallery-nav span::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 14px;
	height: 14px;
	margin: -7px 0 0 -7px;
	border-top: 1.5px solid #000;
	border-left: 1.5px solid #000;
}

.sdmn-gallery-prev span::before {
	transform: translateX(3px) rotate(-45deg);
}

.sdmn-gallery-next span::before {
	transform: translateX(-3px) rotate(135deg);
}

/* Vignettes */
.sdmn-gallery-thumbs {
	display: flex;
	flex: none;
	gap: 8px;
	padding: 18px 30px 26px;
	overflow-x: auto;
	scrollbar-width: thin;
}

.sdmn-gallery-thumb {
	position: relative;
	flex: none;
	width: 96px;
	height: 64px;
	background: #efefef;
	opacity: .45;
	transition: opacity .2s ease;
}

.sdmn-gallery-thumb:first-child {
	margin-left: auto;
}

.sdmn-gallery-thumb:last-child {
	margin-right: auto;
}

.sdmn-gallery-thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.sdmn-gallery-thumb:hover {
	opacity: .8;
}

.sdmn-gallery-thumb.is-active {
	opacity: 1;
}

.sdmn-gallery-thumb.is-active::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	bottom: -7px;
	height: 2px;
	background: #000;
}

.sdmn-gallery-thumb.is-video {
	background: #000;
}

.sdmn-gallery-thumb.is-video::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	z-index: 1;
	margin: -8px 0 0 -5px;
	border-style: solid;
	border-width: 8px 0 8px 13px;
	border-color: transparent transparent transparent #fff;
}

/* Projet avec une seule image : ni flèches ni vignettes */
.sdmn-gallery.is-single .sdmn-gallery-nav,
.sdmn-gallery.is-single .sdmn-gallery-thumbs {
	display: none;
}

.sdmn-gallery.is-single .sdmn-gallery-main {
	padding-bottom: 30px;
}

/* Mobile */
@media (max-width: 767px) {
	.sdmn-gallery-bar {
		padding: 14px 12px 12px 16px;
	}

	.sdmn-gallery-title {
		font-size: 21px;
	}

	.sdmn-gallery-counter {
		margin: 0 12px;
	}

	.sdmn-gallery-main {
		padding: 0;
	}

	.sdmn-gallery-nav {
		width: 44px;
		height: 44px;
		margin-top: -22px;
		background-color: rgba(255, 255, 255, .85);
	}

	.sdmn-gallery-prev {
		left: 6px;
	}

	.sdmn-gallery-next {
		right: 6px;
	}

	.sdmn-gallery-video {
		max-width: 100%;
	}

	.sdmn-gallery-caption {
		padding: 10px 16px 0;
	}

	.sdmn-gallery-thumbs {
		padding: 14px 16px 20px;
	}

	.sdmn-gallery-thumb {
		width: 72px;
		height: 48px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sdmn-gallery,
	.sdmn-gallery-slide,
	.sdmn-gallery-thumb,
	.sdmn-gallery-close span::before,
	.sdmn-gallery-close span::after {
		transition: none;
	}
}
