/*
 * Themeshawk Product Gallery – front end
 * Layout differences between thumbnail positions are driven by custom properties
 * (--tspg-dir, --tspg-vert, --tspg-tw …) that the plugin prints per position and
 * per mobile breakpoint, so this file contains no position-specific rules.
 */

.tspg {
	/* Defaults – every value is overridden inline by the plugin settings. */
	--tspg-thumb: 84px;
	--tspg-gap: 10px;
	--tspg-cols-d: 5;
	--tspg-cols-m: 4;
	--tspg-side-cols: 1;
	--tspg-thumb-ratio: 1 / 1;
	--tspg-main-ratio: 1 / 1;
	--tspg-fit: contain;
	--tspg-tfit: cover;
	--tspg-radius: 6px;
	--tspg-tradius: 6px;
	--tspg-active: #111;
	--tspg-border: #e2e2e2;
	--tspg-inactive: .7;
	--tspg-bg: #fff;
	--tspg-zoom: 2;
	--tspg-sticky: 30px;
	--tspg-aop: 1;

	/* Derived. */
	--tspg-cols: var(--tspg-cols-d);
	--tspg-side-w: calc(var(--tspg-side-cols) * var(--tspg-thumb) + (var(--tspg-side-cols) - 1) * var(--tspg-gap));

	/* Position fallbacks (bottom) in case the dynamic CSS is missing. */
	--tspg-dir: column;
	--tspg-vert: 0;
	--tspg-tw: 100%;
	--tspg-vp: relative;
	--tspg-flow: row;
	--tspg-ox: auto;
	--tspg-oy: hidden;
	--tspg-gcols: repeat(var(--tspg-cols), minmax(0, 1fr));
	--tspg-tflex: 0 0 calc((100% - (var(--tspg-cols) - 1) * var(--tspg-gap)) / var(--tspg-cols));

	position: relative;
	box-sizing: border-box;
	direction: ltr;
	max-width: 100%;
	min-width: 0;
	-webkit-tap-highlight-color: transparent;
}

.tspg *,
.tspg *::before,
.tspg *::after {
	box-sizing: border-box;
}

.tspg.tspg--sticky {
	position: sticky;
	top: var(--tspg-sticky);
	align-self: flex-start;
}

.tspg--arrows-hover { --tspg-aop: 0; }
.tspg--arrows-hover .tspg__main:hover,
.tspg--arrows-hover .tspg__main:focus-within { --tspg-aop: 1; }
.tspg.tspg--arrows-never button.tspg__arrow { display: none; }

@media (hover: none) {
	.tspg--arrows-hover { --tspg-aop: 1; }
}

/* ---------- Layout ---------- */

.tspg .tspg__inner {
	display: flex;
	flex-direction: var(--tspg-dir);
	align-items: stretch;
	gap: var(--tspg-gap);
	margin: 0;
	padding: 0;
}

.tspg .tspg__main {
	position: relative;
	flex: 1 1 auto;
	width: 100%;
	min-width: 0;
}

.tspg .tspg__thumbs {
	position: relative;
	flex: 0 0 auto;
	width: var(--tspg-tw);
	min-width: 0;
}

.tspg--no-thumbs .tspg__inner { gap: 0; }

/* ---------- Main viewport ---------- */

.tspg .tspg__viewport {
	position: relative;
	overflow: hidden;
	border-radius: var(--tspg-radius);
	background: var(--tspg-bg);
	touch-action: pan-y;
	transition: height .3s ease;
}

.tspg.tspg--ratio-fixed .tspg__viewport {
	aspect-ratio: var(--tspg-main-ratio);
}

.tspg .tspg__track {
	display: flex;
	align-items: flex-start;
	height: 100%;
	margin: 0;
	padding: 0;
	transition: transform .4s cubic-bezier(.22, .61, .36, 1);
	will-change: transform;
}

.tspg.tspg--ratio-fixed .tspg__track { align-items: stretch; }

.tspg .tspg__track.is-dragging,
.tspg .tspg__track.is-instant {
	transition: none;
}

.tspg .tspg__slide {
	position: relative;
	flex: 0 0 100%;
	width: 100%;
	min-width: 0;
	margin: 0;
	padding: 0;
	overflow: hidden;
	background: var(--tspg-bg);
	-webkit-user-select: none;
	user-select: none;
}

