/* ==========================================================================
   UB VIDEO CAROUSEL - FRONTEND STYLES
   ========================================================================== */

.ub-video-carousel {
	position: relative;
	width: 100%;
	overflow: hidden;
	max-width: 100% !important;
}

/* ==========================================================================
   CAROUSEL VIEWPORT & TRACK
   ========================================================================== */

.ub-video-carousel__viewport {
	position: relative;
	width: 100%;
	overflow: hidden;
}

.ub-video-carousel__track {
	display: flex;
	width: 100%;
	gap: var(--ub-video-gap, 24px);
	will-change: transform;
	transition: transform 0.5s ease-in-out;
}

/* ==========================================================================
   VIDEO ITEM STYLES
   ========================================================================== */

.ub-video-item {
	position: relative;
	/* Calculate width accounting for gaps between items */
	flex: 1 0 0;
	max-width: calc((100% - (var(--ub-slides-to-show, 4) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show, 4));
	min-width: calc((100% - (var(--ub-slides-to-show, 4) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show, 4));
	display: flex;
	flex-direction: column;
	transition: max-width 0.4s ease-in-out, min-width 0.4s ease-in-out;
	cursor: pointer;
	overflow: hidden;
}

/* Thumbnail wrapper */
.ub-video-item__thumbnail-wrapper {
	position: relative;
	aspect-ratio: 9 / 16;
	overflow: hidden;
	border-radius: 0.75rem;
	background-color: #000;
}

.ub-video-item__thumbnail {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Video element (hidden by default) */
.ub-video-item__video {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 100%;
	height: 100%;
	object-fit: contain;
	transform: translate(-50%, -50%);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
	background-color: #000;
}

/* Embed iframe (hidden by default, shown when playing - mirrors .ub-video-item__video) */
.ub-video-item__embed {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	pointer-events: none;
	border: none;
	background-color: #000;
	transition: opacity 0.3s ease;
}

.ub-video-item--playing .ub-video-item__embed {
	opacity: 1;
	pointer-events: auto;
}

/* Play icon */
.ub-video-item__play-icon {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 52px;
	height: 52px;
	z-index: 5;
	cursor: pointer;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.ub-video-item__play-icon:hover {
	transform: translate(-50%, -50%) scale(1.1);
}

/* Video controls (fullscreen button) - hidden and non-interactive by default */
.ub-video-item__controls {
	position: absolute;
	bottom: 1rem;
	right: 1rem;
	display: none;
	gap: 0.5rem;
	z-index: 10;
}

/* Only show controls when video is playing */
.ub-video-item--playing .ub-video-item__controls {
	display: flex;
}

.ub-video-item__fullscreen-btn,
.ub-video-item__pause-btn {
	width: 2.5rem;
	height: 2.5rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	color: var(--wp--preset--color--dark-blue);
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.ub-video-item__fullscreen-btn:hover,
.ub-video-item__pause-btn:hover {
	background: var(--wp--preset--color--white);
	transform: scale(1.1);
}

.ub-video-item__fullscreen-btn svg,
.ub-video-item__pause-btn svg {
	width: 1.25rem;
	height: 1.25rem;
}

/* Content area */
.ub-video-item__content {
	padding: 1rem 0;
}

.ub-video-item__title {
	margin: 0;
	font-size: var(--wp--preset--font-size--large);
}
.ub-video-item__description {
	font-size: var(--wp--preset--font-size--small);
	overflow: hidden;
}

/* ==========================================================================
   HOVER STATE
   ========================================================================== */

.ub-video-item:hover .ub-video-item__thumbnail {
	transform: scale(1.05);
}

/* ==========================================================================
   PLAYING STATE
   ========================================================================== */

.ub-video-item--playing .ub-video-item__video {
	opacity: 1;
	pointer-events: auto;
}

.ub-video-item--playing .ub-video-item__thumbnail {
	opacity: 0;
}

.ub-video-item--playing .ub-video-item__play-icon {
	opacity: 0;
	pointer-events: none;
}

/* ==========================================================================
   NAVIGATION - SAME AS SLIDER
   ========================================================================== */

.ub-video-carousel__navigation {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.5rem;
	margin-top: 1.5rem;
	padding: 0.3rem;
}

/* Arrow buttons */
.ub-video-carousel__arrow {
	width: 2.5rem;
	height: 2.5rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: 2px solid var(--wp--preset--color--dark-blue);
	border-radius: 50%;
	cursor: pointer;
	padding: 0;
	color: var(--wp--preset--color--dark-blue);
	transition: all 0.2s ease;
}

.ub-video-carousel__arrow:hover {
	background-color: var(--wp--preset--color--dark-blue) !important;
	color: var(--wp--preset--color--white);
}

.ub-video-carousel__arrow svg {
	width: 1.25rem;
	height: 1.25rem;
}

/* Dots */
.ub-video-carousel__dots.carousel-dots {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0 0.5rem;
}

.ub-video-carousel__dots .carousel-dot {
	width: 0.625rem;
	height: 0.625rem;
	border-radius: 50%;
	border: none;
	cursor: pointer;
	padding: 0;
	transition: background-color 0.3s ease, transform 0.2s ease;
}

.ub-video-carousel__dots .carousel-dot:hover {
	transform: scale(1.2);
}

/* ==========================================================================
   RESPONSIVE - TABLET
   ========================================================================== */

@media (min-width: 781px) and (max-width: 1024px) {
	.ub-video-item {
		max-width: calc((100% - (var(--ub-slides-to-show-tablet, 3) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show-tablet, 3));
		min-width: calc((100% - (var(--ub-slides-to-show-tablet, 3) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show-tablet, 3));
	}
}

/* ==========================================================================
   RESPONSIVE - MOBILE
   ========================================================================== */

@media (max-width: 780px) {
	.ub-video-item {
		max-width: calc((100% - (var(--ub-slides-to-show-mobile, 1) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show-mobile, 1));
		min-width: calc((100% - (var(--ub-slides-to-show-mobile, 1) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show-mobile, 1));
	}

	/* Ensure the track aligns to top and doesn't stretch */
	.ub-video-carousel__track {
		align-items: flex-start;
	}

	.ub-video-carousel__navigation {
		justify-content: center;
	}

	.ub-video-carousel__arrow {
		width: 2.25rem;
		height: 2.25rem;
	}

	.ub-video-carousel__arrow svg {
		width: 1rem;
		height: 1rem;
	}

	.ub-video-carousel__dots .carousel-dot {
		width: 0.5rem;
		height: 0.5rem;
	}

	.ub-video-item__play-icon {
		width: 44px;
		height: 44px;
	}
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.ub-video-carousel__arrow:focus,
.ub-video-carousel__dots .carousel-dot:focus,
.ub-video-item__play-icon:focus,
.ub-video-item__fullscreen-btn:focus {
	outline: 2px solid var(--wp--preset--color--dark-blue);
	outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
	.ub-video-carousel__track,
	.ub-video-item,
	.ub-video-item__thumbnail,
	.ub-video-item__thumbnail-wrapper,
	.ub-video-item__video,
	.ub-video-item__play-icon,
	.ub-video-item__controls,
	.ub-video-carousel__arrow,
	.ub-video-carousel__dots .carousel-dot {
		transition: none !important;
	}
}

/* ==========================================================================
   PSEUDO-CLASSES FOR FULLSCREEN MODE
   ========================================================================== */

.ub-video-carousel-fullscreen-active {
	overflow: hidden !important;
}

.ub-video-carousel--fullscreen-active {
	position: fixed !important;
	inset: 0 !important;
	z-index: 2147483647 !important;
	width: 100vw !important;
	height: 100dvh !important;
	max-width: none !important;
	background: #000 !important;
	padding: 0 !important;
	margin: 0 !important;
	border-radius: 0 !important;
}

.ub-video-carousel--fullscreen-active .ub-video-carousel__viewport,
.ub-video-carousel--fullscreen-active .ub-video-carousel__track {
	width: 100% !important;
	height: 100% !important;
	overflow: visible !important;
	transform: none !important;
	transition: none !important;
	display: block !important;
}

.ub-video-carousel--fullscreen-active .ub-video-item {
	display: none !important;
}

.ub-video-carousel--fullscreen-active .ub-video-item--fullscreen {
	display: block !important;
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	min-width: 0 !important;
	background: #000 !important;
}

.ub-video-carousel--fullscreen-active .ub-video-item--fullscreen .ub-video-item__thumbnail-wrapper {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	aspect-ratio: auto !important;
	border-radius: 0 !important;
	background: #000 !important;
}

.ub-video-carousel--fullscreen-active .ub-video-item--fullscreen video,
.ub-video-carousel--fullscreen-active .ub-video-item--fullscreen iframe {
	position: absolute !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	object-fit: contain !important;
	border: 0 !important;
}

.ub-video-carousel--fullscreen-active .ub-video-item--fullscreen .ub-video-item__content,
.ub-video-carousel--fullscreen-active .ub-video-carousel__navigation {
	display: none !important;
}

.ub-video-carousel--fullscreen-active .ub-video-item--fullscreen .ub-video-item__controls {
	position: fixed !important;
	top: 16px !important;
	right: 16px !important;
	z-index: 2147483647 !important;
}
