/* ==========================================================================
   Beneta Vintage — movimiento
   «La alquimia del tiempo»: arcos que se abren, sombras largas de atardecer,
   palabras empujadas por la tramuntana y un sol que se pone sobre el Empordà.

   Reglas: solo transform/translate/scale, opacity y clip-path. Sin secuestro del
   scroll. Con «reducir movimiento» todo queda estático y legible. Las apariciones
   dependen de la clase .bv-motion (la pone un script en <head> y se retira sola
   si el JS del tema no llega): sin JS, todo se ve desde el principio.
   ========================================================================== */

:root {
	--bv-out: cubic-bezier(.16, 1, .3, 1);
	--bv-in-out: cubic-bezier(.65, 0, .35, 1);
}

/* ---------- Titulares divididos en palabras ---------- */

.bv-split-words .bv-w { display: inline-block; }
.bv-split-words .bv-w > span { display: inline-block; }

/* ==========================================================================
   1. Transiciones entre páginas (View Transitions, mejora progresiva)
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
	@view-transition { navigation: auto; }

	.bv-header { view-transition-name: bv-header; }

	::view-transition-old(root) { animation: bv-vt-out .28s var(--bv-in-out) both; }
	::view-transition-new(root) { animation: bv-vt-in .5s var(--bv-out) both; }

	/* La foto de la tarjeta viaja hasta la galería de la ficha. */
	::view-transition-group(*) { animation-duration: .55s; animation-timing-function: var(--bv-out); }
}

@keyframes bv-vt-out { to { opacity: 0; transform: translateY(-12px); } }
@keyframes bv-vt-in { from { opacity: 0; transform: translateY(18px); } }

/* ==========================================================================
   2. Entrada coreografiada del hero (solo CSS, al cargar; ≤ 1,4 s)
   La imagen principal (LCP) nunca se oculta: solo se asienta con una escala.
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {

	/* Líneas del H1: cada palabra sube desde su máscara (sin tocar la opacidad). */
	:is(.bv-hero__title, .bv-pagehero h1) .bv-w {
		overflow: clip;
		padding: .1em .04em .18em;
		margin: -.1em -.04em -.18em;
		vertical-align: top;
	}

	:is(.bv-hero__title, .bv-pagehero h1) .bv-w > span {
		animation: bv-mask-up .95s var(--bv-out) backwards;
		animation-delay: calc(.05s + var(--i, 0) * .06s);
	}

	/* Antetítulo: la raya se dibuja y el texto aparece. */
	:is(.bv-hero, .bv-pagehero) .is-style-eyebrow::before { transform-origin: left; animation: bv-draw .9s .1s var(--bv-out) backwards; }
	:is(.bv-hero, .bv-pagehero) .is-style-eyebrow { animation: bv-fade 0.9s .15s var(--bv-ease) backwards; }

	/* La firma «la alquimia del tiempo» se escribe de izquierda a derecha. */
	.bv-hero__sign { animation: bv-write 1.1s .5s var(--bv-in-out) backwards; }

	/* Entradilla (puede ser el LCP en móvil: entra enseguida) y llamada a la acción. */
	:is(.bv-hero__lead, .bv-pagehero .is-style-lead) { animation: bv-fade-up .8s .12s var(--bv-out) backwards; }
	:is(.bv-hero__cta, .bv-pagehero .wp-block-buttons) { animation: bv-fade-up .8s .35s var(--bv-out) backwards; }

	/* Imagen principal: se asienta (escala), sin ocultarse. */
	:is(.bv-hero, .bv-pagehero) .bv-media__img,
	:is(.bv-hero, .bv-pagehero) .bv-media__ph { animation: bv-settle 1.6s var(--bv-out) backwards; }

	/* La puerta vintage se abre: un arco que crece desde el suelo. */
	.bv-door--vintage .bv-media__frame { animation: bv-door-open 1.15s .25s var(--bv-in-out) backwards; }
	.bv-door__label { animation: bv-fade-up .8s .7s var(--bv-out) backwards; }
	.bv-door--vintage .bv-door__label { animation-delay: .9s; }

	/* Las sombras de atardecer se alargan. */
	:is(.bv-hero, .bv-pagehero) .bv-media__shadow { animation: bv-shadow-grow 1.5s .35s var(--bv-out) backwards; }
}

