// Design tokens + tweakable defaults for Babiline site
const TWEAKS = /*EDITMODE-BEGIN*/{
  "accent": "#D32027",
  "ink": "#0A0E13",
  "navy": "#0F2C4A",
  "paper": "#FFFFFF",
  "density": "comfortable",
  "slogan": -1
}/*EDITMODE-END*/;

const initialTweaks = (() => {
  try {
    const saved = JSON.parse(localStorage.getItem('babiline_tweaks') || '{}');
    return { ...TWEAKS, ...saved };
  } catch { return TWEAKS; }
})();

// Slogans available on home hero — indexable from tweaks
window.SLOGANS = [
  { line1: "Freight Without",      line2: "the Wait.",                     sub: "Expedited shipping across North America. Dedicated units, 24/7 dispatch, and live GPS from pickup to dock." },
  { line1: "Direct.",              line2: "Dedicated. Done.",              sub: "Every Babiline load rides on a dedicated truck with a driver you can reach — no re-brokering, no surprises." },
  { line1: "Real-Time Solutions",  line2: "for Real-Time Needs.",          sub: "Cargo vans, box trucks, and straight trucks dispatched in minutes and tracked every mile. 24/7 operations you can actually reach." },
  { line1: "Logistics at the",     line2: "Speed of Now.",                 sub: "Time-critical freight handled by dedicated Babiline units. Pickup within hours, delivered on deadline, tracked the whole way." },
  { line1: "Moving America's",     line2: "most urgent freight.",          sub: "Expedited shipping across all 48 states. Dedicated teams, cargo vans, box trucks and straight trucks — dispatched and tracked around the clock." },
];

// Pick a random slogan on each fresh page load, then persist for the session
if (typeof window !== 'undefined') {
  try {
    let idx = sessionStorage.getItem('babiline_slogan_idx');
    if (idx === null) {
      idx = String(Math.floor(Math.random() * window.SLOGANS.length));
      sessionStorage.setItem('babiline_slogan_idx', idx);
    }
    window.CURRENT_SLOGAN_IDX = parseInt(idx, 10);
  } catch { window.CURRENT_SLOGAN_IDX = 0; }
}

// Apply CSS vars
function applyTweaks(t) {
  const r = document.documentElement;
  r.style.setProperty('--accent', t.accent);
  r.style.setProperty('--ink', t.ink);
  r.style.setProperty('--navy', t.navy);
  r.style.setProperty('--paper', t.paper);
  r.style.setProperty('--space-unit', t.density === 'compact' ? '0.85' : t.density === 'spacious' ? '1.15' : '1');
}
applyTweaks(initialTweaks);

window.TWEAKS = TWEAKS;
window.initialTweaks = initialTweaks;
window.applyTweaks = applyTweaks;
