/*
 * Home hero carousel (replaces Slider Revolution).
 *
 * Markup is built in Elementor: a container with the CSS class "rp-hero" whose
 * direct child containers carry the class "rp-hero__slide". rp-hero.js turns them
 * into a Swiper carousel on the front end; inside the Elementor editor the slides
 * stay stacked so each one can be edited.
 *
 * Buttons, arrows, bullets and the entrance of each slide's content reproduce
 * the old Slider Revolution "Home Ripoll" slider.
 */

/* Full width: the theme wraps page content in a boxed container and Elementor
   containers cannot be "stretched" like the old sections, so the hero breaks
   out to the viewport edges. --rp-scrollbar is set by rp-hero.js so the width
   leaves room for the vertical scrollbar (no horizontal scroll). */
.rp-hero {
	--rp-rise: 50px;
	--rp-ease: cubic-bezier(0.645, 0.045, 0.355, 1);
	width: calc(100vw - var(--rp-scrollbar, 0px)) !important;
	max-width: none !important;
	margin-left: calc(50% - (100vw - var(--rp-scrollbar, 0px)) / 2) !important;
	margin-right: calc(50% - (100vw - var(--rp-scrollbar, 0px)) / 2) !important;
}

/* Slide height: same proportions the old slider used (1240x950 desktop grid,
   778x650 tablet grid, 480x720 mobile grid). */
.rp-hero .rp-hero__slide {
	min-height: min(950px, 76.6vw);
}

@media (max-width: 1240px) {
	.rp-hero {
		--rp-rise: 41px;
	}
}

@media (max-width: 1024px) {
	.rp-hero {
		--rp-rise: 31px;
	}

	.rp-hero .rp-hero__slide {
		min-height: min(768px, 83.5vw);
	}
}

@media (max-width: 767px) {
	.rp-hero {
		--rp-rise: 19px;
	}

	.rp-hero .rp-hero__slide {
		min-height: 150vw;
	}
}

/* Before the script runs, show only the first slide (no layout jump). */
body:not(.elementor-editor-active) .rp-hero:not(.rp-hero--ready) > .rp-hero__slide ~ .rp-hero__slide,
body:not(.elementor-editor-active) .rp-hero:not(.rp-hero--ready) > .e-con-inner > .rp-hero__slide ~ .rp-hero__slide {
	display: none;
}

/* Keep the slide content hidden from the first paint until rp-hero.js takes
   over and plays the entrance, so it does not show, vanish and fade back in.
   If the script never runs, it appears after 3s. */
@media (prefers-reduced-motion: no-preference) {
	body:not(.elementor-editor-active) .rp-hero:not(.rp-hero--ready) .rp-hero__slide .elementor-widget:not(.elementor-widget-html) {
		opacity: 0;
		animation: rp-hero-reveal 0s linear 3s forwards;
	}
}

@keyframes rp-hero-reveal {
	to {
		opacity: 1;
	}
}

/* Swiper core rules, kept here so the carousel does not depend on another
   widget loading Swiper's stylesheet. */
.rp-hero__swiper {
	position: relative;
	width: 100%;
	overflow: hidden;
}

.rp-hero__swiper .swiper-wrapper {
	position: relative;
	display: flex;
	width: 100%;
	box-sizing: content-box;
	transition-property: transform;
}

.rp-hero__swiper .swiper-slide {
	position: relative;
	flex-shrink: 0;
	width: 100%;
	--width: 100%;
	/* Swiper's own stylesheet sets height: 100%, which stops shorter slides from
	   stretching to the tallest one and leaves an empty strip below them. */
	height: auto;
	transition-property: transform;
}

.rp-hero__swiper.swiper-fade .swiper-slide {
	pointer-events: none;
	transition-property: opacity;
	/* Elementor containers carry a 0.3s transition; without this, slides 2-5 fade
	   out on load and the last one shows for a moment. Swiper sets its own
	   duration inline when it really animates. */
	transition-duration: 0ms;
}

/* Until Swiper has laid out the slides, only the first one may be seen. */
.rp-hero__swiper:not(.swiper-initialized) .swiper-slide ~ .swiper-slide {
	visibility: hidden;
}

.rp-hero__swiper.swiper-fade .swiper-slide-active {
	pointer-events: auto;
}

