/*
 * Recamán Abogados — motion and interaction layer.
 * Loaded on the homepage first; once approved it is the reference for every other page.
 *
 * Principles:
 * - One authored moment (the hero on load) and one brand motif (handwritten lines that write themselves).
 * - Everything else is feedback (hover, focus, press) or continuity (header, reveals). No decoration for its own sake.
 * - Hidden "before" states exist only under html.rc-motion, which an inline head script sets when the visitor
 *   has not asked for reduced motion. Without scripts, or with reduced motion, every element is simply visible.
 * - Only opacity, transform/translate/scale, clip-path and filter are animated.
 */

:root {
	--rc-ease: cubic-bezier(0.16, 1, 0.3, 1);       /* confident arrival */
	--rc-ease-tinta: cubic-bezier(0.55, 0.1, 0.3, 1); /* a pen stroke: starts gently, ends settled */
	--rc-rapido: 180ms;
	--rc-medio: 360ms;
	--rc-entrada: 900ms;
}

/* ---------- Browser surfaces in the brand palette ---------- */

html {
	scrollbar-color: var(--wp--preset--color--dorado-claro) var(--wp--preset--color--crema);
	scroll-padding-top: calc(var(--rc-pegado) + var(--rc-barra-h-compacta) + 1.5rem);
}

::selection {
	background: color-mix(in srgb, var(--wp--preset--color--dorado) 28%, transparent);
	color: var(--wp--preset--color--marino);
}

.rc-llamada ::selection {
	background: color-mix(in srgb, var(--wp--preset--color--dorado-claro) 45%, transparent);
	color: var(--wp--preset--color--blanco);
}

:where(a, button, input, textarea, .wp-block-button__link):focus-visible {
	outline: 2px solid var(--wp--preset--color--dorado);
	outline-offset: 3px;
	border-radius: 2px;
}

@media (prefers-reduced-motion: no-preference) {
	html {
		scroll-behavior: smooth;
	}
}

/* ---------- Header: the sticky bar compacts on scroll (sizes in recaman.css); the page underneath never moves ---------- */

.rc-cabecera {
	transition: height var(--rc-medio) var(--rc-ease), box-shadow var(--rc-medio) var(--rc-ease), background-color var(--rc-medio) var(--rc-ease);
}

.rc-cabecera__logo img {
	transition: scale var(--rc-medio) var(--rc-ease);
}

.rc-desplazado .rc-cabecera {
	background-color: color-mix(in srgb, var(--wp--preset--color--crema) 97%, transparent);
	box-shadow: 0 6px 24px -12px rgba(22, 41, 74, 0.18);
}

@media (prefers-reduced-motion: reduce) {
	.rc-cabecera,
	.rc-cabecera__logo img {
		transition: none;
	}
}

/* Gold underline that grows from the left, for live navigation links only. */
.rc-cabecera .wp-block-navigation-item__content[href] {
	background: linear-gradient(var(--wp--preset--color--dorado), var(--wp--preset--color--dorado)) no-repeat 0 100% / 0 1px;
	transition: background-size var(--rc-medio) var(--rc-ease), color var(--rc-rapido) ease;
}

.rc-cabecera .wp-block-navigation-item__content[href]:is(:hover, :focus-visible) {
	background-size: 100% 1px;
}

/* ---------- Buttons: lift, press, and a fill that sweeps across the outline style ---------- */

.wp-block-button__link {
	transition:
		background-color var(--rc-medio) var(--rc-ease),
		background-size 450ms var(--rc-ease),
		color var(--rc-medio) var(--rc-ease),
		box-shadow var(--rc-medio) var(--rc-ease),
		translate var(--rc-medio) var(--rc-ease),
		scale var(--rc-rapido) ease;
}

.wp-block-button.is-style-outline .wp-block-button__link {
	background: linear-gradient(var(--wp--preset--color--marino-boton), var(--wp--preset--color--marino-boton)) no-repeat 0 0 / 0 100%;
}

