/*
 * INB Developer — lightbox.css (HOME v2)
 * REUSABLE CORE: powiększony podgląd obrazów kontenera z klasą .inb-lightbox (site.js, sekcja 6).
 * Natywny <dialog> otwierany przez showModal(): reszta strony jest nieaktywna (inert),
 * Escape zamyka, fokus wraca do przycisku, który otworzył podgląd.
 * Przyciski powiększenia (.inb-lightbox__open) tworzy JS — bez JS ich nie ma.
 * Kolory wyłącznie przez tokeny theme.json.
 */

/* Przycisk powiększenia na obrazie: pokrywa cały kadr, ikona w rogu. */
.inb-lightbox figure {
	position: relative;
}

.inb-lightbox__open {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: flex-end;
	justify-content: flex-end;
	padding: clamp(0.75rem, 0.5rem + 0.75vw, 1.25rem);
	border: 0;
	background: transparent;
	cursor: zoom-in;
	-webkit-tap-highlight-color: transparent;
}

.inb-lightbox__open-icon {
	display: grid;
	place-items: center;
	width: 2.75rem;
	height: 2.75rem;
	border-radius: 50%;
	background: color-mix(in srgb, var(--wp--custom--color--surface-dark) 72%, transparent);
	color: var(--wp--custom--color--on-dark);
	box-shadow: 0 0.5rem 1.25rem -0.5rem color-mix(in srgb, var(--wp--preset--color--primary-deep) 80%, transparent);
	transform: scale(0.9);
	opacity: 0.88;
	transition: transform var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing-out),
		opacity var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing),
		background-color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing);
}

.inb-lightbox__open svg,
.inb-lightbox-dialog svg {
	width: 1.25rem;
	height: 1.25rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/*
 * Obraz delikatnie przybliża się przy wskazaniu. Właściwość scale (nie transform), bo transform
 * należy do maski odsłonięcia (base.css, 6b); przejście łączy obie właściwości.
 */
.inb-lightbox figure img {
	transition: scale 900ms var(--wp--custom--motion--easing-out);
}

.inb-js .inb-lightbox .inb-mask img {
	transition: transform 2000ms var(--wp--custom--motion--easing-out) var(--inb-delay, 0ms),
		scale 900ms var(--wp--custom--motion--easing-out);
}

@media (hover: hover) {
	.inb-lightbox figure:hover img {
		scale: 1.035;
	}

	.inb-lightbox figure:hover .inb-lightbox__open-icon {
		transform: none;
		opacity: 1;
		background: var(--wp--custom--color--surface-dark);
	}
}

.inb-lightbox__open:focus-visible {
	outline: 3px solid var(--wp--custom--color--focus);
	outline-offset: -3px;
}

.inb-lightbox__open:focus-visible .inb-lightbox__open-icon {
	transform: none;
	opacity: 1;
	background: var(--wp--custom--color--surface-dark);
	outline: 2px solid var(--wp--custom--color--focus-on-dark);
	outline-offset: 2px;
}

.inb-lightbox__open:active .inb-lightbox__open-icon {
	transform: scale(0.92);
}

/* --- Okno podglądu --- */

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

/*
 * Geometria okna: dialog = pełny ekran (100dvh z fallbackiem 100vh), siatka [podgląd 1fr | podpis auto].
 * Podgląd (.inb-lightbox__stage) ma jawne, określone ścieżki siatki (minmax(0, 1fr)), więc max-width/max-height
 * obrazu liczą się od realnie dostępnego miejsca — obraz zawsze mieści się w całości, bez przycinania
 * i bez zniekształceń. (Wcześniej wiersz auto nie ograniczał obrazu: 1374×773 px w obszarze 1374×724 px.)
 */
.inb-lightbox-dialog {
	--inb-lb-pad-top: clamp(3.75rem, 2.5rem + 3vw, 5rem);
	--inb-lb-pad-inline: clamp(0.75rem, 0.25rem + 2vw, 2.5rem);
	--inb-lb-pad-bottom: clamp(1rem, 0.5rem + 1.5vw, 1.75rem);
	--inb-lb-edge: clamp(0.75rem, 0.5rem + 0.75vw, 1.25rem);
	box-sizing: border-box;
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-height: 100vh;
	max-height: 100dvh;
	margin: 0;
	padding: var(--inb-lb-pad-top) var(--inb-lb-pad-inline) var(--inb-lb-pad-bottom);
	border: 0;
	background: color-mix(in srgb, var(--wp--custom--color--surface-dark) 96%, transparent);
	color: var(--wp--custom--color--on-dark);
	font-family: var(--wp--preset--font-family--body);
	overflow: hidden;
}

.inb-lightbox-dialog[open] {
	display: grid;
	grid-template-rows: minmax(0, 1fr) auto;
	gap: clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
}

.inb-lightbox-dialog::backdrop {
	background: color-mix(in srgb, var(--wp--custom--color--surface-dark) 60%, transparent);
}

/* Podgląd: [strzałka | obraz | strzałka]; strzałki w marginesach obok obrazu, nie na nim. */
.inb-lightbox__stage {
	--inb-lb-nav: clamp(3.5rem, 2.25rem + 2.5vw, 5.5rem);
	display: grid;
	grid-template-columns: var(--inb-lb-nav) minmax(0, 1fr) var(--inb-lb-nav);
	grid-template-rows: minmax(0, 1fr);
	place-items: center;
	min-width: 0;
	min-height: 0;
	touch-action: pan-y;
	user-select: none;
}

.inb-lightbox__img {
	grid-area: 1 / 2;
	display: block;
	box-sizing: border-box;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	min-width: 0;
	min-height: 0;
	object-fit: contain;
	transition: opacity var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing);
}

