/**
 * Argo Gallery — style lightboxa karty produktu.
 * Wstrzykiwane eventem razem z gallery.js (extension/argo/gallery::inject).
 * Prefiks agx-, zero zależności od Bootstrapa/motywu, działa na każdym szablonie.
 */

/* --- blokada scrolla tła (kompensacja paska przewijania w --agx-sbw) --- */
html.agx-lock { overflow: hidden; }
html.agx-lock body { overflow: hidden; padding-right: var(--agx-sbw, 0); }

/* ------------------------------------------------------------------ root */
.agx-root {
	position: fixed;
	inset: 0;
	z-index: 99990;
	display: none;
	-webkit-tap-highlight-color: transparent;
	font: 13px/1.4 Arial, "Helvetica Neue", Helvetica, sans-serif;
	color: #ccc;
	user-select: none;
	-webkit-user-select: none;
	touch-action: none;
}
.agx-root.is-open { display: block; }

.agx-bg {
	position: absolute;
	inset: 0;
	background: #1e1e1e;
	opacity: 0;
	transition: opacity .25s cubic-bezier(.22,.61,.36,1);
}
.agx-root.is-open .agx-bg { opacity: calc(.87 * var(--agx-fade, 1)); }

/* --------------------------------------------------------------- licznik */
.agx-counter {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 99997;
	height: 44px;
	min-width: 44px;
	padding: 0 12px;
	line-height: 44px;
	text-align: center;
	font-size: 13px;
	color: #ccc;
	pointer-events: none;
}

