/*--------------------------------------------------------------
# Header - Flotante y fijo
--------------------------------------------------------------*/


#site-header {
	position: fixed;
	top: 40px;
	left: 0;
	right: 0;
	z-index: 1000;
	width: 100%;
	max-width: calc(var(--header-width) + var(--contenedor-padding) + var(--contenedor-padding));
	margin: 0 auto;
	padding-left: var(--contenedor-padding);
	padding-right: var(--contenedor-padding);
	box-sizing: border-box;
}

/* Ajuste cuando la barra de administración de WordPress está visible */
.admin-bar #site-header {
	top: 72px;
	/* 20px + 32px de la barra de admin */
}

/*
 * Móvil / tablet: menú a 16px del borde superior; píldora 70px de alto.
 * Con .admin-bar: 32px + 16px por encima de 600px; 46px + 16px en pantallas estrechas (WP).
 */
@media screen and (max-width: 991px) {
	#site-header {
		top: 16px;
	}

	.admin-bar #site-header {
		top: 48px;
	}
}

@media screen and (max-width: 600px) {
	.admin-bar #site-header {
		top: 62px;
	}
}

@media screen and (max-width: 767px) {
	#site-header {
		max-width: 100%;
		padding-left: 16px;
		padding-right: 16px;
	}
}

#site-header .inner {
	--header-inner-height: 86px;
	margin: 0 auto;
	width: 100%;
	position: relative;
	background-color: var(--gray-100);
	border: 1px solid var(--primary-40);
	height: var(--header-inner-height);
	/* Radio = mitad de la altura: laterales en semicírculo (píldora) */
	border-radius: calc(var(--header-inner-height) / 2);
	display: flex;
	justify-content: space-between;
	align-items: center;
	transition: background-color 0.3s ease, border 0.3s ease;
	padding-left: 30px;
	padding-right: 30px;
	box-sizing: border-box;
	min-width: 0;
	overflow: visible;
}

/* Móvil / tablet: píldora 70px (mismo padding lateral que desktop: 30px en el bloque base). */
@media screen and (max-width: 991px) {
	#site-header .inner {
		--header-inner-height: 70px;
	}
}

/* Estado inicial en home: blanco semitransparente con borde primary-40 */
.home #site-header .inner {
	background-color: rgba(255, 255, 255, 0.6); /* --gray-100 con opacidad */
	border: 1px solid var(--primary-40);
	transition: background-color 0.1s ease, border-color 0.1s ease;
}

.brand {
	display: flex;
	align-items: center;
	flex-shrink: 0;
	min-width: 0;
}

.brand a {
	display: flex;
	align-items: center;
	line-height: 0;
}

.brand img {
	height: 55px;
	width: auto;
	display: block;
}

@media screen and (max-width: 991px) {
	.brand img {
		height: 50px;
	}
}

.menu {
	display: flex;
	align-items: center;
}

/* Marcador del idioma activo (ítem .dest-header-language-switcher, ver menu-language-labels.php) */
.menu > ul > li.dest-header-language-switcher > a::before {
	content: '';
	display: inline-block;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background-color: var(--accent-100);
	flex-shrink: 0;
}

/* Estilos del texto del selector de idiomas */
.menu > ul > li.dest-header-language-switcher > a {
	font-family: var(--font-body);
	font-weight: 400;
	font-size: var(--menu-language-font-size-mobile);
	line-height: var(--menu-language-line-height-mobile);
	letter-spacing: 0;
	vertical-align: middle;
	display: flex;
	align-items: center;
	gap: 8px;
}

@media screen and (min-width: 992px) {
	.menu > ul > li.dest-header-language-switcher > a {
		font-size: var(--menu-language-font-size);
		line-height: var(--menu-language-line-height);
	}
}

.menu ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	gap: 32px;
	align-items: center;
}

.menu li {
	margin: 0;
	position: relative;
	z-index: 1;
}

.menu li:hover {
	z-index: 1003;
}

/* Icono de flecha para items con submenú */
.menu-item-has-children > a {
	display: flex;
	align-items: center;
	gap: 14px;
}

.menu-item-has-children > a::after {
	content: '';
	width: 10px;
	height: 10px;
	mask-repeat: no-repeat;
	mask-position: center;
	mask-size: contain;
	background-color: var(--black-100);
	display: inline-block;
	flex-shrink: 0;
	transform: translateY(0);
}

