/**
 * MageSlider - Frontend Stylesheet
 *
 * @package MGSlider
 */

/*
 * Constrain the Elementor widget wrapper itself so the slider can never
 * escape the column/container on any screen size.
 */
.elementor-widget-mgslider,
.elementor-widget-lite_slider {
	max-width: 100%;
	overflow: hidden;
	box-sizing: border-box;
}

.mgslider-slider {
	position: relative;
	z-index: 0;
	isolation: isolate;
	overflow: hidden;
	box-sizing: border-box;
	width: 100%;
	/*
	 * max-width: 100% ensures the slider never overflows its Elementor wrapper
	 * regardless of what fixed-px value is set via the Width control.
	 */
	max-width: 100%;
	/*
	 * Remove the global min-height – it conflicts with aspect-ratio on small
	 * screens (e.g. a 16:9 slider inside a narrow column was taller than the
	 * aspect ratio dictated because min-height prevented shrinking).
	 * A data-attribute-driven CSS custom property keeps the Fixed-Height mode
	 * working without an unconditional minimum.
	 */
	align-self: stretch;
	margin-left: auto;
	margin-right: auto;
	touch-action: pan-y;
	-webkit-user-select: none;
	user-select: none;
	outline-offset: 2px;
	/*
	 * Default aspect ratio via CSS custom property so the JS/PHP can override
	 * it cleanly. height: auto pairs with aspect-ratio to let the browser
	 * calculate the intrinsic height – no fixed px value is baked in here.
	 */
	aspect-ratio: var(--mgslider-ar, 16/9);
	height: auto;
}

.mgslider-viewport {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	/*
	 * Explicit overflow:hidden on the viewport element as a second containment
	 * layer. The parent .mgslider-slider already clips with overflow:hidden,
	 * but adding it here prevents slide translate3d animations from ever
	 * painting outside the visible area during the transition frame before the
	 * animation callback fires.
	 */
	overflow: hidden;
}

/* ---- Slides ---- */
.mgslider-slide {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	visibility: hidden;
	opacity: 0;
}

.mgslider-slide.is-active,
.mgslider-slide.is-leaving {
	visibility: visible;
	opacity: 1;
}

.mgslider-slide.is-active {
	z-index: 2;
}

.mgslider-slide.is-leaving {
	z-index: 1;
}

/* Slides hidden on the current device / empty slider */
.mgslider-slide.mgslider-device-hidden {
	display: none !important;
}

.mgslider-slider.mgslider-empty {
	display: none !important;
}

.mgslider-slider .mgslider-slide picture {
	display: block;
	width: 100%;
	height: 100%;
}

.mgslider-slider .mgslider-slide img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	-webkit-user-drag: none;
	pointer-events: none;
}

/* Lower specificity so Elementor controls always win */
.mgslider-slide img {
	object-fit: cover;
	object-position: center center;
}

.mgslider-overlay {
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
}

/* ---- Caption ---- */
.mgslider-caption {
	position: absolute;
	inset: 0;
	z-index: 3;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	text-align: center;
	pointer-events: none;
}

.mgslider-caption-inner {
	pointer-events: auto;
	max-width: 700px;
	width: 100%;
}

.mgslider-slider .mgslider-title {
	margin: 0;
}

.mgslider-slider .mgslider-text {
	margin: 0;
}

.mgslider-slider .mgslider-btn {
	display: inline-block;
	padding: 12px 28px;
	text-decoration: none;
	line-height: 1.2;
	transition: background-color .25s ease, color .25s ease;
}

.mgslider-slide.is-active .mgslider-caption-inner {
	animation: mgslider-up .7s .15s cubic-bezier(.2, .7, .2, 1) both;
}

