/*
 * TriGarden: estilos propios que theme.json no cubre.
 * Reglas: animar solo transform y opacity; respetar prefers-reduced-motion;
 * objetivos táctiles de 44 px o más; foco siempre visible.
 */

/*
 * Fuente de reserva mientras llega Chromate: Georgia ajustada a su ancho (la redonda de Chromate
 * es un 10 % más ancha y la cursiva un 28 % más estrecha). Así los titulares ocupan las mismas
 * líneas antes y después de cargar la fuente y la página no da saltos (CLS).
 */
@font-face {
	font-family: "Chromate Reserva";
	font-style: normal;
	font-weight: 400;
	src: local("Georgia");
	size-adjust: 110%;
}

@font-face {
	font-family: "Chromate Reserva";
	font-style: italic;
	font-weight: 400;
	src: local("Georgia Italic"), local("Georgia-Italic");
	size-adjust: 72%;
}


/* ---------- Pulido tipográfico ---------- */

/* Interletrado negativo en titulares y sin palabras sueltas en la última línea. */
:where(h1, h2, h3) {
	letter-spacing: -0.015em;
	text-wrap: balance;
}

:where(h1) {
	letter-spacing: -0.02em;
}

:where(p, li) {
	text-wrap: pretty;
}

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

/* ---------- Titulares: palabra destacada en Chromate Italic ---------- */

:where(h1, h2, h3) em {
	font-style: italic;
	color: var(--wp--preset--color--bosque);
}

:where(.has-profundo-background-color, .has-bosque-background-color) :where(h1, h2, h3) em {
	color: inherit;
}

/* ---------- Foco visible ---------- */

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--profundo);
	outline-offset: 3px;
}

:where(.has-profundo-background-color, .has-bosque-background-color) :focus-visible {
	outline-color: var(--wp--preset--color--crema);
}

/* ---------- Etiquetas ---------- */