/* Selector de idioma: sin flecha (submenú sigue abriéndose al hover) */
.menu > ul > li.dest-header-language-switcher.menu-item-has-children > a::after {
	content: none;
	display: none;
	mask-image: none;
	width: 0;
	height: 0;
	margin: 0;
}

/* Submenús - ocultos por defecto */
.menu ul ul {
	position: absolute;
	top: 100%;
	left: 0;
	background-color: rgba(255, 255, 255, 0.95); /* --gray-100 con opacidad */
	border: 1px solid var(--primary-60);
	border-radius: 8px;
	padding: 0.5rem 0;
	width: auto;
	box-shadow: 0 4px 6px rgba(19, 48, 64, 0.1); /* --black-100 con opacidad */
	opacity: 0;
	visibility: hidden;
	transform: translateY(-10px);
	transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
	flex-direction: column;
	gap: 0;
	margin-top: 0.5rem;
	z-index: 1003;
}

/* Mostrar submenú al hover */
.menu li:hover > ul,
.menu li.focus > ul {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.menu ul ul li {
	width: 100%;
}

.menu ul ul li:not(:last-child) {
	border-bottom: 1px solid var(--primary-60);
}

.menu ul ul a {
	padding: 0.75rem 1.5rem;
	display: block;
	color: var(--black-100);
	white-space: nowrap;
	text-transform: none;
}

.menu ul ul a:hover {
	background-color: rgba(134, 200, 188, 0.2); /* --accent-100 con opacidad */
}

.menu a {
	text-decoration: none;
	font-family: var(--font-body);
	font-weight: 400;
	font-size: var(--menu-font-size-mobile);
	line-height: var(--menu-line-height-mobile);
	letter-spacing: 0;
	color: var(--black-100);
}

@media screen and (min-width: 992px) {
	.menu a {
		font-size: var(--menu-font-size);
		line-height: var(--menu-line-height);
	}
}

/* Solo primer nivel del menú horizontal (no submenús): Body / XS + .semibold (Figma) */
.menu > ul > li > a {
	text-transform: uppercase;
	font-size: var(--body-xs-font-size-mobile);
	line-height: var(--body-line-height-mobile);
	font-weight: var(--font-weight-semibold);
}

@media screen and (min-width: 992px) {
	.menu > ul > li > a {
		font-size: var(--body-xs-font-size-desktop);
		line-height: var(--body-line-height-desktop);
	}
}

/*
 * Menú desktop: ítem activo solo en primer nivel (> ul > li); sin subrayado en submenús (.menu ul ul).
 * 10px entre texto (y flecha) y la línea secondary; no aplica a .especial.
 */
#site-header .menu > ul > li:not(.especial).current-menu-item > a:not(.especial),
#site-header .menu > ul > li:not(.especial).current-menu-ancestor > a:not(.especial),
#site-header .menu > ul > li:not(.especial).current-menu-parent > a:not(.especial),
#site-header .menu > ul > li:not(.especial).current_page_item > a:not(.especial) {
	text-decoration: none;
	border-bottom: none;
	padding-bottom: 11px;
	margin-bottom: -11px;
	background-image: linear-gradient(
		to bottom,
		transparent 0,
		transparent calc(100% - 1px),
		var(--secondary-100) calc(100% - 1px),
		var(--secondary-100) 100%
	);
	background-size: 100% 100%;
	background-repeat: no-repeat;
	background-position: 0 0;
}

/* Item del menú con clase "especial" - se convierte en botón (solo en header normal) */
#site-header .menu .menu-item.especial > a,
#site-header .menu a.especial {
	background-color: var(--secondary-100);
	color: var(--gray-100);
	padding: 12px 20px;
	/* Píldora: radio = mitad de la altura (misma idea que #site-header .inner) */
	border-radius: 9999px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	position: relative;
	z-index: 0;
	transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

#site-header .menu .menu-item.especial > a:hover,
#site-header .menu a.especial:hover {
	background-color: var(--accent-100);
	color: var(--black-100);
}

#site-header .menu .menu-item.especial.menu-item-has-children > a::after {
	background-color: var(--gray-100);
}

#site-header .menu .menu-item.especial.menu-item-has-children > a:hover::after {
	background-color: var(--black-100);
}

/* Especial en ruta activa: fondo accent-100 (misma lectura que hover) */
#site-header .menu li.menu-item.especial.current-menu-item > a,
#site-header .menu li.menu-item.especial.current-menu-ancestor > a,
#site-header .menu li.menu-item.especial.current-menu-parent > a,
#site-header .menu li.menu-item.especial.current_page_item > a,
#site-header .menu li.current-menu-item > a.especial,
#site-header .menu li.current-menu-ancestor > a.especial,
#site-header .menu li.current-menu-parent > a.especial,
#site-header .menu li.current_page_item > a.especial {
	background-color: var(--accent-100);
	color: var(--black-100);
}

