/**
 * Modulares Impressum für Onepager-Sites.
 *
 * Einbinden: <script src="/shared/impressum.js"></script>
 *
 * Konfiguration via data-Attribute am Script-Tag:
 *   data-owner="msbls"          (default) — Kurzform, msbls.de Satire-Impressum
 *   data-owner="martinsiebels"  — Volles Impressum Martin Siebels
 *   data-style="minimal"        (default) — Einzeiler
 *   data-style="full"           — Komplettes Impressum mit Adresse etc.
 */
(function () {
  const script = document.currentScript;
  const owner = script?.getAttribute('data-owner') || 'msbls';
  const style = script?.getAttribute('data-style') || 'minimal';

  const owners = {
    msbls: {
      minimal: 'Ein Projekt von <a href="https://msbls.de" target="_blank" rel="noopener">msbls.de</a>',
      full: '<strong>Angaben gemäß § 5 TMG:</strong><br>msbls.de — Martin Siebels<br><a href="https://msbls.de/impressum" target="_blank" rel="noopener">Vollständiges Impressum</a>',
    },
  };

  const config = owners[owner] || owners.msbls;
  const html = config[style] || config.minimal;

  // Impressum-Element erstellen
  const el = document.createElement('div');
  el.className = 'onepager-impressum';
  el.innerHTML = html;

  // Styling — erbt Farben vom footer/body, bleibt dezent
  el.style.cssText = 'text-align:center;font-size:0.7rem;opacity:0.5;padding:8px 0;margin-top:4px;';
  el.querySelector('a')?.style && Object.assign(el.querySelector('a').style, {
    color: 'inherit', textDecoration: 'none'
  });

  // Einfügen: in <footer> falls vorhanden, sonst ans body-Ende
  const footer = document.querySelector('footer .container, footer');
  if (footer) {
    footer.appendChild(el);
  } else {
    document.body.appendChild(el);
  }
})();
