.embla {
	max-width: 100%;
	margin: 0 auto;
	--slide-height: auto;
	--slide-size: 66%;
	--slide-spacing: 16px;
}

@media screen and (min-width: 768px) {
	.embla {
		--slide-size: min(calc(var(--four-columns)), 100vw);
		--slide-spacing: 32px;
	}
}

.embla__viewport {
	overflow: hidden;
	/* iOS touch optimizations */
	-webkit-overflow-scrolling: touch;
	transform: translate3d(0, 0, 0);
	/* Prevent layout shift on initial load */
	opacity: 0;
	/* Hold last known transform to prevent flash if inline style is cleared */
	--embla-container-transform: translate3d(0, 0, 0);
}

.embla__viewport.embla-initialized {
	opacity: 1;
	transition: opacity 0.2s ease-out;
}

.embla__container {
	display: flex;
	display: -webkit-flex;
	/* Allow horizontal dragging on desktop, vertical scrolling on touch devices */
	touch-action: pan-y;
	/* Removed transition to prevent layout reflow on initial prev() click */
	will-change: transform;
	/* iOS-specific optimizations */
	transform: var(--embla-container-transform);
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	/* Better cursor feedback for desktop users - handled by JS */
	cursor: grab;
	/* Prevent text selection during drag */
	user-select: none;
	-webkit-user-select: none;
}

/* Remove :active to avoid conflicts with Embla's drag handling */
.embla__slide {
	transform: translate3d(0, 0, 0);
	/* ✅ CRITICAL FIX: Let slide width be determined by content (image aspect ratio) */
	flex: 0 0 auto;
	/* Remove fixed height - let it be controlled by parent/content */
	height: auto;
	/* CRITICAL FIX: Use margin instead of padding to prevent width calculation issues */
	margin-left: calc(var(--slide-spacing) / 2);
	margin-right: calc(var(--slide-spacing) / 2);

	display: flex;
	align-items: center;
	justify-content: center;

	/* iOS-specific optimizations */
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	-webkit-transform: translateZ(0);
	will-change: transform;
}

.embla__controls {
	display: grid;
	grid-template-columns: auto 1fr;
	justify-content: space-between;
	gap: 1.2rem;
	margin-top: 1.8rem;
}
.embla__buttons {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 0.6rem;
	align-items: center;
}
.embla__button {
	-webkit-tap-highlight-color: rgba(var(--text-high-contrast-rgb-value), 0.5);
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-color: transparent;
	touch-action: manipulation;
	display: inline-flex;
	text-decoration: none;
	cursor: pointer;
	border: 0;
	padding: 0;
	margin: 0;
	box-shadow: inset 0 0 0 0.2rem var(--detail-medium-contrast);
	width: 3.6rem;
	height: 3.6rem;
	z-index: 1;
	border-radius: 50%;
	color: var(--text-body);
	display: flex;
	align-items: center;
	justify-content: center;

	/* iOS-specific touch optimizations */
	transform: translateZ(0);
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	/* Larger touch target for iOS */
	min-width: 44px;
	min-height: 44px;
}
.embla__button:disabled {
	color: var(--detail-high-contrast);
}
.embla__button__svg {
	width: 35%;
	height: 35%;
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
	.embla {
		/* Force hardware acceleration on iOS */
		transform: translate3d(0, 0, 0);
		-webkit-backface-visibility: hidden;
		backface-visibility: hidden;
	}

	.embla__viewport {
		/* Better iOS scroll performance */
		-webkit-overflow-scrolling: touch;
		/* Fix iOS rendering issues */
		transform: translateZ(0);
	}

	.embla__container {
		/* Critical for iOS touch handling */
		transform: translate3d(0, 0, 0);
		-webkit-backface-visibility: hidden;
		backface-visibility: hidden;
		will-change: transform;
		/* Override desktop cursor for touch devices */
		cursor: default !important;
		touch-action: pan-y pinch-zoom;
	}

	.embla__slide {
		/* Improve iOS rendering performance */
		transform: translateZ(0);
		-webkit-backface-visibility: hidden;
		backface-visibility: hidden;
		will-change: transform;
	}

	.embla__button {
		/* Better iOS touch response */
		-webkit-tap-highlight-color: transparent;
		transform: translateZ(0);
		/* Ensure proper touch target size for iOS */
		min-width: 44px;
		min-height: 44px;
	}
}

/* Desktop-specific improvements */
@media (pointer: fine) {
	.embla__container {
		/* Ensure horizontal dragging works smoothly on desktop */
		touch-action: pan-y;
		cursor: grab;
		user-select: none;
		-webkit-user-select: none;
	}

	/* Remove :active state to prevent conflicts with Embla drag */

	.embla__slide {
		/* Prevent text selection during drag on desktop */
		user-select: none;
		-webkit-user-select: none;
		-moz-user-select: none;
		-ms-user-select: none;
	}
}