@keyframes bv-mask-up { from { transform: translateY(108%); } }
@keyframes bv-draw { from { transform: scaleX(0); } }
@keyframes bv-fade { from { opacity: 0; } }
@keyframes bv-fade-up { from { opacity: 0; transform: translateY(1.1rem); } }
@keyframes bv-settle { from { transform: scale(1.1); } }
@keyframes bv-write {
	from { clip-path: inset(-40% 100% -60% -8%); }
	to { clip-path: inset(-40% -8% -60% -8%); }
}
@keyframes bv-door-open {
	from { clip-path: inset(100% 0 0 0); }
	to { clip-path: inset(0 0 0 0); }
}
@keyframes bv-shadow-grow { from { transform: skewX(-18deg) scaleY(.06); opacity: 0; } }

/* ==========================================================================
   3. Arcos vivos
   ========================================================================== */

/* Al pasar por una puerta, el arco «respira» (se estira hacia un arco apuntado)
   y su sombra se alarga como al caer la tarde. */
.bv-door .bv-media__frame {
	transition: border-radius 1s var(--bv-out), box-shadow .4s var(--bv-ease);
}

.bv-door:hover .bv-media--arch .bv-media__frame {
	border-radius: 50% 50% 0 0 / calc(var(--arch-r) * 1.32) calc(var(--arch-r) * 1.32) 0 0;
}

.bv-door:hover .bv-media__shadow { transform: skewX(-70deg) scaleY(.4); }

/* Parallax interno: la foto se desplaza dentro de su marco al hacer scroll (±5 %). */
@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		.bv-media__img {
			top: -6%;
			height: 112%;
			animation: bv-parallax linear both;
			animation-timeline: view();
			animation-range: cover;
		}

		:is(.bv-hero, .bv-pagehero) .bv-media__img {
			animation: bv-settle 1.6s var(--bv-out) backwards, bv-parallax linear both;
			animation-timeline: auto, view();
			animation-range: normal, cover;
		}
	}
}

@keyframes bv-parallax {
	from { translate: 0 -5%; }
	to { translate: 0 5%; }
}

/* Revelado al entrar en pantalla: una cortina con forma de arco que se abre desde abajo. */
@media (prefers-reduced-motion: no-preference) {
	.bv-motion .bv-media[data-reveal] .bv-media__frame {
		transition: clip-path 1.5s var(--bv-in-out);
		transition-delay: calc(var(--d, 0) * .12s);
	}

	.bv-motion .bv-media[data-reveal]:not(.is-in) .bv-media__frame { clip-path: ellipse(0% 0% at 50% 100%); }
	.bv-motion .bv-media[data-reveal].is-in .bv-media__frame { clip-path: ellipse(150% 150% at 50% 100%); }

	.bv-motion .bv-media[data-reveal] .bv-media__shadow { transition: transform 1.6s .5s var(--bv-out), opacity 1s .5s var(--bv-ease); }
	.bv-motion .bv-media[data-reveal]:not(.is-in) .bv-media__shadow { transform: skewX(-18deg) scaleY(.06); opacity: 0; }

	.bv-motion .bv-media[data-reveal] .bv-media__caption { transition: opacity .8s .6s var(--bv-ease); }
	.bv-motion .bv-media[data-reveal]:not(.is-in) .bv-media__caption { opacity: 0; }

	/* El hero tiene su propia coreografía. */
	.bv-motion .bv-hero .bv-media[data-reveal] .bv-media__frame { clip-path: none; transition: border-radius 1s var(--bv-out); }
	.bv-motion .bv-hero .bv-media[data-reveal] .bv-media__shadow { transition: transform 1.1s var(--bv-ease), opacity .6s var(--bv-ease); }
	.bv-motion .bv-hero .bv-media[data-reveal]:not(.is-in) .bv-media__shadow { transform: skewX(-62deg) scaleY(.3); opacity: 1; }
}

/* ==========================================================================
   4. Tipografía en movimiento
   ========================================================================== */

/* Titulares de sección: entran palabra a palabra al aparecer. */
@media (prefers-reduced-motion: no-preference) {
	.bv-motion .bv-split-words:not(.bv-hero__title):not(.bv-pagehero h1) .bv-w > span {
		transition: opacity .7s var(--bv-ease), transform 1s var(--bv-out);
		transition-delay: calc(var(--i, 0) * 50ms);
	}

	.bv-motion .bv-split-words:not(.bv-hero__title):not(.bv-pagehero h1):not(.is-in) .bv-w > span {
		opacity: 0;
		transform: translateY(.55em) rotate(4deg);
	}
}

