// Wander — data layer: loads from API, falls back to static seed

const STATIC_TOURS = [
  { id:'merlion-marina', title:'Marina Bay & the Merlion', subtitle:"Singapore's shimmering icon walk", duration:'45 min', distance:'1.8 km', stops:7, rating:4.8, reviews:1284, tier:'free', price:0, formats:['audio','text','ar'], hero:['#FFC93C','#FF8A4C'], emoji:'🦁', blurb:'Half-lion, half-fish, fully Instagrammed. Trace the bay from the spitting Merlion to the lotus dome.' },
  { id:'kampong-glam', title:'Kampong Glam Stories', subtitle:'Sultans, spices and street art', duration:'70 min', distance:'2.4 km', stops:9, rating:4.9, reviews:642, tier:'pro', price:6, formats:['audio','text','video','quiz'], hero:['#9B7EDC','#FF6B5A'], emoji:'🕌', blurb:"From the golden dome of Sultan Mosque to Haji Lane's neon murals — a quarter that refuses to sit still." },
  { id:'chinatown-bites', title:'Chinatown After Dark', subtitle:'Lanterns, hawker bites, hidden temples', duration:'90 min', distance:'2.1 km', stops:11, rating:4.7, reviews:933, tier:'pro', price:8, formats:['audio','video','quiz'], hero:['#FF6B5A','#FFC93C'], emoji:'🏮', blurb:"Eat your way past 200-year-old shophouses, ducking into the temple where time stops at 5pm." },
  { id:'gardens-bay', title:'Gardens by the Bay', subtitle:'Sci-fi forest in the tropics', duration:'60 min', distance:'1.5 km', stops:6, rating:4.9, reviews:2104, tier:'free', price:0, formats:['audio','ar','text'], hero:['#2DD4A7','#4FB7E8'], emoji:'🌳', blurb:"The Supertrees throw a light show every night at 7:45. Here's where to stand and what they actually are." },
  { id:'tiong-bahru', title:'Tiong Bahru Slow Loop', subtitle:'Art deco, indie cafes, old soul', duration:'55 min', distance:'1.6 km', stops:8, rating:4.6, reviews:387, tier:'free', price:0, formats:['text','audio'], hero:['#E89B6C','#FFC93C'], emoji:'☕', blurb:"Singapore's first public housing — now its hippest. Read the murals; smell the kaya." },
  { id:'little-india', title:'Little India Colour Riot', subtitle:'Garlands, gold, and green chutney', duration:'65 min', distance:'1.9 km', stops:9, rating:4.8, reviews:521, tier:'pro', price:6, formats:['audio','video','ar'], hero:['#FF6B5A','#9B7EDC'], emoji:'🪔', blurb:"A six-block sensory ambush. We'll teach you to read a flower garland like a love letter." },
];

const STOPS = [
  { id:1, name:'Merlion Park', dist:'0 m', kind:'icon', blurb:'The 8.6m statue that became a city.', done:true, duration:'6 min' },
  { id:2, name:'Esplanade — Theatres on the Bay', dist:'320 m', kind:'arts', blurb:"Locals call them \"the durians.\" You'll see why.", done:true, duration:'5 min' },
  { id:3, name:'Helix Bridge', dist:'550 m', kind:'arch', blurb:'A double helix in steel. Cross slowly.', done:false, current:true, duration:'7 min' },
  { id:4, name:'Marina Bay Sands SkyPark', dist:'780 m', kind:'view', blurb:'Three towers, one ship balanced on top.', done:false, duration:'8 min' },
  { id:5, name:'ArtScience Museum', dist:'1.1 km', kind:'arts', blurb:'A ten-petalled lotus that catches rainwater.', done:false, duration:'6 min' },
  { id:6, name:'Gardens by the Bay (East)', dist:'1.5 km', kind:'park', blurb:'Sneak preview of the Supertrees.', done:false, duration:'7 min' },
  { id:7, name:'Marina Barrage', dist:'1.8 km', kind:'view', blurb:"A dam, a park, a kite-flyer's paradise.", done:false, duration:'6 min' },
];

const NEARBY = [
  { id:'a', name:'Merlion Park',  kind:'free',    x:42, y:55, emoji:'🦁' },
  { id:'b', name:'Esplanade',     kind:'free',    x:46, y:50, emoji:'🎭' },
  { id:'c', name:'Helix Bridge',  kind:'current', x:52, y:46, emoji:'🌉' },
  { id:'d', name:'MBS SkyPark',   kind:'pro',     x:58, y:42, emoji:'🏙️' },
  { id:'e', name:'ArtScience',    kind:'pro',     x:62, y:48, emoji:'🪷' },
  { id:'f', name:'Gardens',       kind:'free',    x:68, y:55, emoji:'🌳' },
  { id:'g', name:'Lau Pa Sat',    kind:'free',    x:32, y:62, emoji:'🍜' },
  { id:'h', name:'Raffles Place', kind:'pro',     x:28, y:48, emoji:'🏛️' },
];

// Load tours from API; fall back to static data
async function loadTours() {
  try {
    const res = await fetch('/api/tours');
    if (!res.ok) throw new Error('API error');
    return await res.json();
  } catch {
    return STATIC_TOURS;
  }
}

window.WANDER_DATA = { TOURS: STATIC_TOURS, STOPS, NEARBY };
window.loadTours = loadTours;
