/*
 * Galerie photos — élément Avia « Tris » (tris_galerie.php)
 *
 * Langage visuel du site : coins arrondis, bordure beige, rouge de marque
 * --tris-brand-red, titres Newsreader. La visionneuse (.tris-lb) est sombre
 * pour mettre les photos en valeur.
 */

.tris-galerie {
	--tris-g-accent: var(--tris-brand-red, #c0392b);
	--tris-g-accent-soft: #fceeed;
	--tris-g-accent-soft: color-mix(in srgb, var(--tris-g-accent) 10%, #ffffff);
	--tris-g-heading: var(--enfold-main-color-heading, #2f3437);
	--tris-g-text: #5b6165;
	--tris-g-muted: #8a9096;
	--tris-g-border: var(--enfold-main-color-border, #e6d8c9);
	--tris-g-gap: 14px;
	--tris-g-radius: 14px;
	--tris-g-row: 240px;
	--tris-g-ease: cubic-bezier(.2, .8, .2, 1);

	display: block;
	width: 100%;
	margin: 0 0 40px;
	clear: both;
}

.tris-galerie *,
.tris-galerie *::before,
.tris-galerie *::after {
	box-sizing: border-box;
}

.tris-galerie--rows-small { --tris-g-row: 180px; }
.tris-galerie--rows-large { --tris-g-row: 320px; }

/* --- En-tête -------------------------------------------------------------- */

.tris-galerie__head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 10px 24px;
	margin-bottom: 22px;
}

.tris-galerie__head:has(.tris-galerie__heading:empty) {
	justify-content: flex-end;
}

#top .tris-galerie__title {
	margin: 0;
	color: var(--tris-g-heading);
	font-size: clamp(1.5rem, 1.1rem + 1.1vw, 2rem);
	line-height: 1.15;
}

.tris-galerie__subtitle {
	margin: 6px 0 0;
	color: var(--tris-g-muted);
	font-size: 0.95rem;
}

#top .tris-galerie__count {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 7px 14px 7px 12px;
	border: 1px solid var(--tris-g-border);
	border-radius: 999px;
	background: #ffffff;
	color: var(--tris-g-heading);
	font-size: 0.84rem;
	font-weight: 500;
	line-height: 1.2;
}

.tris-galerie__count .tris-galerie__icon {
	width: 16px;
	height: 16px;
	color: var(--tris-g-accent);
}

/* --- Vignettes (commun) ----------------------------------------------------- */

#top .tris-galerie__grid {
	margin: 0;
	padding: 0;
	list-style: none;
}

#top .tris-galerie__item {
	position: relative;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Lot masqué jusqu'au clic sur « Afficher plus » (classe posée par le JS). */
.tris-galerie.is-paged .tris-galerie__item.is-extra {
	display: none;
}

.tris-galerie__item.is-revealing {
	animation: tris-galerie-in 0.6s var(--tris-g-ease) both;
	animation-delay: var(--tris-g-delay, 0ms);
}

@keyframes tris-galerie-in {
	from { opacity: 0; transform: translateY(16px); }
	to { opacity: 1; transform: none; }
}

#top .tris-galerie__figure {
	position: relative;
	height: 100%;
	margin: 0;
	overflow: hidden;
	border-radius: var(--tris-g-radius);
	background: #ebe7e1;
	/* Fond « chargement » discret tant que l'image n'est pas arrivée (lazy). */
	background-image: linear-gradient(110deg, #ebe7e1 30%, #f4f1ec 50%, #ebe7e1 70%);
	background-size: 200% 100%;
	isolation: isolate;
}

/* Chargement (classes posées par le JS) : reflet animé, puis fondu de la photo. */
.tris-galerie__figure.is-loading {
	animation: tris-galerie-shimmer 1.3s linear infinite;
}

.tris-galerie__figure.is-loading .tris-galerie__img {
	opacity: 0;
}

.tris-galerie__figure.is-loaded .tris-galerie__img {
	animation: tris-galerie-fade 0.5s ease both;
}

@keyframes tris-galerie-shimmer {
	from { background-position: 120% 0; }
	to { background-position: -120% 0; }
}

