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

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

/* Full width to container */
.ub-video-carousel.alignfull {
	width: 100%;
	max-width: 100%;
}

.ub-video-carousel.alignwide {
	width: 100%;
	max-width: 100%;
}

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

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

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

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

.ub-video-item {
	position: relative;
	/* Calculate width accounting for gaps between items */
	-webkit-box-flex: 1;
	    -ms-flex: 1 0 0%;
	        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: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-orient: vertical;
	-webkit-box-direction: normal;
	    -ms-flex-direction: column;
	        flex-direction: column;
	-webkit-transition: max-width 0.4s ease-in-out, min-width 0.4s ease-in-out;
	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: 3/4.8;
	overflow: hidden;
	border-radius: 0.75rem;
	background-color: #000;
	-webkit-transition: aspect-ratio 0.4s ease-in-out;
	transition: aspect-ratio 0.4s ease-in-out;
}

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

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

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

.ub-video-item__play-icon:hover {
	-webkit-transform: translate(-50%, -50%) scale(1.1);
	        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: -webkit-box;
	display: -ms-flexbox;
	display: flex;
}

.ub-video-item__fullscreen-btn,
.ub-video-item__pause-btn {
	width: 2.5rem;
	height: 2.5rem;
	display: -webkit-inline-box;
	display: -ms-inline-flexbox;
	display: inline-flex;
	-webkit-box-align: center;
	    -ms-flex-align: center;
	        align-items: center;
	-webkit-box-pack: center;
	    -ms-flex-pack: center;
	        justify-content: center;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	border-radius: 50%;
	cursor: pointer;
	color: #002e5a;
	-webkit-transition: background-color 0.2s ease, -webkit-transform 0.2s ease;
	transition: background-color 0.2s ease, -webkit-transform 0.2s ease;
	transition: background-color 0.2s ease, transform 0.2s ease;
	transition: background-color 0.2s ease, transform 0.2s ease, -webkit-transform 0.2s ease;
}

.ub-video-item__fullscreen-btn:hover,
.ub-video-item__pause-btn:hover {
	background: #fff;
	-webkit-transform: scale(1.1);
	        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: 1rem;
	font-weight: 700;
	color: #002e5a;
	line-height: 1.4;
}

.ub-video-item__description {
	margin: 0.25rem 0 0;
	font-size: 0.875rem;
	color: #3b3c43;
	line-height: 1.5;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ==========================================================================
   HOVER STATE - EXPAND VIDEO
   ========================================================================== */

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

/* ==========================================================================
   EXPANDED STATE (when playing)
   ========================================================================== */

.ub-video-item--expanded {
	max-width: calc((100% - (var(--ub-slides-to-show, 4) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show, 4) * 2);
	min-width: calc((100% - (var(--ub-slides-to-show, 4) - 1) * var(--ub-video-gap, 24px)) / var(--ub-slides-to-show, 4) * 2);
	z-index: 5;
}

/* Keep the same pixel height as other thumbnails: original is 3:4.8, doubled width means 6:4.8 = 5:4 */
.ub-video-item--expanded .ub-video-item__thumbnail-wrapper {
	aspect-ratio: 5/4;
}

/* ==========================================================================
   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: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	    -ms-flex-align: center;
	        align-items: center;
	-webkit-box-pack: end;
	    -ms-flex-pack: end;
	        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: -webkit-inline-box;
	display: -ms-inline-flexbox;
	display: inline-flex;
	-webkit-box-align: center;
	    -ms-flex-align: center;
	        align-items: center;
	-webkit-box-pack: center;
	    -ms-flex-pack: center;
	        justify-content: center;
	background: transparent;
	border: 2px solid #002e5a;
	border-radius: 50%;
	cursor: pointer;
	padding: 0;
	color: #002e5a;
	-webkit-transition: all 0.2s ease;
	transition: all 0.2s ease;
}

.ub-video-carousel__arrow:hover {
	background-color: #002e5a;
	color: #ffffff;
}

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

/* Dots */
.ub-video-carousel__dots.carousel-dots {
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	    -ms-flex-align: center;
	        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;
	-webkit-transition: background-color 0.3s ease, -webkit-transform 0.2s ease;
	transition: background-color 0.3s ease, -webkit-transform 0.2s ease;
	transition: background-color 0.3s ease, transform 0.2s ease;
	transition: background-color 0.3s ease, transform 0.2s ease, -webkit-transform 0.2s ease;
}

.ub-video-carousel__dots .carousel-dot:hover {
	-webkit-transform: scale(1.2);
	        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));
	}

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

	/* Original 3:4.8, width * 1.5, so aspect ratio becomes 4.5:4.8 = 15:16 */
	.ub-video-item--expanded .ub-video-item__thumbnail-wrapper {
		aspect-ratio: 15/16;
	}
}

/* ==========================================================================
   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));
	}

	/* On mobile, expanded takes full width */
	.ub-video-item--expanded {
		max-width: 100%;
		min-width: 100%;
	}

	/* Mobile: When playing, use 16:9 aspect ratio to reduce white space */
	.ub-video-item--playing .ub-video-item__thumbnail-wrapper {
		aspect-ratio: 16/9;
		height: auto;
		padding-bottom: 0;
	}

	/* When a video is playing on mobile, hide other items completely so track shrinks */
	.ub-video-carousel:has(.ub-video-item--playing) .ub-video-item:not(.ub-video-item--playing) {
		display: none;
	}

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

	.ub-video-carousel__navigation {
		-webkit-box-pack: center;
		    -ms-flex-pack: center;
		        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 #002e5a;
	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 {
		-webkit-transition: none !important;
		transition: none !important;
	}
}
