/* global React */

// ── Design tokens ──────────────────────────────────────────────────────────
const C = {
  bg: '#0B0C0E',
  bg1: '#141518',
  bone: '#E6DCCB',
  grey: '#8A8A86',
  mute: '#52524F',
  border: '#1F2024',
  borderHi: '#33353A',
  cyan: '#59A3B3',
  cyanHi: '#7EBFCD',
};

const F = {
  display: "'Playfair Display', Georgia, serif",
  sans: "'IBM Plex Sans', system-ui, sans-serif",
  mono: "'IBM Plex Mono', monospace",
};

const ease = 'cubic-bezier(0.2,0.7,0.2,1)';
const wrap = { width: 'min(1080px, calc(100% - 48px))', margin: '0 auto' };

// ── Viewfinder corner bracket ───────────────────────────────────────────────
function Corner({ top, right, bottom, left }) {
  const color = 'rgba(89,163,179,0.5)';
  const t = 1;
  return (
    <div style={{
      position: 'absolute',
      width: 16, height: 16,
      top, right, bottom, left,
      borderColor: color,
      borderStyle: 'solid',
      borderWidth: 0,
      borderTopWidth: top !== undefined ? t : 0,
      borderBottomWidth: bottom !== undefined ? t : 0,
      borderLeftWidth: left !== undefined ? t : 0,
      borderRightWidth: right !== undefined ? t : 0,
    }} />
  );
}

// ── Showgaze mark (Kenaz) ──────────────────────────────────────────────────
function Mark({ size = 20, animate = false }) {
  return (
    <img
      src="assets/logo/mark-cream-512.png"
      alt="Showgaze mark"
      style={{
        width: size * 1.8,
        height: size,
        objectFit: 'contain',
        objectPosition: 'left center',
        display: 'block',
        // When animate=true, the 'breathe' keyframe owns the transform (includes scaleX(-1))
        transform: animate ? undefined : 'none',
        animation: animate ? 'breathe 6s ease-in-out infinite' : 'none',
        transformOrigin: 'center',
      }}
    />
  );
}

// ── Header ─────────────────────────────────────────────────────────────────
function Header() {
  return (
    <header className="anim-0" style={{
      position: 'sticky',
      top: 0,
      zIndex: 10,
      background: 'rgba(11,12,14,0.90)',
      backdropFilter: 'blur(18px)',
      WebkitBackdropFilter: 'blur(18px)',
      borderBottom: `1px solid ${C.border}`,
    }}>
      <div style={{
        ...wrap,
        height: 56,
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'space-between',
      }}>
        <a href="#" aria-label="Showgaze — home" style={{ display: 'flex', alignItems: 'center', gap: 10, textDecoration: 'none' }}>
          <Mark size={20} animate />
          <span style={{ fontFamily: F.display, fontSize: 18, color: C.bone, letterSpacing: '0.01em' }}>
            Showgaze
          </span>
        </a>
        <div style={{ display: 'flex', alignItems: 'center', gap: 20 }}>



          {/* Organizer login */}
          <a
            href="/apply/login"
            style={{
              display: 'flex',
              alignItems: 'center',
              gap: 6,
              fontFamily: F.mono,
              fontSize: 9,
              letterSpacing: '0.18em',
              textTransform: 'uppercase',
              textDecoration: 'none',
              color: C.grey,
              border: `1px solid ${C.border}`,
              borderRadius: 4,
              padding: '6px 12px',
              transition: `all 160ms ${ease}`,
            }}
            onMouseEnter={e => {
              e.currentTarget.style.borderColor = C.borderHi;
              e.currentTarget.style.color = C.bone;
            }}
            onMouseLeave={e => {
              e.currentTarget.style.borderColor = C.border;
              e.currentTarget.style.color = C.grey;
            }}
          >
            {/* Lock icon inline SVG */}
            <svg width="9" height="9" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" style={{ flexShrink: 0 }}>
              <rect x="3" y="11" width="18" height="11" rx="2" ry="2" />
              <path d="M7 11V7a5 5 0 0 1 10 0v4" />
            </svg>
            Organizer Login
          </a>

        </div>
      </div>
    </header>
  );
}

