// Motion graphic — 45s hero reveal (iframe'd)

const VideoPlaceholder = () => {
  return (
    <div style={{
      background: 'var(--ink)', color: 'var(--paper)',
      border: '1px solid var(--rule-light)',
      position: 'relative',
      aspectRatio: '16 / 9',
      overflow: 'hidden'
    }}>
      <iframe
        src="motion/Concept Outbound Hero Motion.html"
        title="Concept Outbound — Hero Motion Graphic"
        loading="lazy"
        style={{
          position:'absolute', inset: 0, width:'100%', height:'100%',
          border: 0, display:'block', background:'var(--ink)'
        }}
      />

      {/* Corner crop marks — kept for editorial signature */}
      {[
        {top:10,left:10,r:'0deg'},{top:10,right:10,r:'90deg'},
        {bottom:10,right:10,r:'180deg'},{bottom:10,left:10,r:'270deg'}
      ].map((p,i)=>(
        <span key={i} aria-hidden style={{
          position:'absolute', ...p, width:12, height:12,
          borderTop:'1px solid var(--accent)', borderLeft:'1px solid var(--accent)',
          transform:`rotate(${p.r})`, zIndex: 2, pointerEvents:'none'
        }}/>
      ))}
    </div>
  );
};

const SignalTimeline = () => {
  const reduced = React.useRef(window.matchMedia('(prefers-reduced-motion: reduce)').matches);
  const [activeStage, setActiveStage] = React.useState(0); // 0..4 (4 = all lit)

  const stages = [
    { key: 'watch',    ts: 'APR 08 · 09:14', label: 'Signal detected', sub: 'Ramp · ICP news match · "embedded risk tooling" launch', source: 'src: exa.news' },
    { key: 'verify',   ts: 'APR 08 · 09:41', label: 'Signal verified', sub: 'Cross-checked PredictLeads · freshness 6h · confidence 0.91', source: 'src: predictleads' },
    { key: 'contact',  ts: 'APR 08 · 14:22', label: 'Contact resolved', sub: 'VP Risk · Sofia M. · email verified · scored for signal shape', source: 'Contact Forge' },
    { key: 'send',     ts: 'APR 09 · 07:03', label: 'Claim-traced email sent', sub: '4 claims · 4 source fields · 0 fabricated', source: 'Message Mill → Smartlead' },
    { key: 'reply',    ts: 'APR 09 · 11:17', label: 'Reply',            sub: '"Yes, let\u2019s talk. Thursday works."', source: 'meeting booked · +4h 14m' },
  ];

  React.useEffect(() => {
    if (reduced.current) { setActiveStage(stages.length); return; }
    let timeouts = [];
    const run = () => {
      setActiveStage(0);
      stages.forEach((_, i) => {
        timeouts.push(setTimeout(() => setActiveStage(i + 1), 700 + i * 900));
      });
    };
    run();
    const loop = setInterval(run, 700 + stages.length * 900 + 5500);
    return () => { timeouts.forEach(clearTimeout); clearInterval(loop); };
  }, []);

  return (
    <div style={{
      background:'var(--ink)', color:'var(--paper)',
      border:'1px solid var(--rule-light)', position:'relative'
    }}>
      {/* Header */}
      <div style={{display:'flex', justifyContent:'space-between', alignItems:'flex-start', gap: 16,
                   padding:'22px 28px 18px', borderBottom:'1px solid var(--rule-light)'}}>
        <div style={{display:'flex', flexDirection:'column', gap:4}}>
          <div className="mono" style={{fontSize:10, letterSpacing:'0.16em', textTransform:'uppercase', color:'var(--mute-on-ink)', display:'flex', alignItems:'center', gap:8}}>
            <span className="teal-dot" style={{width:6, height:6}}></span>
            One account · One signal · End-to-end
          </div>
          <div className="mono" style={{fontSize:11, color:'var(--mute-on-ink)'}}>
            tam.watch &nbsp;→&nbsp; Ramp &nbsp;·&nbsp; fintech lenders &nbsp;·&nbsp; April 8–9
          </div>
        </div>
        <div className="mono" style={{fontSize:10, letterSpacing:'0.14em', color:'var(--mute-on-ink)'}}>
          <span className="blink">●</span> TIMING · SOLVED
        </div>
      </div>

      {/* Dominant number: signal → reply interval */}
      <div style={{display:'grid', gridTemplateColumns:'auto 1fr', alignItems:'end', gap: 28,
                   padding:'28px 28px 22px'}}>
        <div>
          <span className="mono" style={{fontSize:10, letterSpacing:'0.14em', textTransform:'uppercase', color:'var(--mute-on-ink)'}}>
            Signal → Reply
          </span>
          <div style={{display:'flex', alignItems:'baseline', gap: 10, marginTop: 4}}>
            <span style={{
              fontFamily:'var(--serif)', fontSize: 72, lineHeight: 1,
              letterSpacing:'-0.03em',
              color: 'var(--accent)',
              fontFeatureSettings:'"tnum"',
              fontVariationSettings:'"opsz" 72'
            }}>26h</span>
            <span style={{fontFamily:'var(--serif)', fontSize: 26, color:'var(--paper)', opacity:0.55, letterSpacing:'-0.02em'}}>
              03m
            </span>
          </div>
          <span className="sig" style={{color:'var(--mute-on-ink)', marginTop: 4, display:'inline-block'}}>
            ↳ From in-market moment to "Thursday works."
          </span>
        </div>
        <div style={{display:'flex', flexDirection:'column', alignItems:'flex-end', gap: 4}}>
          <span className="mono" style={{fontSize:10, letterSpacing:'0.14em', color:'var(--mute-on-ink)', textTransform:'uppercase'}}>
            The sequence →
          </span>
          <span className="sig" style={{color:'var(--mute-on-ink)', maxWidth: 320, textAlign:'right'}}>
            Same five steps every week. The timing is what the sequence is solving for.
          </span>
        </div>
      </div>

      {/* The rail */}
      <div style={{padding:'18px 28px 32px', position:'relative'}}>
        {/* Horizontal rule behind the dots */}
        <div aria-hidden style={{
          position:'absolute', top: 40, left: '6%', right: '6%', height: 1,
          background:'var(--rule-light)'
        }} />
        {/* Progress fill */}
        <div aria-hidden style={{
          position:'absolute', top: 40, left: '6%',
          width: `calc(${Math.max(0, activeStage - 1) / (stages.length - 1) * 88}%)`,
          height: 1, background:'var(--accent)',
          transition:'width 500ms ease-out'
        }} />

        <div className="timeline-stages" style={{display:'grid', gridTemplateColumns:`repeat(${stages.length}, 1fr)`, gap: 12}}>
          {stages.map((s, i) => {
            const lit = activeStage > i;
            const current = activeStage === i + 1;
            return (
              <div key={s.key} style={{display:'flex', flexDirection:'column', gap: 8, position:'relative'}}>
                {/* Timestamp (above dot) */}
                <span className="mono" style={{
                  fontSize: 10, letterSpacing:'0.1em',
                  color: lit ? 'var(--accent)' : 'var(--mute-on-ink)',
                  opacity: lit ? 1 : 0.5,
                  transition:'color 300ms, opacity 300ms'
                }}>
                  {s.ts}
                </span>
                {/* Dot */}
                <div style={{position:'relative', height: 14, display:'flex', alignItems:'center'}}>
                  <span aria-hidden style={{
                    width: lit ? 12 : 8, height: lit ? 12 : 8, borderRadius:'50%',
                    background: lit ? 'var(--accent)' : 'var(--ink)',
                    border: `1px solid ${lit ? 'var(--accent)' : 'var(--rule-light)'}`,
                    boxShadow: current ? '0 0 0 6px color-mix(in oklab, var(--accent) 22%, transparent)' : 'none',
                    transition: 'all 300ms'
                  }}/>
                </div>
                {/* Label */}
                <span style={{
                  fontFamily:'var(--serif)', fontSize: 18, lineHeight: 1.15,
                  letterSpacing:'-0.015em',
                  color: lit ? 'var(--paper)' : 'var(--paper)',
                  opacity: lit ? 1 : 0.45,
                  transition:'opacity 300ms'
                }}>
                  {s.label}
                </span>
                {/* Sub */}
                <span className="mono" style={{
                  fontSize: 10.5, lineHeight: 1.5, color:'var(--paper)',
                  opacity: lit ? 0.72 : 0.3, transition:'opacity 300ms'
                }}>
                  {s.sub}
                </span>
                {/* Source tag */}
                <span className="mono" style={{
                  fontSize: 9.5, letterSpacing:'0.08em', color:'var(--accent)',
                  opacity: lit ? 0.9 : 0.3,
                  transition:'opacity 300ms'
                }}>
                  ↳ {s.source}
                </span>
              </div>
            );
          })}
        </div>
      </div>

      {/* Badge */}
      <div style={{
        position: 'absolute', right: 20, bottom: 20,
        border: '1px solid var(--accent)', color: 'var(--accent)',
        padding: '5px 10px', fontFamily:'var(--mono)', fontSize: 10,
        letterSpacing:'0.14em', textTransform:'uppercase',
        display:'flex', alignItems:'center', gap: 6,
        background:'var(--ink)'
      }}>
        <span style={{width:6, height:6, background:'var(--accent)', borderRadius:'50%'}}></span>
        0 fabricated claims
      </div>
    </div>
  );
};