.tg-etiqueta {
	margin: 0;
	font-size: var(--wp--preset--font-size--etiqueta);
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

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

.wp-block-button__link {
	min-height: 44px;
	transition: transform 0.25s ease;
}

.wp-block-button__link:hover {
	transform: translateY(-2px);
}

/* Hundido al pulsar. */
.wp-block-button__link:active {
	transform: scale(0.97);
}

/* ---------- Botón flotante de contacto (solo escritorio) ---------- */

.tg-flotante {
	display: none;
}

@media (min-width: 782px) {
	.tg-flotante {
		position: fixed;
		right: 24px;
		bottom: 24px;
		z-index: 50;
		display: grid;
		place-items: center;
		width: 60px;
		height: 60px;
		border: 2px solid var(--wp--preset--color--crema);
		border-radius: 50%;
		background: var(--wp--preset--color--profundo);
		color: var(--wp--preset--color--crema);
		box-shadow: 0 0 6px rgba(7, 68, 52, 0.24), 0 8px 12px rgba(7, 68, 52, 0.14);
		transition: transform 0.2s ease;
	}

	.tg-flotante:hover {
		transform: translateY(-2px);
	}

	.tg-flotante:active {
		transform: scale(0.95);
	}

	.tg-flotante svg {
		width: 26px;
		height: 26px;
		fill: currentColor;
	}
}

/* ---------- Cabecera ---------- */

/* Sin hueco entre cabecera, contenido y pie: cada sección pone su propio aire. */
.wp-site-blocks > * + * {
	margin-block-start: 0;
}

/*
 * La cabecera acompaña al scroll: el <header> es sticky y se desplaza hacia arriba
 * el alto de la barra superior, así la barra se va y la píldora se queda fija.
 * Sin transform ni backdrop-filter en la cabecera: romperían el menú móvil (position: fixed).
 */
:root {
	--tg-alto-barra: 0px;
	--tg-alto-cabecera: 76px; /* margen superior + píldora; lo usan los elementos sticky de la portada. */
}

@media (min-width: 782px) {
	:root {
		--tg-alto-barra: 40px;
	}
}

html {
	scroll-padding-top: calc(var(--tg-alto-cabecera) + 12px);
}

.wp-site-blocks > header.wp-block-template-part {
	display: flow-root; /* Evita que el margen de la píldora se salga y quede pegada arriba en móvil. */
	position: sticky;
	top: calc(-1 * var(--tg-alto-barra));
	z-index: 60;
	pointer-events: none; /* El hueco alrededor de la píldora deja pasar los clics. */
}

.tg-barra-superior,
.tg-cabecera {
	pointer-events: auto;
}

.wp-block-group.tg-barra-superior {
	box-sizing: border-box;
	height: var(--tg-alto-barra);
	padding: 0 var(--wp--style--root--padding-right) 0 var(--wp--style--root--padding-left) !important;
	align-items: center;
}

.tg-barra-superior p {
	margin: 0;
}

/* Píldora flotante. */
.wp-block-group.tg-cabecera {
	position: relative;
	box-sizing: border-box;
	width: calc(100% - 2 * clamp(8px, 2vw, 24px));
	max-width: 1376px;
	margin: 10px auto 0;
	padding: 10px clamp(16px, 2.5vw, 28px) !important;
	border-radius: 999px;
	background: rgba(255, 246, 231, 0.97);
	box-shadow: 0 1px 2px rgba(7, 68, 52, 0.06), 0 10px 30px rgba(7, 68, 52, 0.12);
}

/* Línea de progreso del scroll dentro de la píldora (solo con soporte de scroll-timeline). */
.tg-cabecera::after {
	content: "";
	position: absolute;
	right: 32px;
	bottom: 0;
	left: 32px;
	height: 2px;
	border-radius: 2px;
	background: var(--wp--preset--color--bosque);
	transform: scaleX(0);
	transform-origin: left;
	pointer-events: none;
}

/* Carril tenue bajo la línea de progreso, para que se lea como barra y no como subrayado. */
.tg-cabecera::before {
	content: "";
	position: absolute;
	right: 32px;
	bottom: 0;
	left: 32px;
	height: 2px;
	border-radius: 2px;
	background: rgba(81, 124, 99, 0.18);
	pointer-events: none;
}

@supports (animation-timeline: scroll()) {
	.tg-cabecera::after {
		animation: tg-progreso linear both;
		animation-timeline: scroll(root);
	}
}

@keyframes tg-progreso {
	to {
		transform: scaleX(1);
	}
}

.tg-logo {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	flex-shrink: 0;
}

.tg-logo img {
	display: block;
	height: 44px;
	width: auto;
}

/* Objetivos táctiles de 44 px en el menú sin cambiar su aspecto. */
.tg-cabecera .wp-block-navigation-item__content {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}

/* Enlaces dentro de texto (pie, barra superior, formulario): zona táctil ampliada sin mover el texto. */
:is(.tg-pie, .tg-barra-superior, .tg-formulario__privacidad) a {
	display: inline-block;
	padding-block: 16px;
	margin-block: -16px;
}

/* Portátiles pequeños y tabletas en horizontal: menos hueco para que el menú quepa en una línea. */
@media (min-width: 782px) and (max-width: 1199px) {
	.tg-cabecera .wp-block-navigation__container {
		gap: clamp(12px, 1.6vw, 24px) !important;
	}

	.tg-cabecera .wp-block-navigation {
		font-size: 14px;
	}
}

/* Por debajo de 1100 px no caben seis enlaces: se ocultan Zonas y Trabajos (anclas de la portada). */
@media (min-width: 782px) and (max-width: 1099px) {
	.tg-cabecera .wp-block-navigation__container > li:nth-child(4),
	.tg-cabecera .wp-block-navigation__container > li:nth-child(5) {
		display: none;
	}
}

.tg-cabecera .wp-block-navigation__responsive-container-open,
.tg-cabecera .wp-block-navigation__responsive-container-close {
	min-width: 44px;
	min-height: 44px;
	justify-content: center;
}

/* ---------- Garantías (lista con ✓) ---------- */

.tg-garantias {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	padding: 0;
	list-style: none;
}

.tg-garantias li::before {
	content: "✓ ";
}

/* ---------- Migas de pan ---------- */

.tg-migas ol {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 0;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: var(--wp--preset--font-size--pequeno);
	color: var(--wp--preset--color--bosque);
}

.tg-migas li + li::before {
	content: "›";
	margin: 0 10px;
	color: var(--wp--preset--color--salvia);
}

.tg-migas a {
	display: inline-block;
	padding-block: 12px; /* Zona táctil de 44 px. */
	color: inherit;
	text-underline-offset: 3px;
}

.tg-migas span[aria-current] {
	display: inline-block;
	padding-block: 12px;
	color: var(--wp--preset--color--profundo);
}

/* ---------- Páginas legales (plantilla "legal"): texto largo en una columna ---------- */

.tg-legal {
	background: var(--wp--preset--color--crema);
}

.tg-legal h1 {
	margin-block: 16px 0;
	font-size: clamp(36px, 4.5vw, 56px);
}

.tg-legal__texto {
	padding-block: clamp(32px, 4vw, 56px) clamp(56px, 7vw, 96px);
	line-height: 1.7;
}

.tg-legal__texto h2 {
	margin-block: 1.6em 0.5em;
	font-size: clamp(24px, 2.4vw, 30px);
}

.tg-legal__texto h3 {
	margin-block: 1.6em 0.4em;
	font-size: 20px;
}

.tg-legal__texto :is(p, ul) {
	margin-block: 0 1em;
}

.tg-legal__texto li + li {
	margin-top: 0.35em;
}

.tg-legal__texto a {
	color: var(--wp--preset--color--profundo);
	text-underline-offset: 3px;
	overflow-wrap: anywhere;
}

/* ---------- Contacto: cabecera y tarjetas de WhatsApp, teléfono y email ---------- */

.tg-contacto__titulo {
	margin-block: 16px 0;
	font-size: var(--wp--preset--font-size--titulo-1);
}

/* El diseño "constrained" centra lo que tiene ancho máximo: aquí va alineado a la izquierda. */
.tg-contacto > .tg-contacto__entrada {
	max-width: 46ch;
	margin-left: 0 !important;
	margin-bottom: var(--wp--preset--spacing--30);
	font-size: clamp(17px, 1.6vw, 20px);
}

.tg-vias {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.tg-vias__tarjeta {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 28px;
	border: 1px solid rgba(81, 124, 99, 0.35);
	border-radius: 24px;
	background: var(--wp--preset--color--blanco);
}

.tg-vias__tarjeta p {
	margin: 0;
}

.tg-vias__tarjeta--destacada {
	border-color: transparent;
	background: var(--wp--preset--color--profundo);
	color: var(--wp--preset--color--crema);
}

.tg-vias__icono {
	width: 28px;
	height: 28px;
	fill: currentColor;
}

.tg-vias__nombre {
	font-family: var(--wp--preset--font-family--chromate);
	font-size: var(--wp--preset--font-size--titulo-3);
	line-height: 1.1;
}

.tg-vias__enlace {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	min-height: 44px;
	margin-top: auto;
	padding-top: 6px;
	color: inherit;
	text-decoration-thickness: 1.5px;
	text-underline-offset: 4px;
	overflow-wrap: anywhere;
}

/* ---------- Pie ---------- */

.tg-pie p {
	margin: 0;
	line-height: 1.9;
}

.tg-pie__legal {
	padding-top: 24px;
	border-top: 1px solid var(--wp--preset--color--salvia);
	opacity: 0.9;
}

/* ---------- Barra fija móvil (WhatsApp y Llamar) ---------- */

.tg-barra-movil {
	display: none;
}

/*
 * WordPress solo pasa al menú desplegable por debajo de 600 px. Entre 600 y 781 px (tabletas en
 * vertical) el menú completo no cabe en la píldora: se fuerza también ahí el botón de menú.
 */
@media (min-width: 600px) and (max-width: 781px) {
	.tg-cabecera .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

	.tg-cabecera .wp-block-navigation__responsive-container:not(.hidden-by-default):not(.is-menu-open) {
		display: none;
	}
}

@media (max-width: 781px) {
	/* Doble clase para ganar a .is-layout-flex de WordPress. */
	.wp-block-group.tg-barra-superior {
		display: none;
	}

	/* Píldora en móvil: logo, "Pedir presupuesto" y menú, como en la demo. */
	.tg-logo img {
		height: 28px;
	}

	.wp-block-buttons.tg-cabecera__boton {
		order: 2;
		margin-left: auto;
	}

	.tg-cabecera .wp-block-navigation {
		order: 3;
	}

	.tg-cabecera__boton .wp-block-button__link {
		padding: 12px 16px !important;
		font-size: 13px;
	}

	.tg-barra-movil {
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 50;
		display: grid;
		grid-auto-columns: 1fr;
		grid-auto-flow: column;
		gap: 10px;
		padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
		background: var(--wp--preset--color--crema);
		border-top: 1px solid var(--wp--preset--color--salvia);
	}

	/* Hueco para que la barra no tape el final de la página. */
	body {
		padding-bottom: calc(73px + env(safe-area-inset-bottom, 0px));
	}
}

/* Móviles muy estrechos: no cabe el botón en la píldora (ya están el hero y la barra de Llamar). */
@media (max-width: 359px) {
	.wp-block-buttons.tg-cabecera__boton {
		display: none;
	}
}

.tg-barra-movil__boton {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 0 12px;
	border-radius: 999px;
	font-size: var(--wp--preset--font-size--pequeno);
	text-align: center;
	text-decoration: none;
}

.tg-barra-movil__boton--relleno {
	background: var(--wp--preset--color--profundo);
	color: var(--wp--preset--color--crema);
}

.tg-barra-movil__boton--contorno {
	border: 1.5px solid var(--wp--preset--color--profundo);
	color: var(--wp--preset--color--profundo);
}

/* ---------- Aviso de cookies ---------- */

.tg-cookies {
	position: fixed;
	right: 16px;
	bottom: 16px;
	left: 16px;
	z-index: 70;
	display: grid;
	gap: 16px;
	max-width: 440px;
	padding: 20px;
	border: 1px solid var(--wp--preset--color--salvia);
	border-radius: 16px;
	background: var(--wp--preset--color--crema);
	color: var(--wp--preset--color--profundo);
	box-shadow: 0 0 6px rgba(7, 68, 52, 0.16), 0 12px 24px rgba(7, 68, 52, 0.14);
}

.tg-cookies[hidden] {
	display: none;
}

.tg-cookies__texto {
	margin: 0;
	font-size: var(--wp--preset--font-size--pequeno);
	line-height: 1.5;
}

.tg-cookies__texto a {
	color: inherit;
}

.tg-cookies__botones {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

/* Los dos botones iguales: aceptar y rechazar tienen que pesar lo mismo. */
.tg-cookies__boton {
	min-height: 48px;
	padding: 0 16px;
	border: 0;
	border-radius: 999px;
	background: var(--wp--preset--color--profundo);
	color: var(--wp--preset--color--crema);
	font: inherit;
	font-size: var(--wp--preset--font-size--pequeno);
	cursor: pointer;
}

.tg-pie__cookies {
	min-height: 44px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	cursor: pointer;
}

/* En móvil, por encima de la barra fija de WhatsApp y Llamar. */
@media (max-width: 781px) {
	.tg-cookies {
		right: 12px;
		bottom: calc(85px + env(safe-area-inset-bottom, 0px));
		left: 12px;
		max-width: none;
	}
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