// ── Kenaz mark — draws on load, rune pivots around circle on scroll ────────
function KenazMark({ size = 80 }) {
  const pathRef = React.useRef(null);

  const angleRef = React.useRef(-45); // Initial offset to ease into place
  const targetAngleRef = React.useRef(0);

  React.useEffect(() => {
    let frameId;

    function update() {
      // Lower damping = more 'skid' / less resistance
      const damping = 0.06;
      const diff = targetAngleRef.current - angleRef.current;

      // Only update if there's a meaningful difference to save cycles
      if (Math.abs(diff) > 0.01) {
        angleRef.current += diff * damping;
        if (pathRef.current) {
          pathRef.current.setAttribute('transform', `rotate(${angleRef.current}, 700, 512)`);
        }
      }

      frameId = requestAnimationFrame(update);
    }

    function onScroll() {
      // Calculate target angle based on scroll depth
      targetAngleRef.current = window.scrollY * 0.90;
    }

    // Initialize position
    onScroll();

    window.addEventListener('scroll', onScroll, { passive: true });
    frameId = requestAnimationFrame(update);

    return () => {
      window.removeEventListener('scroll', onScroll);
      cancelAnimationFrame(frameId);
    };
  }, []);

  return (
    <svg
      viewBox="0 0 1024 1024"
      width={size}
      height={size}
      aria-hidden="true"
      style={{ display: 'block', overflow: 'visible' }}
    >
      <g fill="none" stroke="#E6DCCB" strokeLinecap="butt" strokeLinejoin="miter">
        {/* Path draws first, then circle closes around it */}
        <path
          ref={pathRef}
          d="M492 318 L304 512 L492 706"
          strokeWidth="76"
          style={{
            strokeDasharray: 545,
            animation: 'drawPath 0.55s cubic-bezier(0.4,0,0.2,1) 0.15s both',
          }}
        />
        <circle
          cx="700" cy="512" r="108"
          strokeWidth="56"
          style={{
            strokeDasharray: 685,
            animation: 'drawCircle 0.6s cubic-bezier(0.4,0,0.2,1) 0.5s both',
          }}
        />
      </g>
    </svg>
  );
}

// ── Hero CTA — links to the intake form ────────────────────────────────────
function HeroForm() {
  return (
    <div className="anim-5" style={{
      flex: '1 1 240px',
      maxWidth: 320,
      paddingLeft: 48,
      borderLeft: '1px solid rgba(255,255,255,0.07)',
      display: 'flex',
      flexDirection: 'column',
      justifyContent: 'center',
    }}>
      <p style={{
        margin: '0 0 16px',
        fontFamily: F.display,
        fontSize: 'clamp(20px, 2vw, 26px)',
        color: C.bone,
        lineHeight: 1.1,
      }}>
        Ready to start?
      </p>

      <a
        href="/apply/"
        style={{
          display: 'block',
          width: '100%',
          textAlign: 'center',
          textDecoration: 'none',
          fontFamily: F.mono,
          fontSize: 10,
          letterSpacing: '0.18em',
          textTransform: 'uppercase',
          background: C.cyan,
          color: '#0B0C0E',
          border: `1px solid ${C.cyan}`,
          borderRadius: 4,
          padding: '12px 0',
          cursor: 'pointer',
          transition: `all 180ms ${ease}`,
          marginBottom: 10,
        }}
        onMouseEnter={e => {
          e.currentTarget.style.background = C.cyanHi || '#7EBFCD';
          e.currentTarget.style.borderColor = C.cyanHi || '#7EBFCD';
        }}
        onMouseLeave={e => {
          e.currentTarget.style.background = C.cyan;
          e.currentTarget.style.borderColor = C.cyan;
        }}
      >
        Apply Now
      </a>

      <a
        href="#contact"
        style={{
          display: 'block',
          width: '100%',
          textAlign: 'center',
          textDecoration: 'none',
          fontFamily: F.mono,
          fontSize: 10,
          letterSpacing: '0.18em',
          textTransform: 'uppercase',
          background: 'transparent',
          color: C.grey,
          border: `1px solid ${C.border}`,
          borderRadius: 4,
          padding: '11px 0',
          cursor: 'pointer',
          transition: `all 180ms ${ease}`,
          marginBottom: 14,
        }}
        onMouseEnter={e => {
          e.currentTarget.style.borderColor = C.borderHi;
          e.currentTarget.style.color = C.bone;
        }}
        onMouseLeave={e => {
          e.currentTarget.style.borderColor = C.border;
          e.currentTarget.style.color = C.grey;
        }}
      >
        Want to know more?
      </a>

      <a
        href="mailto:hello@showgaze.app"
        style={{ display: 'block', margin: '0 0 32px', fontFamily: F.mono, fontSize: 9, letterSpacing: '0.06em', color: C.mute, textDecoration: 'none', transition: `color 140ms ${ease}` }}
        onMouseEnter={e => { e.currentTarget.style.color = C.grey; }}
        onMouseLeave={e => { e.currentTarget.style.color = C.mute; }}
      >
        hello@showgaze.app
      </a>

      {/* Beta Status Panel */}
      <div style={{
        marginTop: 'auto',
        padding: '16px 18px',
        background: 'rgba(20,21,24,0.4)',
        backdropFilter: 'blur(12px)',
        WebkitBackdropFilter: 'blur(12px)',
        border: `1px solid ${C.cyan}22`,
        borderRadius: 4,
      }}>
        <div style={{
          fontFamily: F.mono,
          fontSize: 8,
          letterSpacing: '0.22em',
          textTransform: 'uppercase',
          color: C.cyan,
          marginBottom: 10,
          display: 'flex',
          alignItems: 'center',
          gap: 8,
        }}>
          <span style={{ width: 4, height: 4, borderRadius: '50%', background: C.cyan, boxShadow: `0 0 8px ${C.cyan}` }} />
          BETA STATUS
        </div>
        <div style={{
          fontFamily: F.sans,
          fontSize: 12,
          fontWeight: 600,
          color: C.bone,
          marginBottom: 6,
          lineHeight: 1.3,
        }}>
          Private beta · limited event intake
        </div>
        <div style={{
          fontFamily: F.sans,
          fontSize: 11,
          lineHeight: 1.5,
          color: 'rgba(230,220,203,0.45)',
        }}>
          Each event is currently reviewed and quality-checked by hand, so availability is limited.
        </div>
      </div>
    </div>
  );
}

