<footer id="ftr">
  <div class="ftr-main">
    <div>
      <a href="<?= SITE_URL ?>/" class="hdr-logo" style="display:inline-flex;">
        <div class="logo-hex"><span class="logo-hex-v">V</span></div>
        <div class="logo-wordmark">
          <span class="logo-wm-top">VOLKER</span>
          <span class="logo-wm-btm">Savunma Teknolojileri</span>
        </div>
      </a>
      <p class="ftr-brand-desc"><?=clean(setting('footer_text','Profesyonel savunma ve endüstriyel ekipman tedarikinde güvenilir çözüm ortağınız.'))?></p>
    </div>
    <div>
      <div class="ftr-ttl">Sayfalar</div>
      <div class="ftr-links">
        <a href="<?= SITE_URL ?>/" class="ftr-link">Ana Sayfa</a>
        <a href="<?= SITE_URL ?>/urunler.php" class="ftr-link">Ürünler</a>
        <a href="<?= SITE_URL ?>/hakkimizda.php" class="ftr-link">Hakkımızda</a>
        <a href="<?= SITE_URL ?>/iletisim.php" class="ftr-link">İletişim</a>
      </div>
    </div>
    <div>
      <div class="ftr-ttl">Kategoriler</div>
      <div class="ftr-links">
        <?php try{ $fc=db()->query("SELECT name,slug FROM vs_categories ORDER BY sort_order LIMIT 6")->fetchAll(PDO::FETCH_ASSOC); foreach($fc as $c): ?><a href="<?= SITE_URL ?>/urunler.php?kategori=<?=clean($c['slug'])?>" class="ftr-link"><?=clean($c['name'])?></a><?php endforeach; }catch(Exception $e){} ?>
      </div>
    </div>
    <div>
      <div class="ftr-ttl">İletişim</div>
      <div class="ftr-links">
        <a href="mailto:<?=clean(setting('contact_email','info@volkersavunma.com'))?>" class="ftr-link"><?=clean(setting('contact_email','info@volkersavunma.com'))?></a>
        <a href="tel:<?=clean(setting('contact_phone','+903120000000'))?>" class="ftr-link"><?=clean(setting('contact_phone','+90 312 000 00 00'))?></a>
        <span class="ftr-link" style="cursor:default;"><?=clean(setting('contact_address','Ankara, Türkiye'))?></span>
      </div>
    </div>
  </div>
  <div class="ftr-bot">
    <span class="ftr-copy">&copy; <?=date('Y')?> <span>VOLKER SAVUNMA</span> — Tüm hakları saklıdır.</span>
    <span class="ftr-tag">Güç · Güvenlik · Güven</span>
  </div>
