// Injecte la barre de selection de variante en haut de page.
// Ajouter une variante = ajouter une ligne dans VARIANTS, c'est tout.
(function () {
  const VARIANTS = [
    { file: 'index.html',     label: 'A. Editorial' },
    { file: 'cinematic.html', label: 'B. Cinematic' },
    { file: 'magazine.html',  label: 'C. Magazine' },
    { file: 'mocha.html',     label: 'D. Mocha' },
    { file: 'tokyo.html',     label: 'E. Tokyo Night' },
    { file: 'brutalist.html', label: 'F. Brutalist' },
  ];

  const current = (location.pathname.split('/').pop() || 'index.html').toLowerCase();
  const aside = document.createElement('aside');
  aside.className = 'variant-switcher';
  aside.setAttribute('role', 'navigation');
  aside.setAttribute('aria-label', 'Selecteur de variante de design');

  const label = document.createElement('span');
  label.className = 'variant-switcher__label';
  label.textContent = 'Variante :';
  aside.appendChild(label);

  for (const v of VARIANTS) {
    const a = document.createElement('a');
    a.className = 'variant-switcher__link';
    a.href = v.file;
    a.textContent = v.label;
    if (v.file.toLowerCase() === current || (current === '' && v.file === 'index.html')) {
      a.classList.add('is-active');
    }
    aside.appendChild(a);
  }

  if (document.body) {
    document.body.insertBefore(aside, document.body.firstChild);
  } else {
    document.addEventListener('DOMContentLoaded', () =>
      document.body.insertBefore(aside, document.body.firstChild)
    );
  }
})();