// ── Hero — text over photograph ────────────────────────────────────────────
function Hero() {
  const imgRef = React.useRef(null);

  React.useEffect(() => {
    function tick() {
      if (!imgRef.current) return;
      imgRef.current.style.transform = `translateY(${window.scrollY * 0.22}px)`;
    }
    window.addEventListener('scroll', tick, { passive: true });
    return () => window.removeEventListener('scroll', tick);
  }, []);

  return (
    <section aria-label="Hero" style={{
      position: 'relative',
      height: 'calc(100vh - 56px)',
      minHeight: 540,
      maxHeight: 920,
      overflow: 'hidden',
      display: 'flex',
      flexDirection: 'column',
      justifyContent: 'flex-end',
    }}>
      {/* Photograph — slightly oversized for parallax headroom */}
      <img
        ref={imgRef}
        src="assets/images/crowd_filming_cinematic.png"
        alt=""
        aria-hidden="true"
        style={{
          position: 'absolute',
          top: '-8%',
          left: 0,
          width: '100%',
          height: '116%',
          objectFit: 'cover',
          objectPosition: 'center 22%',
          willChange: 'transform',
        }}
      />

      {/* Gradient — darkens bottom so text reads clean */}
      <div style={{
        position: 'absolute',
        inset: 0,
        background: [
          `linear-gradient(to top, ${C.bg} 0%, rgba(11,12,14,0.72) 28%, rgba(11,12,14,0.1) 60%)`,
          `linear-gradient(to right, rgba(11,12,14,0.55) 0%, transparent 70%)`,
        ].join(', '),
        pointerEvents: 'none',
      }} />

      {/* Viewfinder corner marks */}
      <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>
        <Corner top={18} left={22} />
        <Corner top={18} right={22} />
        <Corner bottom={18} left={22} />
        <Corner bottom={18} right={22} />
      </div>

      {/* Slow scanline sweep */}
      <div style={{
        position: 'absolute',
        left: 0, right: 0,
        height: 1,
        background: `linear-gradient(90deg, transparent, ${C.cyan}44, transparent)`,
        animation: 'scanline 9s ease-in-out infinite',
        pointerEvents: 'none',
      }} />

      {/* Text — two-column, bottom-anchored */}
      <div style={{
        position: 'relative', zIndex: 1,
        ...wrap, paddingBottom: 64,
        display: 'flex',
        alignItems: 'flex-end',
        gap: '40px 72px',
        flexWrap: 'wrap',
      }}>

        {/* Left — branding + headline */}
        <div style={{ flex: '3 1 320px' }}>

          {/* Logo lockup */}
          <div className="anim-1" style={{
            display: 'flex',
            alignItems: 'center',
            gap: 18,
            marginBottom: 28,
          }}>
            <KenazMark size={80} />
            <span style={{
              fontFamily: F.display,
              fontSize: 26,
              fontWeight: 600,
              color: C.bone,
              letterSpacing: '0.08em',
              lineHeight: 1,
            }}>
              SHOWGAZE
            </span>
          </div>

          <h1 className="anim-2" style={{
            margin: '0 0 12px',
            fontFamily: F.display,
            fontSize: 'clamp(28px, 4.2vw, 56px)',
            lineHeight: 1.08,
            letterSpacing: '-0.01em',
            color: C.bone,
            fontWeight: 400,
          }}>
            Well... You've got all these people filming anyway.
          </h1>

          <p className="anim-3" style={{
            margin: '0 0 20px',
            fontFamily: F.mono,
            fontSize: 'clamp(11px, 1vw, 14px)',
            letterSpacing: '0.18em',
            color: C.bone,
            opacity: 0.45,
          }}>
            Sync. Cut. Post.
          </p>

          <p className="anim-4" style={{
            margin: 0,
            fontFamily: F.sans,
            fontSize: 'clamp(12px, 1.2vw, 14px)',
            lineHeight: 1.75,
            color: 'rgba(230,220,203,0.55)',
            maxWidth: 440,
          }}>
            Showgaze helps event teams collect, sync, review, and deliver audience-shot
            footage after a show. It is currently in private beta with limited event capacity.
          </p>
        </div>

        {/* Right — compact contact form */}
        <HeroForm />

      </div>
    </section>
  );
}

