/*
 * Coverflow carousel (pixel-fix plan chunk 03; EXP-ROBOTICS-14 to -38, DEFENCE-11 to -20): the v6.5
 * prototype's centre-stage carousel on a Divi Group with the class cds-coverflow (its child Groups
 * are the slides, each holding an Image module). Divi limitation: the Group Carousel module only
 * slides a flat strip of equal tiles (no per-slide scale, fade or overlap), so the stage is drawn
 * here and coverflow.js sets each slide's data-cds-pos. Values: markup.html "hasCarousel".
 * !important: Divi prints the Group's own sizing, overflow and flex settings per module.
 * Literal colours: the slide shadow, and fallbacks for variables a page may not print (Divi prints
 * only the colour variables a page uses; light.css defines all of them in light mode).
 */

/* Before the script runs, in the Builder and without JavaScript: a row that scrolls sideways. */
.cds-coverflow:not(.cds-coverflow--ready) {
	scroll-snap-type: x mandatory;
}

.cds-coverflow:not(.cds-coverflow--ready) > .et_pb_group {
	scroll-snap-align: center;
}

html body .cds-coverflow.cds-coverflow--ready {
	position: relative;
	display: block !important;
	overflow: visible !important;
	height: 460px; /* coverflow.js sets it from the width: centre width × 9/16 + 47px (460px at 1184px) */
}

html body .cds-coverflow--ready > .cds-coverflow__slide {
	position: absolute !important;
	top: 50%;
	left: 50%;
	flex: none !important;
	width: var(--cds-cf-centre, 62%) !important;
	max-width: none !important;
	height: auto !important;
	aspect-ratio: 16 / 9;
	margin: 0 !important;
	padding: 0 !important;
	border-radius: 14px;
	overflow: hidden;
	background-color: var(--gcid-cds-surface, #131417);
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
	transform: translate(-50%, -50%) translateX(0%) scale(0.7);
	opacity: 0;
	z-index: 1;
	transition: transform 0.65s cubic-bezier(0.33, 1, 0.68, 1), opacity 0.65s ease;
}

html body .cds-coverflow--ready > .cds-coverflow__slide[data-cds-pos="0"] {
	transform: translate(-50%, -50%) translateX(0%) scale(1);
	opacity: 1;
	z-index: 3;
}

html body .cds-coverflow--ready > .cds-coverflow__slide[data-cds-pos="1"] {
	transform: translate(-50%, -50%) translateX(46%) scale(0.8);
	opacity: 0.55;
	z-index: 2;
}

html body .cds-coverflow--ready > .cds-coverflow__slide[data-cds-pos="-1"] {
	transform: translate(-50%, -50%) translateX(-46%) scale(0.8);
	opacity: 0.55;
	z-index: 2;
}

html body .cds-coverflow--ready > .cds-coverflow__slide .et_pb_image,
html body .cds-coverflow--ready > .cds-coverflow__slide .et_pb_image_wrap,
html body .cds-coverflow--ready > .cds-coverflow__slide img {
	display: block;
	width: 100% !important;
	max-width: none !important;
	height: 100% !important;
	margin: 0 !important;
}

html body .cds-coverflow--ready > .cds-coverflow__slide img {
	object-fit: cover;
	object-position: 50% 50%;
}

/*
 * The neighbour slides reach past the stage (past the viewport on a phone): clip them at the section,
 * which is as wide as the viewport, so the page gets no horizontal scrollbar. clip, not hidden, so the
 * section doesn't become a scroll container (and a sticky header keeps working).
 */
html body .et_pb_section:has(.cds-coverflow--ready) {
	overflow-x: clip;
}

/* Arrows: 46px bordered circles, 8px inside the stage, vertically centred; accent hover at once. */
html body .cds-coverflow__arrow,
html body .cds-coverflow__pause {
	position: absolute;
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 1px solid var(--gcid-cds-border-2, #2A2B30);
	border-radius: 50%;
	background-color: var(--gcid-cds-card, #15161A);
	color: var(--gcid-cds-text, #F0F0F0);
	cursor: pointer;
	transition: none;
}

html body .cds-coverflow__arrow {
	top: 50%;
	width: 46px;
	height: 46px;
	transform: translateY(-50%);
}

html body .cds-coverflow__arrow--prev {
	left: 8px;
}

html body .cds-coverflow__arrow--next {
	right: 8px;
}

/* WCAG 2.2.2 Pause, Stop, Hide: not in the prototype; sits under the right-hand slide. */
html body .cds-coverflow__pause {
	right: 8px;
	bottom: 8px;
	width: 36px;
	height: 36px;
}

html body .cds-coverflow__arrow:hover,
html body .cds-coverflow__pause:hover {
	border-color: var(--gcid-cds-accent, #7D8DEB);
	color: var(--gcid-cds-accent-hover, #9AA7F2);
}

html body .cds-coverflow__arrow svg,
html body .cds-coverflow__pause svg {
	display: block;
}

/* Reduced motion (WCAG 2.3.3, best practice): slides change at once. */
@media (prefers-reduced-motion: reduce) {
	html body .cds-coverflow--ready > .cds-coverflow__slide {
		transition: none;
	}
}