/* Palabras manuscritas que derivan con la tramuntana (ligado al scroll). */
@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		.bv-script,
		.bv-path__kicker,
		.bv-related__title .bv-script {
			animation: bv-drift linear both;
			animation-timeline: view();
			animation-range: cover;
		}

		.bv-chapter__name {
			animation: bv-drift-far linear both;
			animation-timeline: view();
			animation-range: cover;
		}
	}
}

@keyframes bv-drift {
	from { translate: -.35em 0; rotate: 2deg; }
	to { translate: .35em 0; rotate: -1.5deg; }
}

@keyframes bv-drift-far {
	from { translate: 7vw 0; rotate: 3deg; }
	to { translate: -2vw 0; rotate: -2deg; }
}

@media (max-width: 781px) {
	@keyframes bv-drift-far {
		from { translate: 3vw 0; rotate: 3deg; }
		to { translate: -3vw 0; rotate: -1deg; }
	}

	@keyframes bv-drift {
		from { translate: -.18em 0; rotate: 1.5deg; }
		to { translate: .18em 0; rotate: -1deg; }
	}
}

/* ==========================================================================
   5. Líneas, numeración y listas que se dibujan al entrar
   ========================================================================== */

.bv-chapter__head,
.bv-step,
.bv-services,
.bv-catindex,
.bv-faq,
.bv-related__title {
	position: relative;
}

@media (prefers-reduced-motion: no-preference) {
	/* La raya superior se dibuja de izquierda a derecha. */
	.bv-motion :is(.bv-chapter__head, .bv-step) { border-top-color: transparent; }

	.bv-motion :is(.bv-chapter__head, .bv-step)::before {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		top: -1px;
		height: 1px;
		background: var(--bv-tinta);
		transform-origin: left;
		transition: transform 1.3s var(--bv-out);
		transition-delay: calc(var(--d, 0) * .12s);
	}

	.bv-motion .bv-step::before { background: var(--bv-line-strong); }

	.bv-motion :is(.bv-chapter__head, .bv-step):not(.is-in)::before { transform: scaleX(0); }

	/* Número de capítulo y de paso: sube desde su línea. */
	.bv-motion :is(.bv-chapter__num, .bv-step > *) {
		transition: opacity .8s var(--bv-ease), transform 1s var(--bv-out);
		transition-delay: calc(var(--d, 0) * .12s + .15s);
	}

	.bv-motion .bv-step > * + * { transition-delay: calc(var(--d, 0) * .12s + .28s); }

	.bv-motion .bv-chapter__head:not(.is-in) .bv-chapter__num,
	.bv-motion .bv-step:not(.is-in) > * { opacity: 0; transform: translateY(.8rem); }

	.bv-motion .bv-step:not(.is-in) .bv-step__n { transform: translateY(60%); }

	/* Filas del índice de categorías, servicios y preguntas. */
	.bv-motion :is(.bv-catindex > li, .bv-services > li) {
		transition: opacity .8s var(--bv-ease), transform 1s var(--bv-out);
		transition-delay: calc(var(--d, 0) * 80ms);
	}

	.bv-motion :is(.bv-catindex > li, .bv-services > li):not(.is-in) { opacity: 0; transform: translateX(-1.5rem); }

	/* Caminos de la encrucijada y piezas de las rejillas. */
	.bv-motion :is(.bv-path, .bv-grid .wc-block-product-template > li, .bv-faq, .bv-panel) {
		transition: opacity .9s var(--bv-ease), transform 1.1s var(--bv-out);
		transition-delay: calc(var(--d, 0) * 90ms);
	}

	.bv-motion :is(.bv-path, .bv-grid .wc-block-product-template > li, .bv-faq, .bv-panel):not(.is-in) {
		opacity: 0;
		transform: translateY(2.5rem);
	}
}

/* ==========================================================================
   6. El sol del Empordà: cielo, sol y mar en la sección oscura
   ========================================================================== */

.bv-emporda {
	--bv-sunset-h: clamp(7.5rem, 4rem + 11vw, 15rem);
	padding-top: calc(var(--bv-sunset-h) + clamp(2rem, 1rem + 3vw, 4.5rem)) !important;
}

.bv-sunset {
	position: absolute;
	inset: 0 0 auto;
	height: var(--bv-sunset-h);
	overflow: clip;
	pointer-events: none;
	view-timeline: --bv-sunset block;
}