const Hero = () => {
  return (
    <section id="top" className="paper" style={{paddingTop: 130, paddingBottom: 80, position:'relative'}}>
      <div className="wrap">
        {/* Headline + subline */}
        <div style={{maxWidth: 1280}}>
          <h1 className="display" style={{
            fontSize: 'clamp(48px, 7.6vw, 124px)',
            margin: 0,
            marginBottom: 36,
            letterSpacing: '-0.03em',
            textWrap: 'balance'
          }}>
            An in-market<br/>
            outbound pipeline, <em style={{color:'var(--accent-deep)'}}>not</em><br/>
            another cold-list spray.
          </h1>

          <div className="hero-subgrid" style={{display:'grid', gridTemplateColumns:'1fr 1fr', gap: 48, marginBottom: 56, alignItems:'end'}}>
            <p style={{
              fontFamily:'var(--sans)',
              fontSize: 22,
              lineHeight: 1.4,
              maxWidth: 560,
              margin: 0,
              color: 'var(--ink)',
              fontWeight: 400,
              letterSpacing: '-0.01em'
            }}>
              Most outbound starts with a list and hunts for signals.
              We start with your TAM and send only when a signal fires.
              <span style={{color:'var(--ink)', fontStyle:'italic', fontFamily:'var(--serif)'}}> The TAM is the moat.</span>
            </p>
            <div style={{display:'flex', flexDirection:'column', gap: 16, alignItems:'flex-start'}}>
              <div style={{display:'flex', gap: 4, alignItems:'center'}}>
                <a href="#cta" style={{
                  background:'var(--ink)', color:'var(--paper)',
                  padding:'16px 26px', fontFamily:'var(--mono)', fontSize: 13,
                  letterSpacing:'0.08em', textTransform:'uppercase',
                  display:'inline-flex', alignItems:'center', gap: 10,
                  transition:'background 150ms'
                }}
                onMouseOver={e=>e.currentTarget.style.background='var(--accent-deep)'}
                onMouseOut={e=>e.currentTarget.style.background='var(--ink)'}
                >
                  Book a pilot · From $1,500
                  <svg width="14" height="10" viewBox="0 0 14 10" fill="none"><path d="M1 5h12m0 0L9 1m4 4L9 9" stroke="currentColor" strokeWidth="1.2"/></svg>
                </a>
                <a href="#mechanism" style={{
                  padding:'16px 22px', fontFamily:'var(--mono)', fontSize: 13,
                  letterSpacing:'0.08em', textTransform:'uppercase',
                  border:'1px solid var(--ink)', color:'var(--ink)',
                  display:'inline-flex', alignItems:'center', gap: 10
                }}>
                  See a live test
                </a>
              </div>
              <span className="sig" style={{fontStyle:'normal'}}>
                Pilots from $1,500 · Fixed-term, no retainer · Delivered by Travis Ross
              </span>
            </div>
          </div>
        </div>

        {/* Motion graphic placeholder — drop the video in when ready */}
        <VideoPlaceholder />

        {/* Signature line under */}
        <div style={{display:'flex', justifyContent:'space-between', alignItems:'center', marginTop: 18}}>
          <span className="sig">
            ↳ One real account, one real signal, end-to-end. This is what "in the window" looks like.
          </span>
          <span className="sig">04 : 09 : 2026</span>
        </div>
      </div>
    </section>
  );
};

