/* ==========================================================================
   Sitio · Header
   --------------------------------------------------------------------------
   data-tone = tono de la sección que hay debajo del header (lo actualiza el
   JS): "dark" = fondo oscuro, "light" = fondo claro.
     Header inicial: transparente; letras/logo crema sobre oscuro, vino sobre
                     claro.
     Isla flotante:  fondo vino con letras/logo crema sobre secciones claras;
                     fondo crema con letras/logo vino sobre secciones oscuras.
                     La página actual se encapsula en el color inverso.
   ========================================================================== */

.ans-header {
	--hd-wine: #6b1c29;
	--hd-cream: #f5f0ea;
	--hd-fg: var(--hd-wine);
	--is-bg: var(--hd-wine);
	--is-fg: var(--hd-cream);
	--hd-speed: 0.45s;

	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 900;
	font-family: var(--ans-font-sans);
	font-weight: 300;
	font-size: var(--ans-text-sm);
	line-height: 1;
	letter-spacing: var(--ans-tracking);
	text-transform: uppercase;
	pointer-events: none;
}

.ans-header[data-tone="dark"] {
	--hd-fg: var(--hd-cream);
	--is-bg: var(--hd-cream);
	--is-fg: var(--hd-wine);
}

.ans-header *,
.ans-header *::before,
.ans-header *::after {
	box-sizing: border-box;
}

/* Neutraliza estilos genéricos de Hello Elementor para enlaces y botones. */
.ans-header ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.ans-header a,
.ans-header a:visited,
.ans-header a:hover,
.ans-header a:focus,
.ans-header button,
.ans-header button:hover,
.ans-header button:focus {
	font: inherit;
	letter-spacing: inherit;
	text-transform: inherit;
	color: inherit;
	text-decoration: none;
	background: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	padding: 0;
	margin: 0;
	white-space: nowrap;
}

.ans-header button {
	cursor: pointer;
}

.ans-header a:focus-visible,
.ans-header button:focus-visible {
	outline: 1px solid currentColor;
	outline-offset: 4px;
}

/* --------------------------------------------------------------------------
   Logo (dos versiones superpuestas, recortadas a su contorno visible)
   -------------------------------------------------------------------------- */

.ans-logo {
	position: relative;
	display: block;
	height: 100%;
	aspect-ratio: 672 / 760;
	overflow: hidden;
}

.ans-logo__img {
	position: absolute;
	left: -67.26%;
	top: -30.52%;
	width: 238.1% !important;
	max-width: none !important;
	height: auto !important;
	transition: opacity var(--hd-speed) ease;
}

/* Header inicial: logo claro sobre fondo oscuro, logo oscuro sobre claro. */
.ans-header[data-tone="dark"] .ans-header__logo .ans-logo__img--dark,
.ans-header[data-tone="light"] .ans-header__logo .ans-logo__img--light {
	opacity: 0;
}

/* Isla: el logo toma el color de las letras de la isla. */
.ans-header[data-tone="light"] .ans-island .ans-logo__img--dark,
.ans-header[data-tone="dark"] .ans-island .ans-logo__img--light {
	opacity: 0;
}

/* --------------------------------------------------------------------------
   Header inicial
   -------------------------------------------------------------------------- */

.ans-header__top {
	position: relative;
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
	height: clamp(76px, 7vw, 104px);
	padding: 0 clamp(20px, 3.5vw, 56px);
	color: var(--hd-fg);
	transition: color var(--hd-speed) ease, opacity var(--hd-speed) ease, transform var(--hd-speed) var(--ans-ease), visibility 0s linear 0s;
}

.ans-header.is-floating .ans-header__top {
	opacity: 0;
	visibility: hidden;
	transform: translateY(-24px);
	transition: color var(--hd-speed) ease, opacity var(--hd-speed) ease, transform var(--hd-speed) var(--ans-ease), visibility 0s linear var(--hd-speed);
}

.ans-header__top > * {
	pointer-events: auto;
}

.ans-header__nav {
	justify-self: start;
}

.ans-header__list {
	display: flex;
	align-items: center;
	gap: clamp(20px, 2.6vw, 44px);
}

.ans-header__item {
	position: relative;
}

.ans-header .ans-header__top .ans-header__link {
	position: relative;
	display: inline-block;
	padding: 6px 0;
}