// ── Two-column info ────────────────────────────────────────────────────────
function Kicker({ children }) {
  return (
    <h2 style={{
      margin: '0 0 18px',
      fontFamily: F.mono,
      fontSize: 9,
      fontWeight: 500,
      letterSpacing: '0.22em',
      textTransform: 'uppercase',
      color: C.cyan,
    }}>
      {children}
    </h2>
  );
}

function InfoRow() {
  return (
    <section aria-label="About" className="anim-6" style={{
      ...wrap,
      padding: '80px 0 84px',
      display: 'grid',
      gridTemplateColumns: 'repeat(auto-fit, minmax(240px, 1fr))',
      gap: '52px 96px',
      borderBottom: `1px solid ${C.border}`,
    }}>
      <div>
        <Kicker>Who it's for</Kicker>
        <p style={{ margin: 0, fontFamily: F.sans, fontSize: 15, lineHeight: 1.72, color: C.grey }}>
          Event producers and post-production teams who want to capture what the
          crowd sees, without adding complexity to the night itself.
        </p>
      </div>
      <div>
        <Kicker>In practice</Kicker>
        <p style={{ margin: 0, fontFamily: F.sans, fontSize: 15, lineHeight: 1.72, color: C.grey }}>
          Fans contribute through a simple web link — no install required.
          A dedicated fan app is in development. For producers, everything
          arrives in one organised view after the event.
        </p>
      </div>
    </section>
  );
}

function ProcessSection() {
  const steps = [
    {
      n: '01',
      title: 'Submit your event',
      body: 'Fill in the details — event name, date, venue, expected attendance. The intake form takes about two minutes.',
    },
    {
      n: '02',
      title: 'We set up the workflow',
      body: 'We review the submission, configure a dedicated upload point, and generate a QR code and upload link for your event.',
    },
    {
      n: '03',
      title: 'Share, collect, deliver',
      body: 'Display the QR at the venue. Footage arrives in one organised folder. After the show, we sync, review, and deliver.',
    },
  ];

  return (
    <section aria-label="How it works" className="anim-6" style={{
      ...wrap,
      padding: '80px 0 84px',
      borderBottom: `1px solid ${C.border}`,
    }}>
      <Kicker>Getting started</Kicker>
      <div style={{
        display: 'grid',
        gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))',
        gap: '40px 64px',
        marginTop: 32,
      }}>
        {steps.map((step) => (
          <div key={step.n}>
            <div style={{
              fontFamily: F.mono,
              fontSize: 10,
              letterSpacing: '0.22em',
              color: C.cyan,
              opacity: 0.6,
              marginBottom: 14,
            }}>
              {step.n}
            </div>
            <div style={{
              fontFamily: F.display,
              fontSize: 17,
              fontWeight: 600,
              color: C.bone,
              lineHeight: 1.25,
              marginBottom: 10,
            }}>
              {step.title}
            </div>
            <p style={{
              margin: 0,
              fontFamily: F.sans,
              fontSize: 14,
              lineHeight: 1.75,
              color: C.grey,
            }}>
              {step.body}
            </p>
          </div>
        ))}
      </div>
    </section>
  );
}

