/* global React */
// =====================================================
// PIQUEL Landing — Icons (monoline 1.6, 24×24)
// =====================================================
const Icon = ({ name, size = 22, color = 'currentColor', stroke = 1.6, style }) => {
  const paths = {
    bolt:    <><path d="M13 3L4 14h7l-1 7 9-11h-7l1-7z"/></>,
    pin:     <><path d="M12 21s7-7.5 7-12a7 7 0 10-14 0c0 4.5 7 12 7 12z"/><circle cx="12" cy="9" r="2.5"/></>,
    target:  <><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="5"/><circle cx="12" cy="12" r="1.5" fill={color} stroke="none"/></>,
    play:    <><path d="M8 5l12 7-12 7V5z" fill={color} stroke="none"/></>,
    users:   <><circle cx="9" cy="8" r="3.5"/><circle cx="17" cy="10" r="2.5"/><path d="M3 20c0-3.5 3-6 6-6s6 2.5 6 6"/><path d="M15 20c0-2 1.8-3.5 4-3.5s3 1.5 3 3.5"/></>,
    trophy:  <><path d="M8 4h8v4a4 4 0 11-8 0V4z"/><path d="M4 5h4v2a3 3 0 01-4 0zM20 5h-4v2a3 3 0 004 0z"/><path d="M10 14h4v3h-4zM7 21h10"/></>,
    chat:    <><path d="M4 6h16v11H8l-4 3V6z"/></>,
    chev:    <><path d="M9 6l6 6-6 6"/></>,
    chevR:   <><path d="M9 6l6 6-6 6"/></>,
    chevD:   <><path d="M6 9l6 6 6-6"/></>,
    check:   <><path d="M5 12l5 5 9-11"/></>,
    arrow:   <><path d="M5 12h14M13 6l6 6-6 6"/></>,
    plus:    <><path d="M12 5v14M5 12h14"/></>,
    star:    <path d="M12 3l2.5 6 6.5.6-5 4.5 1.5 6.4L12 17l-5.5 3.5L8 14.1 3 9.6l6.5-.6L12 3z"/>,
    sparkle: <><path d="M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"/></>,
    calendar:<><rect x="3.5" y="5" width="17" height="16" rx="2"/><path d="M3.5 10h17M8 3v4M16 3v4"/></>,
    clock:   <><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></>,
    chart:   <><path d="M4 19h16"/><path d="M6 16V8M11 16V4M16 16v-7M21 16v-3"/></>,
    map:     <><path d="M9 4l-5 2v14l5-2 6 2 5-2V4l-5 2-6-2z"/><path d="M9 4v14M15 6v14"/></>,
    shield:  <><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"/></>,
    paddle:  <><circle cx="11" cy="9" r="6"/><path d="M11 15l-5 5"/><circle cx="11" cy="9" r="1" fill={color} stroke="none"/></>,
    globe:   <><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3 3 15 0 18M12 3c-3 3-3 15 0 18"/></>,
    mail:    <><rect x="3.5" y="5.5" width="17" height="13" rx="2"/><path d="M3.5 7l8.5 6 8.5-6"/></>,
    x:       <><path d="M6 6l12 12M6 18L18 6"/></>,
    menu:    <><path d="M4 7h16M4 12h16M4 17h16"/></>,
    twitter: <><path d="M19 5.5c-.7.3-1.4.5-2.1.6.8-.5 1.4-1.2 1.6-2-.7.4-1.5.7-2.4.9a3.7 3.7 0 00-6.3 3.4C7 8.2 4.3 6.8 2.4 4.5a3.7 3.7 0 001.2 4.9c-.6 0-1.2-.2-1.7-.5v.1c0 1.8 1.3 3.3 3 3.7-.3.1-.7.1-1 .1-.3 0-.5 0-.8-.1.5 1.5 1.9 2.6 3.6 2.6A7.5 7.5 0 012 16.7a10.5 10.5 0 005.7 1.7c6.8 0 10.6-5.7 10.6-10.6v-.5c.7-.5 1.3-1.2 1.7-1.8z" fill={color} stroke="none"/></>,
    instagram: <><rect x="3.5" y="3.5" width="17" height="17" rx="5"/><circle cx="12" cy="12" r="4"/><circle cx="17" cy="7" r="1" fill={color} stroke="none"/></>,
    apple:   <><path d="M16.5 12.7c0-2.7 2.2-4 2.3-4-1.3-1.8-3.2-2.1-3.9-2.1-1.7-.2-3.3 1-4.1 1-.9 0-2.2-1-3.6-.9-1.8 0-3.6 1-4.5 2.7-2 3.4-.5 8.4 1.4 11.1.9 1.4 2 2.9 3.4 2.8 1.4-.1 1.9-.9 3.5-.9 1.7 0 2.1.9 3.5.8 1.5 0 2.4-1.3 3.3-2.7.7-1 1.3-2.1 1.7-3.3-3.8-1.4-3.9-5.5 0-5.5zM14 4.8a4 4 0 001-2.8c-1.1.1-2.3.7-3 1.5a3.4 3.4 0 00-.9 2.7c1.1.1 2.2-.6 2.9-1.4z" fill={color} stroke="none"/></>,
    google:  <><path d="M21 12c0-.7-.1-1.4-.2-2H12v3.8h5.1a4.4 4.4 0 01-1.9 2.9v2.4h3.1A9 9 0 0021 12z" fill="#4285F4" stroke="none"/><path d="M12 21c2.6 0 4.7-.9 6.3-2.3l-3-2.4c-.9.6-2 .9-3.3.9-2.5 0-4.7-1.7-5.5-4.1H3.4v2.5A9 9 0 0012 21z" fill="#34A853" stroke="none"/><path d="M6.5 13.1c-.2-.6-.3-1.3-.3-2 0-.7.1-1.4.3-2V6.6H3.4a9 9 0 000 8.7l3.1-2.2z" fill="#FBBC05" stroke="none"/><path d="M12 6c1.4 0 2.7.5 3.7 1.5L18.4 5A9 9 0 003.4 6.6L6.5 9c.7-2.3 2.9-4 5.5-4z" fill="#EA4335" stroke="none"/></>,
    eye:     <><path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/></>,
    fire:    <><path d="M12 21c-3.5 0-6-2.4-6-5.5 0-2 1.3-3.5 2.5-5 1-1.3 1.5-2.7 1-4.5 0 0 4.5 1.5 5 6 0-1 1.5-2 1.5-3.5 0 0 2 2.5 2 6 0 3.6-2.5 6.5-6 6.5z"/></>,
    sun:     <><circle cx="12" cy="12" r="4"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4L7 17M17 7l1.4-1.4"/></>,
    moon:    <><path d="M20 14a8 8 0 11-10-10 7 7 0 0010 10z"/></>,
  };
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color}
      strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round" style={style} aria-hidden="true">
      {paths[name]}
    </svg>
  );
};

// =====================================================
// Shared reveal hook
// =====================================================
const useReveal = () => {
  React.useEffect(() => {
    if (typeof IntersectionObserver === 'undefined') return;
    const els = document.querySelectorAll('.pq-reveal:not(.in)');
    const io = new IntersectionObserver(entries => {
      entries.forEach(e => {
        if (e.isIntersecting) {
          e.target.classList.add('in');
          io.unobserve(e.target);
        }
      });
    }, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
    els.forEach(el => io.observe(el));
    return () => io.disconnect();
  }, []);
};

Object.assign(window, { Icon, useReveal });