.rc-llamada .wp-block-button.is-style-outline .wp-block-button__link {
	background-image: linear-gradient(var(--wp--preset--color--blanco), var(--wp--preset--color--blanco));
}

@media (hover: hover) {
	.wp-block-button__link[href]:hover {
		translate: 0 -2px;
		box-shadow: 0 10px 22px -10px rgba(22, 41, 74, 0.45);
	}

	.wp-block-button.is-style-outline .wp-block-button__link[href]:hover {
		background-size: 100% 100%;
	}
}

.wp-block-button__link[href]:active {
	translate: 0 0;
	scale: 0.98;
	box-shadow: none;
}

/* The arrow leans forward on hover. */
.wp-block-button.is-style-flecha .wp-block-button__link::after,
.rc-enlace-mas a::after {
	display: inline-block;
	transition: translate var(--rc-medio) var(--rc-ease);
}

/* An inline-block drops the leading space of " →": restore the gap. */
.rc-enlace-mas a::after {
	margin-left: 0.3em;
}

.wp-block-button.is-style-flecha .wp-block-button__link:hover::after,
.rc-enlace-mas a[href]:hover::after,
.rc-area-breve:hover .rc-enlace-mas a[href]::after {
	transform: none;
	translate: 4px 0;
}

/* ---------- Cards (practice areas, contact details) ---------- */

.wp-block-group.is-style-tarjeta {
	position: relative;
	overflow: hidden;
	transition: translate 500ms var(--rc-ease), box-shadow 500ms var(--rc-ease), border-color var(--rc-medio) ease;
}

/* A gold edge that draws itself along the top of the card. */
.wp-block-group.is-style-tarjeta::before {
	content: "";
	position: absolute;
	inset: 0 0 auto;
	height: 2px;
	background: var(--wp--preset--color--dorado);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform 600ms var(--rc-ease);
}

.is-style-tarjeta .wp-block-image.is-style-icono img {
	transition: translate 500ms var(--rc-ease);
}

/* Only cards with a live link behave as links (sections closed to visitors stay inert):
   the card's own link covers the whole card, so every part of it is clickable. */
.is-style-tarjeta:has(a[href]) {
	cursor: pointer;
}

.rc-area-breve .rc-enlace-mas a[href]::before,
.rc-dato-contacto a[href]::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

/* The address card offers the directions link; its address text is not a second target. */
.rc-dato-contacto:has(.rc-enlace-mas a[href]) p:not(.rc-enlace-mas) a::before {
	content: none;
}

@media (hover: hover) {
	.is-style-tarjeta:has(a[href]):hover {
		translate: 0 -4px;
		border-color: var(--wp--preset--color--dorado-claro);
		box-shadow: 0 22px 40px -24px rgba(22, 41, 74, 0.35);
	}

	.is-style-tarjeta:has(a[href]):hover::before {
		transform: scaleX(1);
	}

	.is-style-tarjeta:has(a[href]):hover .wp-block-image.is-style-icono img {
		translate: 0 -3px;
	}
}

.is-style-tarjeta:has(a[href]:focus-visible)::before {
	transform: scaleX(1);
}

/* ---------- Services: each area's photo breathes a little under the pointer ---------- */

.rc-area .wp-block-image:not(.is-style-icono) {
	overflow: hidden;
	border-radius: 4px;
}

.rc-area .wp-block-image:not(.is-style-icono) img {
	transition: scale 1200ms var(--rc-ease);
}

@media (hover: hover) {
	.rc-area:hover .wp-block-image:not(.is-style-icono) img {
		scale: 1.04;
	}
}

/* ---------- Consultation form: focus, sending and the answer ---------- */

.rc-formulario :is(input[type="text"], input[type="email"], input[type="tel"], textarea) {
	transition: border-color var(--rc-medio) var(--rc-ease), box-shadow var(--rc-medio) var(--rc-ease), background-color var(--rc-medio) ease;
}