/* czytnik ekranu — wizualnie ukryty */
.agx-live {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* --------------------------------------------------------------- toolbar */
.agx-toolbar {
	position: absolute;
	top: 0;
	right: 0;
	z-index: 99997;
	display: flex;
}

.agx-btn {
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 10px;
	border: 0;
	border-radius: 0;
	background: rgba(30, 30, 30, .6);
	color: #ccc;
	cursor: pointer;
	transition: color .2s;
}
.agx-btn:hover,
.agx-btn:focus-visible { color: #fff; }
.agx-btn:focus { outline: none; }
.agx-btn:focus-visible { outline: 1px dotted #ccc; outline-offset: -4px; }
.agx-btn svg { display: block; width: 100%; height: 100%; }

/* lupka: w powiększeniu chowamy pionową kreskę plusa → minus */
.agx-btn-zoom.is-out .agx-zoom-v { display: none; }

/* --------------------------------------------------------------- strzałki */
.agx-nav {
	position: absolute;
	top: 50%;
	z-index: 99996;
	width: 60px;
	height: 100px;
	margin-top: -50px;
	padding: 31px 13px;
	border: 0;
	background: transparent;
	color: #ccc;
	cursor: pointer;
	transition: color .2s;
}
.agx-nav:hover, .agx-nav:focus-visible { color: #fff; }
.agx-nav:focus { outline: none; }
.agx-nav svg {
	display: block;
	width: 34px;
	height: 38px;
	padding: 5px;
	background: rgba(30, 30, 30, .6);
}
.agx-nav--prev { left: 0; }
.agx-nav--next { right: 0; }

/* ----------------------------------------------------------------- scena */
.agx-stage {
	position: absolute;
	inset: 0;
	z-index: 99994;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}
/* (kolumna miniatur zwęża scenę — reguła przy .agx-thumbs niżej) */

.agx-img {
	display: block;
	max-width: calc(100% - 24px);
	max-height: calc(100% - 24px);
	width: auto;
	height: auto;
	box-shadow: 0 6px 36px rgba(0, 0, 0, .55);
	cursor: zoom-in;
	opacity: 0;
	transition: transform .25s cubic-bezier(.22,.61,.36,1), opacity .2s ease;
	will-change: transform, opacity;
}
.agx-img.agx-moving { transition: opacity .2s ease; }
.agx-root.is-zoomed .agx-img { cursor: grab; }

/* animacja wejścia slajdu — kierunek z data-agx-dir */
.agx-img[data-agx-dir="1"]  { transform: translateX(42px); }
.agx-img[data-agx-dir="-1"] { transform: translateX(-42px); }
.agx-img[data-agx-dir="0"]  { transform: scale(.96); }
.agx-img.agx-in { opacity: 1; transform: translate(0, 0) scale(1); }

.agx-root.is-loading .agx-img { opacity: 0; }

/* --------------------------------------------------------------- spinner */
.agx-spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 50px;
	height: 50px;
	margin: -25px 0 0 -25px;
	border: 5px solid rgba(100, 100, 100, .4);
	border-top-color: rgba(255, 255, 255, .7);
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
	animation: agx-rotate .8s infinite linear;
}
.agx-root.is-loading .agx-spinner { opacity: 1; }

@keyframes agx-rotate { to { transform: rotate(359deg); } }

.agx-error {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	padding: 14px 22px;
	background: rgba(30, 30, 30, .85);
	color: #eee;
	font-size: 14px;
}

/* ------------------------------------- kolumna miniatur (prawa, wzór fancybox) */
.agx-thumbs {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 99995;
	width: 212px;
	display: flex;
	flex-wrap: wrap;
	align-content: flex-start;
	justify-content: center;
	gap: 4px;
	padding: 52px 6px 8px;   /* kafelki startują pod toolbarem */
	overflow-y: auto;
	overflow-x: hidden;
	background: rgba(20, 20, 20, .55);
	transform: translateX(100%);
	transition: transform .25s ease;
	scrollbar-width: thin;
	scrollbar-color: #555 transparent;
}
.agx-root.agx-thumbs-open .agx-thumbs { transform: translateX(0); }

/* otwarta kolumna zwęża scenę i dosuwa strzałkę next */
.agx-root.agx-thumbs-open .agx-stage { right: 212px; }
.agx-root.agx-thumbs-open .agx-nav--next { right: 212px; }

.agx-thumb {
	flex: 0 0 auto;
	width: 96px;
	height: 72px;
	padding: 0;
	border: 0;
	background: #111;
	cursor: pointer;
	position: relative;
	opacity: .75;
	transition: opacity .2s;
}
.agx-thumb:hover, .agx-thumb:focus-visible { opacity: 1; }
.agx-thumb:focus { outline: none; }
.agx-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.agx-thumb::after {
	content: '';
	position: absolute;
	inset: 0;
	border: 2px solid transparent;
	transition: border-color .2s;
}
.agx-thumb.is-active { opacity: 1; }
.agx-thumb.is-active::after { border-color: #4ea7f9; }

/* auto-otwarcie kolumny na szerokich ekranach */
@media (min-width: 768px) {
	.agx-root.agx-thumbs-auto .agx-thumbs { transform: translateX(0); }
	.agx-root.agx-thumbs-auto .agx-stage { right: 212px; }
	.agx-root.agx-thumbs-auto .agx-nav--next { right: 212px; }
}

/* ------------------------------------------------------------ mobile */
@media (max-width: 767px) {
	.agx-btn { width: 40px; height: 40px; padding: 9px; }
	.agx-counter { height: 40px; line-height: 40px; }
	.agx-nav { width: 46px; padding: 31px 6px; }
	/* wąska kolumna jak w fancybox ≤800px: 110px, kafelki 1 w rzędzie */
	.agx-thumbs { width: 110px; padding-top: 48px; }
	.agx-thumb { width: 94px; height: 70px; }
	.agx-root.agx-thumbs-open .agx-stage { right: 110px; }
	.agx-root.agx-thumbs-open .agx-nav--next { right: 110px; }
}

/* --------------------------------------------------- dostępność / print */
@media (prefers-reduced-motion: reduce) {
	.agx-bg, .agx-img, .agx-thumbs, .agx-btn, .agx-nav, .agx-thumb { transition: none !important; }
	.agx-spinner { animation-duration: 1.6s; }
}

@media print {
	.agx-root { display: none !important; }
}
