/* ==========================================================================
   Sekcja: Galeria realizacji (Figma 1:966) — mozaika zdjęć z CPT `realizacja`
   Desktop: 4 kolumny, rzędy 256 px, odstęp 16 px; rzędy [mały, mały, szeroki] / [szeroki, mały, mały].
   Mobile (projekt własny): 2 kolumny — małe po 2 w rzędzie, szerokie na całą szerokość.
   ========================================================================== */

.gallery {
	--gallery-gap: 0.75rem;
	--gallery-row: clamp(140px, 42vw, 200px);
	--gallery-overlay: rgb(16 36 58 / 0.85);
}

/* Nagłówek: 30/36 px (Figma), odstęp do siatki 48 px, bez belki. */
.gallery__head {
	margin-bottom: clamp(2rem, 4vw, 3rem);
}

.gallery__head .section-head__heading {
	font-size: clamp(1.625rem, 1vw + 1.25rem, 1.875rem);
	line-height: 1.2;
	letter-spacing: -0.0166em;
}

/* Siatka */
.gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	grid-auto-rows: var(--gallery-row);
	gap: var(--gallery-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.gallery__item--wide,
.gallery__item--full {
	grid-column: 1 / -1;
}

@media (min-width: 768px) {
	.gallery {
		--gallery-gap: 1rem;
		--gallery-row: clamp(180px, 20vw, 256px);
	}

	.gallery__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.gallery__item--wide {
		grid-column: span 2;
	}
}

/* Wejście: miękkie pojawienie z rozmyciem (data-reveal="fade") + zdjęcie oddala się w środku
   (1.08 → 1), jak w „Naszych realizacjach”. Bez odsłaniania od dołu. Kaskada w rzędzie co 100 ms. */
.gallery__grid > .gallery__item:nth-child(3n + 2) {
	--reveal-delay: 100ms;
}

.gallery__grid > .gallery__item:nth-child(3n) {
	--reveal-delay: 200ms;
}

@keyframes optitek-gallery-image-in {
	from {
		transform: scale(1.08);
	}

	to {
		transform: none;
	}
}

.has-reveal .gallery__item[data-reveal].is-revealed .gallery__image {
	animation: optitek-gallery-image-in 1.15s var(--ease-out) var(--reveal-delay, 0ms) backwards;
}

/* Kafel */
.gallery__item {
	min-width: 0;
}

.gallery__link {
	position: relative;
	display: block;
	height: 100%;
	overflow: hidden;
	border-radius: var(--radius-lg);
	background: var(--color-bg-light);
	box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
	color: #fff;
	text-decoration: none;
	cursor: zoom-in;
	transition: box-shadow 0.4s ease;
}

.gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.6s var(--ease-out);
}

/* Podpis (tytuł zdjęcia) + okrągła ikona powiększenia */
.gallery__caption {
	position: absolute;
	inset: auto 0 0;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1rem;
	padding: 3.5rem 1.25rem 1.25rem;
	background: linear-gradient(to top, var(--gallery-overlay), rgb(16 36 58 / 0));
	transition: opacity 0.4s ease, transform 0.4s var(--ease-out);
}

.gallery__title {
	min-width: 0;
	font-family: var(--font-heading);
	font-size: 1.125rem;
	font-weight: 700;
	line-height: 1.35;
	text-wrap: balance;
}

.gallery__zoom {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 9999px;
	background: var(--color-accent);
	color: #fff;
	transition: transform 0.4s var(--ease-out);
}

.gallery__zoom-icon {
	width: 14px;
	height: 16px;
}

/* Urządzenia z kursorem: same zdjęcia (jak w Figmie), podpis i ikona dopiero na hover/focus. */
@media (hover: hover) {
	.gallery__caption {
		opacity: 0;
		transform: translateY(0.5rem);
	}

	.gallery__zoom {
		transform: scale(0.6) rotate(-90deg);
	}

	.gallery__link:hover,
	.gallery__link:focus-visible {
		box-shadow: var(--shadow-card-hover);
	}

	.gallery__link:hover .gallery__caption,
	.gallery__link:focus-visible .gallery__caption {
		opacity: 1;
		transform: none;
	}

	.gallery__link:hover .gallery__zoom,
	.gallery__link:focus-visible .gallery__zoom {
		transform: none;
	}

	.gallery__link:hover .gallery__image,
	.gallery__link:focus-visible .gallery__image {
		transform: scale(1.04);
	}
}

/* Ekrany dotykowe: małe kafle nie mieszczą podpisu — zostaje sama ikona w rogu (podpis w lightboxie). */
@media (hover: none) {
	.gallery__caption {
		padding: 0.625rem;
		background: none;
		justify-content: flex-end;
	}

	.gallery__title {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}

	.gallery__zoom {
		width: 32px;
		height: 32px;
		box-shadow: 0 4px 10px rgb(0 0 0 / 0.25);
	}

	.gallery__zoom-icon {
		width: 12px;
		height: 14px;
	}
}

