/* ==========================================================================
   Carrusel de proyectos (galería con pestañas: Cocinas, Baños…)
   Rejilla de 4: en la 1.ª columna etiqueta → 15 → descripción → 30 → índice (15 entre filas);
   de la 2.ª a la 4.ª, las fotos en filas, a 15 entre ellas. Debajo, contador, raya y flechas (gg-ui).
   Medidas, colores y movimiento: los de gg-base.
   ========================================================================== */
.gi {
	--gi-vis: 3;
	margin: 0;
	color: var(--gg-marron);
}

/* ---------- Columna del índice ---------- */
.gi-filterbar {
	position: relative;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0 var(--gg-15);
	margin: 0 0 var(--gg-30);
}
.gi-filters {
	display: flex;
	gap: var(--gg-30);
	margin: 0;
	padding: 0;
	counter-reset: gitab;
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	flex: 1 1 0;
	min-width: 0;
}
.gi-filters::-webkit-scrollbar { display: none; }

/* Pestaña: número 01, 02… y nombre; gris, marrón al pasar y la activa, con su raya debajo */
.gi .gi-filter,
.gi .gi-filter:hover,
.gi .gi-filter:focus,
.gi .gi-filter:active {
	appearance: none;
	display: inline-flex;
	flex-direction: row;
	align-items: baseline;
	gap: var(--gg-15);
	margin: 0;
	padding: 0;
	min-height: 0;
	width: auto;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	background: none;
	font: inherit;
	font-size: var(--gg-texto);
	line-height: var(--gg-interlineado);
	text-align: left;
	text-decoration: none;
	white-space: nowrap;
	color: var(--gg-gris);
	cursor: pointer;
	transition: color var(--gg-color) var(--gg-curva);
}
.gi .gi-filter::before {
	counter-increment: gitab;
	content: counter(gitab, decimal-leading-zero);
	flex: 0 0 auto;
	min-width: 22px;
	font-variant-numeric: tabular-nums;
}
.gi .gi-filter:hover,
.gi .gi-filter.is-active { color: var(--gg-marron); }
.gi .gi-filter:focus-visible { outline: 1px solid var(--gg-marron); outline-offset: 3px; }
.gi .gi-ftxt { position: relative; }
.gi .gi-ftxt::before {
	content: "";
	position: absolute;
	left: 0;
	bottom: calc(.21em - 6px);
	width: 100%;
	border-top: 1px solid currentColor;
	transform: scaleX(0);
	transform-origin: 0 50%;
	transition: transform var(--gg-mueve) var(--gg-curva);
	pointer-events: none;
}
.gi .gi-filter:hover .gi-ftxt::before,
.gi .gi-filter.is-active .gi-ftxt::before { transform: scaleX(1); }

.gi-filterbar .gi-idx-label,
.gi-filterbar .gg-desc { flex: 0 0 100%; }

/* Flechas de las pestañas (tablet y móvil, cuando no caben) */
.gi .gi-fnav,
.gi .gi-fnav:hover,
.gi .gi-fnav:focus {
	appearance: none;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: 45px;
	height: 45px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	background: transparent;
	color: var(--gg-marron);
	cursor: pointer;
	transition: transform var(--gg-mueve) var(--gg-curva), color var(--gg-color);
}
.gi .gi-fnav::before,
.gi .gi-fnav::after { display: none !important; }
.gi .gi-fnav svg { display: block; width: 30px; height: 30px; }
.gi .gi-fnav svg * { vector-effect: non-scaling-stroke; }
.gi .gi-fnav--prev:not([disabled]):hover { transform: translateX(-4px); }
.gi .gi-fnav--next:not([disabled]):hover { transform: translateX(4px); }
.gi .gi-fnav[disabled] { color: var(--gg-gris); cursor: default; }
.gi .gi-fnav:focus-visible { outline: 1px solid var(--gg-marron); outline-offset: 2px; }

