.ttsn-pip-root * {
	box-sizing: border-box;
}

.ttsn-pip-gallery {
	display: flex;
	flex-direction: column;
	gap: 14px;
}

.ttsn-pip-thumbs-left .ttsn-pip-gallery {
	flex-direction: row-reverse;
	align-items: flex-start;
}

.ttsn-pip-thumbs-left .ttsn-pip-main {
	flex: 1 1 auto;
	min-width: 0;
}

.ttsn-pip-thumbs-left .ttsn-pip-thumbs {
	flex: 0 0 auto;
}

/* ---------------- Main image (always full/uncropped) ---------------- */

.ttsn-pip-main {
	position: relative;
	width: 100%;
	overflow: hidden;
	background: #fafafa;
}

.ttsn-pip-main-track {
	position: relative;
	width: 100%;
	height: auto;
}

.ttsn-pip-main-slide {
	display: none;
	width: 100%;
}

.ttsn-pip-main-slide.is-active {
	display: block;
	animation: ttsn-pip-fade .25s ease;
}

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

.ttsn-pip-main-slide img {
	width: 100%;
	height: auto;
	display: block;
}

.ttsn-pip-badge {
	position: absolute;
	top: 12px;
	left: 12px;
	background: #e0622f;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: 3px;
	z-index: 3;
}

/* Cursor-following zoom (desktop hover + fine pointer only) */
@media (hover: hover) and (pointer: fine) {
	.ttsn-pip-root[data-zoom="yes"][data-zoom-style="inline"] .ttsn-pip-main-slide.is-active img {
		cursor: zoom-in;
	}
}

.ttsn-pip-main.ttsn-pip-zoomed .ttsn-pip-main-slide.is-active {
	overflow: hidden;
}

.ttsn-pip-main.ttsn-pip-zoomed .ttsn-pip-main-slide.is-active img {
	transform-origin: var(--ttsn-pip-zoom-x, 50%) var(--ttsn-pip-zoom-y, 50%);
	transform: scale(var(--ttsn-pip-zoom-level, 2.4));
	cursor: zoom-out;
	transition: transform .06s linear;
	max-width: none;
}

/* ---------------- Lens zoom (cursor-tracking box + side result panel) ---------------- */

.ttsn-pip-root[data-zoom-style="lens"] .ttsn-pip-gallery {
	position: relative;
}

.ttsn-pip-lens {
	position: absolute;
	top: 0;
	left: 0;
	border: 2px solid #2c6ecb;
	background: rgba(44, 110, 203, .15);
	pointer-events: none;
	opacity: 0;
	z-index: 5;
	will-change: transform;
}

.ttsn-pip-main.ttsn-pip-lens-active .ttsn-pip-lens {
	opacity: 1;
}

.ttsn-pip-main.ttsn-pip-lens-active .ttsn-pip-main-slide.is-active img {
	cursor: crosshair;
}

.ttsn-pip-zoom-result {
	position: absolute;
	top: 0;
	left: calc(100% + 16px);
	width: 100%;
	height: 100%;
	border: 1px solid #e5e5e5;
	border-radius: 8px;
	background-color: #fafafa;
	background-repeat: no-repeat;
	box-shadow: 0 12px 28px rgba(0, 0, 0, .14);
	opacity: 0;
	visibility: hidden;
	transition: opacity .15s ease;
	z-index: 20;
	pointer-events: none;
}

.ttsn-pip-zoom-result.is-visible {
	opacity: 1;
	visibility: visible;
}

/* The side panel needs real room beside the gallery — not viable on
   narrow/tablet+mobile widths, so the Lens style just shows the lens box
   there without a result panel (still a clear "you can inspect this"
   affordance) rather than overflowing the layout. */
@media (max-width: 1024px) {
	.ttsn-pip-zoom-result {
		display: none;
	}
}

.ttsn-pip-main-arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 4;
	opacity: 0;
	visibility: hidden;
	transition: opacity .2s ease, visibility .2s ease;
}

.ttsn-pip-main:hover .ttsn-pip-main-arrow {
	opacity: 1;
	visibility: visible;
}

.ttsn-pip-main-arrow.ttsn-pip-arrow-prev {
	left: 14px;
}

.ttsn-pip-main-arrow.ttsn-pip-arrow-next {
	right: 14px;
}

/* ---------------- Arrows (shared look) ---------------- */

.ttsn-pip-arrow {
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 50%;
	background: #fff;
	color: #333;
	box-shadow: 0 2px 10px rgba(0,0,0,.14);
	cursor: pointer;
	padding: 0;
	flex: 0 0 auto;
	transition: background-color .15s ease, color .15s ease;
}

.ttsn-pip-arrow svg {
	display: block;
	width: 45%;
	height: 45%;
}

.ttsn-pip-arrow:hover {
	background: #2c6ecb;
	color: #fff;
}

.ttsn-pip-arrow:disabled {
	opacity: .35;
	cursor: default;
	pointer-events: none;
}

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

.ttsn-pip-thumbs {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ttsn-pip-thumbs-bottom .ttsn-pip-thumbs {
	width: 100%;
}

.ttsn-pip-thumbs-left .ttsn-pip-thumbs {
	flex-direction: column;
	max-height: 100%;
}

.ttsn-pip-thumbs-arrow {
	width: 26px;
	height: 26px;
	flex: 0 0 26px;
}

.ttsn-pip-thumbs-viewport {
	overflow: hidden;
	flex: 1 1 auto;
	min-width: 0;
}

.ttsn-pip-thumbs-left .ttsn-pip-thumbs-viewport {
	min-height: 0;
}

.ttsn-pip-thumbs-track {
	--ttsn-pip-thumbs-visible: 5;
	--ttsn-pip-thumb-gap: 10px;
	display: flex;
	gap: var(--ttsn-pip-thumb-gap);
	transition: transform .3s ease;
	will-change: transform;
}

.ttsn-pip-thumbs-left .ttsn-pip-thumbs-track {
	flex-direction: column;
}

.ttsn-pip-thumb {
	position: relative;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	overflow: hidden;
	cursor: pointer;
	background: #fff;
	opacity: .7;
	transition: opacity .15s ease, border-color .15s ease;
}

/* Below Main Image: thumbnails fill the entire row width, sized off the
   "Visible Thumbnails" count — not a fixed pixel size — so N thumbnails
   always spans edge to edge with no leftover gap. */
.ttsn-pip-thumbs-bottom .ttsn-pip-thumb {
	flex: 0 0 calc((100% - (var(--ttsn-pip-thumb-gap) * (var(--ttsn-pip-thumbs-visible) - 1))) / var(--ttsn-pip-thumbs-visible));
	width: calc((100% - (var(--ttsn-pip-thumb-gap) * (var(--ttsn-pip-thumbs-visible) - 1))) / var(--ttsn-pip-thumbs-visible));
	aspect-ratio: 1 / 1;
}

/* Left of Main Image: vertical column, height instead comes from the
   Thumbnail Height control (fixed width/height there, see widget PHP). */
.ttsn-pip-thumbs-left .ttsn-pip-thumb {
	flex: 0 0 auto;
	width: 80px;
	height: 80px;
}

.ttsn-pip-thumb:hover {
	opacity: 1;
}

.ttsn-pip-thumb.is-active {
	opacity: 1;
	border-color: #2c6ecb;
}

.ttsn-pip-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

@media (max-width: 767px) {
	.ttsn-pip-thumbs-left .ttsn-pip-gallery {
		flex-direction: column;
	}

	.ttsn-pip-thumbs-left .ttsn-pip-thumb {
		width: 64px;
		height: 64px;
	}
}