#site-header .menu li.menu-item.especial.menu-item-has-children:is(.current-menu-item, .current-menu-ancestor, .current-menu-parent, .current_page_item) > a::after,
#site-header .menu li.menu-item-has-children:is(.current-menu-item, .current-menu-ancestor, .current-menu-parent, .current_page_item) > a.especial::after {
	background-color: var(--black-100);
}

.menu-hamburguesa {
	background: none;
	border: none;
	/* Padding expande el área táctil sin cambiar el visual; margin lo compensa */
	padding: 12px;
	margin: -12px -12px -12px 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--black-100);
	/* Tamaño visual del icono */
	width: 30px;
	height: 20px;
	/* Área táctil mínima 44×44px para iOS/WCAG */
	min-width: 44px;
	min-height: 44px;
	margin-left: calc(2rem - 12px);
	/* Elimina el delay de 300ms en iOS Safari */
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	flex-shrink: 0;
}

.menu-hamburguesa svg {
	width: 30px;
	height: 20px;
	flex-shrink: 0;
}

.menu-hamburguesa:hover {
	opacity: 0.7;
}

/* Hamburguesa solo por debajo de 992px (--breakpoint-desktop) */
@media screen and (min-width: 992px) {
	.menu-hamburguesa {
		display: none;
	}
}

/* Desktop: enlaces del menú alineados a la derecha e idioma justo después (mismo grupo) */
@media screen and (min-width: 992px) {
	#site-header .inner .menu {
		flex: 1;
		min-width: 0;
		justify-content: flex-end;
	}

	#site-header .menu > ul {
		flex: 0 1 auto;
		min-width: 0;
		justify-content: flex-end;
	}
}

/* Ocultar enlaces del menú en mobile/tablet; mantener solo idioma y hamburguesa */
@media screen and (max-width: 991px) {
	.menu > ul:has(.dest-header-language-switcher) > li:not(.dest-header-language-switcher) {
		display: none;
	}

	/*
	 * Sin ítems WPML/Polylang en el menú (p. ej. CPT singular donde get_ls_languages no añade LS):
	 * no mostrar el último enlace como si fuera idioma; solo logo + hamburguesa.
	 */
	.menu > ul:not(:has(.dest-header-language-switcher)) > li {
		display: none;
	}

	.menu > ul {
		display: flex;
		align-items: center;
		gap: 0.75rem;
	}
	
	.menu {
		flex-wrap: nowrap;
		min-width: 0;
		flex-shrink: 1;
	}
	
	.menu-hamburguesa {
		margin-left: 1rem;
		flex-shrink: 0;
	}
	
	/* Asegurar que el selector de idioma no se salga */
	.menu > ul > li.dest-header-language-switcher {
		flex-shrink: 1;
		min-width: 0;
	}
	
	.menu > ul > li.dest-header-language-switcher > a {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		max-width: 100%;
	}

	/*
	 * Idioma: en táctil el desplegable se abre con clic (clase .focus en JS), no con hover.
	 */
	#site-header .menu > ul > li.dest-header-language-switcher.menu-item-has-children:hover > ul,
	#header-modal .menu > ul > li.dest-header-language-switcher.menu-item-has-children:hover > ul {
		opacity: 0;
		visibility: hidden;
		transform: translateY(-10px);
		pointer-events: none;
	}

	#site-header .menu > ul > li.dest-header-language-switcher.menu-item-has-children.focus > ul,
	#site-header .menu > ul > li.dest-header-language-switcher.menu-item-has-children:focus-within > ul,
	#header-modal .menu > ul > li.dest-header-language-switcher.menu-item-has-children.focus > ul,
	#header-modal .menu > ul > li.dest-header-language-switcher.menu-item-has-children:focus-within > ul {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
	}

	#site-header .menu > ul > li.dest-header-language-switcher.menu-item-has-children > ul,
	#header-modal .menu > ul > li.dest-header-language-switcher.menu-item-has-children > ul {
		left: auto;
		right: 0;
		min-width: 12rem;
		z-index: 10050;
	}

	/*
	 * Área mínima de activación 50px (táctil / accesibilidad) en móvil y tablet.
	 */
	#site-header .menu > ul > li > a,
	#header-modal .menu > ul > li > a {
		min-height: 50px;
		display: inline-flex;
		align-items: center;
		box-sizing: border-box;
	}

	#site-header .menu ul ul a,
	#header-modal .menu ul ul a {
		min-height: 50px;
		display: flex;
		align-items: center;
		box-sizing: border-box;
	}

	.menu-modal-nav .contenedor-header > ul > li > a {
		min-height: 50px;
		display: flex;
		align-items: center;
		box-sizing: border-box;
	}

	.menu-modal-nav ul ul a {
		min-height: 50px;
		display: flex;
		align-items: center;
		box-sizing: border-box;
	}
}