/* Subrayado sutil al pasar el cursor y en la página actual. */
.ans-header__link::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 1px;
	background: currentColor;
	transform: scaleX(0);
	transform-origin: 0 50%;
	transition: transform 0.35s var(--ans-ease);
}

.ans-header__link:hover::after,
.ans-header__link:focus-visible::after,
.ans-header__link.is-active::after {
	transform: scaleX(1);
}

/* Proyectos: lista desplegable hacia abajo. */
.ans-header__sub {
	position: absolute;
	top: 100%;
	left: 0;
	display: flex;
	flex-direction: column;
	gap: 16px;
	/* Separación entre "Proyectos" y su lista (también puente para el cursor). */
	padding-top: 34px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 0.3s ease, transform 0.35s var(--ans-ease), visibility 0s linear 0.35s;
}

.ans-header .ans-header__sub .ans-header__link {
	padding: 2px 0;
}

.has-sub:hover .ans-header__sub,
.has-sub:focus-within .ans-header__sub,
.has-sub.is-open .ans-header__sub {
	opacity: 1;
	visibility: visible;
	transform: none;
	transition: opacity 0.3s ease, transform 0.35s var(--ans-ease), visibility 0s;
}

/* Home: el menú inicial no se monta sobre los espirales del cuaderno. */
.ans-page-home .ans-header__top {
	padding-left: calc(max(8.2vh, 4.7vw) + 24px);
}

.ans-header__logo {
	display: block;
	height: clamp(48px, 4.6vw, 70px);
}

.ans-header__end {
	justify-self: end;
	min-width: 1px;
}

.ans-header__toggle {
	display: none;
}

/* --------------------------------------------------------------------------
   Isla flotante (forma de referencia: pestaña pegada al borde superior y
   barra que se despliega justo debajo)
   -------------------------------------------------------------------------- */

.ans-island {
	position: absolute;
	top: 0;
	left: 50%;
	display: flex;
	flex-direction: column;
	align-items: center;
	transform: translate(-50%, -110%);
	transition: transform var(--hd-speed) var(--ans-ease);
}

.ans-header.is-floating .ans-island {
	transform: translate(-50%, 0);
}

.ans-header.is-floating .ans-island > * {
	pointer-events: auto;
}

.ans-island__tab {
	position: relative;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 10px 30px 10px;
	color: var(--is-fg);
	background: var(--is-bg);
	border-radius: 0 0 16px 16px;
	transition: background-color var(--hd-speed) ease, color var(--hd-speed) ease;
}

.ans-island__logo {
	display: block;
	height: 40px;
}

/* Botón para abrir el menú en pantallas táctiles (sin hover). */
.ans-header .ans-island__toggle {
	display: none;
	width: 22px;
	height: 14px;
}

.ans-island__toggle span {
	display: block;
	width: 6px;
	height: 6px;
	margin: 0 auto;
	border-radius: 50%;
	background: currentColor;
	transition: transform 0.3s var(--ans-ease);
}

.ans-island.is-open .ans-island__toggle span {
	transform: scale(1.5);
}

/* Barra horizontal que se despliega bajo la isla. */
.ans-island__bar {
	position: relative;
	z-index: 1;
	margin-top: -16px;
	padding: 24px 10px 10px;
	color: var(--is-fg);
	background: var(--is-bg);
	border-radius: 16px;
	clip-path: inset(0 calc(50% - 60px) 100% calc(50% - 60px) round 16px);
	opacity: 0;
	visibility: hidden;
	transition: clip-path 0.5s var(--ans-ease), opacity 0.2s ease 0.15s, visibility 0s linear 0.5s, background-color var(--hd-speed) ease, color var(--hd-speed) ease;
}

.ans-island:hover .ans-island__bar,
.ans-island:focus-within .ans-island__bar,
.ans-island.is-open .ans-island__bar {
	clip-path: inset(0 0 0 0 round 16px);
	opacity: 1;
	visibility: visible;
	transition: clip-path 0.5s var(--ans-ease), opacity 0.15s ease, visibility 0s, background-color var(--hd-speed) ease, color var(--hd-speed) ease;
}

.ans-island__list {
	display: flex;
	align-items: center;
	gap: 4px;
}

.ans-header .ans-island .ans-island__link {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 8px 18px 10px;
	border-radius: 10px;
	transition: background-color 0.3s ease, color 0.3s ease;
}

