/* Day Trip Planner — sample data (themed around Roseville, CA) */

const INTERESTS = [
  'Dining', 'Hiking', 'Shopping', 'Museums',
  'Breweries', 'Kid-friendly', 'Scenic Drives', 'Quirky/Oddities',
];

// default 4-stop itinerary
const DEFAULT_STOPS = [
  {
    id: 'hidden-falls', name: 'Hidden Falls Regional Park', area: 'Auburn',
    cat: 'Hiking', tone: 'sage', photo: 'waterfall,forest', lock: 11,
    why: 'An easy 1.2-mile loop to a real waterfall. Worth the short detour.',
    long: 'A gentle, well-marked loop through oak canyon to a two-tier falls overlook. Mostly shade, a few benches, and a footbridge the kids will want to cross twice. Go now while the creek is still running.',
    hours: '8:00 AM – Sunset', addr: '7587 Mears Pl, Auburn, CA', drive: 28, stay: '1h 30m',
  },
  {
    id: 'old-town', name: 'Old Town Auburn', area: 'Auburn',
    cat: 'Dining', tone: 'coral', photo: 'historic,street', lock: 22,
    why: 'Gold-rush storefronts and the best patio tacos in the foothills.',
    long: 'Brick storefronts from the 1850s, antique windows to peek in, and a handful of patios. Grab tacos and a horchata, then wander the hill before the next stop. Easy parking on Lincoln Way.',
    hours: '11:00 AM – 9:00 PM', addr: '1493 Lincoln Way, Auburn, CA', drive: 14, stay: '1h 15m',
  },
  {
    id: 'knee-deep', name: 'Knee Deep Brewing Co.', area: 'Auburn',
    cat: 'Breweries', tone: 'amber', photo: 'brewery,beer', lock: 33,
    why: 'A slow flight on the patio before you point the car home.',
    long: 'A relaxed taproom with a big shaded patio and rotating foothill beers. Flights are easy to split, there is usually a food truck, and it is a short hop from Old Town. A mellow way to land the afternoon.',
    hours: '12:00 PM – 8:00 PM', addr: '13395 New Airport Rd, Auburn, CA', drive: 6, stay: '1h 00m',
  },
  {
    id: 'beals-point', name: 'Beals Point, Folsom Lake', area: 'Granite Bay',
    cat: 'Scenic Drives', tone: 'sky', photo: 'lake,sunset', lock: 44,
    why: 'End on the water. Bring a blanket for golden hour.',
    long: 'A wide beach and bluff on the north shore with long views down the lake. Time it for sunset, find a spot on the grass, and let the day wind down. There is a small day-use fee at the gate.',
    hours: '6:00 AM – 9:00 PM', addr: '7806 Auburn-Folsom Rd, Granite Bay, CA', drive: 22, stay: '1h 00m',
  },
];

// alternates used when a stop is rerolled
const ALT_STOPS = [
  {
    id: 'maidu', name: 'Maidu Museum & Historic Site', area: 'Roseville',
    cat: 'Museums', tone: 'sage', photo: 'nature,trail', lock: 55,
    why: 'Quiet trails wrapped around a 30-acre archaeological preserve.',
    long: 'A small, thoughtful museum with an interpretive loop past grinding rocks and petroglyphs. Cool, shaded, and right in town — a calm counterpoint to a busy day.',
    hours: '9:00 AM – 4:00 PM', addr: '1970 Johnson Ranch Dr, Roseville, CA', drive: 12, stay: '1h 00m',
  },
  {
    id: 'fountains', name: 'The Fountains', area: 'Roseville',
    cat: 'Shopping', tone: 'coral', photo: 'fountain,plaza', lock: 66,
    why: 'Open-air shops around a splash plaza the kids will not leave.',
    long: 'A walkable outdoor center with shops, ice cream, and a choreographed fountain show on the hour. Easy strolling, lots of shade, and plenty for restless kids.',
    hours: '10:00 AM – 8:00 PM', addr: '1013 Galleria Blvd, Roseville, CA', drive: 9, stay: '1h 10m',
  },
  {
    id: 'lucchesi', name: 'Lucchesi Vineyards', area: 'Lincoln',
    cat: 'Breweries', tone: 'amber', photo: 'vineyard,wine', lock: 77,
    why: 'Hilltop pours with a long view back over the foothills.',
    long: 'A family winery on a ridge above Lincoln with a generous tasting patio. Order a flight, share a cheese plate, and watch the light go gold over the valley.',
    hours: '11:00 AM – 5:00 PM', addr: '19698 Wise Rd, Lincoln, CA', drive: 18, stay: '1h 15m',
  },
  {
    id: 'quarry', name: 'Quarry Park Adventures', area: 'Rocklin',
    cat: 'Kid-friendly', tone: 'sky', photo: 'zipline,adventure', lock: 88,
    why: 'Zip lines and climbing walls in an old granite quarry.',
    long: 'A small adventure park built into a historic quarry — zip lines over the water, cliff jumps, and ropes courses. Book a slot ahead on weekends; great for older kids.',
    hours: '10:00 AM – 6:00 PM', addr: '4000 Rocklin Rd, Rocklin, CA', drive: 15, stay: '1h 30m',
  },
  {
    id: 'asra', name: 'Auburn State Recreation Area', area: 'Auburn',
    cat: 'Scenic Drives', tone: 'sage', photo: 'canyon,river', lock: 99,
    why: 'Canyon overlooks along the North Fork American River.',
    long: 'A string of pullouts and short paths above the confluence, with the old Foresthill Bridge soaring overhead. A scenic, low-effort detour with some of the best views in the county.',
    hours: '7:00 AM – Sunset', addr: '501 El Dorado St, Auburn, CA', drive: 24, stay: '0h 45m',
  },
  {
    id: 'flower-farm', name: 'Flower Farm Café', area: 'Loomis',
    cat: 'Dining', tone: 'coral', photo: 'cafe,garden', lock: 111,
    why: 'Brunch under the oaks at an old working nursery.',
    long: 'A café tucked into a citrus nursery with patio tables under big oaks. Strong brunch, good coffee, and a nursery to wander afterward. A soft, easy first stop.',
    hours: '7:00 AM – 3:00 PM', addr: '4150 Auburn Folsom Rd, Loomis, CA', drive: 11, stay: '1h 00m',
  },
];

// derive totals from a list of stops
function tripTotals(stops, baseHours = 6) {
  const driving = stops.reduce((s, x) => s + (x.drive || 0), 0);
  const dh = Math.floor(driving / 60), dm = driving % 60;
  const drivingLabel = dh > 0 ? `${dh} hr${dm ? ' ' + dm + ' min' : ''}` : `${dm} min`;
  const drivingShort = dh > 0 ? `${dh}h ${dm}m` : `${dm}m`;
  const cost = 60 + stops.length * 22; // rough per-trip estimate for two
  return {
    timeLabel: `${baseHours} hrs`,
    drivingLabel,
    drivingShort,
    costLabel: `$${cost}`,
    drivingMin: driving,
  };
}

// build a stable, theme-matching stock photo URL for a stop
function stopPhoto(stop, w, h) {
  if (!stop || !stop.photo) return null;
  return `https://loremflickr.com/${w}/${h}/${encodeURIComponent(stop.photo)}?lock=${stop.lock || 1}`;
}

Object.assign(window, { INTERESTS, DEFAULT_STOPS, ALT_STOPS, tripTotals, stopPhoto });
