/* ==========================================================================
   Cargo Pilot — Horizontal Product Media  v1.0.2 Beta
   ========================================================================== */

/* ---- Wrapper ---- */
.cp-hpm-wrapper {
	display: flex;
	flex-direction: column;
	width: 100%;
}

/* ============================================================
   MAIN PREVIEW
   ============================================================ */
.cp-hpm-preview {
	position: relative;
	width: 100%;
	overflow: hidden;
	line-height: 0;
	/* default: auto mode, height driven by image */
}

/* ------ AUTO MODE: natural image dimensions ------- */
.cp-hpm-preview[data-mode="auto"] .cp-hpm-preview-item {
	display: none;
	width: 100%;
}

.cp-hpm-preview[data-mode="auto"] .cp-hpm-preview-item.cp-active {
	display: block;
}

.cp-hpm-preview[data-mode="auto"] img,
.cp-hpm-preview[data-mode="auto"] video {
	display: block;
	width: 100%;
	height: auto;
	/* natural height — no forced crop */
}

/* ------ RATIO MODE: container has aspect-ratio; image fills + crops ------ */
/* aspect-ratio is set inline via PHP                                         */
.cp-hpm-preview[data-mode="ratio"] {
	overflow: hidden;
}

.cp-hpm-preview[data-mode="ratio"] .cp-hpm-preview-item {
	/* All items sit in the same absolute slot; hidden ones are display:none  */
	position: absolute;
	inset: 0;
	display: none;
	width: 100%;
	height: 100%;
}

.cp-hpm-preview[data-mode="ratio"] .cp-hpm-preview-item.cp-active {
	display: block;
}

.cp-hpm-preview[data-mode="ratio"] img,
.cp-hpm-preview[data-mode="ratio"] video {
	display: block;
	width: 100%;
	height: 100%;
	/* fill the aspect-ratio container  */
	object-fit: cover;
	/* crop to fill — centred by default */
}

/* ============================================================
   BOTTOM ROW: thumbnails + nav
   ============================================================ */
.cp-hpm-bottom {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	/* margin-top controlled by Elementor spacing control */
}

/* ---- Scrollable thumbnail strip ---- */
.cp-hpm-thumbnails-wrap {
	flex: 1 1 auto;
	min-width: 0;
	/* CRITICAL: prevents flex child from overflowing */
	overflow: hidden;
	/* clips thumbnails to the reserved width */
}

.cp-hpm-thumbnails {
	display: flex;
	flex-direction: row;
	align-items: flex-start;
	gap: 10px;
	/* overridden by Elementor spacing control */
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	will-change: transform;
}

/* ---- Individual thumbnail ---- */
.cp-hpm-thumb {
	flex: 0 0 auto;
	cursor: pointer;
	overflow: hidden;
	/* clips image to border-radius — no gap */
	position: relative;
	line-height: 0;
	box-sizing: border-box;
	transition: opacity 0.2s ease;
}

.cp-hpm-thumb:hover {
	opacity: 0.8;
}

/* Active indicator: outline is independent of Elementor border control */
.cp-hpm-thumb.cp-active {
	outline: 2px solid #333;
	outline-offset: -2px;
}

.cp-hpm-thumb img,
.cp-hpm-thumb video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Video play badge */
.cp-hpm-thumb-video-badge {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.35);
	color: #fff;
	pointer-events: none;
}

/* ============================================================
   NAVIGATION BUTTONS
   ============================================================ */
.cp-hpm-nav {
	flex: 0 0 auto;
	/* reserves its own space — thumbnails never overlap */
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-left: 10px;
}

.cp-hpm-nav-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	border: none;
	outline: none;
	background: #f0f0f0;
	color: #333;
	border-radius: 6px;
	font-size: 14px;
	padding: 0;
	line-height: 1;
	flex-shrink: 0;
	/* Minimum size so nav always reserves space before JS runs */
	min-width: 36px;
	min-height: 36px;
	/* width/height also set by JS to align with thumbnail height */
	box-sizing: border-box;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.cp-hpm-nav-btn i,
.cp-hpm-nav-btn svg {
	display: block;
	pointer-events: none;
}

/* ============================================================
   EDITOR PLACEHOLDER
   ============================================================ */
.cp-hpm-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 200px;
	background: #f5f5f5;
	border: 2px dashed #ccc;
	color: #888;
	font-size: 14px;
	font-family: sans-serif;
	border-radius: 6px;
	width: 100%;
	box-sizing: border-box;
	text-align: center;
	padding: 20px;
}

.cp-hpm-thumb-placeholder {
	flex: 0 0 auto;
	background: #e5e5e5;
	border-radius: 6px;
}