/* Icons + tiny shared primitives — exported to window */
const I = {
  wa: (p)=> <svg viewBox="0 0 24 24" fill="currentColor" {...p}><path d="M17.5 14.4c-.3-.2-1.7-.8-2-.9-.3-.1-.5-.2-.7.2-.2.3-.7.9-.9 1.1-.2.2-.3.2-.6.1-1.7-.9-2.9-1.6-4-3.6-.3-.5.3-.5.8-1.5.1-.2 0-.4 0-.5 0-.2-.7-1.6-.9-2.2-.2-.6-.5-.5-.7-.5h-.6c-.2 0-.5.1-.8.4-.3.3-1 1-1 2.5s1.1 2.9 1.2 3.1c.2.2 2.2 3.4 5.3 4.7 2 .8 2.7.9 3.7.8.6-.1 1.7-.7 2-1.4.2-.7.2-1.2.2-1.4-.1-.1-.3-.2-.6-.3M12 2a10 10 0 0 0-8.6 15l-1.3 4.7 4.8-1.3A10 10 0 1 0 12 2"/></svg>,
  ig: (p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" {...p}><rect x="3" y="3" width="18" height="18" rx="5"/><circle cx="12" cy="12" r="4"/><circle cx="17.4" cy="6.6" r="1" fill="currentColor" stroke="none"/></svg>,
  arrow: (p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" {...p}><path d="M5 12h14M13 6l6 6-6 6"/></svg>,
  arrowDown: (p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...p}><path d="M12 5v14M6 13l6 6 6-6"/></svg>,
  check: (p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" {...p}><path d="M20 6 9 17l-5-5"/></svg>,
  sail: (p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}><path d="M3 18h18l-2 3H5z"/><path d="M11 3 5 16h6zM13 7l5 9h-5z"/></svg>,
  anchor:(p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}><circle cx="12" cy="5" r="2"/><path d="M12 7v14M5 12H3a9 9 0 0 0 18 0h-2M12 21a9 9 0 0 1-7-3M12 21a9 9 0 0 0 7-3"/></svg>,
  sun:(p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>,
  compass:(p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}><circle cx="12" cy="12" r="9"/><path d="m15.5 8.5-2 5-5 2 2-5z"/></svg>,
  pin:(p)=> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" {...p}><path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0Z"/><circle cx="12" cy="10" r="2.5"/></svg>,
  wave:(p)=> <svg viewBox="0 0 48 8" fill="none" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" {...p}><path d="M1 5c4-4 8-4 12 0s8 4 12 0 8-4 12 0 8 4 11 0"/></svg>,
};

// reveal-on-scroll wrapper
function Reveal({children, className="", delay=0, as:Tag="div", ...rest}){
  const ref = React.useRef(null);
  React.useEffect(()=>{
    const el=ref.current; if(!el) return;
    const io=new IntersectionObserver(([e])=>{
      if(e.isIntersecting){ el.classList.add("in"); io.unobserve(el); }
    },{threshold:.12});
    io.observe(el); return ()=>io.disconnect();
  },[]);
  return <Tag ref={ref} className={"fade-up "+className} style={{transitionDelay:delay+"ms"}} {...rest}>{children}</Tag>;
}

// Real photography mapped per slot. Falls back to generated placeholder; a user drop overrides either.
const PHOTOS = {
  "heroA-bg":"IMG_6256",   // sunset catamaran silhouette
  "exp-0":"IMG_6228",      // private charter — deck & cushions
  "exp-1":"IMG_6224",      // catamaran day — turquoise coast from cockpit
  "exp-2":"IMG_6262",      // sunset cruise — aperitivo on board
};
// image slot helper — renders the web component
function Slot({id, ph, style, shape="rounded", radius=14, className="", src}){
  const finalSrc = src || (PHOTOS[id] ? "assets/photos/"+PHOTOS[id]+".jpg" : "assets/ph/"+id+".png");
  return <image-slot id={id} placeholder={ph} shape={shape} radius={String(radius)}
    src={finalSrc} class={className} style={style}></image-slot>;
}

const WAIcon = I.wa, IGIcon = I.ig, Arrow = I.arrow;

Object.assign(window, { I, Reveal, Slot });
