/*
 * Onfocus Gallery frontend
 * Copyright (C) NSZZP Małopolska Team
 * License: GPLv2 or later
 */

.og-gallery,
.og-gallery * {
	box-sizing: border-box;
}

.og-gallery {
	width: 100%;
	clear: both;
}

.og-gallery.aligncenter {
	margin-inline: auto;
}

.og-gallery__item {
	position: relative;
	min-width: 0;
	margin: 0;
	overflow: hidden;
}

.og-gallery__media {
	position: relative;
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	overflow: hidden;
	background: #e9e9e9;
	color: inherit;
	font: inherit;
	text-align: inherit;
	text-decoration: none;
}

button.og-gallery__media {
	appearance: none;
	height: auto;
	min-height: 0;
	max-height: none;
	line-height: normal;
	cursor: zoom-in;
}

.og-gallery__image {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	transition: transform .25s ease, opacity .2s ease;
}

.og-gallery__link:hover .og-gallery__image {
	transform: scale(1.025);
}

.og-gallery__link:focus-visible {
	outline: 3px solid #2271b1;
	outline-offset: -3px;
}

/* Masonry opiera się wyłącznie na stabilnych kolumnach CSS. */
.og-gallery--masonry .og-gallery__grid {
	column-count: var(--og-columns, 3);
	column-gap: var(--og-gap, 10px);
}

.og-gallery--masonry .og-gallery__item {
	break-inside: avoid;
	margin-bottom: var(--og-gap, 10px);
}

.og-gallery--masonry .og-gallery__media {
	border-radius: inherit;
}

.og-gallery__caption {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: 5px;
	padding-inline: 2px;
	color: #555;
	font-size: .82rem;
	line-height: 1.4;
	text-align: center;
}

/* Creative: CSS Grid, pozycje i liczba kolumn są wyliczane lokalnie. */
.og-gallery--creative .og-gallery__grid {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	grid-auto-rows: var(--og-grid-row-size, clamp(32px, 6vw, 88px));
	gap: var(--og-gap, 10px);
}

.og-gallery--creative .og-gallery__item {
	grid-column: span var(--og-w, 2);
	grid-row: span var(--og-h, 2);
	min-height: 0;
}

.og-gallery--creative .og-gallery__media,
.og-gallery--creative .og-gallery__image {
	height: 100%;
}

.og-gallery--creative .og-gallery__image {
	object-fit: cover;
	object-position: var(--og-object-x, center) var(--og-object-y, center);
}

.og-gallery__overlay {
	position: absolute;
	inset: auto 0 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
	padding: clamp(10px, 3vw, 24px) clamp(10px, 2.5vw, 20px) 12px;
	background: linear-gradient(transparent, rgba(0, 0, 0, .78));
	color: #fff;
	text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
	transition: opacity .2s ease;
}

.og-gallery__title {
	font-size: clamp(.9rem, 1.5vw, 1.15rem);
	line-height: 1.25;
}

.og-gallery__description {
	font-size: clamp(.75rem, 1.2vw, .9rem);
	line-height: 1.35;
}

@media (hover: hover) {
	.og-gallery--creative .og-gallery__overlay {
		opacity: .12;
	}

	.og-gallery--creative .og-gallery__media:hover .og-gallery__overlay,
	.og-gallery--creative .og-gallery__media:focus-visible .og-gallery__overlay {
		opacity: 1;
	}
}

@media screen and (max-width: 900px) {
	.og-gallery--masonry .og-gallery__grid {
		column-count: min(var(--og-columns, 3), 2);
	}
}

@media screen and (max-width: 600px) {
	.og-gallery--masonry .og-gallery__grid {
		column-count: 1;
	}
}

/* Własny lightbox oparty na natywnym HTMLDialogElement. */
.og-lightbox {
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(10, 10, 12, .96);
	color: #fff;
	overflow: hidden;
}

.og-lightbox[open] {
	display: block;
}

.og-lightbox:focus {
	outline: 0;
}

.og-lightbox::backdrop {
	background: rgba(0, 0, 0, .88);
}

.og-lightbox__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	touch-action: none;
}

.og-lightbox__figure {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	margin: 0;
}

