/*
Theme Name: HygroGuide
Theme URI: https://hygroguide.com/
Description: Tema de bloques de HygroGuide, derivado del de Aerotermia Sencillo (mismo diseño). Solo presentación: la funcionalidad vive en el plugin Hygro Tools.
Version: 0.1.0
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 8.1
Author: HygroGuide
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: hygroguide
*/

/*
 * Solo lo que theme.json no puede expresar (pseudo-elementos, estados,
 * posicionamiento). Colores, tipografía y espaciados salen de los presets.
 */

/* ---------- Base ---------- */

html {
	-webkit-text-size-adjust: 100%;
	scroll-padding-top: 6rem;
}

body {
	-webkit-font-smoothing: antialiased;
	overflow-wrap: break-word;
}

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

:where(.wp-site-blocks) a:where(:not(.wp-element-button)) {
	text-decoration-color: var(--wp--preset--color--outline);
	text-underline-offset: 0.2em;
	text-decoration-thickness: 1px;
}

:where(.wp-site-blocks) a:where(:not(.wp-element-button)):hover {
	text-decoration-color: currentColor;
}

img {
	height: auto;
	max-width: 100%;
}

h1,
h2 {
	text-wrap: balance;
}

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

@media (min-width: 782px) {
	.wp-site-blocks > header.wp-block-template-part {
		position: sticky;
		top: 0;
		z-index: 50;
	}

	.admin-bar .wp-site-blocks > header.wp-block-template-part {
		top: var(--wp-admin--admin-bar--height, 32px);
	}
}

.site-header {
	box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
}

.site-header__bar {
	min-height: 4.5rem;
}

.site-header .custom-logo {
	width: 13.5rem;
	height: auto;
}

.site-header .site-header__cta .wp-block-button__link {
	white-space: nowrap;
}

@media (max-width: 599px) {
	.site-header .custom-logo {
		width: 11rem;
	}

	.site-header .site-header__cta {
		display: none;
	}

	.site-topbar {
		display: none;
	}
}

/*
 * Core cambia a menú desplegable por debajo de 600px; con siete secciones el
 * menú horizontal no cabe hasta ~1100px, así que se amplía ese rango.
 */
