// V1 · Spotlight — bold centered, cursor-following neon-yellow gradient,
// the SPOT logo as a glowing focal point. Black canvas + grain.

function V1Bold({ tweaks }) {
  const ref = React.useRef(null);
  const [pos, setPos] = React.useState({ x: 0.5, y: 0.5 });
  const [isTouch, setIsTouch] = React.useState(false);

  React.useEffect(() => {
    setIsTouch(window.matchMedia('(hover: none)').matches);
  }, []);

  React.useEffect(() => {
    if (!tweaks.animations) { setPos({ x: 0.5, y: 0.5 }); return; }
    const el = ref.current;
    if (!el) return;

    if (isTouch) {
      let raf;
      const start = performance.now();
      const tick = (now) => {
        const t = (now - start) / 6000;
        const angle = t * Math.PI * 2;
        setPos({
          x: 0.5 + Math.cos(angle) * 0.18,
          y: 0.5 + Math.sin(angle) * 0.14,
        });
        raf = requestAnimationFrame(tick);
      };
      raf = requestAnimationFrame(tick);
      return () => cancelAnimationFrame(raf);
    }

    const onMove = (e) => {
      const r = el.getBoundingClientRect();
      setPos({
        x: Math.max(0, Math.min(1, (e.clientX - r.left) / r.width)),
        y: Math.max(0, Math.min(1, (e.clientY - r.top) / r.height)),
      });
    };
    const onLeave = () => setPos({ x: 0.5, y: 0.5 });
    el.addEventListener('mousemove', onMove);
    el.addEventListener('mouseleave', onLeave);
    return () => {
      el.removeEventListener('mousemove', onMove);
      el.removeEventListener('mouseleave', onLeave);
    };
  }, [tweaks.animations, isTouch]);

  const features = [
    { k: '01', t: 'Discover events', d: 'Festivals, club nights, house parties - all in one feed.' },
    { k: '02', t: 'Host your own', d: 'Public or private, free or invite-only. Your scene, your rules.' },
    { k: '03', t: 'See who\u2019s going', d: 'Spot the crowd before you commit. Bring your people.' },
  ];

  const headlines = {
    'x-marks':  { pre: 'X marks',     mid: 'the',     hi: 'SPOT',  post: '.', preItalic: true },
    'save-spot':{ pre: 'Save',        mid: 'the',     hi: 'SPOT',  post: '.', preItalic: true },
    'hit-spot': { pre: 'Hits',        mid: 'the',     hi: 'SPOT',  post: '.', preItalic: true },
    'on-spot':  { pre: 'You\u2019re', mid: 'on the',  hi: 'SPOT',  post: '.', preItalic: true },
    'spot-on':  { pre: '',            mid: '',        hi: 'SPOT',  post: '. On.', preItalic: false },
  };
  const h = headlines[tweaks.headline] || headlines['x-marks'];

  return (
    <div ref={ref} style={{
      position:'relative', width:'100%', minHeight:'100%',
      display:'flex', flexDirection:'column',
      background:'#0a0a09', color:'#fff', overflow:'hidden',
      fontFamily:'Geist, system-ui, sans-serif',
    }}>
      {/* Cursor-following neon glow */}
      <div style={{
        position:'absolute', inset:0,
        background:`radial-gradient(circle at ${pos.x*100}% ${pos.y*100}%, #d8ff00 0%, #c8ee00 12%, #4a5400 30%, #0a0a09 60%)`,
        transition: tweaks.animations ? (isTouch ? 'none' : 'background 0.4s cubic-bezier(.2,.8,.3,1)') : 'background 0.6s ease',
        filter:'blur(0px)',
      }} />
      {/* Secondary deeper black falloff */}
      <div style={{
        position:'absolute', inset:0,
        background:`radial-gradient(circle at ${(1-pos.x)*100}% ${(1-pos.y)*100}%, rgba(0,0,0,0.55) 0%, transparent 50%)`,
        transition: isTouch && tweaks.animations ? 'none' : 'background 0.6s ease',
      }} />
      {/* Grain */}
      <div style={{
        position:'absolute', inset:0, pointerEvents:'none', opacity:0.35, mixBlendMode:'overlay',
        backgroundImage:`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>")`,
      }} />

      {/* Top bar */}
      <header className="v1-header" style={{
        position:'relative', zIndex:2, display:'flex', alignItems:'center', justifyContent:'space-between',
        padding:'32px 56px', fontSize:14, letterSpacing:'0.08em', textTransform:'uppercase',
      }}>
        <span style={{display:'flex', alignItems:'center', gap:10}}>
          <span style={{width:8, height:8, borderRadius:'50%', background:'#d8ff00', boxShadow: tweaks.animations ? '0 0 16px #d8ff00' : 'none', animation: tweaks.animations ? 'spotPulse 2s ease-in-out infinite' : 'none'}} />
          spotevent.be
        </span>
        <a
          href="#"
          aria-label="Instagram"
          target="_blank"
          rel="noopener noreferrer"
          style={{
            display:'inline-flex', alignItems:'center', justifyContent:'center',
            width:36, height:36, borderRadius:8,
            color:'rgba(255,255,255,0.7)',
            transition:'color 0.2s ease, transform 0.2s ease',
          }}
          onMouseEnter={(e) => { e.currentTarget.style.color = '#d8ff00'; e.currentTarget.style.transform = 'scale(1.1)'; }}
          onMouseLeave={(e) => { e.currentTarget.style.color = 'rgba(255,255,255,0.7)'; e.currentTarget.style.transform = 'scale(1)'; }}
        >
          <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
            <rect x="2" y="2" width="20" height="20" rx="5" ry="5"></rect>
            <path d="M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z"></path>
            <line x1="17.5" y1="6.5" x2="17.51" y2="6.5"></line>
          </svg>
        </a>
      </header>

      {/* Hero */}
      <main className="v1-hero" style={{
        position:'relative', zIndex:2, display:'flex', flexDirection:'column', alignItems:'center', justifyContent:'center',
        padding:'40px 56px 0', textAlign:'center', flex:'1 1 auto',
      }}>
        <SpotLogo size={120} glow={tweaks.animations} className="v1-logo" />
        <h1 className="v1-headline" style={{
          fontFamily:'Bricolage Grotesque, system-ui, sans-serif',
          fontWeight:600, fontSize:'clamp(56px, 12vw, 108px)', lineHeight:1, margin:'clamp(24px, 4vw, 40px) 0 0',
          letterSpacing:'-0.045em',
          fontVariationSettings: '"opsz" 96',
          display:'flex', flexDirection:'column', alignItems:'center', gap:0,
        }}>
          {h.pre && (
            <span style={{
              fontFamily: h.preItalic ? 'Caveat, cursive' : 'Bricolage Grotesque, system-ui, sans-serif',
              fontWeight: h.preItalic ? 700 : 500,
              fontSize: h.preItalic ? 'clamp(36px, 7vw, 56px)' : 'inherit',
              lineHeight: h.preItalic ? 0.9 : 1,
              fontStyle: 'normal',
              color: h.preItalic ? '#d8ff00' : '#fff',
              display: 'block',
              transform: h.preItalic ? 'rotate(-4deg)' : 'none',
              marginBottom: h.preItalic ? 4 : 0,
              textShadow: h.preItalic && tweaks.animations ? '0 0 28px rgba(216,255,0,0.4)' : 'none',
            }}>
              {h.pre}
            </span>
          )}
          <span style={{display:'block', whiteSpace:'nowrap'}}>
            {h.mid && <span style={{fontWeight:400, opacity:0.9}}>{h.mid} </span>}
            <span style={{
              fontWeight:700, letterSpacing:'-0.05em',
              color:'#d8ff00',
              textShadow: tweaks.animations ? '0 0 36px rgba(216,255,0,0.55)' : 'none',
            }}>{h.hi}</span>
            <span style={{fontWeight:600}}>{h.post}</span>
          </span>
        </h1>
        <p className="v1-tagline" style={{
          marginTop:'clamp(20px, 3vw, 28px)', fontSize:'clamp(15px, 1.6vw, 18px)', maxWidth:580, opacity:0.78, lineHeight:1.5,
          fontFamily:'Geist, system-ui, sans-serif', fontWeight:400,
        }}>
          {tweaks.tagline} A social app for discovering, hosting, and showing up to events - from festivals to the smallest house party.
        </p>
      </main>

      {/* Footer feature strip */}
      <footer className="v1-footer" style={{
        position:'relative', zIndex:2,
        padding:'28px 56px 32px',
        display:'grid', gridTemplateColumns:'repeat(3, 1fr)', gap:32,
        borderTop:'1px solid rgba(255,255,255,0.12)',
        background:'linear-gradient(to top, rgba(10,10,9,0.85), rgba(10,10,9,0.0))',
        backdropFilter:'blur(2px)',
      }}>
        {features.map((f) => (
          <div key={f.k} style={{display:'flex', gap:14}}>
            <span style={{
              fontFamily:'JetBrains Mono, monospace', fontSize:11, color:'#d8ff00',
              letterSpacing:'0.1em', paddingTop:3, minWidth:24,
            }}>{f.k}</span>
            <div>
              <div style={{fontSize:15, fontWeight:600, marginBottom:4}}>{f.t}</div>
              <div style={{fontSize:13, opacity:0.65, lineHeight:1.4}}>{f.d}</div>
            </div>
          </div>
        ))}
      </footer>

      <style>{`
        @keyframes spotPulse { 0%, 100% { transform: scale(1); opacity: 1 } 50% { transform: scale(1.4); opacity: 0.7 } }
        @media (max-width: 768px) {
          .v1-header { padding: 20px 24px !important; font-size: 12px !important; }
          .v1-hero { padding: 24px 24px !important; }
          .v1-footer { grid-template-columns: 1fr !important; gap: 14px !important; padding: 20px 24px 24px !important; }
        }
        @media (max-width: 480px) {
          .v1-header { padding: 16px 16px !important; }
          .v1-hero { padding: 20px 16px !important; }
          .v1-logo { width: 80px !important; height: auto !important; }
          .v1-footer { padding: 16px 16px 20px !important; }
        }
      `}</style>
    </div>
  );
}

window.V1Bold = V1Bold;
