/**
 * galerie.css — Galerie publique : cartes d'album, mosaïque, visionneuse.
 *
 * Le plugin ne définit jamais :root. Il lit les jetons du thème s'ils existent
 * (--ts-*) et retombe sur ses propres valeurs sinon : il reste donc lisible
 * avec n'importe quel thème.
 *
 * @package Tresor_Galerie
 */

.tsg-page,
.tsg-grille,
.tsg-mosaique,
.tsg-filtres,
.tsg-vue {
	--tsg-vert:      var(--ts-vert, #113A22);
	--tsg-papier:    var(--ts-papier, #EEF0E7);
	--tsg-surface:   var(--ts-papier-haut, #F7F8F2);
	--tsg-creux:     var(--ts-papier-bas, #E4E7DB);
	--tsg-encre:     var(--ts-encre, #17251C);
	--tsg-encre-d:   var(--ts-encre-douce, #4D5A4F);
	--tsg-encre-p:   var(--ts-encre-pale, #77836F);
	--tsg-filet:     var(--ts-filet, #D0D4C2);
	--tsg-filet-f:   var(--ts-filet-fort, #B7BDA6);
	--tsg-laiton:    var(--ts-laiton, #8A6E30);
	--tsg-titre:     var(--ts-titre, "Amiri", Georgia, serif);
	--tsg-texte:     var(--ts-texte, "Spectral", Georgia, serif);
	--tsg-rubr:      var(--ts-rubr, "Archivo", system-ui, sans-serif);
	--tsg-rayon:     var(--ts-rayon, 2px);
	--tsg-transit:   var(--ts-transit, 0.25s cubic-bezier(0.2, 0.7, 0.3, 1));
	--tsg-colonnes:  3;
}

/* ==============================================================
 * PAGE
 * ============================================================ */

.tsg-page {
	/* Le thème Trésor Sublime empile le site en colonne flex : sans cette
	   ligne, une page de galerie courte serait comprimée par le pied. */
	flex: 1 0 auto;
	padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(3.5rem, 8vw, 6rem);
	color: var(--tsg-encre);
	font-family: var(--tsg-texte);
}

.tsg-contenant {
	width: 100%;
	max-width: 1180px;
	margin-inline: auto;
	padding-inline: clamp(1.15rem, 4vw, 2.5rem);
}

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

.tsg-entete {
	max-width: 46rem;
	margin: 0 auto clamp(2rem, 4vw, 3rem);
	text-align: center;
}

.tsg-fil {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin-bottom: 0.9rem;
	font-family: var(--tsg-rubr);
	font-size: 0.7rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--tsg-encre-p);
}

.tsg-fil a {
	color: inherit;
	text-decoration: none;
}

.tsg-fil a:hover,
.tsg-fil a:focus {
	color: var(--tsg-vert);
	text-decoration: underline;
}

.tsg-fil span[aria-hidden] {
	color: var(--tsg-laiton);
}

.tsg-surtitre {
	margin: 0;
	font-family: var(--tsg-rubr);
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.17em;
	text-transform: uppercase;
	color: var(--tsg-laiton);
}

.tsg-surtitre a {
	color: inherit;
	text-decoration: none;
}

.tsg-surtitre a:hover,
.tsg-surtitre a:focus {
	text-decoration: underline;
}

.tsg-titre {
	margin: 0.6rem 0 0;
	font-family: var(--tsg-titre);
	font-weight: 400;
	font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.2rem);
	line-height: 1.1;
	color: var(--tsg-encre);
	text-wrap: balance;
}

.tsg-filet {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.9rem;
	margin: 1.4rem 0;
	color: var(--tsg-filet-f);
}

.tsg-filet::before,
.tsg-filet::after {
	content: "";
	width: 3rem;
	height: 1px;
	background-color: currentColor;
}

.tsg-ornement {
	font-family: var(--tsg-titre);
	font-size: 1.3rem;
	line-height: 1;
	color: var(--tsg-laiton);
}

.tsg-intro {
	font-size: 1.06rem;
	line-height: 1.7;
	color: var(--tsg-encre-d);
}

.tsg-intro p:last-child {
	margin-bottom: 0;
}

.tsg-compte {
	margin: 1.2rem 0 0;
	font-family: var(--tsg-rubr);
	font-size: 0.72rem;
	letter-spacing: 0.11em;
	text-transform: uppercase;
	color: var(--tsg-encre-p);
	font-variant-numeric: tabular-nums;
}

/* ==============================================================
 * FILTRES PAR RUBRIQUE
 * ============================================================ */

.tsg-filtres {
	margin-bottom: clamp(1.75rem, 4vw, 2.75rem);
}

.tsg-filtres ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.45rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tsg-filtres li {
	margin: 0;
}

.tsg-filtre {
	display: inline-flex;
	align-items: baseline;
	gap: 0.45rem;
	padding: 0.5rem 0.95rem;
	border: 1px solid var(--tsg-filet);
	border-radius: 100px;
	background: none;
	font-family: var(--tsg-rubr);
	font-size: 0.72rem;
	font-weight: 600;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	text-decoration: none;
	color: var(--tsg-encre-d);
	transition: color var(--tsg-transit), border-color var(--tsg-transit), background-color var(--tsg-transit);
}

.tsg-filtre:hover,
.tsg-filtre:focus {
	border-color: var(--tsg-laiton);
	color: var(--tsg-vert);
}

.tsg-filtre.est-actif {
	background-color: var(--tsg-vert);
	border-color: var(--tsg-vert);
	color: var(--tsg-surface);
}

.tsg-filtre__n {
	font-size: 0.66rem;
	opacity: 0.72;
	font-variant-numeric: tabular-nums;
}

/* ==============================================================
 * GRILLE D'ALBUMS
 * ============================================================ */

.tsg-grille {
	display: grid;
	grid-template-columns: repeat(var(--tsg-colonnes), minmax(0, 1fr));
	gap: clamp(1.25rem, 3vw, 2.25rem);
}

@media (max-width: 900px) {
	.tsg-grille {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.tsg-grille {
		grid-template-columns: minmax(0, 1fr);
	}
}

.tsg-carte {
	margin: 0;
}

.tsg-carte__lien {
	display: grid;
	gap: 0;
	height: 100%;
	text-decoration: none;
	color: inherit;
}

/* --- Le visuel ---------------------------------------------- */

.tsg-carte__media {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	border-radius: var(--tsg-rayon);
	background-color: var(--tsg-creux);
}

.tsg-carte__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 0;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.tsg-carte__lien:hover .tsg-carte__img,
.tsg-carte__lien:focus-visible .tsg-carte__img {
	transform: scale(1.045);
}

/* Un voile qui monte du bas : le compteur reste lisible sur toute image. */
.tsg-carte__media::after {
	content: "";
	position: absolute;
	inset: 40% 0 0;
	background: linear-gradient(to bottom, transparent, rgba(13, 44, 26, 0.72));
	opacity: 0;
	transition: opacity var(--tsg-transit);
}

.tsg-carte__lien:hover .tsg-carte__media::after,
.tsg-carte__lien:focus-visible .tsg-carte__media::after {
	opacity: 1;
}

.tsg-carte__vide {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
	font-family: var(--tsg-titre);
	font-size: 3rem;
	color: var(--tsg-filet-f);
}

.tsg-carte__compte {
	position: absolute;
	right: 0.7rem;
	bottom: 0.7rem;
	z-index: 1;
	padding: 0.28rem 0.6rem;
	border-radius: 100px;
	background-color: rgba(13, 44, 26, 0.82);
	backdrop-filter: blur(3px);
	font-family: var(--tsg-rubr);
	font-size: 0.66rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #EDEFE3;
	font-variant-numeric: tabular-nums;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity var(--tsg-transit), transform var(--tsg-transit);
}

.tsg-carte__lien:hover .tsg-carte__compte,
.tsg-carte__lien:focus-visible .tsg-carte__compte {
	opacity: 1;
	transform: none;
}

/* --- Le texte ----------------------------------------------- */

.tsg-carte__corps {
	display: block;
	padding-top: 0.9rem;
}

.tsg-carte__rubrique {
	display: block;
	font-family: var(--tsg-rubr);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--tsg-laiton);
}

.tsg-carte__titre {
	display: block;
	margin: 0.35rem 0 0;
	font-family: var(--tsg-titre);
	font-size: 1.32rem;
	line-height: 1.24;
	color: var(--tsg-encre);
}

.tsg-carte__lien:hover .tsg-carte__titre,
.tsg-carte__lien:focus-visible .tsg-carte__titre {
	color: var(--tsg-vert);
	text-decoration: underline;
	text-decoration-color: var(--tsg-laiton);
	text-underline-offset: 3px;
}

.tsg-carte__resume {
	display: block;
	margin-top: 0.4rem;
	font-size: 0.95rem;
	line-height: 1.6;
	color: var(--tsg-encre-d);
}

/* ==============================================================
 * MOSAÏQUE D'IMAGES
 *
 * En colonnes plutôt qu'en grille : chaque image garde ses proportions,
 * une planche verticale n'est pas recadrée pour tenir dans une case.
 * ============================================================ */

.tsg-mosaique {
	column-count: var(--tsg-colonnes);
	column-gap: clamp(0.85rem, 2vw, 1.5rem);
}

@media (max-width: 900px) {
	.tsg-mosaique {
		column-count: 2;
	}
}

@media (max-width: 560px) {
	.tsg-mosaique {
		column-count: 1;
	}
}

.tsg-piece {
	break-inside: avoid;
	margin: 0 0 clamp(0.85rem, 2vw, 1.5rem);
}

.tsg-piece__lien {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--tsg-rayon);
	background-color: var(--tsg-creux);
	line-height: 0;
}

.tsg-piece__img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: 0;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1), filter var(--tsg-transit);
}

.tsg-piece__lien:hover .tsg-piece__img,
.tsg-piece__lien:focus-visible .tsg-piece__img {
	transform: scale(1.035);
	filter: brightness(0.82);
}

/* La loupe n'apparaît qu'au survol : au repos, l'image est seule. */
.tsg-piece__loupe {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity var(--tsg-transit);
	pointer-events: none;
}

.tsg-piece__loupe svg {
	width: 44px;
	height: 44px;
	padding: 11px;
	border: 1px solid rgba(237, 239, 227, 0.75);
	border-radius: 50%;
	color: #EDEFE3;
	background-color: rgba(13, 44, 26, 0.42);
	backdrop-filter: blur(2px);
}

.tsg-piece__lien:hover .tsg-piece__loupe,
.tsg-piece__lien:focus-visible .tsg-piece__loupe {
	opacity: 1;
}

.tsg-piece__legende {
	margin-top: 0.5rem;
	font-family: var(--tsg-rubr);
	font-size: 0.78rem;
	line-height: 1.5;
	color: var(--tsg-encre-p);
}

/* ==============================================================
 * VISIONNEUSE
 *
 * Un fond sombre volontairement constant : une image se regarde sur
 * du noir, quel que soit le thème du site.
 * ============================================================ */

.tsg-vue {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.tsg-vue[hidden] {
	display: none;
}

.tsg-vue__voile {
	position: absolute;
	inset: 0;
	background-color: rgba(8, 16, 11, 0.94);
	opacity: 0;
	transition: opacity 0.28s ease;
}

.tsg-vue.est-ouverte .tsg-vue__voile {
	opacity: 1;
}

.tsg-vue__cadre {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: 100%;
	padding: clamp(3.5rem, 7vw, 5rem) clamp(1rem, 5vw, 4.5rem) clamp(2.5rem, 5vw, 3.5rem);
}

.tsg-vue__scene {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
}

.tsg-vue__img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 2px;
	opacity: 0;
	transform: scale(0.985);
	transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1);
	box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
}

.tsg-vue__img.est-prete {
	opacity: 1;
	transform: none;
}

/* --- Pied : légende et rang --------------------------------- */

.tsg-vue__pied {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: center;
	gap: 0.5rem 1.4rem;
	padding-top: 1.1rem;
	color: #A9BFAF;
	text-align: center;
}

.tsg-vue__legende {
	margin: 0;
	max-width: 60ch;
	font-family: var(--ts-texte, Georgia, serif);
	font-size: 0.95rem;
	line-height: 1.55;
	color: #D8DFD4;
}

.tsg-vue__legende:empty {
	display: none;
}

.tsg-vue__rang {
	margin: 0;
	font-family: var(--ts-rubr, system-ui, sans-serif);
	font-size: 0.72rem;
	letter-spacing: 0.16em;
	color: #B08D3C;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* --- Boutons ------------------------------------------------ */

.tsg-vue__bouton {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 1px solid rgba(237, 239, 227, 0.28);
	border-radius: 50%;
	background-color: rgba(8, 16, 11, 0.6);
	color: #EDEFE3;
	cursor: pointer;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.tsg-vue__bouton:hover,
.tsg-vue__bouton:focus-visible {
	background-color: #B08D3C;
	border-color: #B08D3C;
	color: #0D2C1A;
}

.tsg-vue__bouton[disabled] {
	opacity: 0.3;
	cursor: default;
}

.tsg-vue__bouton--prec {
	left: clamp(0.5rem, 2vw, 1.5rem);
	top: 50%;
	transform: translateY(-50%);
}

.tsg-vue__bouton--suiv {
	right: clamp(0.5rem, 2vw, 1.5rem);
	top: 50%;
	transform: translateY(-50%);
}

.tsg-vue__bouton--fermer {
	top: clamp(0.9rem, 2vw, 1.5rem);
	right: clamp(0.9rem, 2vw, 1.5rem);
}

@media (max-width: 640px) {
	.tsg-vue__bouton--prec,
	.tsg-vue__bouton--suiv {
		top: auto;
		bottom: clamp(0.8rem, 3vw, 1.5rem);
		transform: none;
		width: 44px;
		height: 44px;
	}

	.tsg-vue__cadre {
		padding-bottom: 5.5rem;
	}
}

/* Le corps de la page ne défile plus derrière la visionneuse. */
body.tsg-vue-ouverte {
	overflow: hidden;
}

/* ==============================================================
 * PAGINATION ET NAVIGATION
 * ============================================================ */

.tsg-pagination {
	margin-top: clamp(2.5rem, 5vw, 3.5rem);
	padding-top: 1.5rem;
	border-top: 1px solid var(--tsg-filet);
}

.tsg-pagination ul.page-numbers {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.35rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tsg-pagination li {
	margin: 0;
}

.tsg-pagination a.page-numbers,
.tsg-pagination span.page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	height: 2.5rem;
	padding: 0 0.6rem;
	border: 1px solid var(--tsg-filet);
	border-radius: var(--tsg-rayon);
	font-family: var(--tsg-rubr);
	font-size: 0.78rem;
	font-weight: 600;
	text-decoration: none;
	color: var(--tsg-encre-d);
	font-variant-numeric: tabular-nums;
}

.tsg-pagination a.page-numbers:hover,
.tsg-pagination a.page-numbers:focus {
	border-color: var(--tsg-vert);
	color: var(--tsg-vert);
}

.tsg-pagination span.page-numbers.current {
	background-color: var(--tsg-vert);
	border-color: var(--tsg-vert);
	color: var(--tsg-surface);
}

.tsg-nav-album {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	gap: 1.5rem;
	align-items: center;
	margin-top: clamp(2.5rem, 5vw, 4rem);
	padding-top: 1.5rem;
	border-top: 1px solid var(--tsg-filet);
}

.tsg-nav-album a {
	text-decoration: none;
	color: inherit;
}

.tsg-nav-album__cote--droite {
	text-align: right;
}

.tsg-nav-album__label {
	display: block;
	font-family: var(--tsg-rubr);
	font-size: 0.65rem;
	font-weight: 700;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	color: var(--tsg-laiton);
}

.tsg-nav-album__titre {
	display: block;
	margin-top: 0.25rem;
	font-family: var(--tsg-titre);
	font-size: 1.08rem;
	line-height: 1.3;
	color: var(--tsg-encre);
}

.tsg-nav-album a:hover .tsg-nav-album__titre,
.tsg-nav-album a:focus .tsg-nav-album__titre {
	color: var(--tsg-vert);
}

.tsg-nav-album__retour {
	padding: 0.6rem 1.1rem;
	border: 1px solid var(--tsg-filet-fort, #B7BDA6);
	border-radius: 100px;
	font-family: var(--tsg-rubr);
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--tsg-encre-d);
	white-space: nowrap;
	transition: background-color var(--tsg-transit), color var(--tsg-transit), border-color var(--tsg-transit);
}

.tsg-nav-album__retour:hover,
.tsg-nav-album__retour:focus {
	background-color: var(--tsg-vert);
	border-color: var(--tsg-vert);
	color: var(--tsg-surface);
}

@media (max-width: 640px) {
	.tsg-nav-album {
		grid-template-columns: minmax(0, 1fr);
		justify-items: center;
		text-align: center;
	}

	.tsg-nav-album__cote--droite {
		text-align: center;
	}
}

.tsg-rien {
	padding: 3rem 0;
	text-align: center;
	color: var(--tsg-encre-d);
}

/* ==============================================================
 * MOUVEMENT RÉDUIT
 * ============================================================ */

@media (prefers-reduced-motion: reduce) {
	.tsg-carte__img,
	.tsg-piece__img,
	.tsg-vue__img {
		transition: none !important;
		transform: none !important;
	}
}
