(function(){
  function initReviews(){
    document.querySelectorAll('.notorious-reviews .reviews-grid').forEach(function(track){
      if(track.dataset.safeSlider==='1') return;
      track.dataset.safeSlider='1';
      var cards=[].slice.call(track.children);
      if(cards.length<2) return;
      cards.forEach(function(card){ track.appendChild(card.cloneNode(true)); });
      var i=0;
      function step(){
        var first=track.querySelector('.review-card');
        if(!first) return;
        var gap=16;
        var w=first.getBoundingClientRect().width + gap;
        i++;
        track.scrollTo({left:i*w, behavior:'smooth'});
        if(i>=cards.length){
          setTimeout(function(){ i=0; track.scrollTo({left:0, behavior:'auto'}); }, 650);
        }
      }
      setInterval(step, 3600);
    });
  }
  if(document.readyState==='loading') document.addEventListener('DOMContentLoaded', initReviews); else initReviews();
})();
