/* ===========================================================================
 *  Galeria pod wpisem - style frontowe
 *  TREJKA - https://trejka.com
 * ========================================================================= */

/* ===== Sekcja galerii ===== */
.gpw-gallery {
	margin: 2.5rem 0;
}
.gpw-gallery__title {
	font-size: 1.5rem;
	margin: 0 0 0.5rem;
}
.gpw-gallery__description {
	margin: 0 0 1.25rem;
	color: #555;
	line-height: 1.5;
}
.gpw-gallery__description p { margin: 0 0 0.5rem; }
.gpw-gallery__description p:last-child { margin-bottom: 0; }

/* ===== Siatka miniatur ===== */
.gpw-gallery__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 6px;
}
.gpw-gallery__grid[data-columns="3"] { grid-template-columns: repeat(3, 1fr); }
.gpw-gallery__grid[data-columns="4"] { grid-template-columns: repeat(4, 1fr); }
.gpw-gallery__grid[data-columns="5"] { grid-template-columns: repeat(5, 1fr); }
.gpw-gallery__grid[data-columns="6"] { grid-template-columns: repeat(6, 1fr); }

/* Wyrównanie itemów do góry, by podpisy o różnych wysokościach nie psuły siatki */
.gpw-gallery__grid { align-items: start; }

/* ===== Pojedynczy element ===== */
.gpw-gallery__figure {
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}
.gpw-gallery__item {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: 4px;
	background: #f0f0f0;
}

/* Proporcje miniatur */
.gpw-gallery__grid[data-ratio="1-1"]      .gpw-gallery__item { aspect-ratio: 1 / 1; }
.gpw-gallery__grid[data-ratio="4-3"]      .gpw-gallery__item { aspect-ratio: 4 / 3; }
.gpw-gallery__grid[data-ratio="16-9"]     .gpw-gallery__item { aspect-ratio: 16 / 9; }
/* Oryginalna proporcja - obraz definiuje wysokość */
.gpw-gallery__grid[data-ratio="original"] .gpw-gallery__item {
	aspect-ratio: auto;
	background: transparent;
}
.gpw-gallery__grid[data-ratio="original"] .gpw-gallery__item img {
	height: auto !important;
	object-fit: initial !important;
}

.gpw-gallery__item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}
.gpw-gallery__item:hover img { transform: scale(1.05); }
.gpw-gallery__item:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: 2px;
}

/* ===== Podpisy pod miniaturami ===== */
.gpw-gallery__caption {
	font-size: 0.85rem;
	color: #555;
	line-height: 1.35;
	padding: 0 2px;
}

/* ===== Responsywność siatki ===== */
@media (max-width: 900px) {
	.gpw-gallery__grid[data-columns="5"],
	.gpw-gallery__grid[data-columns="6"] { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
	.gpw-gallery__grid { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 400px) {
	.gpw-gallery__grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ===========================================================================
 *  Lightbox
 * ========================================================================= */
.gpw-lightbox {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.92);
	display: none;
	z-index: 99999;
	padding: 1.5rem;
}
.gpw-lightbox.is-open { display: block; }
.gpw-lightbox__inner {
	display: flex;
	gap: 1rem;
	width: 100%;
	height: 100%;
	align-items: stretch;
}
.gpw-lightbox__main {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}
.gpw-lightbox__img {
	max-width: 100%;
	max-height: calc(100vh - 6rem);
	object-fit: contain;
	box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* Licznik 3 / 15 */
.gpw-lightbox__counter {
	position: fixed;
	top: 1rem;
	left: 1rem;
	color: #fff;
	background: rgba(255,255,255,0.12);
	padding: 0.4rem 0.85rem;
	border-radius: 999px;
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
	z-index: 2;
}

/* Caption / tytuł zdjęcia */
.gpw-lightbox__caption {
	position: absolute;
	bottom: 0.5rem;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	background: rgba(0,0,0,0.65);
	padding: 0.4rem 0.9rem;
	border-radius: 4px;
	max-width: 80%;
	text-align: center;
	font-size: 0.85rem;
	line-height: 1.3;
}
.gpw-lightbox__caption:empty { display: none; }

/* ===== Pasek miniatur z prawej ===== */
.gpw-lightbox__thumbs {
	flex: 0 0 110px;
	width: 110px;
	overflow-y: auto;
	overflow-x: hidden;
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 2px;
	scrollbar-width: thin;
	scrollbar-color: rgba(255,255,255,0.4) transparent;
}
.gpw-lightbox__thumbs::-webkit-scrollbar { width: 8px; }
.gpw-lightbox__thumbs::-webkit-scrollbar-track { background: transparent; }
.gpw-lightbox__thumbs::-webkit-scrollbar-thumb {
	background: rgba(255,255,255,0.3);
	border-radius: 4px;
}
.gpw-lightbox__thumb {
	flex: 0 0 auto;
	width: 100%;
	aspect-ratio: 1 / 1;
	border: 2px solid transparent;
	border-radius: 4px;
	overflow: hidden;
	cursor: pointer;
	background: none;
	padding: 0;
	opacity: 0.55;
	transition: opacity 0.2s, border-color 0.2s;
}
.gpw-lightbox__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.gpw-lightbox__thumb:hover { opacity: 0.85; }
.gpw-lightbox__thumb.is-active {
	opacity: 1;
	border-color: #fff;
}
.gpw-lightbox__thumb:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* ===== Przyciski sterujące ===== */
.gpw-lightbox__close,
.gpw-lightbox__prev,
.gpw-lightbox__next {
	position: absolute;
	background: rgba(255,255,255,0.12);
	border: none;
	color: #fff;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 1.5rem;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	z-index: 2;
}
.gpw-lightbox__close:hover,
.gpw-lightbox__prev:hover,
.gpw-lightbox__next:hover { background: rgba(255,255,255,0.28); }
.gpw-lightbox__close {
	position: fixed;
	top: 1rem;
	right: 1rem;
}
.gpw-lightbox__prev { left: 0.5rem; top: 50%; transform: translateY(-50%); }
.gpw-lightbox__next { right: 0.5rem; top: 50%; transform: translateY(-50%); }

/* ===== Mobile: miniatury na dole, licznik mniejszy ===== */
@media (max-width: 768px) {
	.gpw-lightbox { padding: 1rem; }
	.gpw-lightbox__inner { flex-direction: column; }
	.gpw-lightbox__main { flex: 1 1 auto; min-height: 0; }
	.gpw-lightbox__img { max-height: calc(100vh - 12rem); }
	.gpw-lightbox__thumbs {
		flex: 0 0 80px;
		width: 100%;
		height: 80px;
		flex-direction: row;
		overflow-x: auto;
		overflow-y: hidden;
	}
	.gpw-lightbox__thumb {
		flex: 0 0 80px;
		width: 80px;
		height: 80px;
	}
	.gpw-lightbox__counter {
		top: 0.5rem;
		left: 0.5rem;
		font-size: 0.75rem;
		padding: 0.3rem 0.65rem;
	}
}
@media (max-width: 480px) {
	.gpw-lightbox__thumbs { display: none; }
}