/* Punto sobre cada enlace (como en la referencia). */
.ans-island__link::before {
	content: "";
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: currentColor;
}

.ans-header .ans-island .ans-island__link.is-active,
.ans-header .ans-island .ans-island__link:hover,
.ans-header .ans-island .ans-island__link:focus-visible {
	color: var(--is-bg);
	background: var(--is-fg);
}

.ans-header .ans-island .ans-island__link:not(.is-active):hover,
.ans-header .ans-island .ans-island__link:not(.is-active):focus-visible {
	color: var(--is-fg);
	background: color-mix(in srgb, var(--is-fg) 16%, transparent);
}

/* Entrada escalonada de los enlaces al desplegar la barra. */
.ans-island__list li {
	opacity: 0;
	transform: translateY(-6px);
	transition: opacity 0.25s ease, transform 0.35s var(--ans-ease);
}

.ans-island:hover .ans-island__list li,
.ans-island:focus-within .ans-island__list li,
.ans-island.is-open .ans-island__list li {
	opacity: 1;
	transform: none;
}

.ans-island:hover .ans-island__list li:nth-child(2),
.ans-island.is-open .ans-island__list li:nth-child(2) { transition-delay: 0.03s; }
.ans-island:hover .ans-island__list li:nth-child(3),
.ans-island.is-open .ans-island__list li:nth-child(3) { transition-delay: 0.06s; }
.ans-island:hover .ans-island__list li:nth-child(4),
.ans-island.is-open .ans-island__list li:nth-child(4) { transition-delay: 0.09s; }
.ans-island:hover .ans-island__list li:nth-child(5),
.ans-island.is-open .ans-island__list li:nth-child(5) { transition-delay: 0.12s; }
.ans-island:hover .ans-island__list li:nth-child(6),
.ans-island.is-open .ans-island__list li:nth-child(6) { transition-delay: 0.15s; }

/* En táctil se muestra el botón para abrir el menú. */
@media (hover: none) {
	.ans-header .ans-island__toggle {
		display: block;
	}
}

/* --------------------------------------------------------------------------
   Móvil y tablet vertical
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
	.ans-header__top {
		height: 72px;
		padding: 0 20px;
	}

	.ans-header__logo {
		height: 46px;
	}

	.ans-header .ans-header__toggle {
		display: inline-block;
		justify-self: start;
		grid-column: 1;
		grid-row: 1;
		padding: 8px 0;
	}

	/* Menú del header inicial: panel bajo el header. */
	.ans-header__nav {
		position: absolute;
		justify-self: stretch;
		top: 100%;
		left: 12px;
		right: 12px;
		padding: 22px 22px 24px;
		color: var(--is-fg);
		background: var(--is-bg);
		border-radius: 16px;
		opacity: 0;
		visibility: hidden;
		transform: translateY(-8px);
		transition: opacity 0.3s ease, transform 0.35s var(--ans-ease), visibility 0s linear 0.35s, background-color var(--hd-speed) ease, color var(--hd-speed) ease;
	}

	.ans-header.is-menu-open .ans-header__nav {
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: opacity 0.3s ease, transform 0.35s var(--ans-ease), visibility 0s, background-color var(--hd-speed) ease, color var(--hd-speed) ease;
	}

	.ans-header__list {
		flex-direction: column;
		align-items: flex-start;
		gap: 18px;
	}

	.ans-header__sub {
		position: static;
		padding: 14px 0 0 16px;
		opacity: 1;
		visibility: visible;
		transform: none;
	}

	.ans-header__sub-toggle {
		pointer-events: none;
	}

	.ans-header__logo {
		grid-column: 2;
		grid-row: 1;
	}

	.ans-header__end {
		grid-column: 3;
		grid-row: 1;
	}

	/* Isla: menú vertical bajo la pestaña. */
	.ans-island__logo {
		height: 34px;
	}

	.ans-island__bar {
		width: min(78vw, 300px);
		padding: 26px 10px 10px;
	}

	.ans-island__list {
		flex-direction: column;
		align-items: stretch;
		gap: 2px;
	}

	.ans-header .ans-island .ans-island__link {
		flex-direction: row;
		justify-content: center;
		padding: 12px 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ans-header {
		--hd-speed: 0.01s;
	}

	.ans-island__bar,
	.ans-island__list li,
	.ans-header__sub {
		transition-duration: 0.01s !important;
		transition-delay: 0s !important;
	}
}