@media (min-width: 600px) and (max-width: 1099px) {
	.site-header .wp-block-navigation__responsive-container-open:not(.always-shown) {
		display: flex;
	}

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

/* Enlace activo de la navegación principal (clase añadida en functions.php). */
.site-header .wp-block-navigation-item.is-current-section > a {
	color: var(--wp--preset--color--surface);
	background: var(--wp--preset--color--primary);
	border-radius: var(--wp--preset--border-radius--sm);
}

.site-header .wp-block-navigation-item > a {
	padding: 0.375rem 0.5rem;
}

.site-header .wp-block-navigation__responsive-container.is-menu-open {
	padding: var(--wp--preset--spacing--40);
}

.site-header .wp-block-search__inside-wrapper {
	padding: 2px;
	border: 1px solid var(--wp--preset--color--outline);
	border-radius: var(--wp--preset--border-radius--sm);
	background: var(--wp--preset--color--surface-low);
}

.site-header .wp-block-search__input {
	width: 11rem;
	border: 0;
	background: transparent;
	font-size: var(--wp--preset--font-size--small);
}

.site-header .wp-block-search__button {
	margin-left: 0;
	padding: 0.375rem;
	border-radius: 2px;
}

@media (max-width: 1279px) {
	.site-header .wp-block-search {
		display: none;
	}
}

/* Metadatos del artículo: autor en línea y separados por un punto medio. */
.entry-meta .wp-block-post-author__content {
	display: flex;
	flex: 0 0 auto;
	gap: 0.3em;
}

.entry-meta .wp-block-post-author__byline,
.entry-meta .wp-block-post-author__name {
	margin: 0;
	font-size: inherit;
	text-transform: none;
}

@media (min-width: 600px) {
	.entry-meta > * + *::before {
		content: "·";
		margin-right: var(--wp--preset--spacing--10);
	}
}

@media (max-width: 599px) {
	.entry-meta {
		flex-direction: column;
		align-items: flex-start !important;
		gap: 0 !important;
	}
}

/* Listas de enlaces del pie */
.site-footer__links {
	list-style: none;
}

/* ---------- Tarjetas enlazadas ---------- */

/* Toda la tarjeta es clicable mediante el enlace del título (un solo enlace, accesible). */
.is-linked-card {
	position: relative;
	transition: box-shadow 0.15s ease;
}

.is-linked-card:hover {
	box-shadow: var(--wp--preset--shadow--md);
}

.is-linked-card :where(h2, h3, h4) a::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.is-linked-card :where(h2, h3, h4) a {
	text-decoration: none;
}

.is-linked-card :where(h2, h3, h4) a:focus-visible {
	outline: none;
}

.is-linked-card:focus-within {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

/* Las tarjetas estiran su contenido para alinear los pies. */
.is-style-tarjeta.is-layout-flex.is-vertical,
.is-style-panel.is-layout-flex.is-vertical {
	height: 100%;
}

.wp-block-post-template.is-layout-grid > li > .is-style-tarjeta {
	height: 100%;
}

/* Imagen destacada a sangre en las tarjetas de la rejilla de artículos. */
.is-style-tarjeta > .tarjeta-imagen:first-child {
	margin: calc(-1 * var(--wp--preset--spacing--40)) calc(-1 * var(--wp--preset--spacing--40)) 0;
	border-radius: var(--wp--preset--border-radius--md) var(--wp--preset--border-radius--md) 0 0;
	overflow: hidden;
}

.is-style-tarjeta > .tarjeta-imagen img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ---------- Estilos de bloque registrados en functions.php ---------- */

/* Insignia con punto */
.is-style-insignia {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.25rem 0.625rem;
	border-radius: var(--wp--preset--border-radius--sm);
	background: var(--wp--preset--color--surface-mid);
	color: var(--wp--preset--color--muted);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.is-style-insignia::before {
	content: "";
	flex: none;
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--wp--preset--color--secondary);
}

/* Lista de verificación */
.is-style-checklist {
	list-style: none;
	padding-left: 0;
}

.is-style-checklist > li {
	position: relative;
	padding-left: 1.875rem;
}

.is-style-checklist > li + li {
	margin-top: 0.5rem;
}

.is-style-checklist > li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.2em;
	width: 1.25rem;
	height: 1.25rem;
	border-radius: 50%;
	background: var(--wp--preset--color--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 10.5l3 3 6-7'/%3E%3C/svg%3E") center / 100% no-repeat;
}

/* Lista de enlaces tipo navegación */
.is-style-enlaces {
	list-style: none;
	padding-left: 0;
}

.is-style-enlaces > li + li {
	margin-top: 0.5rem;
}

.is-style-enlaces > li > a {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.625rem 0.75rem;
	border-radius: var(--wp--preset--border-radius--sm);
	background: var(--wp--preset--color--surface);
	font-weight: 600;
	text-decoration: none;
}

.is-style-enlaces > li > a:hover {
	background: var(--wp--preset--color--surface-high);
	color: var(--wp--preset--color--primary);
}

.is-style-enlaces > li > a::after {
	content: "›";
	flex: none;
	font-size: 1.25rem;
	line-height: 1;
}

/* Pasos numerados */
.is-style-pasos {
	list-style: none;
	padding-left: 0;
	counter-reset: paso;
}

.is-style-pasos > li {
	position: relative;
	counter-increment: paso;
	padding-left: 2.5rem;
	min-height: 1.75rem;
}

.is-style-pasos > li + li {
	margin-top: 0.75rem;
}

.is-style-pasos > li::before {
	content: counter(paso);
	position: absolute;
	left: 0;
	top: 0;
	width: 1.75rem;
	height: 1.75rem;
	display: grid;
	place-items: center;
	border-radius: 50%;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
}

/* Enlace con flecha */
.is-style-flecha a {
	font-weight: 600;
	text-decoration: none;
}

.is-style-flecha a::after {
	content: " →";
}

/* ---------- Componentes editoriales ---------- */

.is-style-nota > :first-child,
.is-style-advertencia > :first-child,
.is-style-respuesta > :first-child,
.is-style-ejemplo > :first-child {
	margin-top: 0;
}

.is-style-nota::before,
.is-style-advertencia::before {
	content: "";
	display: block;
	width: 1.25rem;
	height: 1.25rem;
	margin-bottom: 0.25rem;
	background: currentColor;
	-webkit-mask: var(--ra-icon) center / contain no-repeat;
	mask: var(--ra-icon) center / contain no-repeat;
}

.is-style-nota::before {
	--ra-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z'/%3E%3C/svg%3E");
	color: var(--wp--preset--color--accent);
}

.is-style-advertencia::before {
	--ra-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
	color: var(--wp--preset--color--secondary);
}

/* Tablas: desplazamiento horizontal dentro de la tabla, nunca en la página. */
.wp-block-table {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.wp-block-table table {
	min-width: 32rem;
	border-collapse: collapse;
}

.wp-block-table :where(th, td) {
	padding: 0.625rem 0.75rem;
	border-color: var(--wp--preset--color--outline);
	text-align: left;
	vertical-align: top;
}

.wp-block-table thead th {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
	border-color: var(--wp--preset--color--primary);
	font-weight: 600;
}

.wp-block-table.is-style-comparativa tbody td:first-child {
	font-weight: 600;
	color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--surface-low);
}

.wp-block-table figcaption {
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
}

/* Preguntas frecuentes */
.wp-block-details > summary {
	cursor: pointer;
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 700;
	color: var(--wp--preset--color--primary);
	list-style: none;
	display: flex;
	justify-content: space-between;
	gap: 1rem;
}

.wp-block-details > summary::-webkit-details-marker {
	display: none;
}

.wp-block-details > summary::after {
	content: "+";
	flex: none;
	font-size: 1.25rem;
	line-height: 1.2;
	color: var(--wp--preset--color--muted);
}

.wp-block-details[open] > summary::after {
	content: "−";
}

.wp-block-details[open] > summary {
	padding-bottom: var(--wp--preset--spacing--20);
	margin-bottom: var(--wp--preset--spacing--20);
	border-bottom: 1px solid var(--wp--preset--color--surface-high);
}

/* Paginación */
.wp-block-query-pagination a,
.wp-block-query-pagination .current {
	padding: 0.375rem 0.625rem;
	border-radius: var(--wp--preset--border-radius--sm);
	text-decoration: none;
}

.wp-block-query-pagination .current {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
}

/* Contenido del artículo: medida de lectura cómoda */
.entry-content > h2 {
	margin-top: var(--wp--preset--spacing--50);
}

.entry-content > h3 {
	margin-top: var(--wp--preset--spacing--40);
}

/* Movimiento reducido */
@media (prefers-reduced-motion: reduce) {
	* {
		transition: none !important;
		scroll-behavior: auto !important;
	}
}

/* Franjas que solo contienen un bloque dinámico: se ocultan si este no devuelve nada. */
.is-optional-band:not(:has(> :not(style))) {
	display: none;
}

/* Llamada visual al pie de una tarjeta enlazada (el enlace real es el título). */
.card-cta {
	font-weight: 600;
	color: var(--wp--preset--color--primary);
}

.card-cta::after {
	content: " →";
}

.is-linked-card:hover .card-cta {
	color: var(--wp--preset--color--secondary);
}

/* Número en círculo */
.ra-num {
	flex: none;
	display: grid;
	place-items: center;
	width: 1.75rem;
	height: 1.75rem;
	margin: 0;
	border-radius: 50%;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--surface);
	font-family: var(--wp--preset--font-family--mono);
	font-size: var(--wp--preset--font-size--x-small);
}

.screen-reader-text:not(:focus) {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Artículo + barra lateral publicitaria fija en escritorio ancho. */
.article-rail {
	display: none;
}

@media (min-width: 1200px) {
	.article-layout:has(.ats-ad) {
		display: grid;
		grid-template-columns: minmax(0, 760px) 300px;
		justify-content: center;
		align-items: start;
		column-gap: var(--wp--preset--spacing--50);
	}

	.article-layout:has(.ats-ad) > .article-rail {
		display: block;
		position: sticky;
		top: 7.5rem;
		margin-top: var(--wp--preset--spacing--50);
	}

	.admin-bar .article-layout:has(.ats-ad) > .article-rail {
		top: calc(7.5rem + var(--wp-admin--admin-bar--height, 32px));
	}
}

/* Banner de ahorro de la portada */
.savings-banner .wp-block-columns {
	margin-block: 0;
}

.savings-banner__points > li::before {
	background-color: var(--wp--preset--color--highlight);
}

.savings-ticket {
	box-shadow: var(--wp--preset--shadow--md);
}

.savings-ticket__row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding-block: 0.5rem;
	border-bottom: 1px solid var(--wp--preset--color--surface-high);
	font-size: var(--wp--preset--font-size--small);
}

.savings-ticket__row strong {
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	color: var(--wp--preset--color--primary);
	white-space: nowrap;
}

.savings-ticket__total {
	border-bottom: 0;
}

.savings-ticket__total strong {
	font-size: var(--wp--preset--font-size--x-large);
	color: var(--wp--preset--color--success);
}

/* Tarjetas de preguntas */
.question-card h3 {
	margin: 0;
}

.question-card:hover {
	background: var(--wp--preset--color--surface-mid);
}

/* Invitación a la calculadora al final de los artículos */
.calc-invite > * {
	margin: 0;
}

.calc-invite p {
	margin: 0;
}

/* Selector de idioma de la cabecera */
.lang-switch ul {
	display: flex;
	gap: 0.125rem;
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: var(--wp--preset--font-size--small);
}
.lang-switch a {
	display: inline-block;
	min-width: 2.25rem;
	padding: 0.35rem 0.5rem;
	border-radius: 4px;
	color: var(--wp--preset--color--muted);
	font-weight: 600;
	text-align: center;
	text-decoration: none;
}
.lang-switch a:hover,
.lang-switch a:focus-visible {
	color: var(--wp--preset--color--primary);
}
.lang-switch a[aria-current] {
	color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--surface-low);
}