// ── Contact form ───────────────────────────────────────────────────────────
function ContactForm() {
  const [email, setEmail] = React.useState('');
  const [message, setMessage] = React.useState('');
  const [sent, setSent] = React.useState(false);
  const [submitting, setSubmitting] = React.useState(false);

  async function handleSubmit(e) {
    e.preventDefault();
    setSubmitting(true);
    try {
      const response = await fetch('/api/contact', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ email, message }),
      });

      if (response.ok) {
        setSent(true);
      } else {
        const error = await response.json();
        console.error('Contact form error:', error);
        alert('There was a problem sending your message. Please try again or email us directly at hello@showgaze.app');
      }
    } catch (err) {
      console.error('Contact form submission failed:', err);
      alert('Network error. Please check your connection and try again.');
    } finally {
      setSubmitting(false);
    }
  }

  const inputStyle = {
    display: 'block',
    width: '100%',
    padding: '11px 14px',
    fontSize: 13,
    fontFamily: F.mono,
    background: C.bg,
    border: `1px solid ${C.border}`,
    borderRadius: 4,
    color: C.bone,
    outline: 'none',
    transition: `border-color 180ms ${ease}`,
  };

  const labelStyle = {
    display: 'block',
    fontFamily: F.mono,
    fontSize: 9,
    letterSpacing: '0.18em',
    textTransform: 'uppercase',
    color: C.grey,
    marginBottom: 8,
  };

  return (
    <section id="contact" aria-label="Contact" className="anim-5" style={{ ...wrap, padding: '88px 0 104px', borderTop: `1px solid ${C.border}` }}>
      <div style={{
        maxWidth: 560,
        margin: '0 auto',
        padding: 'clamp(32px, 5vw, 56px) clamp(24px, 5vw, 48px)',
        background: 'rgba(20,21,24,0.55)',
        backdropFilter: 'blur(16px)',
        WebkitBackdropFilter: 'blur(16px)',
        border: `1px solid ${C.border}`,
        borderRadius: 8,
      }}>

        <div style={{ marginBottom: 36 }}>
          <p style={{
            margin: '0 0 10px',
            fontFamily: F.mono,
            fontSize: 9,
            letterSpacing: '0.22em',
            textTransform: 'uppercase',
            color: C.cyan,
          }}>
            Get in touch
          </p>
          <p style={{
            margin: '0 0 10px',
            fontFamily: F.display,
            fontSize: 'clamp(22px, 2.8vw, 32px)',
            color: C.bone,
            lineHeight: 1.1,
          }}>
            Tell us about your event.
          </p>
          <p style={{
            margin: 0,
            fontFamily: F.sans,
            fontSize: 13,
            lineHeight: 1.65,
            color: C.grey,
          }}>
            We'll follow up with next steps and availability.
          </p>
        </div>

        {sent ? (
          <div style={{ padding: '24px 0' }}>
            <p style={{
              margin: '0 0 8px',
              fontFamily: F.mono,
              fontSize: 9,
              letterSpacing: '0.22em',
              textTransform: 'uppercase',
              color: '#6FB89B',
            }}>
              ✓ Message sent
            </p>
            <p style={{ margin: 0, fontFamily: F.sans, fontSize: 13, color: C.grey, lineHeight: 1.65 }}>
              We've received your inquiry and will follow up with you shortly.
            </p>
          </div>
        ) : (
          <form onSubmit={handleSubmit}>
            <div style={{ marginBottom: 16 }}>
              <label style={labelStyle}>Email address</label>
              <input
                type="email"
                required
                value={email}
                onChange={e => setEmail(e.target.value)}
                placeholder="you@company.com"
                style={inputStyle}
                onFocus={e => { e.target.style.borderColor = C.cyan; }}
                onBlur={e => { e.target.style.borderColor = C.border; }}
              />
            </div>

            <div style={{ marginBottom: 28 }}>
              <label style={labelStyle}>
                About your event{' '}
                <span style={{ color: C.mute, letterSpacing: '0.06em', textTransform: 'none' }}>— optional</span>
              </label>
              <textarea
                value={message}
                onChange={e => setMessage(e.target.value)}
                placeholder="Event name, date, venue, what you're hoping to capture..."
                rows={4}
                style={{
                  ...inputStyle,
                  fontFamily: F.sans,
                  resize: 'vertical',
                  lineHeight: 1.6,
                }}
                onFocus={e => { e.target.style.borderColor = C.cyan; }}
                onBlur={e => { e.target.style.borderColor = C.border; }}
              />
            </div>

            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16, flexWrap: 'wrap' }}>
              <button
                type="submit"
                disabled={submitting}
                style={{
                  fontFamily: F.mono,
                  fontSize: 10,
                  letterSpacing: '0.18em',
                  textTransform: 'uppercase',
                  fontWeight: 500,
                  background: submitting ? 'transparent' : C.cyan,
                  color: submitting ? C.cyan : '#0B0C0E',
                  border: `1px solid ${C.cyan}`,
                  borderRadius: 4,
                  padding: '12px 32px',
                  cursor: submitting ? 'default' : 'pointer',
                  transition: `all 180ms ${ease}`,
                  opacity: submitting ? 0.7 : 1,
                }}
                onMouseEnter={e => {
                  if (submitting) return;
                  e.currentTarget.style.background = 'transparent';
                  e.currentTarget.style.color = C.cyan;
                }}
                onMouseLeave={e => {
                  if (submitting) return;
                  e.currentTarget.style.background = C.cyan;
                  e.currentTarget.style.color = '#0B0C0E';
                }}
              >
                {submitting ? 'Sending...' : 'Send'}
              </button>
              <a
                href="mailto:hello@showgaze.app"
                style={{
                  fontFamily: F.mono,
                  fontSize: 10,
                  letterSpacing: '0.1em',
                  color: C.mute,
                  textDecoration: 'none',
                  transition: `color 140ms ${ease}`,
                }}
                onMouseEnter={e => { e.currentTarget.style.color = C.grey; }}
                onMouseLeave={e => { e.currentTarget.style.color = C.mute; }}
              >
                hello@showgaze.app
              </a>
            </div>
          </form>
        )}
      </div>
    </section>
  );
}

