/*
 * Tema Leadrive — bloques del editor (construcción libre).
 *
 * Viste los bloques del núcleo (botones, columnas, grupos, preguntas...) con
 * los tokens --lr-* del estilo activo, en el sitio Y dentro del editor (este
 * archivo se carga en los dos). Nada de colores sueltos: todo sale de los
 * tokens, así un mismo diseño se ve bien en Vitrina, Concesionario, Premium
 * y Cercano.
 */

/*
 * Los colores del editor (theme.json) apuntan a los tokens VIVOS. Se declaran
 * otra vez acá, sobre el body, porque WordPress los resuelve en :root y el
 * modo oscuro de Vitrina cambia los tokens en el body.
 */
body.lr, .editor-styles-wrapper {
	--wp--preset--color--fondo: var(--lr-bg);
	--wp--preset--color--superficie: var(--lr-surface);
	--wp--preset--color--superficie-2: var(--lr-surface-2);
	--wp--preset--color--texto: var(--lr-fg);
	--wp--preset--color--texto-suave: var(--lr-fg-2);
	--wp--preset--color--gris: var(--lr-muted);
	--wp--preset--color--linea: var(--lr-line);
	--wp--preset--color--acento: var(--lr-accent);
	--wp--preset--color--confianza: var(--lr-trust);
}

/* ------------------------------------------------------------------------ */
/* El lienzo: portada editable y plantilla "Libre"                           */
/* ------------------------------------------------------------------------ */

.lr-libre { padding-bottom: var(--lr-espacio); }
.lr-libre:has(> :is(.is-style-lr-banda, .is-style-lr-oscura, .lr-bloque--cita):last-child) { padding-bottom: 0; }
.lr-libre > .lr-bloque:last-child > .lr-seccion { padding-bottom: 0; }

/* Las secciones del tema traen su propio espacio arriba. */
.lr-libre > .lr-bloque, .lr-libre > .is-style-lr-seccion { margin-block-start: 0; }
.lr-libre > .lr-bloque--portada + * { margin-block-start: 0; }
.is-style-lr-seccion { padding-top: var(--lr-espacio); }

/* Un bloque suelto al principio no queda pegado a la cabecera. */
.lr-libre > :first-child:not(.lr-bloque):not(.alignfull):not(.is-style-lr-seccion) { margin-block-start: clamp(40px, 6vw, 72px); }
.lr-libre > :first-child { margin-block-start: 0; }
.lr-libre > :first-child:not(.lr-bloque):not(.alignfull):not(.is-style-lr-seccion) { margin-block-start: clamp(40px, 6vw, 72px); }

/* Bandas de color: aire adentro y separación con lo que viene. */
.is-style-lr-banda, .is-style-lr-oscura { padding-block: clamp(56px, 7vw, 104px); }
.lr-libre > :is(.is-style-lr-banda, .is-style-lr-oscura) { margin-block-start: var(--lr-espacio); }
.lr-libre > :is(.is-style-lr-banda, .is-style-lr-oscura):first-child { margin-block-start: 0; }
.lr-libre > :is(.is-style-lr-banda, .is-style-lr-oscura) + :is(.is-style-lr-banda, .is-style-lr-oscura) { margin-block-start: 0; }
.lr-libre > :is(.is-style-lr-banda, .is-style-lr-oscura) + :not(.lr-bloque):not(.is-style-lr-seccion):not(.is-style-lr-banda):not(.is-style-lr-oscura) { margin-block-start: var(--lr-espacio); }
.lr-libre > .lr-bloque + :not(.lr-bloque):not(.is-style-lr-seccion):not(.is-style-lr-banda):not(.is-style-lr-oscura) { margin-block-start: var(--lr-espacio); }

