// main.js — Generado automáticamente por SuperCerebro
(function() {
  'use strict';
  const CFG = window.THEME_CONFIG || {};
  const LOTTIE_BASE = (CFG.themeUrl || '') + '/assets/lottie/';

  // ─── Lazy-load Lottie con IntersectionObserver ───
  function lazyLottie(containerId, jsonFile, opts) {
    const el = document.getElementById(containerId);
    if (!el) return;
    const load = () => {
      if (typeof lottie === 'undefined') { setTimeout(load, 100); return; }
      fetch(LOTTIE_BASE + jsonFile)
        .then(r => r.json())
        .then(data => lottie.loadAnimation({
          container: el, renderer: 'svg', loop: true, autoplay: true,
          animationData: data, ...(opts || {})
        }))
        .catch(e => console.error('Lottie load failed:', containerId, e));
    };
    new IntersectionObserver(es => {
      if (es[0].isIntersecting) { load(); es[0].target._loaded = true; }
    }, { rootMargin: '200px' }).observe(el);
  }

})();