@keyframes tris-galerie-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

#top .tris-galerie__link {
	display: block;
	height: 100%;
	border: 0;
	color: inherit;
	text-decoration: none;
	outline: none;
	cursor: zoom-in;
}

#top .tris-galerie__img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
	object-fit: cover;
	transition: transform 0.7s var(--tris-g-ease), filter 0.4s ease;
}

/* Voile + pictogramme « agrandir » au survol */
.tris-galerie__link::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(20, 22, 24, 0.55) 0%, rgba(20, 22, 24, 0) 45%);
	opacity: 0;
	transition: opacity 0.35s ease;
	pointer-events: none;
}

.tris-galerie__zoom {
	position: absolute;
	z-index: 1;
	top: 12px;
	right: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 38px;
	height: 38px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	color: var(--tris-g-accent);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	opacity: 0;
	transform: scale(0.8);
	transition: opacity 0.3s ease, transform 0.35s var(--tris-g-ease);
	pointer-events: none;
}

.tris-galerie__link:hover .tris-galerie__img,
.tris-galerie__link:focus-visible .tris-galerie__img {
	transform: scale(1.045);
}

.tris-galerie__link:hover::after,
.tris-galerie__link:focus-visible::after,
.tris-galerie__link:hover .tris-galerie__zoom,
.tris-galerie__link:focus-visible .tris-galerie__zoom {
	opacity: 1;
	transform: none;
}

.tris-galerie__link:focus-visible {
	outline: none;
}

.tris-galerie__figure:has(.tris-galerie__link:focus-visible) {
	outline: 3px solid var(--tris-g-accent);
	outline-offset: 3px;
}

/* Légende sur la photo */
.tris-galerie__caption {
	position: absolute;
	z-index: 1;
	right: 0;
	bottom: 0;
	left: 0;
	padding: 28px 14px 12px;
	background: linear-gradient(to top, rgba(20, 22, 24, 0.72), rgba(20, 22, 24, 0));
	color: #ffffff;
	font-size: 0.82rem;
	font-weight: 500;
	line-height: 1.35;
	pointer-events: none;
	display: -webkit-box;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.tris-galerie--captions-none .tris-galerie__caption {
	display: none;
}

.tris-galerie--captions-hover .tris-galerie__caption {
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.3s ease, transform 0.35s var(--tris-g-ease);
}

.tris-galerie--captions-hover .tris-galerie__figure:hover .tris-galerie__caption,
.tris-galerie--captions-hover .tris-galerie__figure:focus-within .tris-galerie__caption {
	opacity: 1;
	transform: none;
}

/* Écrans tactiles : pas de survol → légendes toujours visibles. */
@media (hover: none) {
	.tris-galerie--captions-hover .tris-galerie__caption {
		opacity: 1;
		transform: none;
	}
}

/* --- Mosaïque (rangées justifiées, sans rognage) ---------------------------
   Chaque vignette reçoit son ratio (--tris-r) : flex-grow proportionnel au ratio
   = toutes les photos d'une rangée ont la même hauteur. Le pseudo-élément final
   empêche la dernière rangée incomplète de s'étirer. */

#top .tris-galerie--mosaic .tris-galerie__grid {
	display: flex;
	flex-wrap: wrap;
	gap: var(--tris-g-gap);
}

#top .tris-galerie--mosaic .tris-galerie__grid::after {
	content: "";
	flex-grow: 999;
}

#top .tris-galerie--mosaic .tris-galerie__item {
	flex-grow: var(--tris-r);
	flex-basis: calc(var(--tris-r) * var(--tris-g-row));
	min-width: 0;
}

#top .tris-galerie--mosaic .tris-galerie__img {
	height: auto;
	aspect-ratio: var(--tris-r);
}

/* --- Grilles ---------------------------------------------------------------- */

#top .tris-galerie--grid .tris-galerie__grid,
#top .tris-galerie--feature .tris-galerie__grid {
	display: grid;
	grid-template-columns: repeat(var(--tris-g-cols, 4), minmax(0, 1fr));
	grid-auto-flow: dense;
	gap: var(--tris-g-gap);
}

