// Top10AI — shared header / footer / bottom-nav / sticky compare
// Mobile-first: below 860px the top header collapses into a hamburger button
// that opens a full-screen drawer, and a persistent 5-item bottom nav pins
// the most-tapped destinations to the thumb zone.
(function () {
const path = location.pathname;
const locale = window.__T10_LOCALE || (document.body && document.body.getAttribute('data-locale')) || 'en';
const prefix = locale === 'en' ? '' : '/' + locale;
// The language switcher is only shown on pages that actually have locale
// twins — i.e. blog posts (on top10ai.com, review/category/compare pages
// exist only in English, so a switcher on them would just dump the user
// on the translated homepage, which is confusing).
// The blog-single template sets
and
// optionally to drive the per-locale URL.
const hasTranslations = !!(document.body && document.body.getAttribute('data-has-translations') === 'true');
const translationSlug = (document.body && document.body.getAttribute('data-translation-slug')) || '';
// Given a target locale, return the URL of the CURRENT page in that locale.
// Strips any existing locale prefix, then prepends the new one (or none for EN).
function localizedUrl(targetLocale) {
let path = location.pathname.replace(/^\/([a-z]{2})(\/|$)/, '/');
if (!path.startsWith('/')) path = '/' + path;
if (targetLocale === 'en') return path;
// Keep trailing slash behavior consistent
return '/' + targetLocale + path;
}
// Chrome-string i18n table (mirrors preview/templates/_i18n.js).
const STR = {
'nav.video':{en:'Video',ar:'فيديو',de:'Video',el:'Βίντεο',es:'Vídeo',fr:'Vidéo',it:'Video',nl:'Video',pt:'Vídeo',ru:'Видео'},
'nav.image':{en:'Image',ar:'صورة',de:'Bild',el:'Εικόνα',es:'Imagen',fr:'Image',it:'Immagine',nl:'Afbeelding',pt:'Imagem',ru:'Изображение'},
'nav.logo':{en:'Logo',ar:'شعار',de:'Logo',el:'Λογότυπο',es:'Logo',fr:'Logo',it:'Logo',nl:'Logo',pt:'Logo',ru:'Логотип'},
'nav.website':{en:'Website',ar:'موقع',de:'Website',el:'Ιστότοπος',es:'Sitio web',fr:'Site web',it:'Sito web',nl:'Website',pt:'Site',ru:'Сайт'},
'nav.free':{en:'Free Tools',ar:'أدوات مجانية',de:'Gratis-Tools',el:'Δωρεάν εργαλεία',es:'Herramientas gratis',fr:'Outils gratuits',it:'Strumenti gratuiti',nl:'Gratis tools',pt:'Ferramentas grátis',ru:'Бесплатные инструменты'},
'nav.compare':{en:'Compare',ar:'قارن',de:'Vergleichen',el:'Σύγκριση',es:'Comparar',fr:'Comparer',it:'Confronta',nl:'Vergelijken',pt:'Comparar',ru:'Сравнить'},
'nav.blog':{en:'Blog',ar:'مدونة',de:'Blog',el:'Ιστολόγιο',es:'Blog',fr:'Blog',it:'Blog',nl:'Blog',pt:'Blog',ru:'Блог'},
'cta.findTool':{en:'Find my tool →',ar:'ابحث عن أداتي →',de:'Tool finden →',el:'Βρες εργαλείο →',es:'Encontrar mi herramienta →',fr:'Trouver mon outil →',it:'Trova il mio strumento →',nl:'Vind mijn tool →',pt:'Encontrar ferramenta →',ru:'Найти инструмент →'},
'bnav.home':{en:'Home',ar:'الرئيسية',de:'Start',el:'Αρχική',es:'Inicio',fr:'Accueil',it:'Home',nl:'Home',pt:'Início',ru:'Главная'},
'bnav.finder':{en:'Finder',ar:'البحث',de:'Finden',el:'Εύρεση',es:'Buscar',fr:'Chercher',it:'Trova',nl:'Zoeken',pt:'Buscar',ru:'Поиск'},
'bnav.tools':{en:'Tools',ar:'أدوات',de:'Tools',el:'Εργαλεία',es:'Herramientas',fr:'Outils',it:'Strumenti',nl:'Tools',pt:'Ferramentas',ru:'Инструменты'},
'bnav.compare':{en:'Compare',ar:'قارن',de:'Vergleich',el:'Σύγκριση',es:'Comparar',fr:'Comparer',it:'Confronta',nl:'Vergelijk',pt:'Comparar',ru:'Сравнить'},
'bnav.blog':{en:'Blog',ar:'مدوне',de:'Blog',el:'Ιστολόγιο',es:'Blog',fr:'Blog',it:'Blog',nl:'Blog',pt:'Blog',ru:'Блог'},
'label.shortlist':{en:'SHORTLIST',ar:'قائمتي',de:'MERKLISTE',el:'ΕΠΙΛΟΓΕΣ',es:'FAVORITOS',fr:'SÉLECTION',it:'PREFERITI',nl:'SHORTLIST',pt:'FAVORITOS',ru:'ИЗБРАННОЕ'},
};
const t = k => (STR[k] && (STR[k][locale] || STR[k].en)) || k;
// ─────────────────────────── HEADER ───────────────────────────
const hdr = document.getElementById('site-header');
if (hdr) {
hdr.className = 'site-header';
hdr.innerHTML = `
★Top10AI