/* JBC Galerie – front */

.jbcg {
	--jbcg-gap: 8px;
	--jbcg-bg: #0c0c0e;
	--jbcg-tile: #19191c;
	--jbcg-text: #f3efe7;
	--jbcg-muted: rgba(243, 239, 231, .55);
	--jbcg-accent: #c8a45d;
	background: var(--jbcg-bg);
	color: var(--jbcg-text);
	padding: clamp(16px, 3vw, 40px);
	box-sizing: border-box;
}
.jbcg--clair {
	--jbcg-bg: transparent;
	--jbcg-tile: #ece8e1;
	--jbcg-text: #17171a;
	--jbcg-muted: rgba(23, 23, 26, .55);
	--jbcg-accent: #9a7b3c;
	padding-left: 0;
	padding-right: 0;
}
.jbcg *, .jbcg *::before, .jbcg *::after { box-sizing: border-box; }

/* ---------- Filtres ---------- */
.jbcg-filtres {
	display: flex;
	justify-content: center;
	gap: 4px 28px;
	flex-wrap: wrap;
	margin: 0 0 clamp(18px, 2.5vw, 32px);
	padding: 0;
}
.jbcg .jbcg-filtre {
	appearance: none;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	margin: 0;
	padding: 10px 0 8px;
	color: var(--jbcg-muted);
	font: inherit;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: .2em;
	line-height: 1.2;
	text-transform: uppercase;
	cursor: pointer;
	position: relative;
	transition: color .3s ease;
	white-space: nowrap;
}
.jbcg .jbcg-filtre::after {
	content: "";
	position: absolute;
	left: 0; right: .2em; bottom: 0;
	height: 1px;
	background: var(--jbcg-accent);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform .4s cubic-bezier(.2, .7, .2, 1);
}
.jbcg .jbcg-filtre:hover,
.jbcg .jbcg-filtre:focus-visible,
.jbcg .jbcg-filtre[aria-pressed="true"] { color: var(--jbcg-text); background: none; }
.jbcg .jbcg-filtre[aria-pressed="true"]::after { transform: scaleX(1); }
.jbcg .jbcg-filtre:focus-visible { outline: 1px solid var(--jbcg-accent); outline-offset: 4px; }

/* ---------- Grille justifiée : chaque photo garde son format, toutes les rangées sont alignées ---------- */
.jbcg-grille {
	display: flex;
	flex-wrap: wrap;
	gap: var(--jbcg-gap);
	margin: 0;
	padding: 0;
}
.jbcg .jbcg-item {
	position: relative;
	flex: var(--r) 1 calc(var(--r) * var(--jbcg-h));
	aspect-ratio: var(--r);
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: var(--jbcg-tile);
	transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .2, 1);
}
.jbcg .jbcg-item[hidden] { display: none; }
.jbcg-fin { flex: 1000 1 0; height: 0; }

.jbcg .jbcg-lien {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
	outline-offset: -3px;
	border: 0;
	box-shadow: none;
}
.jbcg .jbcg-lien:focus-visible { outline: 2px solid var(--jbcg-accent); }
.jbcg .jbcg-img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	margin: 0;
	border: 0;
	transform: scale(1.001);
	transition: transform 1.4s cubic-bezier(.2, .7, .2, 1), filter .6s ease;
}

/* Légende en surimpression au survol (ordinateur). Toujours présente dans le code pour Google. */
.jbcg .jbcg-legende {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	margin: 0;
	padding: 48px 18px 16px;
	background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, 0));
	color: #f3efe7;
	font-size: 13px;
	letter-spacing: .04em;
	line-height: 1.4;
	text-align: left;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity .45s ease, transform .45s ease;
	pointer-events: none;
}
@media (hover: hover) {
	.jbcg .jbcg-item:hover .jbcg-img { transform: scale(1.045); }
	.jbcg .jbcg-item:hover .jbcg-legende,
	.jbcg .jbcg-item:focus-within .jbcg-legende { opacity: 1; transform: none; }
}
@media (hover: none) {
	.jbcg .jbcg-legende { display: none; }
}

