
/* NOTORIOUS FINAL STABLE JS */
(function(){
  function ready(fn){ if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',fn); else fn(); }
  function normalizePath(){ try{ if(window.scrollX) window.scrollTo(0, window.scrollY); }catch(e){} }
  ready(function(){
    normalizePath();
    window.addEventListener('resize', normalizePath, {passive:true});

    // Guarantee the information card is directly below the slider on both languages.
    var slider=document.querySelector('.store-feature-slider, .fixed-top-slider, .promo-showcase-section');
    var isEn=(document.documentElement.lang||'').toLowerCase().indexOf('en')===0 || location.pathname.indexOf('/eng/')>-1;
    var html='<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>';
    var sec=document.querySelector('.store-info-section');
    if(!sec){ sec=document.createElement('section'); sec.className='store-info-section'; sec.innerHTML=html; if(slider) slider.insertAdjacentElement('afterend',sec); }
    else { sec.innerHTML=html; if(slider && sec.previousElementSibling!==slider){ slider.insertAdjacentElement('afterend',sec); } sec.style.display='block'; sec.style.visibility='visible'; sec.style.opacity='1'; }

    // Reliable hamburger toggle + close on second tap / X / outside / Escape.
    var btn=document.getElementById('menuToggle');
    var menu=document.getElementById('mobileMenu') || document.querySelector('.mobile-menu');
    var close=document.getElementById('closeMenu') || (menu && menu.querySelector('.close-menu'));
    function opened(){return menu && (menu.classList.contains('show')||menu.classList.contains('open')||menu.classList.contains('is-open'));}
    function openMenu(){ if(!menu) return; menu.classList.add('show','open','is-open'); document.body.classList.add('menu-open'); if(btn){btn.textContent='×'; btn.setAttribute('aria-expanded','true');} }
    function closeMenu(){ if(!menu) return; menu.classList.remove('show','open','is-open'); document.body.classList.remove('menu-open'); if(btn){btn.textContent='☰'; btn.setAttribute('aria-expanded','false');} }
    if(btn){
      btn.onclick=null;
      btn.addEventListener('click',function(e){ e.preventDefault(); e.stopPropagation(); opened()?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(); });
  });
})();