/*--------------------------------------------------------------
# Modal del menú hamburguesa
--------------------------------------------------------------*/

/* inset:0 en vez de 100vw/100vh: 100vw incluye el ancho de la barra de scroll y provoca
   overflow-x en escritorio; en móvil el efecto no suele notarse. */
.menu-modal {
	position: fixed;
	inset: 0;
	width: auto;
	height: auto;
	z-index: 9999;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	overflow-x: hidden;
}

.menu-modal.active {
	opacity: 1;
	visibility: visible;
}

.menu-modal-overlay {
	position: absolute;
	inset: 0;
	background-color: var(--primary-10);
}

.menu-modal-content {
	position: relative;
	width: 100%;
	height: 100%;
	background-color: var(--primary-10);
	display: flex;
	flex-direction: column;
	overflow-y: auto;
	overflow-x: hidden;
	scrollbar-gutter: stable;
	scrollbar-width: auto;
}

.menu-modal-content::-webkit-scrollbar {
	width: auto;
}

/* Header del modal: misma distancia al borde superior y mismo ancho que #site-header (móvil/tablet/escritorio). */
#header-modal {
	position: fixed;
	top: 40px;
	left: 0;
	right: 0;
	z-index: 10000;
	width: 100%;
	max-width: calc(var(--header-width) + var(--contenedor-padding) * 2);
	margin: 0 auto;
	padding-left: var(--contenedor-padding);
	padding-right: var(--contenedor-padding);
	box-sizing: border-box;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.admin-bar #header-modal {
	top: 72px;
}

/* Mismos top que .admin-bar #site-header (barra WP). */
@media screen and (max-width: 991px) {
	#header-modal {
		top: 16px;
	}

	.admin-bar #header-modal {
		top: 48px;
	}
}

@media screen and (max-width: 600px) {
	.admin-bar #header-modal {
		top: 62px;
	}
}

.menu-modal.active #header-modal {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

@media screen and (max-width: 767px) {
	#header-modal {
		max-width: 100%;
	}
}

#header-modal .inner {
	margin: 0 auto;
	width: 100%;
	position: relative;
	background-color: transparent;
	border: none;
	height: 86px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-left: 30px;
	padding-right: 30px;
	box-sizing: border-box;
}

/* Misma altura de franja que la píldora de #site-header en móvil/tablet. */
@media screen and (max-width: 991px) {
	#header-modal .inner {
		height: 70px;
	}
}

/* Ocultar items del menú en el header del modal, pero mostrar selector de idioma */
#header-modal .menu > ul:has(.dest-header-language-switcher) > li:not(.dest-header-language-switcher) {
	display: none;
}

#header-modal .menu > ul:not(:has(.dest-header-language-switcher)) > li {
	display: none;
}

/* Mostrar selector de idioma en el header del modal en todos los dispositivos */
#header-modal .menu > ul > li.dest-header-language-switcher {
	display: block !important;
}

/* Asegurar que el menú del header modal sea visible en mobile para mostrar el selector de idioma */
@media screen and (max-width: 991px) {
	#header-modal .menu > ul {
		display: flex !important;
	}
	
	#header-modal .menu > ul > li.dest-header-language-switcher {
		display: block !important;
	}
}

/* Botón de cerrar: misma márgenes que .menu-hamburguesa en móvil (1rem) para alinear el selector de idioma. */
#header-modal .menu-modal-close {
	background: none;
	border: none;
	padding: 12px;
	margin: -12px -12px -12px 0;
	cursor: pointer;
	color: var(--black-100);
	width: 30px;
	height: 20px;
	min-width: 44px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-left: calc(1rem - 12px);
	flex-shrink: 0;
	transition: opacity 0.3s ease;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

#header-modal .menu-modal-close:hover {
	opacity: 0.7;
}

#header-modal .menu-modal-close img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