/* ---------- Fotos: carrusel de filas ---------- */
.gi .gi-grid {
	display: grid;
	grid-auto-flow: column;
	grid-template-rows: repeat(var(--gi-rows, 2), auto);
	grid-auto-columns: calc((100% - (var(--gi-vis) - 1) * var(--gg-entre-fotos)) / var(--gi-vis));
	gap: var(--gg-entre-fotos);
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}
.gi .gi-grid::-webkit-scrollbar { display: none; }
.gi .gi-item {
	position: relative;
	margin: 0;
	padding: 0;
	overflow: hidden;
	aspect-ratio: var(--gi-ratio, 3/2);
	scroll-snap-align: start;
	background: transparent;
}
.gi .gi-item::before { content: none; }
.gi .gi-item[hidden] { display: none; }
.gi .gi-link {
	display: block;
	width: 100%;
	height: 100%;
	overflow: hidden;
	color: inherit;
	text-decoration: none;
}
.gi img,
.gi .gi-item,
.gi .gi-link { border: 0 !important; box-shadow: none !important; outline: 0; border-radius: 0; }
/* La foto, 2 px más grande que su marco para que no asome nada */
.gi .gi-photo {
	display: block;
	width: calc(100% + 4px) !important;
	height: calc(100% + 4px) !important;
	max-width: none !important;
	margin: -2px !important;
	object-fit: cover;
	transition: transform 1.6s var(--gg-curva);
}
.gi a.gi-link:hover .gi-photo,
.gi a.gi-link:focus-visible .gi-photo { transform: scale(1.1); }
.gi a.gi-link:focus-visible { outline: 1px solid var(--gg-marron); outline-offset: 2px; }

/* Formato original (mosaico) */
.gi--auto .gi-item { aspect-ratio: auto; }
.gi--auto .gi-photo { height: auto !important; }

/* Entrada escalonada al filtrar */
.gi.is-waiting .gi-item { opacity: 0; }
.gi .gi-item.is-in {
	animation: gi-in var(--gg-mueve) var(--gg-curva) both;
	animation-delay: calc(var(--k, 0) * 60ms);
}
@keyframes gi-in { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: none; } }

/* ---------- Escritorio: índice en la columna 1, fotos de la 2 a la 4 ---------- */
@media (min-width: 981px) {
	.gi.gi--idx {
		display: grid;
		grid-template-columns: repeat(4, minmax(0, 1fr));
		column-gap: var(--gg-entre-fotos);
		align-items: start;
	}
	.gi.gi--idx > .gi-filterbar {
		grid-column: 1;
		grid-row: 1 / span 2;
		flex-direction: column;
		align-items: flex-start;
		margin: 0;
		padding-right: calc(var(--gg-texto-foto) - var(--gg-entre-fotos) / 2);
	}
	.gi.gi--idx > .gi-filterbar > :first-child { margin-top: calc(-1 * var(--gg-aire-arriba)); }
	.gi.gi--idx .gi-filters {
		flex-direction: column;
		gap: calc(var(--gg-15) - var(--gg-aire-abajo) - var(--gg-aire-arriba));
		overflow: visible;
		width: 100%;
	}
	.gi.gi--idx .gi-filter,
	.gi.gi--idx .gi-filter:hover,
	.gi.gi--idx .gi-filter:focus { display: flex; width: 100%; white-space: normal; }
	.gi.gi--idx .gi-fnav { display: none; }
	.gi.gi--idx > .gi-grid,
	.gi.gi--idx > .gi-ui { grid-column: 2 / span 3; }
}

/* ---------- Tablet y móvil: el índice arriba en horizontal, con sus flechas ---------- */
@media (max-width: 980px) {
	.gi { --gi-vis: 2.2; }
	.gi-filterbar .gg-desc:not(:last-child) { margin-bottom: var(--gg-15); }
}
@media (max-width: 640px) {
	.gi { --gi-vis: 1.25; }
}

@media (prefers-reduced-motion: reduce) {
	.gi .gi-item.is-in { animation: none; }
	.gi.is-waiting .gi-item { opacity: 1; }
	.gi .gi-photo, .gi .gi-ftxt::before, .gi .gi-fnav { transition: none; }
}