.tspg--lightbox .tspg__slide[data-type="image"] { cursor: zoom-in; }
.tspg--lightbox:not(.tspg--zoom) .tspg__slide[data-type="image"] { cursor: pointer; }

.tspg .tspg__slide img.tspg__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	-webkit-user-drag: none;
}

.tspg.tspg--ratio-fixed .tspg__slide { height: 100%; }

.tspg.tspg--ratio-fixed .tspg__slide img.tspg__img {
	height: 100%;
	object-fit: var(--tspg-fit);
}

/* Hover zoom layer (created lazily by JS). */
.tspg .tspg__slide img.tspg__zoom {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: var(--tspg-fit);
	background: var(--tspg-bg);
	opacity: 0;
	pointer-events: none;
	transform-origin: 50% 50%;
	transition: transform .25s ease, opacity .2s ease;
}

.tspg .tspg__slide.is-zooming img.tspg__zoom.is-ready {
	opacity: 1;
	transform: scale(var(--tspg-zoom));
}

/* ---------- Buttons: reset against aggressive theme button styles ---------- */

.tspg button,
.tspg button:hover,
.tspg button:focus,
.tspg button:active {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	text-decoration: none;
	min-width: 0;
	min-height: 0;
	height: auto;
	width: auto;
	float: none;
	cursor: pointer;
	outline: 0;
}

.tspg button:focus-visible {
	outline: 2px solid var(--tspg-active);
	outline-offset: 2px;
}

.tspg .tspg__icon {
	display: block;
	flex: none;
	pointer-events: none;
}

/* ---------- Main arrows / expand ---------- */

.tspg button.tspg__arrow,
.tspg button.tspg__expand,
.tspg button.tspg__tnav {
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(255, 255, 255, .94);
	color: #111;
	box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
	transition: opacity .2s ease, transform .2s ease, background-color .2s ease;
}

.tspg button.tspg__arrow:hover,
.tspg button.tspg__expand:hover,
.tspg button.tspg__tnav:hover {
	background: #fff;
	color: #000;
}

.tspg button.tspg__arrow {
	position: absolute;
	top: 50%;
	z-index: 3;
	width: 40px;
	height: 40px;
	margin-top: -20px;
	opacity: var(--tspg-aop);
}

.tspg button.tspg__arrow--prev { left: 10px; }
.tspg button.tspg__arrow--next { right: 10px; }
.tspg button.tspg__arrow:hover { transform: scale(1.08); }

.tspg button.tspg__arrow[disabled] {
	opacity: calc(var(--tspg-aop) * .35);
	cursor: default;
	pointer-events: none;
}

.tspg button.tspg__expand {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	width: 38px;
	height: 38px;
}

/* ---------- Dots ---------- */

.tspg .tspg__dots {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 10px;
	z-index: 3;
	display: none;
	justify-content: center;
	gap: 7px;
	pointer-events: none;
}

.tspg--dots-always .tspg__dots { display: flex; }

.tspg button.tspg__dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: rgba(0, 0, 0, .3);
	box-shadow: 0 0 0 1px rgba(255, 255, 255, .7);
	pointer-events: auto;
	transition: width .2s ease, background-color .2s ease;
}

.tspg button.tspg__dot:hover { background: rgba(0, 0, 0, .5); }

.tspg button.tspg__dot.is-active {
	width: 20px;
	border-radius: 4px;
	background: var(--tspg-active);
}

/* ---------- Thumbnails ---------- */

.tspg .tspg__thumbs-viewport {
	position: var(--tspg-vp);
	inset: 0;
	overflow-x: var(--tspg-ox);
	overflow-y: var(--tspg-oy);
	overscroll-behavior: contain;
	scroll-behavior: smooth;
	scrollbar-width: none;
}

.tspg .tspg__thumbs-viewport::-webkit-scrollbar { display: none; }