.inb-lightbox__img.is-loading {
	opacity: 0;
}

.inb-lightbox__bar {
	width: min(100%, 64rem);
	margin-inline: auto;
}

.inb-lightbox__caption {
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.45;
	color: var(--wp--custom--color--on-dark-muted);
	text-align: center;
	text-wrap: balance;
}

.inb-lightbox__count {
	display: inline-block;
	margin-inline-end: 0.5rem;
	font-weight: var(--wp--custom--font-weight--bold);
	letter-spacing: 0.08em;
	color: var(--wp--custom--color--accent-on-dark);
	font-variant-numeric: tabular-nums;
}

.inb-lightbox__close {
	position: absolute;
	z-index: 2;
	top: var(--inb-lb-edge);
	right: var(--inb-lb-edge);
	display: grid;
	place-items: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 1px solid var(--wp--custom--color--rule-on-dark);
	border-radius: 50%;
	background: transparent;
	color: var(--wp--custom--color--on-dark);
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing),
		border-color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing),
		color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing),
		transform var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing-out);
}

/*
 * Strzałki poprzednie/następne: duży, smukły szewron bez obwódki, mocno przezroczysty;
 * przy wskazaniu — pełna widoczność, piaskowy akcent, delikatne zielone tło i lekkie przesunięcie w kierunku strzałki.
 */
.inb-lightbox__nav {
	position: relative;
	z-index: 1;
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 100%;
	min-width: 2.75rem;
	height: min(100%, 11rem);
	min-height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 0.75rem;
	background: transparent;
	color: var(--wp--custom--color--on-dark);
	opacity: 0.42;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: opacity var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing),
		color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing),
		background-color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing);
}

.inb-lightbox__nav--prev {
	grid-area: 1 / 1;
}

.inb-lightbox__nav--next {
	grid-area: 1 / 3;
}

.inb-lightbox__nav svg {
	width: clamp(1.125rem, 0.75rem + 0.9vw, 1.75rem);
	height: clamp(2.25rem, 1.5rem + 1.8vw, 3.5rem);
	stroke-width: 1.25;
	transition: transform var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing-out);
}

.inb-lightbox__nav path {
	vector-effect: non-scaling-stroke;
}