</footer>
<script>
/* VOLKER SAVUNMA — Premium JS v3.1 */
(function(){
'use strict';

// Add js-ready after a tick so content renders first, THEN animate
requestAnimationFrame(function(){
  requestAnimationFrame(function(){
    document.body.classList.add('js-ready');
    initReveal();
  });
});

function initReveal() {
  const srAll = document.querySelectorAll('[data-sr],[data-sr-l],[data-sr-r]');
  if (!srAll.length) return;

  function revealEl(el) { el.classList.add('vis'); }
  function revealAll() { srAll.forEach(revealEl); }

  if ('IntersectionObserver' in window) {
    const io = new IntersectionObserver(entries => {
      entries.forEach(e => { if (e.isIntersecting) { revealEl(e.target); io.unobserve(e.target); } });
    }, { threshold: 0.01, rootMargin: '60px 0px 60px 0px' });

    srAll.forEach(el => {
      const rect = el.getBoundingClientRect();
      if (rect.top < window.innerHeight + 200) {
        revealEl(el); // already in/near viewport
      } else {
        io.observe(el);
      }
    });
  } else {
    revealAll();
  }
  // Hard fallback
  setTimeout(revealAll, 800);
}

// Custom cursor (desktop only)
if (window.matchMedia('(pointer:fine)').matches) {
  const dot = document.createElement('div'); dot.className = 'cursor-dot';
  const ring = document.createElement('div'); ring.className = 'cursor-ring';
  document.body.append(dot, ring);
  let mx=window.innerWidth/2, my=window.innerHeight/2, rx=mx, ry=my;
  dot.style.cssText = `left:${mx}px;top:${my}px`;
  ring.style.cssText = `left:mx;top:${my}px`;
  document.addEventListener('mousemove', e => { mx=e.clientX; my=e.clientY; dot.style.left=mx+'px'; dot.style.top=my+'px'; });
  (function animRing(){ ring.style.left=Math.round(rx)+'px'; ring.style.top=Math.round(ry)+'px'; rx+=(mx-rx)*.14; ry+=(my-ry)*.14; requestAnimationFrame(animRing); })();
  document.querySelectorAll('a,button,.pcard,.cat-panel').forEach(el => {
    el.addEventListener('mouseenter',()=>{ ring.style.width='56px'; ring.style.height='56px'; dot.style.opacity='0'; });
    el.addEventListener('mouseleave',()=>{ ring.style.width='36px'; ring.style.height='36px'; dot.style.opacity='1'; });
  });
}

// Header
const hdr = document.getElementById('hdr');
if (hdr) {
  const onScroll = () => hdr.classList.toggle('opaque', window.scrollY > 50);
  window.addEventListener('scroll', onScroll, {passive:true});
  onScroll();
}

// Mobile menu
const burger = document.getElementById('hdrbgr');
const mob = document.getElementById('mobmenu');
if (burger && mob) {
  burger.addEventListener('click', () => {
    const o = burger.classList.toggle('open');
    mob.classList.toggle('open', o);
    document.body.style.overflow = o ? 'hidden' : '';
  });
  mob.querySelectorAll('a').forEach(a => a.addEventListener('click', () => {
    burger.classList.remove('open'); mob.classList.remove('open'); document.body.style.overflow='';
  }));
}

// Counter animation
document.querySelectorAll('[data-count]').forEach(el => {
  if (!('IntersectionObserver' in window)) return;
  const co = new IntersectionObserver(entries => {
    entries.forEach(e => {
      if (!e.isIntersecting) return;
      const t = +e.target.dataset.count, d = 1600, s = performance.now();
      const go = now => { const p=Math.min((now-s)/d,1),ease=1-Math.pow(1-p,4); e.target.textContent=Math.round(ease*t); if(p<1)requestAnimationFrame(go);else e.target.textContent=t; };
      requestAnimationFrame(go); co.unobserve(e.target);
    });
  }, {threshold:.3});
  co.observe(el);
});

// Product filter
document.querySelectorAll('.ftab').forEach(btn => {
  btn.addEventListener('click', () => {
    document.querySelectorAll('.ftab').forEach(b => { b.classList.remove('btn-primary'); b.classList.add('btn-outline'); });
    btn.classList.add('btn-primary'); btn.classList.remove('btn-outline');
    const cat = btn.dataset.cat;
    document.querySelectorAll('.pcard[data-cat]').forEach(c => {
      c.style.display = (cat==='all' || c.dataset.cat===cat) ? '' : 'none';
    });
  });
});

// Contact form
const form = document.getElementById('cform');
if (form) {
  form.addEventListener('submit', async e => {
    e.preventDefault();
    const btn = form.querySelector('.submit-btn'), al = document.getElementById('falert'), orig = btn.innerHTML;
    btn.disabled = true; btn.innerHTML = 'Gönderiliyor...';
    try {
      const res = await fetch('/volker/iletisim.php', { method:'POST', body:new FormData(form), headers:{'X-Requested-With':'XMLHttpRequest'} });
      const data = await res.json();
      if (al) { al.className='alert '+(data.success?'alert-ok':'alert-err'); al.textContent=data.message; al.style.display='block'; if(data.success){form.reset();setTimeout(()=>al.style.display='none',6000);} }
    } catch(err) { if(al){al.className='alert alert-err';al.textContent='Bağlantı hatası.';al.style.display='block';} }
    btn.disabled=false; btn.innerHTML=orig;
  });
}

// Gallery
window.setThumb = (src, el) => { const m=document.getElementById('pdmain'); if(m)m.src=src; document.querySelectorAll('.pd-thumb').forEach(t=>t.classList.remove('on')); if(el)el.classList.add('on'); };

})();

</script>
</body></html>
