/* ==========================================================================
   Galerie Réalisations
   Les variables ci-dessous permettent d'ajuster rapidement le rendu.
   ========================================================================== */
.gr-galerie {
	--gr-accent: #E1FF00;
	--gr-trait: #1a1a1a;          /* bordure et texte des boutons de filtre */
	--gr-ecart: 6px;              /* espace entre les cases */
	--gr-ratio: 10 / 9;           /* proportions d'une case (largeur / hauteur) */
	--gr-colonnes: 4;
	width: 100%;
}

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

/* --- Filtres ------------------------------------------------------------ */
.gr-galerie .gr-filtres {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 12px;
	margin: 0 0 50px;
	padding: 2px;
}

.gr-galerie .gr-filtre {
	-webkit-appearance: none;
	appearance: none;
	margin: 0;
	padding: 7px 15px;
	font: inherit;
	font-size: 0.95rem;
	line-height: 1.2;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	white-space: nowrap;
	color: var(--gr-trait);
	background: transparent;
	border: 1px solid var(--gr-trait);
	border-radius: 999px;
	box-shadow: none;
	transform: none;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Neutralise les styles :focus / :active du thème : le bouton garde son apparence normale */
.gr-galerie .gr-filtre:focus,
.gr-galerie .gr-filtre:active {
	color: var(--gr-trait);
	background: transparent;
	border-color: var(--gr-trait);
	box-shadow: none;
	transform: none;
	outline: none;
}

.gr-galerie .gr-filtre:hover {
	color: var(--gr-trait);
	background: rgba(225, 255, 0, 0.35);
	background: color-mix(in srgb, var(--gr-accent) 35%, transparent);
	border-color: var(--gr-trait);
}

.gr-galerie .gr-filtre.is-active,
.gr-galerie .gr-filtre.is-active:hover,
.gr-galerie .gr-filtre.is-active:focus,
.gr-galerie .gr-filtre.is-active:active {
	color: #000;
	font-weight: 700;
	background: var(--gr-accent);
	border-color: var(--gr-accent);
}

/* Contour visible uniquement pour la navigation au clavier */
.gr-galerie .gr-filtre:focus-visible {
	outline: 2px solid var(--gr-trait);
	outline-offset: 3px;
}

/* --- Grille ------------------------------------------------------------- */
/* Pleine largeur : la grille touche les bords de l'écran, quel que soit le conteneur.
   --gr-vw est la largeur réelle de la fenêtre hors barre de défilement (calculée en JS). */
.gr-galerie .gr-grille {
	display: grid;
	grid-template-columns: repeat(var(--gr-colonnes), minmax(0, 1fr));
	gap: var(--gr-ecart);
	width: var(--gr-vw, 100vw);
	max-width: none;
	margin-left: calc(50% - var(--gr-vw, 100vw) / 2);
	margin-right: 0;
	background: #333; /* couleur visible dans l'espace entre les réalisations */
}

/* --- Carte -------------------------------------------------------------- */
.gr-galerie .gr-carte {
	position: relative;
	display: block;
	aspect-ratio: var(--gr-ratio);
	overflow: hidden;
	isolation: isolate;
	color: #fff;
	text-decoration: none;
	background: #333;
}

.gr-galerie a.gr-carte:hover,
.gr-galerie a.gr-carte:focus {
	color: #fff;
	text-decoration: none;
}

.gr-galerie a.gr-carte:focus-visible {
	outline: 3px solid var(--gr-accent);
	outline-offset: -3px;
}

.gr-galerie .gr-carte__image {
	position: absolute;
	inset: 0;
	z-index: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border-radius: 0;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Dégradé transparent en haut, noir en bas, opacité 0.5 sur toute la case */
.gr-galerie .gr-carte__voile {
	position: absolute;
	inset: 0;
	z-index: 1;
	background: linear-gradient(180deg, transparent 0%, #000 100%);
	opacity: 0.5;
	pointer-events: none;
}

.gr-galerie .gr-carte__contenu {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: 0;
	padding: clamp(20px, 2.5vw, 42px);
}

/* Le titre est un <h3> pour les réalisations visibles au chargement,
   une <div class="titre-galerie-realisation"> pour les autres : même rendu. */
.gr-galerie .gr-carte__titre,
.gr-galerie .titre-galerie-realisation {
	display: block;
	margin: 0;
	padding: 0;
	font-family: inherit;
	font-size: 30px;
	font-weight: 500;
	line-height: 1.05;
	color: #fff;
	overflow-wrap: break-word;
}

.gr-galerie .gr-carte__pied {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
}

.gr-galerie .gr-carte__ville {
	display: inline-flex;
	align-items: center;
	gap: 0.6em;
	font-size: 1rem;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.gr-galerie .gr-carte__ville svg {
	flex: none;
	width: 1.15em;
	height: 1.15em;
	fill: var(--gr-accent);
}

.gr-galerie .gr-carte__fleche {
	flex: none;
	width: clamp(40px, 4.2vw, 70px);
	margin-left: auto;
	line-height: 0;
	transition: transform 0.35s ease;
}

.gr-galerie .gr-carte__fleche svg {
	width: 100%;
	height: auto;
	fill: var(--gr-accent);
}

/* Survol */
.gr-galerie a.gr-carte:hover .gr-carte__image {
	transform: scale(1.05);
}

.gr-galerie a.gr-carte:hover .gr-carte__fleche {
	transform: translate(6px, -6px);
}

/* --- États de filtrage ------------------------------------------------- */
.gr-galerie .gr-carte.is-hidden {
	display: none;
}

.gr-galerie .gr-carte.is-entering {
	animation: gr-apparition 0.45s ease both;
}

@keyframes gr-apparition {
	from { opacity: 0; transform: translateY(12px); }
	to   { opacity: 1; transform: none; }
}

/* État initial, avant l'exécution du JavaScript (ou sans JavaScript) */
.gr-galerie:not(.is-ready) .gr-masque {
	display: none;
}

@media (min-width: 1025px) {
	.gr-galerie:not(.is-ready) .gr-masque-d { display: none; }
}

@media (min-width: 768px) and (max-width: 1024px) {
	.gr-galerie:not(.is-ready) .gr-masque-t { display: none; }
}

@media (max-width: 767px) {
	.gr-galerie:not(.is-ready) .gr-masque-m { display: none; }
}

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 1024px) {
	.gr-galerie {
		--gr-colonnes: 2;
	}

	.gr-galerie .gr-filtres {
		flex-wrap: nowrap;
		overflow-x: auto;
		margin-bottom: 32px;
		padding-bottom: 6px;
		scroll-snap-type: x proximity;
		scrollbar-width: none;
		-webkit-overflow-scrolling: touch;
	}

	.gr-galerie .gr-filtres::-webkit-scrollbar {
		display: none;
	}

	/* « safe » évite de couper les premiers boutons quand la barre déborde */
	.gr-galerie .gr-filtres {
		justify-content: safe center;
	}

	.gr-galerie .gr-filtre {
		flex: none;
		scroll-snap-align: start;
	}
}

@media (max-width: 767px) {
	.gr-galerie {
		--gr-colonnes: 1;
	}

	.gr-galerie .gr-carte__fleche {
		width: 48px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.gr-galerie .gr-carte.is-entering { animation: none; }
	.gr-galerie .gr-carte__image,
	.gr-galerie .gr-carte__fleche { transition: none; }
	.gr-galerie a.gr-carte:hover .gr-carte__image { transform: none; }
}
