
/* FINAL TRUE menu toggle + loader timing */
(function(){
  function ready(fn){ if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',fn); else fn(); }
  ready(function(){
    var btn=document.getElementById('menuToggle');
    var menu=document.getElementById('mobileMenu');
    var close=document.getElementById('closeMenu');
    function isOpen(){return menu && (menu.classList.contains('show')||menu.classList.contains('open')||menu.classList.contains('is-open'));}
    function openMenu(){if(menu){menu.classList.add('show');document.body.classList.add('menu-open');} if(btn){btn.setAttribute('aria-expanded','true');btn.textContent='×';}}
    function closeMenu(){if(menu){menu.classList.remove('show','open','is-open');document.body.classList.remove('menu-open');} if(btn){btn.setAttribute('aria-expanded','false');btn.textContent='☰';}}
    if(btn && menu){
      var clone=btn.cloneNode(true); btn.parentNode.replaceChild(clone,btn); btn=clone;
      btn.addEventListener('click',function(e){e.preventDefault();e.stopPropagation(); isOpen()?closeMenu():openMenu();},true);
    }
    if(close) close.addEventListener('click',function(e){e.preventDefault();closeMenu();},true);
    if(menu){menu.addEventListener('click',function(e){if(e.target===menu) closeMenu();}); menu.querySelectorAll('a').forEach(function(a){a.addEventListener('click',closeMenu);});}
    document.addEventListener('keydown',function(e){if(e.key==='Escape') closeMenu();});

    // Guarantee info card exists immediately after the slider.
    var slider=document.querySelector('.fixed-top-slider, .store-feature-slider');
    if(slider && !document.querySelector('.store-info-section')){
      var isEn=(document.documentElement.lang||'').toLowerCase().indexOf('en')===0;
      var sec=document.createElement('section'); sec.className='store-info-section';
      sec.innerHTML='<div class="store-info-card reveal"><div class="store-info-row"><span>OPEN</span><strong>'+(isEn?'24/7':'24ωρο')+'</strong></div><div class="store-info-row"><span>ADDRESS</span><strong>'+(isEn?'Gounari 193':'Γούναρη 193')+'</strong></div><div class="store-info-row"><span>AREA</span><strong>'+(isEn?'Ano Glyfada':'Ανω Γλυφάδα')+'</strong></div></div>';
      slider.insertAdjacentElement('afterend',sec);
    }
  });
})();