@media (hover: hover) {
	.inb-lightbox__close:hover {
		background: var(--wp--custom--color--on-dark);
		border-color: var(--wp--custom--color--on-dark);
		color: var(--wp--custom--color--surface-dark);
	}

	.inb-lightbox__nav:hover {
		opacity: 1;
		color: var(--wp--custom--color--accent-on-dark);
		background: color-mix(in srgb, var(--wp--preset--color--primary) 22%, transparent);
	}
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.inb-lightbox__nav--prev:hover svg { transform: translate3d(-0.3rem, 0, 0); }
	.inb-lightbox__nav--next:hover svg { transform: translate3d(0.3rem, 0, 0); }
}

.inb-lightbox__close:active {
	transform: scale(0.94);
}

.inb-lightbox__nav:active {
	opacity: 1;
	color: var(--wp--custom--color--accent-on-dark);
}

.inb-lightbox-dialog :focus-visible {
	outline: 2px solid var(--wp--custom--color--focus-on-dark);
	outline-offset: 3px;
}

/* Fokus z klawiatury: strzałka w pełni widoczna, z czytelnym tłem i obrysem. */
.inb-lightbox-dialog .inb-lightbox__nav:focus-visible {
	opacity: 1;
	color: var(--wp--custom--color--accent-on-dark);
	background: color-mix(in srgb, var(--wp--custom--color--surface-dark) 55%, var(--wp--preset--color--primary));
	outline-offset: -2px;
}

.inb-lightbox-dialog.is-single .inb-lightbox__nav {
	visibility: hidden;
}

/* Wejście okna (bez prefers-reduced-motion). */
@media (prefers-reduced-motion: no-preference) {
	.inb-lightbox-dialog[open] {
		animation: inb-lightbox-in 360ms var(--wp--custom--motion--easing-out) both;
	}

	.inb-lightbox-dialog[open] .inb-lightbox__stage {
		animation: inb-lightbox-zoom 520ms var(--wp--custom--motion--easing-out) both;
	}
}

@keyframes inb-lightbox-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes inb-lightbox-zoom {
	from { transform: scale(0.96); }
	to { transform: none; }
}

@media (max-width: 600px) {
	.inb-lightbox__caption .inb-lightbox__text {
		display: -webkit-box;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	/*
	 * Wąski ekran: obraz dostaje całą szerokość; strzałki przy krawędziach (częściowo w marginesie okna),
	 * nad obrazem tylko minimalnie, z lekkim tłem dla czytelności. Obszar dotykowy 2.75rem × 4rem (≥ 44 px).
	 */
	.inb-lightbox__stage {
		grid-template-columns: minmax(0, 1fr);
	}

	.inb-lightbox__img,
	.inb-lightbox__nav--prev,
	.inb-lightbox__nav--next {
		grid-area: 1 / 1;
	}

	.inb-lightbox__nav {
		width: 2.75rem;
		height: 4rem;
		opacity: 0.72;
		background: color-mix(in srgb, var(--wp--custom--color--surface-dark) 38%, transparent);
	}

	.inb-lightbox__nav--prev {
		justify-self: start;
		margin-inline-start: calc(-1 * var(--inb-lb-pad-inline) + 0.25rem);
	}

	.inb-lightbox__nav--next {
		justify-self: end;
		margin-inline-end: calc(-1 * var(--inb-lb-pad-inline) + 0.25rem);
	}

	.inb-lightbox__nav svg {
		width: 1rem;
		height: 2rem;
	}
}

/*
 * Niski ekran (laptop z małym oknem, telefon poziomo): mniej miejsca nad obrazem.
 * Przycisk zamknięcia siedzi wtedy w prawym górnym rogu nad kolumną strzałki — poza obszarem obrazu
 * (kolumna strzałki + margines ≥ odsunięcie + szerokość przycisku).
 */
@media (min-width: 601px) and (max-height: 560px) {
	.inb-lightbox-dialog {
		--inb-lb-pad-top: 0.75rem;
		--inb-lb-pad-bottom: 0.625rem;
		--inb-lb-edge: 0.5rem;
	}

	.inb-lightbox-dialog[open] {
		gap: 0.5rem;
	}

	.inb-lightbox__caption .inb-lightbox__text {
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}
}