// Proof strip — ink background, single line of evidence
const ProofStrip = () => (
  <section className="proof-section ink" style={{padding: '48px 0'}}>
    <div className="wrap">
      <div className="proof-grid" style={{display:'grid', gridTemplateColumns:'repeat(3, 1fr)', gap: 48, alignItems:'start'}}>
        <Proof
          number="$2M"
          label="close"
          body="Messaging I wrote contributed to a $2M close."
          sig="client-reference"
        />
        <Proof
          number="14/40/0"
          label="signals · emails · fabricated"
          body="April 12 live test. 14 signals fired, 40 emails queued, zero fabricated claims."
          sig="live-test"
        />
        <Proof
          number="574"
          label="accounts"
          body="574 unique companies scanned across our own TAM in a month of runs."
          sig="ongoing-production"
        />
      </div>
    </div>
  </section>
);

const Proof = ({ number, label, body, sig }) => (
  <div style={{display:'flex', flexDirection:'column', gap: 10}}>
    <div style={{display:'flex', alignItems:'baseline', gap: 12}}>
      <span style={{fontFamily:'var(--serif)', fontSize: 56, lineHeight: 1, letterSpacing:'-0.03em', fontVariationSettings:'"opsz" 144'}}>{number}</span>
      <span className="mono" style={{fontSize:10, letterSpacing:'0.14em', textTransform:'uppercase', color:'var(--mute-on-ink)'}}>{label}</span>
    </div>
    <p style={{margin:0, fontSize:17, lineHeight:1.45, color:'var(--paper)', maxWidth: 340}}>{body}</p>
    <span className="sig">·&nbsp;{sig}</span>
  </div>
);

Object.assign(window, { Hero, ProofStrip, SignalTimeline, VideoPlaceholder });