.rc-formulario :is(input[type="text"], input[type="email"], input[type="tel"], textarea):focus {
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--wp--preset--color--dorado) 16%, transparent);
}

.rc-formulario input[type="submit"] {
	transition: background-color var(--rc-medio) var(--rc-ease), translate var(--rc-medio) var(--rc-ease), box-shadow var(--rc-medio) var(--rc-ease), scale var(--rc-rapido) ease, opacity var(--rc-medio) ease;
}

@media (hover: hover) {
	.rc-formulario input[type="submit"]:not(:disabled):hover {
		translate: 0 -2px;
		box-shadow: 0 10px 22px -10px rgba(22, 41, 74, 0.45);
	}
}

.rc-formulario input[type="submit"]:active {
	scale: 0.985;
	translate: 0 0;
	box-shadow: none;
}

/* While Contact Form 7 sends, the button rests and says so through its state. */
.rc-formulario form.submitting input[type="submit"] {
	opacity: 0.7;
	cursor: progress;
}

.rc-formulario .wpcf7-response-output,
.rc-formulario .wpcf7-not-valid-tip {
	animation: rc-subir 450ms var(--rc-ease) both;
}

/* ---------- Footer links: the same gold underline as the menu ---------- */

.rc-pie a[href] {
	background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
	transition: background-size var(--rc-medio) var(--rc-ease), color var(--rc-rapido) ease;
}

.rc-pie a[href]:is(:hover, :focus-visible) {
	background-size: 100% 1px;
}

/* ---------- The authored moment: every page opens with an entrance ---------- */

@keyframes rc-asentar-foto {
	from { opacity: 0; scale: 1.16; filter: blur(6px); }
	to   { opacity: 1; scale: 1.08; filter: blur(0); }
}

/* Stacked layout (phones, portrait tablets): the photo sits above the text and fades into it, so any scale
   would push its edge past the fade. There the photo only comes into focus. */
@keyframes rc-enfocar-foto {
	from { opacity: 0; filter: blur(6px); }
	to   { opacity: 1; filter: blur(0); }
}

/* The mask opens downwards, in reading order. Negative insets in the final state: descenders and
   overhanging glyphs are never cropped. */
@keyframes rc-emerger {
	from { opacity: 0; clip-path: inset(-10% -5% 100% -5%); translate: 0 0.3em; }
	20%  { opacity: 1; }
	to   { opacity: 1; clip-path: inset(-10% -5% -25% -5%); translate: 0 0; }
}

@keyframes rc-subir {
	from { opacity: 0; translate: 0 1rem; }
	to   { opacity: 1; translate: 0 0; }
}

@keyframes rc-trazo {
	from { transform: scaleX(0); }
	to   { transform: scaleX(1); }
}

@keyframes rc-bajar {
	from { opacity: 0; translate: 0 -0.75rem; }
	to   { opacity: 1; translate: 0 0; }
}

/* A portrait drawn into view like a curtain rising. */
@keyframes rc-cortina {
	from { clip-path: inset(100% 0 0 0); scale: 1.06; }
	to   { clip-path: inset(0 0 0 0); scale: 1; }
}

/* Backwards only: a transform kept after the entry would trap the fixed mobile menu inside the header bar. */
.rc-motion header :is(.rc-preheader, .rc-cabecera) {
	animation: rc-bajar 700ms var(--rc-ease) backwards;
}

/* Photo banner openers (home, services, consultations, contact). */
.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .wp-block-cover__image-background {
	/* Grow away from the faded edge, so the gradient and the photo never separate. */
	transform-origin: left center;
	animation: rc-asentar-foto 1600ms var(--rc-ease) both;
}

@media (max-width: 781px) {
	.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .wp-block-cover__image-background {
		animation: rc-enfocar-foto 1400ms var(--rc-ease) both;
	}
}

