/**
 * CPH Gallery Slider
 *
 * Center-mode carousel with 3D effects and arrow navigation.
 *
 * @package Salient_Child
 * @since   1.0.0
 */

/* ==========================================================================
   CSS Custom Properties (set via inline styles from PHP)
   ========================================================================== */

.cph-gallery-slider {
	--slider-height: 600px;
	--slide-width: 60%;
	--slide-radius: 25px;
	--slide-gap: 40px;
	--side-scale: 0.75;
	--side-opacity: 0.6;
	--arrow-color: #ffffff;
	--arrow-outline-color: #ffffff;
	--arrow-offset: 30px;
	--arrow-gap: 16px;
	--dot-size: 12px;
	--dot-gap: 10px;
	--pagination-offset: 20px;
	--transition-duration: 600ms;
	--perspective: 1000px;

	position: relative;
	width: 100%;
	height: var(--slider-height);
	overflow: hidden;
}

/* ==========================================================================
   Viewport
   ========================================================================== */

.cph-gallery-slider__viewport {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: visible;
	/* Let track extend beyond, container clips */
	perspective: var(--perspective);
}

/* ==========================================================================
   Track (contains slides, positioned for center mode)
   ========================================================================== */

.cph-gallery-slider__track {
	display: flex;
	align-items: center;
	/* Gap handled via JS margin-right for precise control */
	height: 100%;
	will-change: transform;
	transform-style: preserve-3d;
}

.cph-gallery-slider--draggable .cph-gallery-slider__track {
	cursor: grab;
	user-select: none;
}

.cph-gallery-slider--draggable .cph-gallery-slider__track:active {
	cursor: grabbing;
}

/* ==========================================================================
   Slide Base Styles
   ========================================================================== */

.cph-gallery-slider__slide {
	flex-shrink: 0;
	/* Width set by JS - do not use CSS percentage here as it resolves incorrectly in flex track */
	height: 100%;
	border-radius: var(--slide-radius);
	overflow: hidden;
	/* Transitions handled by GSAP for better control */
	transform-style: preserve-3d;
	backface-visibility: hidden;
	will-change: transform, opacity, filter;
}

.cph-gallery-slider__slide img,
.row .col .cph-gallery-slider__slide img {
	width: 100%;
	height: 100%;
	max-height: none;
	object-fit: cover;
	display: block;
	margin: 0;
	padding: 0;
	border-radius: 0;
	pointer-events: none;
}

/* ==========================================================================
   Captions
   ========================================================================== */

/* Captions position against the slide (overlay mode) and inherit the
   slide's transforms/opacity naturally in both modes. */
.cph-gallery-slider--captions .cph-gallery-slider__slide {
	position: relative;
}

.cph-gallery-slider__caption {
	margin: 0;
	padding: 0;
	line-height: 1.4;
	/* Keep drag/swipe working over the caption (imgs already do this). */
	pointer-events: none;
}

.cph-gallery-slider__caption--left   { text-align: left; }
.cph-gallery-slider__caption--center { text-align: center; }
.cph-gallery-slider__caption--right  { text-align: right; }

/* Placement: below the image (outside). The slide becomes a column — the
   image flexes to fill what the caption doesn't use, and the rounded
   corners move from the slide to the img so the caption isn't clipped. */
.cph-gallery-slider--caption-below .cph-gallery-slider__slide {
	display: flex;
	flex-direction: column;
	overflow: visible;
	border-radius: 0;
}

.cph-gallery-slider--caption-below .cph-gallery-slider__slide img,
.row .col .cph-gallery-slider--caption-below .cph-gallery-slider__slide img {
	flex: 1 1 auto;
	min-height: 0;
	height: auto;
	border-radius: var(--slide-radius);
}

.cph-gallery-slider--caption-below .cph-gallery-slider__caption {
	flex: 0 0 auto;
	margin-top: var(--caption-offset, 10px);
}

/* Placement: over the image (overlay), anchored near the bottom. */
.cph-gallery-slider--caption-overlay .cph-gallery-slider__caption {
	position: absolute;
	left: var(--caption-offset, 20px);
	right: var(--caption-offset, 20px);
	bottom: var(--caption-offset, 20px);
	z-index: 2;
	color: #ffffff;
	text-shadow: 0 1px 14px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   3D Effect - Initial States (GSAP takes over after init)
   ========================================================================== */

/* Hide slides initially until GSAP positions them */
.cph-gallery-slider:not(.is-initialized) .cph-gallery-slider__slide {
	opacity: 0;
}

/* ==========================================================================
   Arrow Nav Container
   ========================================================================== */

/* Overlay layout: container is transparent to layout so the absolutely
   positioned arrows resolve against the slider wrapper (default behavior). */
.cph-gallery-slider__nav {
	display: contents;
}

/* ==========================================================================
   Arrow Buttons - Base
   ========================================================================== */

.cph-gallery-slider__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 10;

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

	padding: 0;
	background: transparent;
	border: none;
	color: var(--arrow-color);

	cursor: pointer;
	transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease;
}

