/* eslint-disable react/prop-types */
/**
* Header · Navegación principal del sitio.
* Brief 0.1 §5 + Brief 1 §2. Refinamiento estilo gehlpeople.com:
* - Underline cobre animado scale-x desde la izquierda
* - Megamenú fade + translateY con entry escalonada de sub-items
* - Sticky shrink suave (transform + height)
* - data-cursor="link" en items para el cursor custom
*/
const { useState: uS_H, useEffect: uE_H, useRef: uR_H } = React;
const NAV_ITEMS = [
{ label: 'INICIO', href: '/home/Home.html' },
{
label: 'NUESTRO TRABAJO',
href: '/distritos/Distritos.html',
children: [
{ label: 'Distritos', href: '/distritos/Distritos.html', desc: '40+ distritos co-creados a lo largo de 18 años.' },
{ label: 'Servicios', href: '/servicios/Servicios.html', desc: 'Originación, Co-Desarrollo y Dataria.' },
{ label: 'Originación', href: '/servicios/Servicios.html#originacion', desc: 'De la lectura del polígono al diseño del negocio.' },
{ label: 'Co-Desarrollo', href: '/servicios/Servicios.html#co-desarrollo', desc: 'Acompañamos la operación con riesgo compartido.' },
{ label: 'Dataria', href: '/servicios/Servicios.html#digo', desc: 'La plataforma que pone DIGO® en operación.' },
{ label: 'Nuestro Enfoque', href: '/enfoque/NuestroEnfoque.html', desc: 'Por qué empezar por la persona y terminar por el negocio.' },
],
},
{
label: 'SOBRE NOSOTROS',
href: '/sobre-nosotros/Equipo.html',
children: [
{ label: 'Equipo', href: '/sobre-nosotros/Equipo.html', desc: '35 personas haciéndose la misma pregunta.' },
{ label: 'Historia', href: '/sobre-nosotros/Historia.html', desc: '18 años originando lo que la industria no veía.' },
{ label: 'Responsabilidad', href: '/sobre-nosotros/Responsabilidad.html', desc: 'Cinco compromisos con la ciudad.' },
],
},
{
label: 'CONOCIMIENTO',
href: '/conocimiento/Blog.html',
children: [
{ label: 'Blog', href: '/conocimiento/Blog.html', desc: 'Cómo pensamos, lo que aprendemos.' },
{ label: 'Casos', href: '/conocimiento/Casos.html', desc: 'Las historias detrás de los distritos.' },
{ label: 'Publicaciones', href: '/conocimiento/Publicaciones.html', desc: 'Reportes, whitepapers e índices.' },
{ label: 'Eventos', href: '/conocimiento/Eventos.html', desc: 'Dónde estamos hablando.' },
{ label: 'Prensa', href: '/conocimiento/Prensa.html', desc: 'En los medios.' },
{ label: 'Podcast', href: '/conocimiento/Podcast.html', desc: 'Creamos lo Extraordinario.' },
],
},
{ label: 'BOLSA DE TRABAJO', href: '/bolsa-de-trabajo/BolsaDeTrabajo.html' },
{ label: 'CONTACTO', href: '/home/Home.html#contacto' },
];
function Header() {
const [shrunk, setShrunk] = uS_H(false);
const [hovered, setHovered] = uS_H(null);
const [mobileOpen, setMobileOpen] = uS_H(false);
const [mobileExpanded, setMobileExpanded] = uS_H(null);
const closeTimer = uR_H(null);
uE_H(() => {
const onScroll = () => setShrunk(window.scrollY > 100);
window.addEventListener('scroll', onScroll, { passive: true });
return () => window.removeEventListener('scroll', onScroll);
}, []);
uE_H(() => {
document.body.style.overflow = mobileOpen ? 'hidden' : '';
return () => { document.body.style.overflow = ''; };
}, [mobileOpen]);
uE_H(() => {
const onKey = (e) => { if (e.key === 'Escape') { setHovered(null); setMobileOpen(false); } };
window.addEventListener('keydown', onKey);
return () => window.removeEventListener('keydown', onKey);
}, []);
const openMenu = (label) => {
if (closeTimer.current) clearTimeout(closeTimer.current);
setHovered(label);
};
const closeMenuSoon = () => {
if (closeTimer.current) clearTimeout(closeTimer.current);
closeTimer.current = setTimeout(() => setHovered(null), 160);
};
return (
{window.NotificationBar &&
}
);
}
const headerStyles = {
header: {
position: 'relative',
background: 'rgba(250, 249, 244, 0.92)',
backdropFilter: 'blur(12px) saturate(140%)',
WebkitBackdropFilter: 'blur(12px) saturate(140%)',
boxShadow: '0 1px 0 rgba(33, 52, 64, 0.08)',
transition: 'padding 320ms cubic-bezier(0.16, 1, 0.3, 1), background 320ms ease',
},
inner: {
maxWidth: 1280, margin: '0 auto',
padding: '0 var(--container-padding-mobile)',
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
gap: 24,
},
logoLink: { display: 'flex', alignItems: 'center' },
logoImg: { transition: 'height 320ms cubic-bezier(0.16, 1, 0.3, 1)', width: 'auto' },
navDesktop: {
display: 'none',
alignItems: 'center',
gap: 28,
},
navItemWrap: {
position: 'relative',
display: 'inline-flex',
alignItems: 'center',
},
navLink: {
position: 'relative',
fontSize: 12,
fontWeight: 700,
letterSpacing: '0.14em',
textTransform: 'uppercase',
color: 'var(--color-navy-deep)',
transition: 'color 240ms cubic-bezier(0.16, 1, 0.3, 1)',
display: 'inline-flex', alignItems: 'center',
padding: '12px 0',
whiteSpace: 'nowrap',
lineHeight: 1,
},
underline: {
position: 'absolute',
left: 0, right: 0, bottom: 6,
height: 2,
background: 'var(--color-copper-fallback)',
transformOrigin: 'left center',
transition: 'transform 360ms cubic-bezier(0.16, 1, 0.3, 1)',
},
waLink: {
display: 'inline-flex',
alignItems: 'center',
gap: 8,
paddingInline: 14,
paddingBlock: 9,
background: '#25D366',
color: '#fff',
fontWeight: 700,
fontSize: 12,
letterSpacing: '0.10em',
textTransform: 'uppercase',
borderRadius: 999,
textDecoration: 'none',
whiteSpace: 'nowrap',
lineHeight: 1,
transition: 'background 240ms ease, transform 240ms cubic-bezier(0.16,1,0.3,1), box-shadow 240ms ease',
boxShadow: '0 2px 8px rgba(37, 211, 102, 0.25)',
},
waIcon: {
display: 'block',
},
waLabel: {
color: '#fff',
fontWeight: 700,
},
hamburger: {
background: 'transparent', border: 0,
padding: 0,
width: 44, height: 44, /* tamaño táctil iOS HIG */
display: 'flex', alignItems: 'center', justifyContent: 'center',
color: 'var(--color-navy-deep)',
cursor: 'pointer',
},
hamburgerIcon: {
/* override del bug de Icon.jsx — fuerza stroke visible */
stroke: 'var(--color-navy-deep)',
strokeWidth: 1.8,
fill: 'none',
},
megamenu: {
position: 'absolute', top: '100%', left: 0, right: 0,
background: 'rgba(255,255,255,0.98)',
backdropFilter: 'blur(8px)',
WebkitBackdropFilter: 'blur(8px)',
borderTop: '1px solid rgba(33, 52, 64, 0.06)',
boxShadow: '0 18px 36px rgba(33, 52, 64, 0.08)',
padding: '40px 80px 48px',
animation: 'megaFadeIn 320ms cubic-bezier(0.16,1,0.3,1)',
},
megaInner: {
maxWidth: 1280, margin: '0 auto',
display: 'grid', gridTemplateColumns: 'minmax(220px, 0.8fr) 1.6fr', gap: 64,
},
megaCol: { display: 'flex', flexDirection: 'column', gap: 18 },
megaLink: {
fontSize: 22, fontWeight: 800,
color: 'var(--color-navy-deep)',
paddingBlock: 6,
letterSpacing: '-0.005em',
},
megaLinkInner: {
display: 'inline-flex',
alignItems: 'center',
gap: 12,
transition: 'color 240ms ease, gap 360ms cubic-bezier(0.16,1,0.3,1)',
},
megaArrow: {
color: 'var(--color-copper-fallback)',
display: 'inline-flex',
opacity: 0,
transform: 'translateX(-8px)',
transition: 'opacity 280ms ease, transform 360ms cubic-bezier(0.16,1,0.3,1)',
},
megaDesc: {
margin: 0,
fontSize: 15,
color: 'var(--color-navy-medium)',
lineHeight: 1.7,
paddingBlock: 6,
},
overlay: {
position: 'fixed',
top: 0, left: 0, right: 0, bottom: 0,
width: '100%',
height: '100vh',
/* dvh = dynamic viewport height en navegadores modernos, mejor para mobile */
minHeight: '100dvh',
background: 'var(--color-cream)',
zIndex: 1100,
display: 'flex', flexDirection: 'column',
animation: 'slideDown 320ms cubic-bezier(0.16, 1, 0.3, 1)',
overflowY: 'auto',
},
overlayTop: {
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
padding: '20px 24px',
borderBottom: '1px solid rgba(33, 52, 64, 0.08)',
},
closeBtn: { background: 'transparent', border: 0, padding: 8, color: 'var(--color-navy-deep)' },
overlayNav: {
flex: 1, overflowY: 'auto',
display: 'flex', flexDirection: 'column',
padding: '40px 24px 80px',
gap: 28,
},
overlayLink: {
display: 'block',
fontSize: 30, fontWeight: 800, color: 'var(--color-navy-deep)',
letterSpacing: '-0.01em',
},
overlayBtn: {
width: '100%',
display: 'flex', alignItems: 'center', justifyContent: 'space-between',
background: 'transparent', border: 0, padding: 0,
fontSize: 30, fontWeight: 800, color: 'var(--color-navy-deep)',
textAlign: 'left', letterSpacing: '-0.01em',
},
overlaySubs: {
paddingLeft: 4, paddingTop: 16,
display: 'flex', flexDirection: 'column', gap: 12,
},
overlaySub: {
fontSize: 17, fontWeight: 700, color: 'var(--color-navy-medium)',
display: 'flex', alignItems: 'center', gap: 12,
},
};
const headerMQ = document.createElement('style');
headerMQ.textContent = `
/* Bug fix: Icon.jsx renderiza stroke="" en vez de stroke="currentColor".
Forzamos visualización correcta del SVG dentro de TODOS los íconos del header. */
header button[aria-label="Abrir menú"] svg,
header button[aria-label="Abrir menú"] svg *,
div[role="dialog"] button svg,
div[role="dialog"] button svg *,
div[role="dialog"] a svg,
div[role="dialog"] a svg * {
stroke: var(--color-navy-deep) !important;
fill: none !important;
}
header button[aria-label="Abrir menú"]:hover svg,
header button[aria-label="Abrir menú"]:hover svg * {
stroke: var(--color-copper-fallback) !important;
}
header a[aria-label="Conversar por WhatsApp"]:hover {
background: #1ebe5d !important;
transform: translateY(-1px);
box-shadow: 0 6px 16px rgba(37, 211, 102, 0.35) !important;
}
@media (min-width: 1024px) {
header nav[aria-label="Menú principal"] { display: flex !important; }
header button[aria-label="Abrir menú"] { display: none !important; }
}
@media (min-width: 1280px) {
header nav[aria-label="Menú principal"] { gap: 40px !important; }
}
/* Megamenu link hover state */
header div[style*="background: rgba(255,255,255,0.98)"] a:hover > span:first-child {
color: var(--color-copper-fallback) !important;
gap: 18px !important;
}
header div[style*="background: rgba(255,255,255,0.98)"] a:hover > span:first-child > span:last-child {
opacity: 1 !important;
transform: translateX(0) !important;
}
@keyframes slideDown {
from { transform: translateY(-12px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
@keyframes megaFadeIn {
from { opacity: 0; transform: translateY(-6px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes megaIn {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
`;
document.head.appendChild(headerMQ);
window.Header = Header;