@keyframes mgslider-up {
	from {
		opacity: 0;
		transform: translateY(22px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ---- Arrows ---- */
.mgslider-slider .mgslider-arrow {
	position: absolute;
	top: 50%;
	z-index: 6;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .45);
	color: #fff;
	line-height: 1;
	box-shadow: none;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity .25s ease, background-color .25s ease, color .25s ease;
}

.mgslider-slider .mgslider-arrow:hover,
.mgslider-slider .mgslider-arrow:focus-visible {
	background: rgba(0, 0, 0, .7);
}

.mgslider-prev {
	left: 16px;
}

.mgslider-next {
	right: 16px;
}

.mgslider-arrow svg {
	width: 22px;
	height: 22px;
	display: block;
}

.mgslider-arrow svg:not(.mgslider-chev) {
	fill: currentColor;
}

.mgslider-arrow i {
	font-size: 22px;
	line-height: 1;
}

.mgslider-arrow[disabled] {
	opacity: .35;
	cursor: default;
	pointer-events: none;
}

@media (hover: hover) {
	.mgslider-arrows-hover .mgslider-arrow {
		opacity: 0;
	}
	.mgslider-arrows-hover:hover .mgslider-arrow,
	.mgslider-arrows-hover:focus-within .mgslider-arrow {
		opacity: 1;
	}
	.mgslider-arrows-hover:hover .mgslider-arrow[disabled] {
		opacity: .35;
	}
}

/* ---- Pagination ---- */
.mgslider-pagination {
	position: absolute;
	left: 0;
	right: 0;
	bottom: var(--mgslider-pag-offset, 16px);
	z-index: 6;
	display: flex;
	justify-content: center;
	padding: 0 16px;
	pointer-events: none;
}

.mgslider-pag-top .mgslider-pagination {
	bottom: auto;
	top: var(--mgslider-pag-offset, 16px);
}

.mgslider-dots {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	pointer-events: auto;
}

.mgslider-slider .mgslider-dot {
	box-sizing: border-box;
	width: 10px;
	height: 10px;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .5);
	box-shadow: none;
	line-height: 0;
	cursor: pointer;
	transition: background-color .25s ease, transform .25s ease;
}

.mgslider-slider .mgslider-dot.is-active {
	background: #fff;
	transform: scale(1.25);
}

.mgslider-fraction {
	color: #fff;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	pointer-events: auto;
}

.mgslider-progress {
	width: min(240px, 60%);
	height: 4px;
	border-radius: 4px;
	overflow: hidden;
	background: rgba(255, 255, 255, .35);
	pointer-events: auto;
}

.mgslider-progress-bar {
	height: 100%;
	width: 0;
	background: #fff;
	transition: width .4s ease;
}

/* Only one visible slide on this device -> no navigation */
.mgslider-slider.mgslider-single .mgslider-arrow,
.mgslider-slider.mgslider-single .mgslider-pagination {
	display: none !important;
}

.mgslider-slider:focus-visible {
	outline: 2px solid currentColor;
}

@media (prefers-reduced-motion: reduce) {
	.mgslider-slide.is-active .mgslider-caption-inner {
		animation: none;
	}
	.mgslider-slider * {
		transition-duration: .01ms !important;
	}
}

/*
 * Responsive overflow safety net.
 *
 * Elementor's Width control lets editors set a fixed px value for the slider.
 * On narrow screens that pixel value can exceed the viewport width, pushing
 * the slider (and therefore the section) wider than the page and causing the
 * classic "content overflows container / overlaps next section" bug.
 *
 * max-width:100% on .mgslider-slider handles most cases, but we also enforce
 * it here at the device-level in case a theme or Elementor's own CSS resets
 * max-width with higher specificity.
 */
@media (max-width: 1024px) {
	.mgslider-slider {
		max-width: 100% !important;
	}
}

@media (max-width: 767px) {
	.mgslider-slider {
		max-width: 100% !important;
		/*
		 * On mobile the default 16/9 aspect ratio can produce a very short
		 * slider inside narrow columns. We set a lower bound on the intrinsic
		 * height only when the slider is sized by aspect-ratio (i.e. height is
		 * "auto"). The min() clamp ensures the slider never grows taller than
		 * 60 vh either, preventing it from pushing content below the fold.
		 */
		min-height: clamp(120px, 40vw, 60vh);
	}
}