/* Grid / show-more lists scroll inside the column; hint at hidden rows with an edge fade. */
.tspg.tspg--style-grid.has-thumb-overflow .tspg__thumbs-viewport,
.tspg.tspg--style-more.has-thumb-overflow .tspg__thumbs-viewport {
	-webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 0, #000 calc(100% - 34px), transparent 100%);
	mask-image: linear-gradient(to bottom, transparent 0, #000 0, #000 calc(100% - 34px), transparent 100%);
}

.tspg.tspg--style-grid.has-thumb-overflow.thumbs-at-end .tspg__thumbs-viewport,
.tspg.tspg--style-more.has-thumb-overflow.thumbs-at-end .tspg__thumbs-viewport {
	-webkit-mask-image: none;
	mask-image: none;
}

.tspg .tspg__thumbs-track {
	display: flex;
	flex-direction: var(--tspg-flow);
	align-items: flex-start;
	gap: var(--tspg-gap);
	margin: 0;
	padding: 0;
}

.tspg--style-grid .tspg__thumbs-track,
.tspg--style-more .tspg__thumbs-track {
	display: grid;
	grid-template-columns: var(--tspg-gcols);
	align-items: start;
}

.tspg button.tspg__thumb {
	position: relative;
	display: block;
	flex: var(--tspg-tflex);
	width: 100%;
	aspect-ratio: var(--tspg-thumb-ratio);
	overflow: hidden;
	border-radius: var(--tspg-tradius);
	background: var(--tspg-bg);
	opacity: var(--tspg-inactive);
	transition: opacity .2s ease;
}

.tspg button.tspg__thumb:hover,
.tspg button.tspg__thumb.is-active {
	opacity: 1;
}

.tspg button.tspg__thumb img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: var(--tspg-tfit);
	-webkit-user-drag: none;
}

/* Border drawn inside the thumb so scroll containers never clip it. */
.tspg button.tspg__thumb::after {
	content: "";
	position: absolute;
	inset: 0;
	border: 1px solid var(--tspg-border);
	border-radius: inherit;
	pointer-events: none;
	transition: border-color .2s ease;
}

.tspg button.tspg__thumb.is-active::after {
	border: 2px solid var(--tspg-active);
}

.tspg button.tspg__thumb:focus-visible { outline-offset: -3px; }

.tspg .tspg__thumb-play {
	position: absolute;
	left: 50%;
	top: 50%;
	z-index: 1;
	width: 26px;
	height: 26px;
	margin: -13px 0 0 -13px;
	border-radius: 50%;
	background: rgba(0, 0, 0, .65);
}

.tspg .tspg__thumb-play::before {
	content: "";
	position: absolute;
	left: 10px;
	top: 7px;
	border-style: solid;
	border-width: 6px 0 6px 9px;
	border-color: transparent transparent transparent #fff;
}

/* ---------- Show more ---------- */

.tspg .tspg__more-badge {
	position: absolute;
	inset: 0;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .58);
	color: #fff;
	font-size: 16px;
	font-weight: inherit;
	letter-spacing: .02em;
}

.tspg--style-more:not(.is-expanded) .tspg__thumb.has-more .tspg__more-badge { display: flex; }
.tspg--style-more:not(.is-expanded) .tspg__thumb--extra { display: none !important; }

.tspg button.tspg__toggle {
	display: block;
	grid-column: 1 / -1;
	width: 100%;
	padding: 9px 12px;
	border: 1px solid var(--tspg-border);
	border-radius: var(--tspg-tradius);
	background: #fff;
	color: #111;
	font-size: 13px;
	font-weight: inherit;
	text-align: center;
	transition: border-color .2s ease;
}

.tspg button.tspg__toggle:hover {
	border-color: var(--tspg-active);
	background: #fff;
	color: #111;
}

.tspg--more-overlay:not(.is-expanded) button.tspg__toggle { display: none; }

/* ---------- Thumbnail slider arrows ---------- */

.tspg button.tspg__tnav {
	position: absolute;
	z-index: 4;
	display: none;
	width: 28px;
	height: 28px;
	left: 4px;
	top: 50%;
	margin-top: -14px;
	box-shadow: 0 1px 6px rgba(0, 0, 0, .28);
}

.tspg button.tspg__tnav--next { left: auto; right: 4px; }
.tspg.has-thumb-overflow button.tspg__tnav { display: flex; }
.tspg button.tspg__tnav .tspg__icon { width: 16px; height: 16px; }

.tspg.is-vert button.tspg__tnav,
.tspg.is-vert button.tspg__tnav--next {
	left: 50%;
	right: auto;
	top: 4px;
	margin: 0 0 0 -14px;
}

.tspg.is-vert button.tspg__tnav--next { top: auto; bottom: 4px; }
.tspg.is-vert button.tspg__tnav .tspg__icon { transform: rotate(90deg); }

.tspg button.tspg__tnav[disabled] {
	opacity: 0;
	pointer-events: none;
}

/* ---------- Video ---------- */