// ── FAQ ────────────────────────────────────────────────────────────────────
const FAQ_ITEMS = [
  {
    q: 'What does Showgaze do?',
    a: 'Showgaze helps event teams collect, sync, review, and use audience-shot footage from live events.',
  },
  {
    q: 'Is Showgaze a SaaS app?',
    a: 'No. Showgaze is currently run on a local, isolated setup. This ensures that your event data can be quality-checked and reviewed by hand during the beta testing process.',
  },
  {
    q: 'Who is Showgaze for?',
    a: 'Showgaze is designed for event organisers, venues, artists, production teams, and anyone who needs a cleaner way to work with crowd-shot footage after a show.',
  },
  {
    q: 'Does the audience need to install an app?',
    a: 'No. The workflow can be built around simple upload links or QR-code collection, depending on the event setup.',
  },
  {
    q: 'What kind of footage can be used?',
    a: 'Showgaze is designed around phone footage captured by people at the event. The best results come from footage with usable audio, stable framing, and enough coverage across the performance.',
  },
  {
    q: 'What does an event team receive?',
    a: 'Depending on the job, an event team may receive reviewed footage, synced clips, production-ready material, exports, reports, or edited video outputs.',
  },
  {
    q: 'Is Showgaze a replacement for professional camera operators?',
    a: 'No. Showgaze is designed to help make better use of audience-shot footage. It can sit beside professional production workflows rather than replacing them.',
  },
  {
    q: 'Is Showgaze a tiered service?',
    a: "Yes — Showgaze is meant to accommodate multiple levels of users from club through to event promotion. We're working hard on an end-of-tour service that conglomerates performances of individual songs across multiple locations to produce a complete music video and highlights package!",
  },
  {
    q: 'Is this AI?',
    a: 'Showgaze incorporates machine-learned tools and pipelines including a proprietary computer-vision analysis library based on over 10 years of my own music video work. But it is not an AI tool.',
  },
  {
    q: 'Is Showgaze currently available?',
    a: 'Showgaze is currently in beta. Event capacity is limited while workflows are reviewed and quality-checked by hand.',
  },
];