.tris-galerie--cols-3 { --tris-g-cols: 3; }
.tris-galerie--cols-4 { --tris-g-cols: 4; }
.tris-galerie--cols-5 { --tris-g-cols: 5; }

.tris-galerie--ratio-4-3 { --tris-g-ratio: 4 / 3; }
.tris-galerie--ratio-3-2 { --tris-g-ratio: 3 / 2; }
.tris-galerie--ratio-1-1 { --tris-g-ratio: 1 / 1; }

#top .tris-galerie--grid .tris-galerie__figure,
#top .tris-galerie--feature .tris-galerie__figure {
	aspect-ratio: var(--tris-g-ratio, 4 / 3);
}

/* Photo à la une : 2 × 2 cases. */
#top .tris-galerie--feature .tris-galerie__item:first-child {
	grid-column: span 2;
	grid-row: span 2;
}

#top .tris-galerie--feature .tris-galerie__item:first-child .tris-galerie__figure {
	aspect-ratio: auto;
	height: 100%;
}

/* --- « Afficher plus » -------------------------------------------------------- */

.tris-galerie__more {
	display: flex;
	justify-content: center;
	margin-top: 32px;
}

.tris-galerie__more[hidden] {
	display: none;
}

#top .tris-galerie__more-btn {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	height: 50px;
	margin: 0;
	padding: 0 24px;
	border: 1.5px solid var(--tris-g-accent);
	border-radius: 12px;
	background: #ffffff;
	color: var(--tris-g-accent);
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.25s ease, color 0.25s ease;
}

#top .tris-galerie__more-btn:hover {
	background: var(--tris-g-accent);
	color: #ffffff;
}

#top .tris-galerie__more-btn:focus-visible {
	outline: 2px solid var(--tris-g-accent);
	outline-offset: 3px;
}

.tris-galerie__more-count {
	min-width: 26px;
	padding: 4px 8px;
	border-radius: 999px;
	background: var(--tris-g-accent-soft);
	color: var(--tris-g-accent);
	font-size: 0.75rem;
	font-weight: 700;
	text-align: center;
	transition: background 0.25s ease, color 0.25s ease;
}

.tris-galerie__more-btn:hover .tris-galerie__more-count {
	background: rgba(255, 255, 255, 0.22);
	color: #ffffff;
}

/* --- Responsive -------------------------------------------------------------- */

@media (max-width: 1100px) {
	.tris-galerie--cols-5 { --tris-g-cols: 4; }
	.tris-galerie--cols-4 { --tris-g-cols: 3; }
}

@media (max-width: 767px) {
	.tris-galerie {
		--tris-g-gap: 8px;
		--tris-g-radius: 10px;
		/* Hauteur de BASE (les photos grandissent pour remplir la rangée) :
		   ~2 photos paysage par rangée, même dans une colonne étroite. */
		--tris-g-row: 80px;
	}

	.tris-galerie--rows-small { --tris-g-row: 64px; }
	.tris-galerie--rows-large { --tris-g-row: 110px; }

	.tris-galerie__head,
	.tris-galerie__head:has(.tris-galerie__heading:empty) {
		justify-content: flex-start;
		margin-bottom: 16px;
	}

	/* Mosaïque mobile : chaque rangée remplit toute la largeur (pas de vide à droite,
	   y compris la dernière) et la 1re photo s'affiche en grand. */
	#top .tris-galerie--mosaic .tris-galerie__grid::after {
		display: none;
	}

	#top .tris-galerie--mosaic .tris-galerie__item:first-child {
		flex-basis: 100%;
	}

	.tris-galerie--cols-3,
	.tris-galerie--cols-4,
	.tris-galerie--cols-5 { --tris-g-cols: 2; }

	.tris-galerie__zoom {
		display: none;
	}

	.tris-galerie__caption {
		padding: 22px 10px 8px;
		font-size: 0.75rem;
	}
}

/* =========================================================================
   VISIONNEUSE (une seule par page, créée par tris_galerie.js)
   ========================================================================= */

html:has(.tris-lb[open]) {
	overflow: hidden;
}