.is-style-lr-banda { background: var(--lr-accent); color: #FFFFFF; }
.is-style-lr-oscura { background: var(--lr-fg); color: var(--lr-bg); }
.is-style-lr-banda :is(h1, h2, h3, h4, p, li, a), .is-style-lr-oscura :is(h1, h2, h3, h4, p, li, a) { color: inherit; }
.is-style-lr-caja {
	background: var(--lr-surface);
	border: 1px solid var(--lr-line);
	border-radius: var(--lr-radius);
	padding: clamp(20px, 3vw, 40px);
}

/* ------------------------------------------------------------------------ */
/* Texto                                                                     */
/* ------------------------------------------------------------------------ */

/*
 * Todo esto es para el texto que se escribe en el editor. NUNCA dentro de una
 * sección Leadrive (.lr-bloque): esas ya tienen su diseño, y estas reglas lo
 * cambiarían (pasó: la ubicación quedaba 14 px más alta que en la portada).
 */
:where(.lr-libre, .editor-styles-wrapper) :where(h1):not(.lr-bloque *) { font-size: clamp(40px, 6vw, 72px); line-height: 1; }
:where(.lr-libre, .editor-styles-wrapper) :where(h2):not(.lr-bloque *) { font-size: clamp(30px, 3.4vw, 44px); }
:where(.lr-libre, .editor-styles-wrapper) :where(h3):not(.lr-bloque *) { font-size: clamp(22px, 2vw, 26px); line-height: 1.15; }
:where(.lr-libre, .editor-styles-wrapper) :where(h4):not(.lr-bloque *) { font-size: 19px; line-height: 1.25; }
:where(.lr-libre, .editor-styles-wrapper) :where(p, li):not(.lr-bloque *) { text-wrap: pretty; }
:where(.lr-libre, .editor-styles-wrapper) :where(ul, ol):not([class*="is-style-"]):not(.lr-bloque *) { padding-left: 1.2em; }
:where(.lr-libre, .editor-styles-wrapper) :where(li + li):not(.lr-bloque *) { margin-top: 0.4em; }
:where(.lr-libre, .editor-styles-wrapper) :where(p a, li a):not(.lr-bloque *) { font-weight: 600; }
.lr-libre .has-mediana-font-size, .lr-libre .has-grande-font-size { line-height: 1.45; }

/*
 * Ritmo del texto: un título se separa más de lo que viene antes que de lo
 * que lo sigue (así se lee a qué pertenece). Le gana al espacio parejo de
 * WordPress entre bloques. Solo entre bloques del editor (hijos directos de
 * un contenedor de bloques), nunca dentro de una sección Leadrive.
 */
:is(.lr-libre, .is-root-container, .wp-block-group, .wp-block-column, .wp-block-cover__inner-container, .wp-block-media-text__content) > :is(p, ul, ol, .wp-block-buttons, .wp-block-image, .lr-bloque--whatsapp) + :is(h2, h3) { margin-block-start: 1.6em; }
:is(.lr-libre, .is-root-container, .wp-block-group, .wp-block-column, .wp-block-cover__inner-container, .wp-block-media-text__content) > :is(h1, h2, h3, h4) + :is(p, ul, ol) { margin-block-start: 14px; }
:is(.lr-libre, .is-root-container, .wp-block-group, .wp-block-column, .wp-block-cover__inner-container) > h1 + p { margin-block-start: 20px; }
.wp-block-column > h3 + p { margin-block-start: 6px; }
:is(.lr-libre, .is-root-container, .wp-block-group, .wp-block-column, .wp-block-cover__inner-container, .wp-block-media-text__content) > :is(p, ul, ol) + .wp-block-buttons { margin-block-start: 28px; }
:is(.lr-libre, .is-root-container, .wp-block-group, .wp-block-column) > :is(h2, .wp-block-group) + :is(.wp-block-columns, .lr-preguntas) { margin-block-start: clamp(28px, 3vw, 40px); }
/* En una columna el título baja un escalón: con letra expandida, una palabra larga no cabe. */
.wp-block-column > h2:not([class*="-font-size"]) { font-size: clamp(26px, 2.6vw, 36px); }
:where(.lr-libre, .editor-styles-wrapper) :where(h1, h2, h3):not(.lr-bloque *) { overflow-wrap: break-word; hyphens: manual; }

/* Las fuentes de los títulos del estilo (con su ancho y peso) en cualquier bloque que las pida. */
.has-titulos-font-family { font-stretch: var(--lr-display-stretch); font-weight: var(--lr-display-weight); letter-spacing: var(--lr-display-tracking); }

/* ------------------------------------------------------------------------ */
/* Botones                                                                   */
/* ------------------------------------------------------------------------ */

/* Los colores y el peso salen de tokens --lr-b-* que define cada estilo (base.css, premium.css...). */
:is(body.lr, .editor-styles-wrapper) .wp-block-button__link {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px;
	min-height: 48px; padding: 0 22px;
	border: 0; border-radius: var(--lr-radius-btn);
	background: var(--lr-b-bg); color: var(--lr-b-fg);
	font-family: var(--lr-b-familia); font-weight: var(--lr-b-peso); font-size: var(--lr-b-tam); line-height: 1.1;
	text-transform: var(--lr-b-mayus); letter-spacing: var(--lr-b-espaciado);
	text-decoration: none; text-align: center;
	transition: background-color 160ms var(--lr-ease), color 160ms var(--lr-ease), transform 160ms var(--lr-ease);
}
:is(body.lr, .editor-styles-wrapper) .wp-block-button__link:hover { background: var(--lr-b-bg-hover); color: var(--lr-b-fg-hover); }
:is(body.lr, .editor-styles-wrapper) .wp-block-button__link:active { transform: translateY(1px); }
:is(body.lr, .editor-styles-wrapper) .is-style-outline > .wp-block-button__link { background: transparent; color: var(--lr-fg); box-shadow: inset 0 0 0 1.5px currentColor; }
:is(body.lr, .editor-styles-wrapper) .is-style-outline > .wp-block-button__link:hover { background: var(--lr-fg); color: var(--lr-bg); }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-whatsapp > .wp-block-button__link { background: var(--lr-b-wa-bg); color: var(--lr-b-wa-fg); box-shadow: var(--lr-b-wa-borde); }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-whatsapp > .wp-block-button__link:hover { background: var(--lr-wa-hover); color: #FFFFFF; box-shadow: none; }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-whatsapp > .wp-block-button__link::before {
	content: ""; width: 18px; height: 18px; flex: none; background: currentColor;
	-webkit-mask: url("../img/whatsapp.svg") center / contain no-repeat; mask: url("../img/whatsapp.svg") center / contain no-repeat;
}
:is(body.lr, .editor-styles-wrapper) .is-style-lr-tinta > .wp-block-button__link { background: var(--lr-fg); color: var(--lr-bg); }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-tinta > .wp-block-button__link:hover { background: var(--lr-fg-2); color: var(--lr-bg); }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-confianza > .wp-block-button__link { background: var(--lr-trust); color: #FFFFFF; }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-confianza > .wp-block-button__link:hover { background: var(--lr-fg); color: var(--lr-bg); }

/* Sobre la banda del color de acento, el botón principal pasa a blanco (si no, desaparece). */
:is(body.lr, .editor-styles-wrapper) .is-style-lr-banda .wp-block-button:not([class*="is-style-lr-"]):not(.is-style-outline) > .wp-block-button__link { background: #FFFFFF; color: #0E0F12; }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-banda .wp-block-button:not([class*="is-style-lr-"]):not(.is-style-outline) > .wp-block-button__link:hover { background: #F2F0EB; color: #0E0F12; }
/* Sobre la banda de contraste, el que defina el estilo (en Premium esa banda es clara). */
:is(body.lr, .editor-styles-wrapper) .is-style-lr-oscura .wp-block-button:not([class*="is-style-lr-"]):not(.is-style-outline) > .wp-block-button__link { background: var(--lr-b-en-contraste-bg); color: var(--lr-b-en-contraste-fg); }
:is(body.lr, .editor-styles-wrapper) :is(.is-style-lr-banda, .is-style-lr-oscura) .is-style-outline > .wp-block-button__link { color: inherit; }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-banda .is-style-outline > .wp-block-button__link:hover { background: #FFFFFF; color: #0E0F12; }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-oscura .is-style-outline > .wp-block-button__link:hover { background: var(--lr-bg); color: var(--lr-fg); }
:is(body.lr, .editor-styles-wrapper) .is-style-lr-oscura .is-style-lr-tinta > .wp-block-button__link { background: var(--lr-bg); color: var(--lr-fg); }

.lr-botones--centro { justify-content: center; }
.lr-bloque--whatsapp.aligncenter .lr-botones, .lr-bloque--whatsapp .lr-botones--centro { justify-content: center; }

/* ------------------------------------------------------------------------ */
/* Bloques del núcleo                                                        */
/* ------------------------------------------------------------------------ */

.lr-libre .wp-block-image img, .editor-styles-wrapper .wp-block-image img { border-radius: var(--lr-radius); }
.wp-block-image figcaption, .wp-block-gallery figcaption { font-size: 14px; color: var(--lr-muted); }
.wp-block-cover { border-radius: 0; }
.wp-block-cover.alignwide, .wp-block-cover:not(.alignfull) { border-radius: var(--lr-radius); }
.wp-block-cover :is(h1, h2, h3, p) { color: inherit; }
.wp-block-media-text { gap: 0; }
.wp-block-media-text > .wp-block-media-text__content { padding: 0 0 0 clamp(24px, 5vw, 72px); }
.wp-block-media-text.has-media-on-the-right > .wp-block-media-text__content { padding: 0 clamp(24px, 5vw, 72px) 0 0; }
.wp-block-media-text .wp-block-media-text__media img { border-radius: var(--lr-radius); }
@media (max-width: 600px) {
	.wp-block-media-text.is-stacked-on-mobile > .wp-block-media-text__content,
	.wp-block-media-text.is-stacked-on-mobile.has-media-on-the-right > .wp-block-media-text__content { padding: 24px 0 0; }
}

hr.wp-block-separator { border: 0; border-top: 1px solid var(--lr-line); opacity: 1; margin-block: 40px; }
hr.wp-block-separator.is-style-wide { border-top-width: 2px; border-top-color: var(--lr-fg); }

.wp-block-quote { margin-inline: 0; padding-left: 24px; border-left: 2px solid var(--lr-fg); }
.wp-block-quote p { font-size: 20px; line-height: 1.5; }
.wp-block-quote cite { display: block; margin-top: 12px; font-size: 14px; font-style: normal; color: var(--lr-muted); }
.wp-block-quote.is-style-lr-grande { padding-left: 0; border-left: 0; }
.wp-block-quote.is-style-lr-grande p { font-family: var(--lr-font-display); font-stretch: var(--lr-display-stretch); font-size: clamp(26px, 3.2vw, 40px); line-height: 1.18; letter-spacing: var(--lr-display-tracking); color: inherit; }
.wp-block-pullquote { border-block: 2px solid var(--lr-fg); padding-block: 40px; }
.wp-block-pullquote blockquote p { font-family: var(--lr-font-display); font-size: clamp(24px, 2.8vw, 34px); line-height: 1.25; }

.wp-block-table table { width: 100%; font-size: 16px; font-variant-numeric: tabular-nums; }
.wp-block-table :is(th, td) { padding: 12px 16px 12px 0; border: 0; border-top: 1px solid var(--lr-line); text-align: left; vertical-align: top; }
.wp-block-table thead th { border-top: 0; border-bottom: 2px solid var(--lr-fg); font-weight: 700; }
.wp-block-table tr:last-child td { border-bottom: 1px solid var(--lr-line); }
.wp-block-table figcaption { font-size: 14px; color: var(--lr-muted); }

/* Columnas como tarjetas */
.wp-block-columns.is-style-lr-tarjetas > .wp-block-column {
	background: var(--lr-surface);
	border: 1px solid var(--lr-line);
	border-radius: var(--lr-radius);
	padding: clamp(20px, 2.4vw, 32px);
}
.wp-block-columns.is-style-lr-tarjetas > .wp-block-column > .wp-block-image:first-child { margin: calc(clamp(20px, 2.4vw, 32px) * -1) calc(clamp(20px, 2.4vw, 32px) * -1) 20px; }
.wp-block-columns.is-style-lr-tarjetas > .wp-block-column > .wp-block-image:first-child img { width: 100%; border-radius: var(--lr-radius) var(--lr-radius) 0 0; aspect-ratio: 4 / 3; object-fit: cover; }

/* Lista con tics */
.wp-block-list.is-style-lr-checks { list-style: none; padding-left: 0; }
.wp-block-list.is-style-lr-checks > li { position: relative; padding-left: 32px; }
.wp-block-list.is-style-lr-checks > li::before {
	content: ""; position: absolute; left: 0; top: 0.25em; width: 20px; height: 20px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5 8 14.5 16 5.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5 8 14.5 16 5.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Pregunta frecuente (bloque Detalles) */
.wp-block-details.is-style-lr-pregunta { border-top: 1px solid var(--lr-line); padding: 0; }
.wp-block-details.is-style-lr-pregunta + .wp-block-details.is-style-lr-pregunta { margin-block-start: 0; }
.wp-block-details.is-style-lr-pregunta:last-of-type { border-bottom: 1px solid var(--lr-line); }
.wp-block-details.is-style-lr-pregunta > summary {
	position: relative; list-style: none; cursor: pointer;
	padding: 20px 44px 20px 0; font-weight: var(--lr-peso-fuerte); font-size: 19px; line-height: 1.35;
}
.wp-block-details.is-style-lr-pregunta > summary::-webkit-details-marker { display: none; }
.wp-block-details.is-style-lr-pregunta > summary::after {
	content: "+"; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
	font-size: 28px; font-weight: 400; line-height: 1; transition: transform 200ms var(--lr-ease);
}
.wp-block-details.is-style-lr-pregunta[open] > summary::after { transform: translateY(-50%) rotate(45deg); }
.wp-block-details.is-style-lr-pregunta > :not(summary) { padding-bottom: 20px; color: var(--lr-fg-2); }
.wp-block-details.is-style-lr-pregunta > summary + * { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .wp-block-details.is-style-lr-pregunta > summary::after { transition: none; } }

/* Pasos (diseño "Pasos"): una regla gruesa arriba de cada uno, como en Financiamiento */
.lr-pasos-fila > .wp-block-column { padding-top: 16px; border-top: 2px solid var(--lr-fg); }
.lr-pasos-fila > .wp-block-column > * + * { margin-top: 6px; }
.lr-pasos-fila h3 { font-size: 20px; }

/* Preguntas: van pegadas, cada una con su regla */
.lr-preguntas > * + * { margin-block-start: 0; }

/* Cifras (diseño "Cifras"): una regla fina arriba, como en Nosotros */
.lr-cifras-fila { padding-top: 24px; border-top: 1px solid var(--lr-line); }
.lr-cifras-fila > .wp-block-column > * + * { margin-top: 6px; }

/* Cifras (párrafos grandes en columnas, ver el diseño "Cifras") */
.lr-cifra { font-family: var(--lr-font-display); font-stretch: var(--lr-display-stretch); font-weight: var(--lr-display-weight); letter-spacing: var(--lr-display-tracking); font-size: clamp(36px, 4.4vw, 56px); line-height: 1; }

/* Galería */
.wp-block-gallery.has-nested-images figure.wp-block-image img { border-radius: var(--lr-radius); }

/* Mapa o video incrustado */
.wp-block-embed iframe { border-radius: var(--lr-radius); }

/* ------------------------------------------------------------------------ */
/* Bloques Leadrive                                                          */
/* ------------------------------------------------------------------------ */

.lr-bloque--formulario .lr-caja-form__titulo { margin-bottom: 4px; }
.lr-bloque--formulario .lr-bloque-form:not(.lr-caja-form) { display: flex; flex-direction: column; gap: 12px; }
.lr-bloque-buscador { background: var(--lr-surface); border: 1px solid var(--lr-line); border-radius: var(--lr-radius); }
.lr-bloque-buscador--simple { border: 0; background: transparent; }
.lr-libre > .lr-bloque--buscador { margin-block-start: var(--lr-espacio); }
.lr-libre > .lr-bloque--portada + .lr-bloque--buscador { margin-block-start: 0; }

/* ------------------------------------------------------------------------ */
/* Solo dentro del editor                                                    */
/* ------------------------------------------------------------------------ */

.editor-styles-wrapper .lr-editor-seccion { margin-block: 0; }
.editor-styles-wrapper .lr-editor-seccion .lr-bloque.alignfull { width: 100%; }
.lr-editor-aviso {
	display: flex; flex-direction: column; gap: 4px;
	margin: 16px auto; max-width: 760px; padding: 20px 24px;
	border: 1.5px dashed var(--lr-line); border-radius: var(--lr-radius);
	background: var(--lr-surface); color: var(--lr-fg-2); font-size: 15px;
}
.lr-editor-aviso strong { color: var(--lr-fg); }

/* Formulario de Leadrive incrustado: el iframe ocupa el ancho y crece con su contenido. */
.lr-form-erp__marco { display: block; width: 100%; border: 0; background: transparent; color-scheme: light; }
