(function(){
'use strict';

// Mobile menu
// var burger = document.getElementById('stb-burger');
// var mob    = document.getElementById('stb-mob');
// var close  = document.getElementById('stb-mob-close');
// if(burger && mob){
//   function openMob(){mob.classList.add('open');mob.setAttribute('aria-hidden','false');burger.setAttribute('aria-expanded','true');document.body.style.overflow='hidden';}
//   function closeMob(){mob.classList.remove('open');mob.setAttribute('aria-hidden','true');burger.setAttribute('aria-expanded','false');document.body.style.overflow='';}
//   burger.addEventListener('click', openMob);
//   if(close) close.addEventListener('click', closeMob);
//   mob.addEventListener('click', function(e){ if(e.target===mob) closeMob(); });
//   document.addEventListener('keydown', function(e){ if(e.key==='Escape') closeMob(); });
// }

// Header scroll shadow
var hdr = document.getElementById('stb-header');
if(hdr){
  window.addEventListener('scroll', function(){
    hdr.style.boxShadow = window.scrollY > 8 ? '0 4px 32px rgba(0,0,0,.5)' : '';
  }, {passive:true});
}

// Hero tabs
var tabs    = document.querySelectorAll('.stb-hero-tab');
var content = [
  {lines:['BUILT FOR','PROFESSIONALS','TRUSTED BY','INSTITUTIONS.'],
   desc:'Access 180+ CFD instruments across Forex, Indices, Commodities, Crypto, and Equities — with institutional-grade execution, raw spreads from 0.0 pips, and PAMM investment services.',
   noteTitle:'Negative Balance Protection',
   noteText:'Your balance can never fall below zero. Even in extreme volatility, STB covers the difference. Active on all accounts.'},
  {lines:['MAXIMUM SPEED','AND CONTROL.','',''],
   desc:'Trade with ultra-fast execution, tight spreads, and advanced tools designed for high-frequency and professional traders.',
   noteTitle:'Low Latency Execution',
   noteText:'Optimized infrastructure ensures lightning-fast order execution with minimal slippage.'},
  {lines:['TAILORED FOR','INSTITUTIONS','LIQUIDITY &','SCALABILITY.'],
   desc:'Institutional-grade liquidity, deep market access, and advanced account management for high-net-worth clients.',
   noteTitle:'Institutional Liquidity',
   noteText:'Access deep liquidity pools and premium execution with dedicated account management.'}
];
var titleLines = document.querySelectorAll('.stb-hero-line');
var desc       = document.querySelector('.stb-hero-desc-text');
var noteTitle  = document.querySelector('.stb-hero-note-title');
var noteText   = document.querySelector('.stb-hero-note-text');
if(tabs.length && titleLines.length){
  tabs.forEach(function(tab, i){
    tab.addEventListener('click', function(){
      tabs.forEach(function(t){ t.classList.remove('active'); t.setAttribute('aria-selected','false'); });
      tab.classList.add('active');
      tab.setAttribute('aria-selected','true');
      var c = content[i];
      titleLines.forEach(function(l, j){ l.textContent = c.lines[j] || ''; });
      if(desc)      desc.textContent = c.desc;
      if(noteTitle) noteTitle.textContent = c.noteTitle;
      if(noteText)  noteText.textContent  = c.noteText;
    });
    tab.setAttribute('role','tab');
    tab.setAttribute('aria-selected', i===0 ? 'true':'false');
  });
}

// Academy tabs (client-side switching — just highlight, cards stay static for now)
var acTabs = document.querySelectorAll('.stb-academy-tab');
acTabs.forEach(function(tab){
  tab.addEventListener('click', function(){
    acTabs.forEach(function(t){ t.classList.remove('active'); });
    tab.classList.add('active');
  });
});

})();

// Inner page interactions
document.addEventListener('DOMContentLoaded', function(){
  // FAQ accordion
  document.querySelectorAll('.ip-faq-q').forEach(function(btn){
    btn.addEventListener('click', function(){
      var item = btn.closest('.ip-faq-item');
      var wasOpen = item.classList.contains('open');
      document.querySelectorAll('.ip-faq-item.open').forEach(function(i){ i.classList.remove('open'); });
      if(!wasOpen) item.classList.add('open');
    });
  });

  // Scroll reveal
  var observer = new IntersectionObserver(function(entries){
    entries.forEach(function(e){
      if(e.isIntersecting){
        e.target.style.animationPlayState = 'running';
        observer.unobserve(e.target);
      }
    });
  }, {rootMargin:'0px 0px -50px 0px'});
  document.querySelectorAll('.ip-animate').forEach(function(el){
    el.style.animationPlayState = 'paused';
    observer.observe(el);
  });
});




// fix menu by dev