.tris-lb {
	--tris-lb-accent: var(--tris-brand-red, #c0392b);

	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(17, 19, 21, 0.96);
	color: #ffffff;
	font-family: 'Public Sans', Arial, sans-serif;
	overscroll-behavior: contain;
}

.tris-lb[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	animation: tris-lb-in 0.25s ease both;
}

.tris-lb::backdrop {
	background: rgba(17, 19, 21, 0.6);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}

@keyframes tris-lb-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

.tris-lb *,
.tris-lb *::before,
.tris-lb *::after {
	box-sizing: border-box;
}

/* Barre du haut */
.tris-lb__bar {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 14px clamp(14px, 3vw, 28px);
}

.tris-lb__counter {
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.1);
	font-size: 0.85rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.tris-lb__album {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	color: rgba(255, 255, 255, 0.72);
	font-family: 'Newsreader', Georgia, serif;
	font-size: 1.15rem;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.tris-lb__actions {
	display: flex;
	gap: 8px;
	margin-left: auto;
}

/* Boutons ronds */
.tris-lb .tris-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-width: 44px;
	height: 44px;
	margin: 0;
	padding: 0 12px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.08);
	color: #ffffff;
	font: inherit;
	font-size: 0.88rem;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.tris-lb [hidden] {
	display: none !important;
}

.tris-lb .tris-lb__btn:hover {
	border-color: rgba(255, 255, 255, 0.4);
	background: rgba(255, 255, 255, 0.16);
	color: #ffffff;
}

.tris-lb .tris-lb__btn:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

.tris-lb__btn svg {
	width: 20px;
	height: 20px;
}

/* Zone photo */
.tris-lb__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 0 clamp(8px, 7vw, 96px);
	touch-action: pan-y pinch-zoom;
}

.tris-lb__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
	object-fit: contain;
	user-select: none;
	-webkit-user-drag: none;
	transition: opacity 0.25s ease, transform 0.3s ease;
}

.tris-lb__img.is-loading {
	opacity: 0;
	transform: scale(0.985);
}

.tris-lb__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 34px;
	height: 34px;
	margin: -17px 0 0 -17px;
	border: 3px solid rgba(255, 255, 255, 0.18);
	border-top-color: #ffffff;
	border-radius: 50%;
	opacity: 0;
	animation: tris-lb-spin 0.8s linear infinite;
	transition: opacity 0.2s ease 0.2s;
	pointer-events: none;
}

.tris-lb__stage.is-loading .tris-lb__spinner {
	opacity: 1;
}

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

.tris-lb .tris-lb__nav {
	position: absolute;
	z-index: 1;
	top: 50%;
	width: 52px;
	height: 52px;
	margin-top: -26px;
	padding: 0;
}

.tris-lb .tris-lb__nav--prev { left: clamp(8px, 2vw, 28px); }
.tris-lb .tris-lb__nav--next { right: clamp(8px, 2vw, 28px); }

.tris-lb .tris-lb__nav[disabled] {
	opacity: 0.3;
	cursor: default;
}

/* Bas : légende */
.tris-lb__foot {
	min-height: 64px;
	padding: 14px clamp(14px, 3vw, 28px) 20px;
	text-align: center;
}

.tris-lb__caption {
	max-width: 760px;
	margin: 0 auto;
	color: rgba(255, 255, 255, 0.88);
	font-size: 0.95rem;
	line-height: 1.5;
}

.tris-lb__hint {
	margin: 6px 0 0;
	color: rgba(255, 255, 255, 0.4);
	font-size: 0.75rem;
}

@media (max-width: 767px) {
	.tris-lb__album,
	.tris-lb__btn-label,
	.tris-lb__hint {
		display: none;
	}

	/* Mobile : flèches en bas, la photo prend toute la largeur. */
	.tris-lb__stage {
		padding: 0;
	}

	.tris-lb .tris-lb__nav {
		top: auto;
		bottom: 10px;
		margin-top: 0;
		width: 44px;
		height: 44px;
	}

	.tris-lb__img {
		border-radius: 0;
	}

	.tris-lb__foot {
		padding-bottom: 64px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tris-galerie *,
	.tris-lb,
	.tris-lb * {
		animation: none !important;
		transition: none !important;
	}
}