/* Entrance of each slide's content: every element rises 50px (41/31/19px on
   smaller screens) and fades in over 1s, staggered like the old slider
   (label 300ms, title 480ms, text 700ms, button 1000ms). rp-hero.js sets each
   element's --rp-delay and toggles the state classes. */
.rp-hero .rp-anim {
	opacity: 0;
	transform: translate3d(0, var(--rp-rise), 0);
}

.rp-hero .rp-anim--fade {
	transform: none;
}

.rp-hero .rp-anim-in .rp-anim {
	opacity: 1;
	transform: none;
	transition: opacity 1s var(--rp-ease) var(--rp-delay, 0ms), transform 1s var(--rp-ease) var(--rp-delay, 0ms);
}

.rp-hero .rp-anim-out .rp-anim {
	opacity: 0;
	transform: none;
	transition: opacity 0.3s linear;
}

/* Buttons: same as the theme's "flat" button used in the old slider. A 6px
   plum bar on the left widens to fill the button and the plus icon turns 90deg. */
.rp-hero .elementor-button {
	position: relative;
	isolation: isolate;
	overflow: hidden;
}

.rp-hero .elementor-button::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	z-index: -1;
	width: 6px;
	height: 100%;
	background: #5e3756;
	transition: width 0.5s ease-in-out;
}

.rp-hero .elementor-button:hover::before,
.rp-hero .elementor-button:focus-visible::before {
	width: 100%;
}

.rp-hero .elementor-button .elementor-button-icon {
	display: inline-flex;
	transition: transform 0.5s ease-in-out;
}

.rp-hero .elementor-button:hover .elementor-button-icon,
.rp-hero .elementor-button:focus-visible .elementor-button-icon {
	transform: rotate(90deg);
}

@media (max-width: 480px) {
	.rp-hero .elementor-button::before {
		width: 4px;
	}
}

/* Arrows (old "metis" style): white 60px squares, 30px from the edges and
   50px below the middle. They fade in while the pointer is over the hero and
   are only used on screens 1400px wide or more, like before. */
.rp-hero__nav {
	position: absolute;
	top: calc(50% + 50px);
	z-index: 5;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	padding: 10px;
	border: 0;
	border-radius: 0;
	background: #ffffff;
	color: #000000;
	cursor: pointer;
	opacity: 0;
	pointer-events: none;
	transform: translateY(-50%);
	transition: opacity 0.1s linear 0.2s, background-color 0.3s;
}

.rp-hero:hover .rp-hero__nav,
.rp-hero__nav:focus-visible {
	opacity: 1;
	pointer-events: auto;
	transition: opacity 0.1s linear 0.1s, background-color 0.3s;
}

.rp-hero__nav:hover,
.rp-hero__nav:focus-visible {
	background: rgba(255, 255, 255, 0.75);
}

.rp-hero__nav svg {
	width: 15px;
	height: 15px;
	transition: transform 0.3s;
}

.rp-hero__nav:hover svg,
.rp-hero__nav:focus-visible svg {
	transform: scale(1.5);
}

.rp-hero__nav--prev {
	left: 30px;
}

.rp-hero__nav--next {
	right: 30px;
}

@media (max-width: 1399px) {
	.rp-hero__nav {
		display: none;
	}
}

/* Bullets (old "hesperiden" style): 12px plum dots 5px apart, 20px from the
   bottom, blue when active or hovered. They fade in 1s after load. */
.rp-hero__dots {
	position: absolute;
	bottom: 20px;
	left: 0;
	right: 0;
	z-index: 5;
	display: flex;
	justify-content: center;
	gap: 5px;
	animation: rp-hero-fade-in 1s ease 1s both;
}

.rp-hero__dots .swiper-pagination-bullet {
	width: 12px;
	height: 12px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #5d3656;
	cursor: pointer;
}

.rp-hero__dots .swiper-pagination-bullet:hover,
.rp-hero__dots .swiper-pagination-bullet-active {
	background: #569ae1;
}

.rp-hero__nav:focus-visible,
.rp-hero__dots .swiper-pagination-bullet:focus-visible {
	outline: 2px solid #569ae1;
	outline-offset: 2px;
}

@keyframes rp-hero-fade-in {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rp-hero .rp-anim,
	.rp-hero .rp-anim-out .rp-anim {
		opacity: 1;
		transform: none;
		transition: none;
	}

	.rp-hero__dots {
		animation: none;
	}
}
