/* ===================================================================
   Siatka miniatur (opcjonalnie – możesz użyć własnej)
   =================================================================== */
.gallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
	gap: 1.2rem;
}
.gallery-grid a {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 1rem;
	background: #eef1f6;
	cursor: zoom-in;
}
.gallery-grid img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .4s cubic-bezier(.25, .8, .25, 1);
}
@media (hover: hover) {
	.gallery-grid a:hover img { transform: scale(1.05); }
}
.gallery-grid a:focus-visible { outline: 3px solid #0aa4e8; outline-offset: 3px; }

/* ===================================================================
   Okno galerii
   =================================================================== */
html.lb-open { overflow: hidden; }

.lb {
	--lb-bg: rgba(8, 12, 24, .97);
	--lb-fg: #fff;
	--lb-accent: #0aa4e8;
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--lb-bg);
	color: var(--lb-fg);
	display: grid;
	grid-template-rows: 1fr auto auto;
	overflow: hidden;
	animation: lb-in .25s ease-out;
	font-size: 15px;
	line-height: 1.4;
}
.lb:not([open]) { display: none; }
.lb::backdrop { background: rgba(8, 12, 24, .5); backdrop-filter: blur(6px); }
.lb--closing { animation: lb-out .2s ease-in forwards; }
@keyframes lb-in { from { opacity: 0; } }
@keyframes lb-out { to { opacity: 0; } }

/* Scena ze zdjęciem */
.lb__stage {
	grid-row: 1;
	display: grid;
	place-items: center;
	overflow: hidden;
	padding: 56px 72px 12px;
	min-height: 0;
	/* Jawny rozmiar komórki – dzięki temu max-height: 100% zdjęcia działa
	   i pionowe zdjęcia mieszczą się w całości zamiast być ucinane u dołu. */
	grid-template-rows: minmax(0, 1fr);
	grid-template-columns: minmax(0, 1fr);
	touch-action: pan-y pinch-zoom;
}
.lb__img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 6px;
	user-select: none;
	-webkit-user-drag: none;
	opacity: 0;
	transform: scale(.98);
	transition: opacity .25s ease, transform .25s ease;
	cursor: zoom-in;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
}
.lb__img.is-in { opacity: 1; transform: none; }
.lb__stage .lb__img[style*="translate"] { transition: none; }

/* Powiększenie: zdjęcie w naturalnym rozmiarze, przewijanie = przesuwanie */
.lb--zoom .lb__stage { overflow: auto; place-items: start; padding: 0; touch-action: auto; }
.lb--zoom .lb__img { max-width: none; max-height: none; border-radius: 0; cursor: zoom-out; margin: auto; }
.lb--zoom .lb__nav, .lb--zoom .lb__thumbs, .lb--zoom .lb__bar { opacity: 0; pointer-events: none; }

/* Wskaźnik ładowania */
.lb--loading .lb__stage::after {
	content: "";
	position: absolute;
	width: 40px;
	height: 40px;
	border: 3px solid rgba(255, 255, 255, .25);
	border-top-color: var(--lb-fg);
	border-radius: 50%;
	animation: lb-spin .8s linear infinite;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }

/* Przyciski */
.lb__btn {
	position: absolute;
	display: grid;
	place-items: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .1);
	color: var(--lb-fg);
	cursor: pointer;
	transition: background-color .2s, opacity .2s;
	z-index: 2;
}
.lb__btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb__btn:hover { background: rgba(255, 255, 255, .22); }
.lb__btn:focus-visible { outline: 3px solid var(--lb-accent); outline-offset: 2px; }
.lb__close { top: 12px; right: 12px; }
.lb__nav { top: calc(50% - 60px); }
.lb__prev { left: 12px; }
.lb__next { right: 12px; }
.lb--single .lb__nav, .lb--single .lb__toggle, .lb--single .lb__thumbs { display: none; }

/* Podpis + licznik */
.lb__bar {
	grid-row: 2;
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 8px 16px;
	min-height: 48px;
	transition: opacity .2s;
}
.lb__count { font-variant-numeric: tabular-nums; opacity: .7; white-space: nowrap; }
.lb__caption { flex: 1; margin: 0; text-align: center; }
.lb__toggle { position: static; width: 40px; height: 40px; }
.lb__toggle svg { width: 18px; height: 18px; }

/* Pasek miniatur */
.lb__thumbs {
	grid-row: 3;
	display: flex;
	gap: 8px;
	padding: 4px 16px 16px;
	overflow-x: auto;
	scrollbar-width: thin;
	justify-content: safe center;
	transition: opacity .2s;
}
.lb--nothumbs .lb__thumbs { display: none; }
.lb__thumb {
	flex: 0 0 auto;
	width: 72px;
	height: 54px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	background: #222;
	opacity: .55;
	cursor: pointer;
	transition: opacity .2s, border-color .2s;
}
.lb__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb__thumb:hover, .lb__thumb.is-active { opacity: 1; }
.lb__thumb.is-active { border-color: var(--lb-fg); }
.lb__thumb:focus-visible { outline: 2px solid var(--lb-accent); outline-offset: 2px; }

/* Telefony: strzałki nad dolnym paskiem, więcej miejsca na zdjęcie */
@media (max-width: 700px) {
	.lb__stage { padding: 56px 0 8px; }
	.lb__nav { top: auto; bottom: 12px; width: 44px; height: 44px; background: rgba(255, 255, 255, .14); }
	.lb__prev { left: 8px; }
	.lb__next { right: 8px; }
	.lb__bar { padding: 8px 60px; }
	.lb__thumbs { display: none; }
	.lb__toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.lb, .lb--closing, .lb__img { animation: none; transition: none; }
}