.cph-gallery-slider__arrow svg rect,
.cph-gallery-slider__arrow svg circle,
.cph-gallery-slider__arrow svg path {
	transition: stroke 0.3s ease, stroke-width 0.3s ease, fill 0.3s ease;
}

.cph-gallery-slider__arrow:hover {
	transform: translateY(-50%) scale(1.05);
}

.cph-gallery-slider__arrow:focus {
	outline: none;
}

.cph-gallery-slider__arrow:focus-visible {
	outline: 2px solid var(--arrow-color, #ffffff);
	outline-offset: 4px;
}

.cph-gallery-slider__arrow--prev {
	left: var(--arrow-offset);
}

.cph-gallery-slider__arrow--next {
	right: var(--arrow-offset);
}

/* ==========================================================================
   Arrow Styles - Pill (Default)
   ========================================================================== */

/* Size is driven by height (--arrow-size); width follows the shape's
   aspect ratio so the glyph never distorts. Blank var = per-shape default. */
.cph-gallery-slider--arrows-pill .cph-gallery-slider__arrow {
	height: var(--arrow-size, 50px);
	aspect-ratio: 140 / 50;
	width: auto;
}

.cph-gallery-slider--arrows-pill .cph-gallery-slider__arrow svg {
	width: 100%;
	height: auto;
}

/* ==========================================================================
   Arrow Styles - Circle
   ========================================================================== */

.cph-gallery-slider--arrows-circle .cph-gallery-slider__arrow {
	height: var(--arrow-size, 50px);
	aspect-ratio: 1;
	width: auto;
}

.cph-gallery-slider--arrows-circle .cph-gallery-slider__arrow svg {
	width: 100%;
	height: auto;
}

/* ==========================================================================
   Arrow Styles - Minimal
   ========================================================================== */

.cph-gallery-slider--arrows-minimal .cph-gallery-slider__arrow {
	height: var(--arrow-size, 40px);
	aspect-ratio: 1;
	width: auto;
}

.cph-gallery-slider--arrows-minimal .cph-gallery-slider__arrow svg {
	width: 100%;
	height: auto;
}

/* ==========================================================================
   Pause / Play Button (rendered only when autoplay is on)
   ========================================================================== */

/* Shares the arrow button's chrome and colour scheme, but is always a circle
   at the arrows' height so it reads as a secondary control next to the
   140x50 pill. In overlay layout it sits in the top-right corner, clear of
   the vertically-centred arrows and the bottom-centred pagination dots. */
.cph-gallery-slider__playpause {
	position: absolute;
	top: var(--arrow-offset);
	right: var(--arrow-offset);
	z-index: 11;

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

	height: var(--arrow-size, 50px);
	aspect-ratio: 1;
	width: auto;

	padding: 0;
	background: transparent;
	border: none;
	color: var(--arrow-color);

	cursor: pointer;
	transition: transform 0.3s ease, opacity 0.3s ease, background 0.3s ease;
}

.cph-gallery-slider__playpause svg {
	width: 100%;
	height: auto;
}

.cph-gallery-slider__playpause svg circle {
	stroke: var(--arrow-outline-color, #ffffff);
	fill: var(--arrow-bg-color, transparent);
	transition: stroke 0.3s ease, fill 0.3s ease;
}

.cph-gallery-slider__playpause svg rect,
.cph-gallery-slider__playpause svg path {
	fill: var(--arrow-color, #ffffff);
	transition: fill 0.3s ease;
}

.cph-gallery-slider__playpause:hover {
	transform: scale(1.05);
}

.cph-gallery-slider__playpause:focus {
	outline: none;
}

.cph-gallery-slider__playpause:focus-visible {
	outline: 2px solid var(--arrow-color, #ffffff);
	outline-offset: 4px;
}

/* One icon at a time — the JS toggles is-playing / is-paused on the button. */
.cph-gallery-slider__playpause-icon {
	display: none;
}

.cph-gallery-slider__playpause.is-playing .cph-gallery-slider__playpause-icon--pause,
.cph-gallery-slider__playpause.is-paused .cph-gallery-slider__playpause-icon--play {
	display: block;
}

/* ==========================================================================
   Arrow Layout - Below Slider (centered row beneath the carousel)
   ========================================================================== */

/* Let the wrapper grow to fit the arrow row; move clipping to the viewport. */
.cph-gallery-slider--nav-below {
	height: auto;
	overflow: visible;
}

.cph-gallery-slider--nav-below .cph-gallery-slider__viewport {
	height: var(--slider-height);
	overflow: hidden;
}

/* Lay the two arrows out as a centered row below the slider. */
.cph-gallery-slider--nav-below .cph-gallery-slider__nav {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--arrow-gap);
	margin-top: var(--arrow-offset);
}

.cph-gallery-slider--nav-below .cph-gallery-slider__arrow,
.cph-gallery-slider--nav-below .cph-gallery-slider__playpause {
	position: static;
	top: auto;
	left: auto;
	right: auto;
	transform: none;
}

.cph-gallery-slider--nav-below .cph-gallery-slider__arrow:hover {
	transform: scale(1.05);
}

/* Mobile overlay rule (top: 90%) does not apply in below layout. */
@media (max-width: 690px) {
	.cph-gallery-slider--nav-below .cph-gallery-slider__arrow {
		top: auto;
	}
}

/* ==========================================================================
   Arrows Hidden State (when at edge in non-infinite mode)
   ========================================================================== */

.cph-gallery-slider__arrow.is-hidden {
	opacity: 0;
	pointer-events: none;
}

/* ==========================================================================
   Pagination Dots
   ========================================================================== */

.cph-gallery-slider__pagination {
	position: absolute;
	bottom: var(--pagination-offset);
	left: 50%;
	transform: translateX(-50%);
	z-index: 10;

	display: flex;
	align-items: center;
	justify-content: center;
	gap: var(--dot-gap);
}

.cph-gallery-slider__dot {
	width: var(--dot-size);
	height: var(--dot-size);
	padding: 0;
	border: 1px solid #ffffff;
	border-radius: 50%;
	background: transparent;
	cursor: pointer;
	transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.cph-gallery-slider__dot:hover {
	transform: scale(1.2);
}

.cph-gallery-slider__dot:focus {
	outline: none;
}

.cph-gallery-slider__dot:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.cph-gallery-slider__dot.is-active {
	background-color: #ffffff;
	border-color: #ffffff;
}

/* ==========================================================================
   Responsive - Large Desktop (1440px+)
   ========================================================================== */

@media (min-width: 1440px) {
	.cph-gallery-slider--arrows-pill .cph-gallery-slider__arrow {
		height: var(--arrow-size, 58px);
	}
}

/* ==========================================================================
   Responsive - Tablet (max-width: 999px)
   ========================================================================== */

@media (max-width: 999px) {
	.cph-gallery-slider {
		--slide-width: 70%;
		--slide-gap: 20px;
		--arrow-offset: 20px;
	}

	.cph-gallery-slider--arrows-pill .cph-gallery-slider__arrow {
		height: var(--arrow-size, 36px);
	}

	.cph-gallery-slider--arrows-circle .cph-gallery-slider__arrow {
		height: var(--arrow-size, 40px);
	}

	.cph-gallery-slider--arrows-minimal .cph-gallery-slider__arrow {
		height: var(--arrow-size, 32px);
	}

	.cph-gallery-slider__playpause {
		height: var(--arrow-size, 40px);
	}
}

/* ==========================================================================
   Responsive - Mobile (max-width: 690px)
   ========================================================================== */

@media (max-width: 690px) {
	.cph-gallery-slider {
		--slide-width: 85%;
		--slide-gap: 15px;
		--slide-radius: 15px;
		--arrow-offset: 10px;
	}

	.cph-gallery-slider__arrow {
		top: 90%;
	}

	.cph-gallery-slider--arrows-pill .cph-gallery-slider__arrow {
		height: var(--arrow-size, 30px);
	}

	.cph-gallery-slider--arrows-circle .cph-gallery-slider__arrow {
		height: var(--arrow-size, 36px);
	}

	.cph-gallery-slider--arrows-minimal .cph-gallery-slider__arrow {
		height: var(--arrow-size, 28px);
	}

	.cph-gallery-slider__playpause {
		height: var(--arrow-size, 36px);
	}
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.cph-gallery-slider-empty {
	padding: 40px;
	text-align: center;
	font-family: 'aktiv-grotesk', sans-serif;
	font-size: 18px;
	color: #666;
}

/* ==========================================================================
   Initialization State
   ========================================================================== */

.cph-gallery-slider:not(.is-initialized) .cph-gallery-slider__track {
	opacity: 0;
}

.cph-gallery-slider.is-initialized .cph-gallery-slider__track {
	opacity: 1;
	transition: opacity 0.3s ease;
}