/* Text openers: photo banners and the plain legal header share one sequence. */
.rc-motion .wp-block-post-content > :is(.rc-cabecera-foto, .rc-hero):first-child :is(.is-style-antetitulo, .is-style-antetitulo-centrado) {
	animation: rc-subir 700ms var(--rc-ease) 150ms both;
}

.rc-motion .wp-block-post-content > :is(.rc-cabecera-foto, .rc-hero):first-child :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after {
	transform-origin: left;
	animation: rc-trazo 800ms var(--rc-ease) 450ms both;
}

.rc-motion .wp-block-post-content > :is(.rc-cabecera-foto, .rc-hero):first-child h1 {
	animation: rc-emerger 1100ms var(--rc-ease) 300ms both;
}

.rc-motion .wp-block-post-content > :is(.rc-cabecera-foto, .rc-hero):first-child .rc-entradilla {
	animation: rc-subir var(--rc-entrada) var(--rc-ease) 650ms both;
}

.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .wp-block-buttons {
	animation: rc-subir var(--rc-entrada) var(--rc-ease) 800ms both;
}

/* Consultations: the four facts follow, one after another. */
.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .rc-datos > * {
	animation: rc-subir 700ms var(--rc-ease) both;
}

.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .rc-datos > :nth-child(1) { animation-delay: 850ms; }
.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .rc-datos > :nth-child(2) { animation-delay: 920ms; }
.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .rc-datos > :nth-child(3) { animation-delay: 990ms; }
.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .rc-datos > :nth-child(4) { animation-delay: 1060ms; }

/* About: portrait rises, then the biography, then the timeline milestone by milestone. */
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__retrato img {
	animation: rc-cortina 1300ms var(--rc-ease) 100ms both;
}

.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__bio h1 {
	animation: rc-emerger 1100ms var(--rc-ease) 350ms both;
}

.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__bio > :not(h1) {
	animation: rc-subir 800ms var(--rc-ease) both;
}

