/* Arkebuz – Galeria pełnoekranowa */

.agl-lock,
.agl-lock body {
	overflow: hidden;
}

.wp-block-gallery .wp-block-image img {
	cursor: zoom-in;
}

/* Nagłówek nad galerią (body p – żeby wygrać z marginesem `.entry-content p` motywu) */

body p.agl-heading {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 10px;
	font-size: 15px;
	line-height: 1.4;
}

.agl-heading__count {
	opacity: 0.65;
}

/*
 * Siatka: równe kafelki 4:3, 4 / 3 / 2 kolumny, wąskie odstępy.
 * Szerokości i odstępy z rdzenia WP mają specyficzność z #id, stąd !important.
 */

.wp-block-gallery.has-nested-images {
	display: grid;
	grid-template-columns: repeat( 4, minmax( 0, 1fr ) );
	gap: 8px !important;
}

.wp-block-gallery.has-nested-images > figcaption {
	grid-column: 1 / -1;
}

.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
	width: auto !important;
	margin: 0 !important;
	aspect-ratio: 4 / 3;
	border-radius: 6px;
	overflow: hidden;
}

.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.35s ease-out;
}

/* Ten sam efekt co na stronie „Galeria” (custom CSS w Elementorze). */
.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image):hover img {
	transform: scale( 1.05 );
}

@media ( max-width: 900px ) {
	.wp-block-gallery.has-nested-images {
		grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
	}
}

@media ( max-width: 600px ) {
	.wp-block-gallery.has-nested-images {
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
		gap: 4px !important;
	}

	.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) {
		border-radius: 4px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image) img,
	.wp-block-gallery > .wp-block-image.agl-show {
		transition: none;
		animation: none;
	}

	.wp-block-gallery.has-nested-images figure.wp-block-image:not(#individual-image):hover img {
		transform: none;
	}
}

/* Doładowywanie partiami: 12 = BATCH w lightbox.js. */
.agl-js .wp-block-gallery > .wp-block-image:nth-child(n+13):not(.agl-show) {
	display: none;
}

.wp-block-gallery > .wp-block-image.agl-show {
	animation: agl-fade-in 0.35s ease both;
}

@keyframes agl-fade-in {
	from {
		opacity: 0;
		transform: translateY( 8px );
	}
}

.agl-sentinel {
	height: 1px;
}

/* Okno galerii: pasek górny, zdjęcie, podpis, miniaturki. */

.agl {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: grid;
	grid-template-rows: 56px minmax( 0, 1fr ) auto auto;
	background: #0a0a0a;
	opacity: 0;
	transition: opacity 0.2s ease;
	-webkit-tap-highlight-color: transparent;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.agl[hidden] {
	display: none;
}

.agl.agl--open {
	opacity: 1;
}

.agl .agl__stage {
	position: relative;
	grid-row: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 0 80px;
	box-sizing: border-box;
}

.agl .agl__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	object-fit: contain;
	user-select: none;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.agl .agl__img.agl__img--ready {
	opacity: 1;
}

.agl .agl__spinner {
	position: absolute;
	display: none;
	width: 36px;
	height: 36px;
	border: 3px solid rgba( 255, 255, 255, 0.2 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: agl-spin 0.8s linear infinite;
}

.agl.agl--loading .agl__spinner {
	display: block;
}

@keyframes agl-spin {
	to {
		transform: rotate( 360deg );
	}
}

.agl .agl__caption {
	grid-row: 3;
	justify-self: center;
	max-width: 900px;
	padding: 10px 16px 0;
	color: #e6e6e6;
	font-size: 15px;
	line-height: 1.4;
	text-align: center;
}

.agl .agl__caption[hidden] {
	display: none;
}

.agl .agl__counter {
	position: absolute;
	top: 20px;
	left: 24px;
	color: #d0d0d0;
	font-size: 14px;
	line-height: 1;
	letter-spacing: 0.05em;
}

/* Miniaturki – pseudo-elementy z margin:auto centrują pasek, gdy jest krótki, i nie ucinają go, gdy jest długi. */

.agl .agl__thumbs {
	position: relative;
	grid-row: 4;
	display: flex;
	gap: 6px;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	padding: 12px 16px 14px;
	scrollbar-width: thin;
	scrollbar-color: rgba( 255, 255, 255, 0.25 ) transparent;
}

.agl .agl__thumbs::before,
.agl .agl__thumbs::after {
	content: "";
	margin: auto;
}

.agl .agl__thumb {
	flex: 0 0 auto;
	width: 72px;
	height: 54px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	overflow: hidden;
	background: #222;
	box-shadow: none;
	cursor: pointer;
	opacity: 0.45;
	transition: opacity 0.15s ease;
}

.agl .agl__thumb:hover,
.agl .agl__thumb:focus {
	background: #222;
	opacity: 0.85;
}

.agl .agl__thumb.is-active {
	opacity: 1;
	outline: 2px solid #fff;
	outline-offset: -2px;
}

.agl .agl__thumb:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.agl .agl__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	object-fit: cover;
	pointer-events: none;
}

/* Przyciski */

.agl .agl__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.1 );
	box-shadow: none;
	color: #fff;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease;
}

.agl .agl__btn:hover,
.agl .agl__btn:focus {
	background: rgba( 255, 255, 255, 0.22 );
	color: #fff;
	box-shadow: none;
}

.agl .agl__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.agl .agl__btn svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.agl .agl__close {
	top: 6px;
	right: 14px;
}

.agl .agl__prev,
.agl .agl__next {
	top: 50%;
	transform: translateY( -50% );
}

.agl .agl__prev {
	left: 16px;
}

.agl .agl__next {
	right: 16px;
}

.agl.agl--single .agl__prev,
.agl.agl--single .agl__next,
.agl.agl--single .agl__counter,
.agl.agl--single .agl__thumbs {
	display: none;
}

@media ( max-width: 600px ) {
	.agl .agl__stage {
		padding: 0;
	}

	.agl .agl__prev,
	.agl .agl__next {
		width: 40px;
		height: 40px;
		background: rgba( 0, 0, 0, 0.45 );
	}

	.agl .agl__prev {
		left: 8px;
	}

	.agl .agl__next {
		right: 8px;
	}

	.agl .agl__thumbs {
		gap: 4px;
		padding: 10px 8px 12px;
	}

	.agl .agl__thumb {
		width: 56px;
		height: 42px;
	}
}

/* Telefon poziomo: za mało miejsca na miniaturki. */
@media ( max-height: 500px ) {
	.agl .agl__thumbs {
		display: none;
	}
}