.bv-sunset__sky {
	position: absolute;
	inset: 0;
	background:
		radial-gradient(38% 110% at 72% 100%, rgba(246, 221, 184, .55) 0%, rgba(210, 154, 102, .38) 32%, rgba(168, 106, 54, .14) 62%, transparent 82%),
		linear-gradient(to bottom, var(--bv-mar) 0%, #2A3E4C 55%, #5B4B45 100%);
	opacity: .7;
}

.bv-sunset__sun {
	position: absolute;
	left: 72%;
	top: 0;
	width: clamp(3.25rem, 2rem + 5vw, 7rem);
	aspect-ratio: 1;
	margin-left: calc(clamp(3.25rem, 2rem + 5vw, 7rem) / -2);
	border-radius: 50%;
	background: radial-gradient(circle at 50% 42%, #FBEBD2 0%, #EFC08C 45%, var(--bv-coure-clar) 75%, var(--bv-coure) 100%);
	box-shadow: 0 0 3rem .5rem rgba(239, 192, 140, .35), 0 0 9rem 2rem rgba(210, 154, 102, .22);
	translate: 0 calc(var(--bv-sunset-h) * .5);
}

.bv-sunset__sea {
	position: absolute;
	left: 0;
	right: 0;
	top: 72%;
	bottom: 0;
	background: var(--bv-mar);
	border-top: 1px solid rgba(239, 192, 140, .55);
}

/* Reflejo del sol sobre el agua. */
.bv-sunset__sea::before {
	content: "";
	position: absolute;
	top: 0;
	left: 72%;
	width: clamp(4rem, 2rem + 8vw, 10rem);
	height: 100%;
	translate: -50% 0;
	background: repeating-linear-gradient(to bottom, rgba(239, 192, 140, .5) 0 2px, transparent 2px 7px);
	mask-image: linear-gradient(to bottom, #000, transparent 90%);
	-webkit-mask-image: linear-gradient(to bottom, #000, transparent 90%);
	opacity: .55;
}

@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) {
		.bv-sunset__sun {
			animation: bv-sun-set linear both;
			animation-timeline: --bv-sunset;
			animation-range: cover 5% cover 80%;
		}

		.bv-sunset__sky,
		.bv-sunset__sea::before {
			animation: bv-dusk linear both;
			animation-timeline: --bv-sunset;
			animation-range: cover 5% cover 85%;
		}
	}
}

@keyframes bv-sun-set {
	from { translate: 0 calc(var(--bv-sunset-h) * .06); scale: 1; }
	to { translate: 0 calc(var(--bv-sunset-h) * .92); scale: 1.12; }
}

@keyframes bv-dusk {
	from { opacity: 1; }
	to { opacity: .12; }
}

/* ==========================================================================
   7. Cinta de texto entre capítulos
   ========================================================================== */

.bv-ticker {
	position: relative;
	overflow: clip;
	padding-block: clamp(2rem, 1.2rem + 2.6vw, 3.75rem) clamp(1.25rem, .8rem + 1.6vw, 2.5rem);
	border-block: 1px solid var(--bv-line-strong);
	margin-block: 0 !important;
	-webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
	mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.bv-ticker__track {
	display: flex;
	width: max-content;
}

.bv-ticker__row {
	display: flex;
	align-items: center;
	flex: none;
}

.bv-ticker__item {
	font-size: clamp(2.5rem, 1.4rem + 5.2vw, 7rem);
	font-weight: 290;
	font-stretch: 75%;
	line-height: 1.1;
	letter-spacing: -.02em;
	white-space: nowrap;
	padding-inline: .32em;
	color: var(--bv-tinta);
}

.bv-ticker__item.is-script {
	font-family: var(--bv-script);
	font-weight: 400;
	font-stretch: 100%;
	letter-spacing: 0;
	color: var(--bv-coure);
	font-size: clamp(2.1rem, 1.1rem + 4.2vw, 5.6rem);
	transform: rotate(-4deg) translateY(.04em);
	padding-inline: .4em .3em;
}

.bv-ticker__sep {
	flex: none;
	width: .55rem;
	height: .55rem;
	border-radius: 50%;
	background: var(--bv-coure);
}

.bv-ticker__toggle {
	position: absolute;
	right: var(--bv-gutter);
	bottom: .5rem;
	z-index: 2;
	width: 2.75rem;
	height: 2.75rem;
	border-radius: 50%;
	border: 1px solid var(--bv-line-strong);
	background: color-mix(in srgb, var(--bv-cal) 88%, transparent);
	color: var(--bv-tinta);
	cursor: pointer;
	display: none;
	align-items: center;
	justify-content: center;
	opacity: .75;
	transition: opacity .2s var(--bv-ease), background-color .2s var(--bv-ease);
}

.bv-ticker__toggle:hover,
.bv-ticker__toggle:focus-visible { opacity: 1; background: var(--bv-cal); }

/* Pausa (dos barras) / reproducir (triángulo). */
.bv-ticker__toggle::before {
	content: "";
	width: .7rem;
	height: .8rem;
	background: linear-gradient(90deg, currentColor 0 35%, transparent 35% 65%, currentColor 65%);
}

.bv-ticker__toggle[aria-pressed="true"]::before {
	width: .75rem;
	background: currentColor;
	clip-path: polygon(10% 0, 100% 50%, 10% 100%);
}

@media (prefers-reduced-motion: no-preference) {
	.bv-ticker__track { animation: bv-ticker 70s linear infinite; }
	.bv-ticker__toggle { display: inline-flex; }

	.bv-ticker:hover .bv-ticker__track,
	.bv-ticker.is-paused .bv-ticker__track,
	.bv-ticker.is-off .bv-ticker__track { animation-play-state: paused; }

	.bv-motion .bv-ticker { transition: opacity 1s var(--bv-ease); }
	.bv-motion .bv-ticker:not(.is-in) { opacity: 0; }
}

@media (max-width: 781px) {
	.bv-ticker__track { animation-duration: 45s; }
}

@keyframes bv-ticker { to { transform: translateX(-50%); } }

/* ==========================================================================
   8. Índice de categorías: previsualización que sigue al cursor
   ========================================================================== */

.bv-catprev {
	position: fixed;
	left: 0;
	top: 0;
	z-index: 60;
	width: clamp(11rem, 7rem + 8vw, 17rem);
	aspect-ratio: 4 / 5;
	margin: -62% 0 0 1.75rem;
	pointer-events: none;
	border-radius: 50% 50% 0 0 / 40% 40% 0 0;
	overflow: hidden;
	background: var(--bv-arena);
	box-shadow: 1.5rem 1.75rem 2.5rem -1.5rem rgba(28, 23, 20, .35);
	opacity: 0;
	scale: .6;
	rotate: -6deg;
	transition: opacity .35s var(--bv-ease), scale .6s var(--bv-out), rotate .6s var(--bv-out);
}

.bv-catprev.is-on { opacity: 1; scale: 1; rotate: 0deg; }

.bv-catprev img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
	.bv-catprev { display: none; }
}

/* ==========================================================================
   9. Tarjetas de producto y botones
   ========================================================================== */

.bv-card .wc-block-components-product-image { position: relative; }

.bv-card .wc-block-components-product-image,
.bv-card .bv-card__media {
	transition: transform .7s var(--bv-out), box-shadow .7s var(--bv-out);
}

.bv-card__alt {
	position: absolute !important;
	inset: 0;
	opacity: 0;
	transition: opacity .6s var(--bv-ease), transform 1s var(--bv-ease) !important;
}

@media (hover: hover) and (pointer: fine) {
	.bv-card:hover .wc-block-components-product-image {
		transform: translateY(-.4rem);
		box-shadow: 1.1rem 1.4rem 2rem -1.4rem rgba(28, 23, 20, .32);
	}

	.bv-card:hover .bv-card__alt { opacity: 1; }
}

/* Botones «magnéticos» en escritorio: el JS solo cambia «translate». */
.wp-block-button__link,
.bv-rail-nav button,
.wpcf7-submit,
.bv-product__cart .single_add_to_cart_button {
	transition-property: background-color, color, border-color, translate;
	transition-duration: .25s, .25s, .25s, .5s;
	transition-timing-function: var(--bv-ease), var(--bv-ease), var(--bv-ease), var(--bv-out);
}

/* ==========================================================================
   10. Menú móvil: los enlaces entran escalonados
   ========================================================================== */

@media (prefers-reduced-motion: no-preference) {
	.bv-nav .is-menu-open .wp-block-navigation-item {
		animation: bv-fade-up .7s var(--bv-out) backwards;
	}

	.bv-nav .is-menu-open .wp-block-navigation-item:nth-child(2) { animation-delay: .06s; }
	.bv-nav .is-menu-open .wp-block-navigation-item:nth-child(3) { animation-delay: .12s; }
	.bv-nav .is-menu-open .wp-block-navigation-item:nth-child(4) { animation-delay: .18s; }
	.bv-nav .is-menu-open .wp-block-navigation-item:nth-child(5) { animation-delay: .24s; }
}

/* ==========================================================================
   11. Impresión: todo visible
   ========================================================================== */

@media print {
	.bv-motion * { opacity: 1 !important; transform: none !important; clip-path: none !important; }
	.bv-ticker, .bv-sunset, .bv-catprev { display: none !important; }
}