.og-lightbox__image {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	opacity: 0;
	cursor: zoom-in;
	transform-origin: center;
	user-select: none;
	-webkit-user-drag: none;
	will-change: transform;
	transition: opacity .18s ease, transform .12s ease-out;
}

.og-lightbox__image.is-loaded {
	opacity: 1;
}

.og-lightbox__stage.is-zoomed .og-lightbox__image {
	cursor: grab;
}

.og-lightbox__stage.is-panning .og-lightbox__image {
	cursor: grabbing;
	transition: opacity .18s ease;
}

.og-lightbox__stage.is-loading::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 34px;
	height: 34px;
	margin: -17px;
	border: 3px solid rgba(255, 255, 255, .28);
	border-top-color: #fff;
	border-radius: 50%;
	animation: og-spin .7s linear infinite;
}

.og-lightbox__toolbar {
	position: absolute;
	z-index: 2;
	top: 0;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 64px;
	pointer-events: none;
	background: linear-gradient(rgba(0, 0, 0, .42), transparent);
}

.og-lightbox__status {
	align-self: flex-start;
	margin: 13px 0 0 13px;
	font-variant-numeric: tabular-nums;
	font-size: clamp(20px, 1.45vw, 28px);
	font-weight: 400;
	line-height: 1.2;
	text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.og-lightbox__button {
	position: absolute;
	z-index: 3;
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .35);
	color: #fff;
	font: 300 54px/1 system-ui, sans-serif;
	font-size: 54px !important;
	line-height: 1 !important;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	transition: background .15s ease, transform .15s ease;
}

.og-lightbox__button svg {
	display: block;
	width: 64px;
	height: 64px;
	pointer-events: none;
}

.og-lightbox__button:hover {
	background: rgba(0, 0, 0, .76);
	transform: scale(1.04);
}

.og-lightbox__button:focus-visible {
	outline: 3px solid #72aee6;
	outline-offset: 2px;
}

.og-lightbox__close {
	top: 0;
	right: 0;
	border-radius: 0;
	background: rgba(255, 255, 255, .1);
	font-size: 48px !important;
	pointer-events: auto;
}

.og-lightbox__previous {
	left: clamp(8px, 8vw, 164px);
	top: 50%;
	background: rgba(34, 34, 36, .72);
	transform: translateY(-50%);
}

.og-lightbox__next {
	right: clamp(8px, 8vw, 164px);
	top: 50%;
	background: rgba(34, 34, 36, .72);
	transform: translateY(-50%);
}

.og-lightbox__previous:hover,
.og-lightbox__next:hover {
	transform: translateY(-50%) scale(1.04);
}

.og-lightbox__caption {
	position: absolute;
	z-index: 2;
	left: 50%;
	bottom: 16px;
	display: flex;
	flex-direction: column;
	gap: 3px;
	width: min(820px, calc(100% - 40px));
	padding: 12px 18px;
	border-radius: 4px;
	background: rgba(0, 0, 0, .58);
	text-align: center;
	transform: translateX(-50%);
}

.og-lightbox__caption[hidden],
.og-lightbox__button[hidden],
.og-lightbox__error[hidden] {
	display: none;
}

.og-lightbox__caption-title {
	font-size: 1rem;
}

.og-lightbox__caption-description {
	font-size: .86rem;
	line-height: 1.4;
}

.og-lightbox__error {
	position: absolute;
	padding: 12px 18px;
	border-radius: 4px;
	background: rgba(0, 0, 0, .65);
}

html.og-lightbox-open {
	overflow: hidden;
}

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

@media screen and (max-width: 600px) {
	.og-lightbox__stage {
		padding: 56px 6px 78px;
	}

	.og-lightbox__button {
		width: 50px;
		height: 50px;
		font-size: 43px !important;
	}

	.og-lightbox__button svg {
		width: 50px;
		height: 50px;
	}

	.og-lightbox__close {
		font-size: 38px !important;
	}

	.og-lightbox__previous {
		left: 8px;
	}

	.og-lightbox__next {
		right: 8px;
	}
}

@media (prefers-reduced-motion: reduce) {

	.og-gallery__image,
	.og-gallery__overlay,
	.og-lightbox__image,
	.og-lightbox__button {
		transition: none;
	}

	.og-lightbox__stage.is-loading::after {
		animation-duration: 1.4s;
	}
}