.menu-modal-nav {
	flex: 1;
	display: flex;
	align-items: flex-start;
	justify-content: flex-start;
	padding-top: 4rem;
	padding-bottom: 4rem;
	/* 40 + 86: hueco bajo #header-modal alineado con sitio; en móvil se recalcula (16 + 70) */
	margin-top: 126px;
}

@media screen and (max-width: 991px) {
	.menu-modal-nav {
		margin-top: 86px;
	}

	.admin-bar .menu-modal-nav {
		margin-top: 118px;
	}
}

@media screen and (max-width: 600px) {
	.admin-bar .menu-modal-nav {
		margin-top: 132px;
	}
}

.menu-modal-nav .contenedor-header {
	width: 100%;
	padding-left: calc(var(--contenedor-padding) + 30px);
	padding-right: var(--contenedor-padding);
}

@media screen and (max-width: 991px) {
	.menu-modal-nav .contenedor-header {
		padding-left: calc(var(--contenedor-padding) + 30px);
		padding-right: var(--contenedor-padding);
	}
}

@media screen and (max-width: 767px) {
	.menu-modal-nav .contenedor-header {
		padding-left: calc(16px + 30px);
		padding-right: 16px;
	}
}

.menu-modal-nav ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 30px;
	align-items: flex-start;
	width: 100%;
}

/* Ocultar selector de idioma en el menú del modal (ya está en el header) */
.menu-modal-nav ul > li.dest-header-language-switcher {
	display: none;
}

.menu-modal-nav li {
	margin: 0;
	width: 100%;
	text-align: left;
}

.menu-modal-nav a {
	text-decoration: none;
	font-family: var(--font-title);
	font-weight: 400;
	font-size: 32px;
	line-height: 120%;
	letter-spacing: 0;
	color: var(--secondary-100);
	display: block;
	padding: 0;
	transition: color 0.3s ease;
}

.menu-modal-nav .contenedor-header > ul > li:not(.especial).current-menu-item > a:not(.especial),
.menu-modal-nav .contenedor-header > ul > li:not(.especial).current-menu-ancestor > a:not(.especial),
.menu-modal-nav .contenedor-header > ul > li:not(.especial).current-menu-parent > a:not(.especial),
.menu-modal-nav .contenedor-header > ul > li:not(.especial).current_page_item > a:not(.especial) {
	text-decoration: none;
	border-bottom: none;
}

.menu-modal-nav a:hover {
	color: var(--black-100);
}

.menu-modal-nav .menu-item-has-children > a {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 14px;
}

.menu-modal-nav .menu-item-has-children > a::after {
	content: '';
	width: 10px;
	height: 10px;
	mask-image: url('../img/svg/menu-down.svg');
	mask-repeat: no-repeat;
	mask-position: center;
	mask-size: contain;
	background-color: var(--secondary-100);
	display: inline-block;
	flex-shrink: 0;
	transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	transform: translateY(0);
}

.menu-modal-nav .menu-item-has-children > a:hover::after {
	transform: translateY(0) rotate(-90deg);
}

.menu-modal-nav .menu-item-has-children.active > a::after {
	transform: translateY(0) rotate(-90deg);
}

.menu-modal-nav ul ul {
	display: flex;
	flex-direction: column;
	margin-top: 0;
	gap: 1rem;
	max-height: 0;
	overflow: hidden;
	opacity: 0;
	transform: translateY(-10px);
	transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
	            opacity 0.3s ease 0.1s, 
	            transform 0.3s ease 0.1s, 
	            margin-top 0.3s ease 0.1s;
	visibility: hidden;
}

.menu-modal-nav li.menu-item-has-children.active > ul {
	max-height: 500px;
	opacity: 1;
	transform: translateY(0);
	margin-top: 1rem;
	visibility: visible;
}

/* Submenús: cuerpo regular (Body M), más legible que el tamaño de selector de idioma. */
.menu-modal-nav ul ul a {
	font-family: var(--font-body);
	font-weight: var(--font-weight-regular);
	font-size: var(--body-m-font-size-mobile);
	line-height: 1.4;
	padding: 0;
	color: var(--secondary-100);
	transition: color 0.3s ease;
	text-transform: none;
}

@media screen and (min-width: 992px) {
	.menu-modal-nav ul ul a {
		font-size: var(--body-m-font-size-desktop);
	}
}

/* Solo primer nivel del menú del modal */
.menu-modal-nav .contenedor-header > ul > li > a {
	text-transform: uppercase;
}

.menu-modal-nav ul ul a:hover {
	color: var(--black-100);
}


/* Item especial NO se aplica en el modal - se mantiene como item normal */