/*
 * Gente Solidaria — Galería pública de trabajos realizados.
 *
 * Componente autónomo: funciona con cualquier tema. Los colores y la
 * tipografía se ajustan con variables CSS (--gsg-*), que el tema del
 * proyecto redefine para integrarlos con su identidad.
 */

.gsg-galeria,
.gsg-fotos,
.gsg-visor,
.gsg-detalle-datos,
.gsg-detalle-fotos {
	--gsg-acento: #8a5a0f;
	--gsg-sobre-acento: #ffffff;
	--gsg-suave: rgba(19, 35, 43, 0.74);
	--gsg-linea: rgba(19, 35, 43, 0.18);
	--gsg-fondo-media: #e6dfd1;
	--gsg-foco: #8a5a0f;
	--gsg-fuente-titulos: inherit;
	--gsg-espacio: clamp(16px, 2.2vw, 28px);
	--gsg-radio: 2px;
	box-sizing: border-box;
}

@supports (color: color-mix(in srgb, red 50%, transparent)) {
	.gsg-galeria,
	.gsg-fotos,
	.gsg-detalle-datos,
	.gsg-detalle-fotos {
		--gsg-suave: color-mix(in srgb, currentColor 76%, transparent);
		--gsg-linea: color-mix(in srgb, currentColor 20%, transparent);
	}
}

.gsg-galeria--oscura {
	--gsg-acento: #e0ae52;
	--gsg-sobre-acento: #0b2b33;
	--gsg-foco: #e0ae52;
	--gsg-fondo-media: #133942;
	--gsg-suave: rgba(246, 242, 234, 0.78);
	--gsg-linea: rgba(246, 242, 234, 0.22);
}

.gsg-galeria *,
.gsg-galeria *::before,
.gsg-galeria *::after,
.gsg-fotos *,
.gsg-visor * {
	box-sizing: border-box;
}

.gsg-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.gsg-icono {
	flex: none;
	width: 1em;
	height: 1em;
	vertical-align: -0.125em;
}

/* ---------------------------------------------------------------------
 * Filtros
 * ------------------------------------------------------------------- */

.gsg-filtros {
	margin: 0 0 clamp(24px, 3vw, 40px);
}