/* Apparition douce au défilement (seulement si le script tourne) */
.jbcg.is-js .jbcg-item:not(.is-in) { opacity: 0; transform: translateY(14px); }

@media (max-width: 600px) {
	.jbcg { --jbcg-gap: 4px; --jbcg-h: 150px !important; padding: 12px; }
	.jbcg--clair { padding-left: 0; padding-right: 0; }
	.jbcg-filtres {
		flex-wrap: nowrap;
		justify-content: flex-start;
		overflow-x: auto;
		gap: 22px;
		margin-left: -12px;
		margin-right: -12px;
		padding: 0 12px;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}
	.jbcg-filtres::-webkit-scrollbar { display: none; }
	.jbcg .jbcg-filtre { font-size: 11px; letter-spacing: .16em; }
}
@media (min-width: 601px) and (max-width: 980px) {
	.jbcg { --jbcg-h: 220px !important; }
}

/* ---------- Plein écran ---------- */
html.jbcg-lock, html.jbcg-lock body { overflow: hidden !important; }

.jbcg-lb {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(9, 9, 11, .97);
	color: #f3efe7;
	overflow: hidden;
	opacity: 0;
	transition: opacity .35s ease;
}
.jbcg-lb[open] { display: block; }
.jbcg-lb.is-open { opacity: 1; }
.jbcg-lb::backdrop { background: transparent; }

.jbcg-lb-scene {
	position: absolute;
	inset: 64px 72px 92px;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: pan-y pinch-zoom;
	user-select: none;
}
.jbcg-lb-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	margin: 0;
	box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
	transition: opacity .3s ease, transform .3s ease;
	-webkit-user-drag: none;
}
.jbcg-lb-img.is-loading { opacity: 0; transform: scale(.985); }

.jbcg-lb-bas {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	min-height: 92px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
	text-align: center;
}
.jbcg-lb-legende {
	margin: 0;
	max-width: 780px;
	font-size: 15px;
	letter-spacing: .03em;
	line-height: 1.5;
	color: rgba(243, 239, 231, .85);
}
.jbcg-lb-compteur {
	position: absolute;
	top: 22px; left: 26px;
	font-size: 12px;
	letter-spacing: .24em;
	color: rgba(243, 239, 231, .55);
	font-variant-numeric: tabular-nums;
}
.jbcg-lb-compteur b { color: #f3efe7; font-weight: 500; }

.jbcg-lb button {
	appearance: none;
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: #f3efe7;
	cursor: pointer;
	opacity: .7;
	transition: opacity .25s ease, background .25s ease;
	box-shadow: none;
}
.jbcg-lb button:hover, .jbcg-lb button:focus-visible { opacity: 1; background: rgba(255, 255, 255, .08); }
.jbcg-lb button:focus-visible { outline: 1px solid #c8a45d; outline-offset: 2px; }
.jbcg-lb button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.jbcg-lb-fermer { top: 8px; right: 10px; }
.jbcg-lb-prec { left: 10px; top: 50%; transform: translateY(-50%); }
.jbcg-lb-suiv { right: 10px; top: 50%; transform: translateY(-50%); }
.jbcg-lb.is-single .jbcg-lb-prec, .jbcg-lb.is-single .jbcg-lb-suiv { display: none; }

@media (max-width: 700px), (hover: none) {
	.jbcg-lb-scene { inset: 56px 0 84px; }
	.jbcg-lb-img { box-shadow: none; }
	.jbcg-lb-prec, .jbcg-lb-suiv { display: none !important; }
	.jbcg-lb-legende { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
	.jbcg *, .jbcg-lb, .jbcg-lb * { transition: none !important; }
	.jbcg.is-js .jbcg-item:not(.is-in) { opacity: 1; transform: none; }
}