.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__bio > :nth-child(1) { animation-delay: 250ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__bio > :nth-child(3) { animation-delay: 650ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__bio > :nth-child(4) { animation-delay: 750ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-sobre__bio > :nth-child(5) { animation-delay: 850ms; }

.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-trayectoria > :not(.is-style-manuscrita) {
	animation: rc-subir 800ms var(--rc-ease) both;
}

.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-trayectoria > :nth-child(1) { animation-delay: 700ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-trayectoria > :nth-child(2) { animation-delay: 800ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-trayectoria > :nth-child(3) { animation-delay: 900ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-trayectoria > :nth-child(4) { animation-delay: 1000ms; }
.rc-motion .wp-block-post-content > .rc-sobre:first-child .rc-trayectoria > :nth-child(5) { animation-delay: 1100ms; }

/* The timeline's gold circles draw a soft ring as each milestone lands. */
.rc-hito .wp-block-image.is-style-icono {
	transition: background-color var(--rc-medio) var(--rc-ease), box-shadow var(--rc-medio) var(--rc-ease);
}

@media (hover: hover) {
	.rc-hito:hover .wp-block-image.is-style-icono {
		background-color: var(--wp--preset--color--blanco);
		box-shadow: 0 0 0 6px color-mix(in srgb, var(--wp--preset--color--dorado) 14%, transparent);
	}
}

/* ---------- Scroll reveals (classes set by movimiento.js) ---------- */

/* Hidden states apply instantly; transitions live on the visible state only. Otherwise adding the
   hiding class after load would animate the element *out* first (visible, then fading away). */
.rc-motion .rc-reveal {
	opacity: 0;
	translate: 0 1.25rem;
}

.rc-motion .rc-reveal.is-visible {
	opacity: 1;
	translate: 0 0;
	transition:
		opacity 800ms var(--rc-ease) calc(var(--rc-i, 0) * 70ms),
		translate 800ms var(--rc-ease) calc(var(--rc-i, 0) * 70ms);
}

/* Once revealed (movimiento.js adds .rc-revelado after the stagger), cards answer hover without the reveal delay. */
.rc-motion .is-style-tarjeta.rc-reveal.rc-revelado {
	transition: translate 500ms var(--rc-ease), box-shadow 500ms var(--rc-ease), border-color var(--rc-medio) ease, opacity 800ms var(--rc-ease);
}

/* Section eyebrows: their gold rules draw in after the text arrives. */
.rc-motion .rc-reveal :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::before,
.rc-motion .rc-reveal :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after,
.rc-motion .rc-reveal:is(.is-style-antetitulo, .is-style-antetitulo-centrado)::before,
.rc-motion .rc-reveal:is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after {
	transform: scaleX(0);
}

.rc-motion .rc-reveal :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::before,
.rc-motion .rc-reveal:is(.is-style-antetitulo, .is-style-antetitulo-centrado)::before {
	transform-origin: right;
}

.rc-motion .rc-reveal :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after,
.rc-motion .rc-reveal:is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after {
	transform-origin: left;
}

.rc-motion .rc-reveal.is-visible :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::before,
.rc-motion .rc-reveal.is-visible :is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after,
.rc-motion .rc-reveal.is-visible:is(.is-style-antetitulo, .is-style-antetitulo-centrado)::before,
.rc-motion .rc-reveal.is-visible:is(.is-style-antetitulo, .is-style-antetitulo-centrado)::after {
	transform: scaleX(1);
	transition: transform 900ms var(--rc-ease) 250ms;
}

/* ---------- Brand motif: handwritten lines write themselves ---------- */

/* The pen: the words are uncovered left to right along their own (rotated) baseline, then the gold
   underline is drawn. Negative insets keep swashes and descenders uncropped once written.
   Unwritten, the right inset is 104% so the window is empty: at 100% the -4% left margin let the
   first letter's swash show as a stray tick. Transitions live on the visible state only, so the
   hidden state applies instantly when movimiento.js adds .rc-escritura after load. */
.rc-motion .rc-escritura .rc-tinta {
	display: inline-block;
	clip-path: inset(-40% 104% -60% -4%);
}

.rc-motion .rc-escritura.is-visible .rc-tinta {
	clip-path: inset(-40% -6% -60% -4%);
	transition: clip-path 1500ms var(--rc-ease-tinta) 200ms;
}

.rc-motion .rc-escritura::after {
	transform: rotate(-1deg) scaleX(0);
	transform-origin: left center;
}

.rc-motion .rc-escritura.is-visible::after {
	transform: rotate(-1deg) scaleX(1);
	transition: transform 700ms var(--rc-ease) 1500ms;
}

/* ---------- Depth: banner photographs drift slightly with the scroll (desktop) ---------- */

@supports (animation-timeline: view()) {
	@media (prefers-reduced-motion: no-preference) and (min-width: 782px) {
		@keyframes rc-paralaje {
			from { translate: 0 -3%; }
			to   { translate: 0 3%; }
		}

		.rc-motion .rc-cabecera-foto .wp-block-cover__image-background {
			scale: 1.08;
			/* Grow away from the gradient so the photo's faded edge never moves. */
			transform-origin: left center;
			animation: rc-paralaje linear both;
			animation-timeline: view();
			animation-range: cover;
		}

		.rc-motion .rc-banner-sobre .wp-block-cover__image-background {
			transform-origin: right center;
		}

		/* An opener keeps its entrance and adds the drift on its own timeline. */
		.rc-motion .wp-block-post-content > .rc-cabecera-foto:first-child .wp-block-cover__image-background {
			animation:
				rc-asentar-foto 1600ms var(--rc-ease) both,
				rc-paralaje linear both;
			animation-timeline: auto, view();
			animation-range: normal, cover;
		}
	}
}