.gsg-filtros__lista {
	list-style: none;
	margin: 0;
	padding: 2px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.gsg-filtros__lista li {
	margin: 0;
	padding: 0;
}

.gsg-filtros .gsg-filtro {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 8px 16px;
	border: 1px solid var(--gsg-linea);
	border-radius: 999px;
	color: inherit;
	font-size: 0.9375rem;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.gsg-filtros .gsg-filtro:hover {
	border-color: currentColor;
	color: inherit;
}

.gsg-filtros .gsg-filtro[aria-current="true"] {
	background: var(--gsg-acento);
	border-color: var(--gsg-acento);
	color: var(--gsg-sobre-acento);
}

.gsg-filtro__n {
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
	opacity: 0.8;
}

.gsg-filtros .gsg-filtro[aria-current="true"] .gsg-filtro__n {
	opacity: 1;
}

.gsg-filtro:focus-visible,
.gsg-boton:focus-visible,
.gsg-paginacion a:focus-visible,
.gsg-trabajo__fotos:focus-visible {
	outline: 3px solid var(--gsg-foco);
	outline-offset: 3px;
}

@media (max-width: 639px) {
	/* En teléfonos los filtros forman una sola fila desplazable. */
	.gsg-filtros {
		margin-inline: calc(-1 * var(--gsg-margen-movil, 0px));
	}
	.gsg-filtros__lista {
		flex-wrap: nowrap;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x proximity;
		padding-inline: var(--gsg-margen-movil, 2px);
		padding-bottom: 6px;
		scrollbar-width: thin;
	}
	.gsg-filtros__lista li {
		scroll-snap-align: start;
	}
}

/* ---------------------------------------------------------------------
 * Mosaico de trabajos
 * ------------------------------------------------------------------- */

.gsg-mosaico {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	column-gap: var(--gsg-espacio);
	row-gap: clamp(32px, 4vw, 56px);
	transition: opacity 0.25s ease;
}

.gsg-mosaico.es-cargando {
	opacity: 0.45;
}

.gsg-pieza {
	grid-column: span 12;
	min-width: 0;
	margin: 0;
	padding: 0;
}

@media (min-width: 640px) {
	.gsg-pieza--ancha,
	.gsg-pieza--normal {
		grid-column: span 6;
	}
}

@media (min-width: 1024px) {
	.gsg-pieza--ancha {
		grid-column: span 6;
	}
	.gsg-pieza--normal {
		grid-column: span 4;
	}
}

.gsg-trabajo {
	position: relative;
	display: grid;
	grid-template-areas: "media" "cuerpo";
	grid-template-columns: minmax(0, 1fr);
	gap: 16px;
	align-content: start;
	margin: 0;
	height: 100%;
}

.gsg-trabajo__media {
	grid-area: media;
	position: relative;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: var(--gsg-fondo-media);
	border-radius: var(--gsg-radio);
}

.gsg-pieza--ancha .gsg-trabajo__media {
	aspect-ratio: 3 / 2;
}

.gsg-trabajo__media .gsg-trabajo__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.gsg-trabajo:hover .gsg-trabajo__media .gsg-trabajo__img {
	transform: scale(1.035);
}

.gsg-trabajo__sin-foto {
	display: grid;
	place-items: center;
	width: 100%;
	height: 100%;
	color: var(--gsg-suave);
	font-size: 2.5rem;
}

.gsg-trabajo__cuerpo {
	grid-area: cuerpo;
	min-width: 0;
}

.gsg-trabajo__tipo {
	margin: 0 0 8px;
	color: var(--gsg-acento);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1.4;
	text-transform: uppercase;
}

.gsg-trabajo__titulo {
	margin: 0;
	font-family: var(--gsg-fuente-titulos);
	font-size: clamp(1.1875rem, 1.05rem + 0.45vw, 1.4375rem);
	font-weight: 500;
	line-height: 1.25;
	letter-spacing: -0.005em;
	text-wrap: balance;
}

.gsg-trabajo .gsg-trabajo__enlace {
	color: inherit;
	text-decoration: none;
	background-image: linear-gradient(currentColor, currentColor);
	background-position: 0 100%;
	background-repeat: no-repeat;
	background-size: 0 1px;
	transition: background-size 0.35s ease;
}

.gsg-trabajo .gsg-trabajo__enlace:hover,
.gsg-trabajo:hover .gsg-trabajo__enlace {
	color: inherit;
	background-size: 100% 1px;
}

/* Toda la pieza es clicable; el enlace sigue siendo el título (accesible). */
.gsg-trabajo__enlace::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.gsg-trabajo__enlace:focus {
	outline: none;
}

.gsg-trabajo__enlace:focus-visible::after {
	outline: 3px solid var(--gsg-foco);
	outline-offset: 6px;
	border-radius: var(--gsg-radio);
}

.gsg-trabajo__extracto {
	margin: 14px 0 0;
	color: var(--gsg-suave);
	font-size: 1rem;
	line-height: 1.6;
	max-width: 52ch;
}

.gsg-trabajo__datos {
	list-style: none;
	margin: 12px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 18px;
	color: var(--gsg-suave);
	font-size: 0.875rem;
	line-height: 1.45;
}

.gsg-trabajo__datos li {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	margin: 0;
	padding: 0;
}

.gsg-trabajo .gsg-trabajo__fotos {
	grid-area: media;
	align-self: start;
	justify-self: end;
	position: relative;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 44px;
	min-width: 44px;
	margin: 12px;
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(11, 30, 36, 0.78);
	color: #fff;
	font-size: 0.8125rem;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	transition: background-color 0.2s ease;
}

.gsg-trabajo .gsg-trabajo__fotos:hover {
	background: rgba(11, 30, 36, 0.94);
	color: #fff;
}

/* Pieza principal */
.gsg-pieza--principal .gsg-trabajo__media {
	aspect-ratio: 4 / 5;
}

.gsg-pieza--principal .gsg-trabajo__titulo {
	font-size: clamp(1.625rem, 1.2rem + 1.6vw, 2.5rem);
	line-height: 1.12;
	letter-spacing: -0.015em;
}

@media (min-width: 640px) {
	.gsg-pieza--principal .gsg-trabajo__media {
		aspect-ratio: 16 / 9;
	}
}

@media (min-width: 1024px) {
	.gsg-pieza--principal .gsg-trabajo {
		grid-template-areas: "media cuerpo";
		grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
		column-gap: clamp(28px, 4vw, 64px);
		align-items: end;
	}
	.gsg-pieza--principal .gsg-trabajo__media {
		aspect-ratio: 3 / 2;
	}
	.gsg-pieza--principal .gsg-trabajo__cuerpo {
		padding-bottom: 8px;
		border-top: 1px solid var(--gsg-linea);
		padding-top: 20px;
	}
}

/* Estado vacío */
.gsg-vacio {
	margin: 0;
	padding: clamp(28px, 5vw, 56px) 24px;
	border: 1px dashed var(--gsg-linea);
	border-radius: var(--gsg-radio);
	color: var(--gsg-suave);
	text-align: center;
}

/* ---------------------------------------------------------------------
 * Navegación
 * ------------------------------------------------------------------- */

.gsg-navegacion:not(:empty) {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	margin-top: clamp(40px, 5vw, 64px);
}

.gsg-conteo {
	margin: 0;
	color: var(--gsg-suave);
	font-size: 0.875rem;
	font-variant-numeric: tabular-nums;
}

.gsg-galeria .gsg-boton {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 52px;
	padding: 12px 32px;
	border: 1.5px solid currentColor;
	border-radius: 999px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-weight: 600;
	font-size: 0.9375rem;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.gsg-galeria .gsg-boton:hover {
	background: var(--gsg-acento);
	border-color: var(--gsg-acento);
	color: var(--gsg-sobre-acento);
}

.gsg-boton.es-cargando {
	pointer-events: none;
	opacity: 0.7;
}

.gsg-boton.es-cargando::before {
	content: "";
	width: 14px;
	height: 14px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: gsg-giro 0.8s linear infinite;
}

@keyframes gsg-giro {
	to {
		transform: rotate(360deg);
	}
}

.gsg-paginacion ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 6px;
}

.gsg-paginacion li {
	margin: 0;
}

.gsg-galeria .gsg-paginacion a,
.gsg-galeria .gsg-paginacion span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0 12px;
	border-radius: 999px;
	color: inherit;
	text-decoration: none;
	font-variant-numeric: tabular-nums;
}

.gsg-paginacion a:hover {
	background: var(--gsg-linea);
}

.gsg-paginacion .current {
	background: var(--gsg-acento);
	color: var(--gsg-sobre-acento);
	font-weight: 600;
}

/* ---------------------------------------------------------------------
 * Página de detalle (con cualquier tema)
 * ------------------------------------------------------------------- */

.gsg-detalle-datos {
	list-style: none;
	margin: 0 0 1.5em;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 6px 22px;
	color: var(--gsg-suave);
	font-size: 0.9375rem;
}

.gsg-detalle-datos li {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	margin: 0;
}

.gsg-detalle-fotos {
	margin-top: 2.5em;
	scroll-margin-top: 24px;
}

.gsg-detalle-fotos__titulo {
	font-family: var(--gsg-fuente-titulos);
}

.gsg-detalle-volver {
	margin-top: 2em;
}

/* Mosaico justificado de fotografías: respeta la proporción de cada imagen */
.gsg-fotos__lista {
	--gsg-alto: 280px;
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.gsg-fotos__lista::after {
	content: "";
	flex-grow: 1000;
	min-width: 20%;
}

/* Con pocas fotografías, la fila ocupa todo el ancho. */
.gsg-fotos--pocas .gsg-fotos__lista::after {
	display: none;
}

.gsg-foto {
	flex-grow: calc(var(--gsg-r, 1.5) * 100);
	flex-basis: calc(var(--gsg-r, 1.5) * var(--gsg-alto));
	margin: 0;
	padding: 0;
	min-width: 0;
}

.gsg-foto__enlace {
	position: relative;
	display: block;
	aspect-ratio: var(--gsg-r, 1.5);
	overflow: hidden;
	background: var(--gsg-fondo-media);
	border-radius: var(--gsg-radio);
	cursor: zoom-in;
}

.gsg-foto__enlace .gsg-foto__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.2s ease;
}

.gsg-foto__enlace:hover .gsg-foto__img {
	transform: scale(1.03);
}

.gsg-foto__enlace:focus-visible {
	outline: 3px solid var(--gsg-foco);
	outline-offset: 3px;
}

@media (max-width: 639px) {
	.gsg-fotos__lista {
		--gsg-alto: 150px;
		gap: 6px;
	}
}

/* ---------------------------------------------------------------------
 * Visor (lightbox) — elemento <dialog> nativo
 * ------------------------------------------------------------------- */

html.gsg-visor-abierto {
	overflow: hidden;
}

.gsg-visor {
	position: fixed;
	inset: 0;
	width: 100%;
	max-width: none;
	height: 100%;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: #071a1f;
	color: #f6f2ea;
	font-size: 16px;
	overflow: hidden;
	overscroll-behavior: contain;
}

.gsg-visor::backdrop {
	background: rgba(7, 26, 31, 0.92);
}

.gsg-visor[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	animation: gsg-aparecer 0.22s ease-out;
}

@keyframes gsg-aparecer {
	from {
		opacity: 0;
	}
}

.gsg-visor__barra {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: max(10px, env(safe-area-inset-top)) 12px 6px 20px;
}

.gsg-visor__contador {
	margin: 0;
	font-size: 0.875rem;
	letter-spacing: 0.04em;
	font-variant-numeric: tabular-nums;
	color: rgba(246, 242, 234, 0.82);
}

.gsg-visor__escenario {
	position: relative;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 clamp(8px, 7vw, 96px);
	touch-action: pan-y pinch-zoom;
	user-select: none;
}

.gsg-visor__figura {
	margin: 0;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.gsg-visor .gsg-visor__img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	transition: opacity 0.2s ease;
}

.gsg-visor .gsg-visor__img.es-cargando {
	opacity: 0;
}

.gsg-visor__pie {
	margin: 0 auto;
	max-width: 72ch;
	min-height: 3.2em;
	padding: 12px 20px max(18px, env(safe-area-inset-bottom));
	text-align: center;
	font-size: 0.9375rem;
	line-height: 1.5;
	color: rgba(246, 242, 234, 0.9);
}

.gsg-visor__boton {
	display: inline-grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(246, 242, 234, 0.1);
	color: #f6f2ea;
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.gsg-visor__boton:hover {
	background: rgba(246, 242, 234, 0.22);
}

.gsg-visor__boton:focus-visible {
	outline: 3px solid #e0ae52;
	outline-offset: 2px;
}

.gsg-visor__boton svg {
	width: 24px;
	height: 24px;
}

.gsg-visor__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	transform: translateY(-50%);
	width: 56px;
	height: 56px;
}

.gsg-visor__nav--ant {
	left: clamp(6px, 2vw, 24px);
}

.gsg-visor__nav--sig {
	right: clamp(6px, 2vw, 24px);
}

.gsg-visor__nav[hidden] {
	display: none;
}

@media (max-width: 639px) {
	.gsg-visor__escenario {
		padding: 0;
	}
	.gsg-visor__nav {
		top: auto;
		bottom: 8px;
		transform: none;
		width: 48px;
		height: 48px;
		background: rgba(7, 26, 31, 0.6);
	}
}

/* ---------------------------------------------------------------------
 * Movimiento reducido
 * ------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.gsg-galeria *,
	.gsg-fotos *,
	.gsg-visor,
	.gsg-visor * {
		transition: none !important;
		animation: none !important;
	}
	.gsg-trabajo:hover .gsg-trabajo__img,
	.gsg-foto__enlace:hover .gsg-foto__img {
		transform: none;
	}
}