/* Ostatni kafel, gdy w lightboxie jest więcej zdjęć niż na stronie: przyciemnienie + „+N zdjęć”
   (zawsze widoczne; na hover zostaje sama plakietka, bez podpisu zdjęcia). */
.gallery__more-badge {
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.125rem;
	background: rgb(16 36 58 / 0.62);
	color: #fff;
	text-align: center;
	transition: background-color 0.4s ease;
}

.gallery__more-count {
	font-family: var(--font-heading);
	font-size: clamp(2rem, 3vw + 1rem, 3rem);
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.02em;
}

.gallery__more-word {
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.gallery__link--more .gallery__caption {
	display: none;
}

.gallery__link--more:hover .gallery__more-badge,
.gallery__link--more:focus-visible .gallery__more-badge {
	background: rgb(16 36 58 / 0.74);
}

.gallery__link:focus-visible {
	outline: 3px solid var(--color-accent);
	outline-offset: 3px;
}

.gallery__more {
	display: flex;
	justify-content: center;
	margin-top: clamp(2.5rem, 5vw, 4rem);
}

@media (prefers-reduced-motion: reduce) {
	.gallery__image,
	.gallery__caption,
	.gallery__zoom {
		transition: none;
	}

	.has-reveal .gallery__item[data-reveal].is-revealed .gallery__image {
		animation: none !important;
	}

	.gallery__link:hover .gallery__image,
	.gallery__link:focus-visible .gallery__image {
		transform: none;
	}
}

/* ==========================================================================
   Układ „1 duże + 3 mniejsze” (pole „Układ” = bento) — Figma 1:1359 (Przewierty HDD):
   H2 36/40 wersalikami, 64 px do zdjęć; siatka 4 × 2 rzędy po 288 px, odstęp 24, promień 24.
   Duże 2×2 po lewej, po prawej dwa małe nad szerokim. Mobile: duże na całą szerokość,
   małe po 2 w rzędzie, szerokie pod nimi.
   ========================================================================== */
.gallery--bento .gallery__head {
	margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.gallery--bento .gallery__head .section-head__heading {
	font-size: var(--fs-h2);
	line-height: 1.11;
	letter-spacing: -0.025em;
}

.gallery--bento .gallery__link {
	border-radius: 16px;
	box-shadow: none;
}

.gallery--bento .gallery__item--big {
	grid-column: 1 / -1;
	grid-row: span 2;
}

@media (min-width: 768px) {
	.gallery--bento {
		--gallery-gap: 1.5rem;
		--gallery-row: clamp(180px, 22vw, 288px);
	}

	.gallery--bento .gallery__link {
		border-radius: 24px;
	}

	.gallery--bento .gallery__item--big {
		grid-column: span 2;
	}
}

/* Kaskada: duże → małe → szerokie. */
.gallery--bento .gallery__grid > .gallery__item:nth-child(n) {
	--reveal-delay: 0ms;
}

.gallery--bento .gallery__grid > .gallery__item:nth-child(2) {
	--reveal-delay: 120ms;
}

.gallery--bento .gallery__grid > .gallery__item:nth-child(3) {
	--reveal-delay: 200ms;
}

.gallery--bento .gallery__grid > .gallery__item:nth-child(4) {
	--reveal-delay: 280ms;
}

/* Figma 1:1359: sekcja z układem bento ma 128 px odstępu góra/dół (zamiast 96). */
.section--gallery:has(.gallery--bento) {
	padding-block: clamp(4rem, 9vw, 8rem);
}

/* ==========================================================================
   Układ „2 rzędy” (pole „Układ” = bento6) — Figma 136:60 (Prace ziemne): 6 zdjęć, bez nagłówka.
   ≥1024: 4 kolumny × 2 rzędy po 256 px, odstęp 16, promień 12, cień jak mozaika
   (rząd 1: mały, mały, szeroki · rząd 2: szeroki, mały, mały — rozpiętości liczy szablon).
   <1024 (projekt własny): 2 kolumny — małe parami, szerokie na całą szerokość, wyższe rzędy.
   ========================================================================== */
.gallery--bento6 {
	--gallery-row: clamp(150px, 40vw, 300px);
}

@media (min-width: 768px) {
	.gallery--bento6 .gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.gallery--bento6 .gallery__item--wide {
		grid-column: 1 / -1;
	}
}

@media (min-width: 1024px) {
	.gallery--bento6 {
		--gallery-row: clamp(200px, 20.8vw, 256px);
	}

	.gallery--bento6 .gallery__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.gallery--bento6 .gallery__item--wide {
		grid-column: span 2;
	}
}
