// Milfers · Header · editorial sticky + menú móvil + selector de idioma (i18n)
const MF_LANGS = [
{ code: 'es', label: 'ES', full: 'Español' },
{ code: 'va', label: 'VAL', full: 'Valencià' },
{ code: 'en', label: 'EN', full: 'English' }
];
function mfNav() {
return [
{ href: '#inicio', label: window.t('nav.inicio'), active: true },
{ href: '#marca', label: window.t('nav.marca') },
{ href: '#maduracion', label: window.t('nav.maduracion') },
{ href: '#resenas', label: window.t('nav.resenas') },
{ href: '#reserva', label: window.t('nav.reserva') }
];
}
// Jersey M54 (display) no tiene glifos acentuados — limpia tildes/ñ solo donde se usa esa fuente (menu móvil)
function noTilde(s) { return (s || '').normalize('NFD').replace(/[\u0300-\u036f]/g, ''); }
function LangSwitch({ variant }) {
const current = window.MF_LANG;
return (
{MF_LANGS.map((l, i) => (
{i > 0 && ·}
))}
);
}
function Header() {
const [scrolled, setScrolled] = React.useState(false);
const [menuOpen, setMenuOpen] = React.useState(false);
const NAV = mfNav();
React.useEffect(() => {
const onScroll = () => setScrolled(window.scrollY > 40);
window.addEventListener('scroll', onScroll, { passive: true });
return () => window.removeEventListener('scroll', onScroll);
}, []);
React.useEffect(() => {
document.body.classList.toggle('mf-no-scroll', menuOpen);
const onKey = (e) => { if (e.key === 'Escape') setMenuOpen(false); };
document.addEventListener('keydown', onKey);
return () => {
document.removeEventListener('keydown', onKey);
};
}, [menuOpen]);
return (
<>
{/* ▸ MENÚ MÓVIL — fuera del header para evitar que backdrop-filter rompa position:fixed */}
>
);
}
window.Header = Header;