function FAQItem({ item, i }) {
  const [isOpen, setIsOpen] = React.useState(false);
  const contentRef = React.useRef(null);

  return (
    <div style={{
      borderTop: i === 0 ? 'none' : `1px solid ${C.border}`,
      padding: '20px 0',
    }}>
      <dt
        onClick={() => setIsOpen(!isOpen)}
        style={{
          margin: 0,
          fontFamily: F.sans,
          fontSize: 15,
          fontWeight: 500,
          lineHeight: 1.5,
          color: C.bone,
          cursor: 'pointer',
          display: 'flex',
          alignItems: 'center',
          justifyContent: 'space-between',
          gap: 20,
          transition: `color 180ms ${ease}`,
        }}
        onMouseEnter={e => e.currentTarget.style.color = C.cyan}
        onMouseLeave={e => e.currentTarget.style.color = C.bone}
      >
        <span>{item.q}</span>
        <span style={{
          fontFamily: F.mono,
          fontSize: 18,
          color: isOpen ? C.cyan : C.mute,
          transition: `transform 240ms ${ease}`,
          transform: isOpen ? 'rotate(45deg)' : 'rotate(0deg)',
          display: 'inline-block',
          width: 20,
          textAlign: 'center',
        }}>
          +
        </span>
      </dt>
      <dd
        style={{
          margin: 0,
          overflow: 'hidden',
          transition: `all 300ms ${ease}`,
          maxHeight: isOpen ? (contentRef.current?.scrollHeight || 800) : 0,
          opacity: isOpen ? 1 : 0,
        }}
      >
        <div ref={contentRef} style={{
          padding: '12px 0 16px',
          fontFamily: F.sans,
          fontSize: 15,
          lineHeight: 1.75,
          color: C.grey,
          maxWidth: 'min(860px, 100%)',
        }}>
          {item.a}
        </div>
      </dd>
    </div>
  );
}

function FAQSection() {
  return (
    <section aria-label="FAQ" style={{
      borderTop: `1px solid ${C.border}`,
    }}>
      <div style={{
        ...wrap,
        padding: '80px 0 84px',
      }}>
        <Kicker>Questions</Kicker>
        <dl style={{ margin: 0 }}>
          {FAQ_ITEMS.map((item, i) => (
            <FAQItem key={i} item={item} i={i} />
          ))}
        </dl>
      </div>
    </section>
  );
}

// ── Footer ─────────────────────────────────────────────────────────────────
function Footer() {
  return (
    <footer style={{ borderTop: `1px solid ${C.border}` }}>
      <div style={{
        ...wrap,
        padding: '22px 0 28px',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'space-between',
        flexWrap: 'wrap',
        gap: 12,
      }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 9 }}>
          <Mark size={15} />
          <span style={{ fontFamily: F.display, fontSize: 15, color: C.bone }}>Showgaze</span>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 20 }}>
          <a
            href="privacy.html"
            style={{
              fontFamily: F.mono,
              fontSize: 9,
              letterSpacing: '0.16em',
              textTransform: 'uppercase',
              color: C.mute,
              textDecoration: 'none',
              transition: `color 140ms ${ease}`,
            }}
            onMouseEnter={e => e.currentTarget.style.color = C.bone}
            onMouseLeave={e => e.currentTarget.style.color = C.mute}
          >
            Privacy
          </a>
          <a
            href="terms.html"
            style={{
              fontFamily: F.mono,
              fontSize: 9,
              letterSpacing: '0.16em',
              textTransform: 'uppercase',
              color: C.mute,
              textDecoration: 'none',
              transition: `color 140ms ${ease}`,
            }}
            onMouseEnter={e => e.currentTarget.style.color = C.bone}
            onMouseLeave={e => e.currentTarget.style.color = C.mute}
          >
            Terms
          </a>
          <span style={{
            fontFamily: F.mono,
            fontSize: 9,
            letterSpacing: '0.16em',
            textTransform: 'uppercase',
            color: C.mute,
          }}>
            © 2026 Showgaze
          </span>
        </div>
      </div>
    </footer>
  );
}



// ── Root ───────────────────────────────────────────────────────────────────
function PromoSite() {
  return (
    <div style={{ background: C.bg, color: C.bone, minHeight: '100vh' }}>
      <Header />
      <main>
        <Hero />
        <InfoRow />
        <ProcessSection />
        <FAQSection />
        <ContactForm />
      </main>
      <Footer />
    </div>
  );
}

window.PromoSite = PromoSite;
