/* =============================================================
   Product Color Gallery — base styles
   Scoped under .pcg-widget so multiple instances never collide.
   ============================================================= */

.pcg-widget {
	--pcg-max-w: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

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

.pcg-empty-state {
	padding: 24px;
	border: 1px dashed #ccc;
	color: #888;
	text-align: center;
	font-size: 14px;
}

.pcg-gallery {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 100%;
}

/* -------------------------------------------------------------
   Main image
   ------------------------------------------------------------- */

.pcg-main-image-wrap {
	--pcg-img-pad-top: 0px;
	--pcg-img-pad-right: 0px;
	--pcg-img-pad-bottom: 0px;
	--pcg-img-pad-left: 0px;
	position: relative;
	display: block;
	width: 100%;
	max-width: 100%;
	height: clamp(220px, 40vw, 500px);
	overflow: hidden; /* Always clip here so width/height controls actually crop the image, independent of the border-radius control. */
	background: #f5f5f5;
	margin-bottom: 16px;
	box-sizing: border-box;
}

.pcg-main-image-inner {
	position: absolute !important;
	top: var(--pcg-img-pad-top, 0px) !important;
	right: var(--pcg-img-pad-right, 0px) !important;
	bottom: var(--pcg-img-pad-bottom, 0px) !important;
	left: var(--pcg-img-pad-left, 0px) !important;
	width: auto;
	height: auto;
	overflow: hidden;
	transition: transform 0.15s ease-out;
	transform-origin: center center;
	will-change: transform;
	box-sizing: border-box;
}

.pcg-main-image {
	position: absolute !important;
	top: 0 !important;
	right: 0 !important;
	bottom: 0 !important;
	left: 0 !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important; /* prevent theme/editor img{max-width:100%} rules from shrinking it inside the absolutely-positioned box */
	max-height: none !important;
	object-fit: contain !important;
	object-position: center center !important;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease;
	pointer-events: none;
	margin: 0 !important;
}

.pcg-main-image.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

/* Zoom lens — kept purely for potential future lens-style zoom;
   current implementation uses transform-scale on the inner wrap,
   which stays clipped by .pcg-main-image-wrap's overflow:hidden. */
.pcg-zoom-lens {
	display: none;
}

.pcg-main-image-wrap.pcg-zoom-enabled {
	cursor: zoom-in;
}

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

.pcg-thumbs-wrap {
	width: 100%;
	max-width: 100%;
	overflow: hidden;
}

.pcg-thumbs {
	position: relative;
	overflow-x: auto;
	overflow-y: hidden;
	padding: 4px 2px 8px;
	max-width: 100%;
	scrollbar-width: thin;
	-webkit-overflow-scrolling: touch;
}

.pcg-thumbs::-webkit-scrollbar {
	height: 6px;
}

.pcg-thumbs::-webkit-scrollbar-thumb {
	background: #d5d5d5;
	border-radius: 4px;
}

/* Each color owns one thumbnail group. Only the active color's group is
   shown — switching colors swaps the entire visible row of thumbnails.
   Inactive groups are display:none so they take no space and don't affect
   scroll width. */
.pcg-thumb-group {
	display: none !important;
}

.pcg-thumb-group.is-active-group {
	display: flex !important;
	flex-wrap: nowrap;
	gap: 10px;
}

.pcg-thumb {
	flex: 0 0 auto;
	width: 80px;
	height: 80px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	background: #f5f5f5;
	overflow: hidden;
	cursor: pointer;
	transition: border-color 0.2s ease, opacity 0.2s ease;
	line-height: 0;
}

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

.pcg-thumb.is-active {
	border-color: #1a1a1a;
}

.pcg-thumb:hover {
	opacity: 0.75;
}

/* -------------------------------------------------------------
   Color swatches — shared
   ------------------------------------------------------------- */

.pcg-swatches {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
}

.pcg-swatch-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}

.pcg-swatch {
	width: 28px;
	height: 28px;
	padding: 0;
	border: 2px solid #fff;
	outline: 1px solid #ddd;
	cursor: pointer;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
	flex-shrink: 0;
	min-width: 20px;
	min-height: 20px;
}

/* NOTE: Elementor's "prefix_class" adds the shape class to the widget's
   own outer wrapper element (an ancestor of our .pcg-widget div), not to
   .pcg-widget itself — so this must be a descendant selector, not a
   same-element compound selector. */
.pcg-swatch-shape-circle .pcg-swatch {
	border-radius: 50%;
}

.pcg-swatch-shape-square .pcg-swatch {
	border-radius: 4px;
}

.pcg-swatch:hover {
	border-color: #888;
}

.pcg-swatch.is-active {
	border-color: #1a1a1a;
}

.pcg-swatch-label {
	font-size: 12px;
	color: #333;
	white-space: nowrap;
	max-width: 90px;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* -------------------------------------------------------------
   Color position: BELOW GALLERY
   ------------------------------------------------------------- */

.pcg-swatches-inline {
	margin-top: 14px;
	gap: 10px;
	row-gap: 12px;
}

/* -------------------------------------------------------------
   Color position: RIGHT MIDDLE (overlay on the main image)
   ------------------------------------------------------------- */

.pcg-swatches-overlay {
	position: absolute;
	top: 50%;
	right: 12px;
	transform: translateY(-50%);
	flex-direction: column;
	gap: 10px;
	z-index: 5;
	max-height: calc(100% - 24px);
	overflow-y: auto;
	overflow-x: hidden;
	padding: 4px;
}

.pcg-swatches-overlay .pcg-swatch-item {
	flex-direction: row-reverse;
}

.pcg-swatches-overlay .pcg-swatch-label {
	background: rgba(255, 255, 255, 0.85);
	padding: 2px 6px;
	border-radius: 3px;
	max-width: 120px;
}

/* -------------------------------------------------------------
   Touch-friendly swatches on small pointers
   ------------------------------------------------------------- */

@media (pointer: coarse) {
	.pcg-swatch {
		min-width: 32px;
		min-height: 32px;
	}
}

/* -------------------------------------------------------------
   Responsive breakpoints
   ------------------------------------------------------------- */

@media (max-width: 1024px) {
	.pcg-main-image-wrap {
		height: clamp(200px, 45vw, 420px);
	}

	.pcg-thumb {
		width: 68px;
		height: 68px;
	}
}

@media (max-width: 767px) {
	.pcg-widget,
	.pcg-gallery {
		width: 100%;
		max-width: 100vw;
	}

	.pcg-main-image-wrap {
		height: clamp(180px, 60vw, 360px);
	}

	.pcg-thumb {
		width: 56px;
		height: 56px;
	}

	.pcg-swatches-overlay {
		right: 8px;
		max-height: calc(100% - 16px);
		gap: 8px;
	}

	.pcg-swatches-overlay .pcg-swatch-label {
		display: none; /* keep the overlay compact on narrow screens */
	}

	.pcg-swatches-inline {
		justify-content: flex-start;
		row-gap: 10px;
	}

	.pcg-swatch {
		width: 30px;
		height: 30px;
	}
}