.tspg button.tspg__play {
	position: absolute;
	left: 50%;
	top: 50%;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 68px;
	height: 68px;
	margin: -34px 0 0 -34px;
	border-radius: 50%;
	background: rgba(0, 0, 0, .66);
	color: #fff;
	transition: transform .2s ease, background-color .2s ease;
}

.tspg button.tspg__play:hover {
	background: rgba(0, 0, 0, .85);
	color: #fff;
	transform: scale(1.07);
}

.tspg button.tspg__play .tspg__icon { margin-left: 3px; }

.tspg .tspg__video {
	position: absolute;
	inset: 0;
	z-index: 4;
	background: #000;
}

.tspg .tspg__video iframe,
.tspg .tspg__video video {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	background: #000;
}

.tspg--preview .tspg__slide[data-type="video"] { cursor: default; }

@media (prefers-reduced-motion: reduce) {
	.tspg *,
	.tspg *::before,
	.tspg *::after {
		transition: none !important;
		scroll-behavior: auto !important;
	}
}

/* =====================================================================
 * Lightbox
 * ===================================================================== */

body.tspg-lb-open { overflow: hidden; }

.tspg-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	color: #fff;
	-webkit-tap-highlight-color: transparent;
}

.tspg-lb.is-open { display: block; animation: tspg-fade .2s ease; }

@keyframes tspg-fade { from { opacity: 0; } to { opacity: 1; } }

.tspg-lb *,
.tspg-lb *::before,
.tspg-lb *::after { box-sizing: border-box; }

.tspg-lb .tspg-lb__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(8, 8, 10, .93);
}

.tspg-lb .tspg-lb__stage {
	position: absolute;
	inset: 56px 80px 56px;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: pan-y;
}

.tspg-lb .tspg-lb__stage img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: 0 10px 50px rgba(0, 0, 0, .5);
	object-fit: contain;
	opacity: 0;
	transition: opacity .25s ease;
	-webkit-user-drag: none;
	user-select: none;
}

.tspg-lb .tspg-lb__stage img.is-loaded { opacity: 1; }

.tspg-lb .tspg-lb__stage iframe,
.tspg-lb .tspg-lb__stage video {
	display: block;
	width: min(100%, 1100px);
	height: auto;
	max-height: 100%;
	aspect-ratio: 16 / 9;
	border: 0;
	background: #000;
}

.tspg-lb.is-loading .tspg-lb__stage::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, .25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: tspg-spin .8s linear infinite;
}

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

.tspg-lb button,
.tspg-lb button:hover,
.tspg-lb button:focus,
.tspg-lb button:active {
	appearance: none;
	-webkit-appearance: none;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	text-shadow: none;
	background: none;
	color: #fff;
	font: inherit;
	line-height: 1;
	min-width: 0;
	min-height: 0;
	cursor: pointer;
	outline: 0;
}

.tspg-lb button.tspg-lb__btn {
	position: absolute;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	transition: background-color .2s ease;
}

.tspg-lb button.tspg-lb__btn:hover { background: rgba(255, 255, 255, .26); }
.tspg-lb button.tspg-lb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.tspg-lb button.tspg-lb__btn svg { display: block; pointer-events: none; }

.tspg-lb button.tspg-lb__close { top: 12px; right: 14px; }
.tspg-lb button.tspg-lb__prev { left: 16px; top: 50%; margin-top: -23px; }
.tspg-lb button.tspg-lb__next { right: 16px; top: 50%; margin-top: -23px; }
.tspg-lb.is-single .tspg-lb__prev,
.tspg-lb.is-single .tspg-lb__next,
.tspg-lb.is-single .tspg-lb__counter { display: none; }

.tspg-lb .tspg-lb__counter {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 16px;
	z-index: 2;
	text-align: center;
	font-size: 14px;
	letter-spacing: .04em;
	color: rgba(255, 255, 255, .8);
	pointer-events: none;
}

@media (max-width: 640px) {
	.tspg-lb .tspg-lb__stage { inset: 60px 8px 52px; }
	.tspg-lb button.tspg-lb__prev { left: 8px; }
	.tspg-lb button.tspg-lb__next { right: 8px; }
	.tspg-lb button.tspg-lb__btn { width: 42px; height: 42px; background: rgba(0, 0, 0, .45); }
}

@media (prefers-reduced-motion: reduce) {
	.tspg-lb, .tspg-lb * { animation: none !important; transition: none !important; }
}
