const TALLY = 'https://tally.so/r/PdkYb0';
const AS = 'https://illegibleweb.vercel.app/assets/';
const IMG = (f) => `${AS}imagery/${f}`;

function Nav({ route, go }) {
  const [open, setOpen] = React.useState(false);
  const items = [['/community', 'Community & Residency'], ['/research', 'Research'], ['/team', 'Founding Team']];
  const nav = (to) => { setOpen(false); go(to); };
  return (
    <header className="nav">
      <a className="wordmark" onClick={() => nav('/')}>in&mdash;between</a>
      <button className="burger" onClick={() => setOpen(!open)}>{open ? 'Close' : 'Menu'}</button>
      <nav className={'nav-links' + (open ? ' open' : '')}>
        {items.map(([to, l]) => <a key={to} className={route === to ? 'on' : ''} onClick={() => nav(to)}>{l}</a>)}
      </nav>
    </header>
  );
}

function Btn({ children, href, onClick, kind = '', wide }) {
  const cls = `btn ${kind} ${wide ? 'wide' : ''}`;
  if (kind === 'soon') return <span className={cls}>{children}</span>;
  return (
    <a className={cls} href={href} onClick={onClick} target={href ? '_blank' : undefined} rel="noopener noreferrer">
      <span>{children}</span><span className="ar">&rarr;</span>
    </a>
  );
}

function Paths() {
  return (
    <div className="paths">
      <div className="path">
        <div className="tag"><span className="n">1</span><span className="eyebrow">Community</span></div>
        <h3>Exploration</h3>
        <p>Dinners, walks and studio days with people who stepped off the beaten path on purpose.</p>
        <Btn href={TALLY} kind="solid" wide>Join the community</Btn>
      </div>
      <div className="path">
        <div className="tag"><span className="n">2</span><span className="eyebrow">Residency</span></div>
        <h3>Building</h3>
        <p>Space, funding and a small crew for the thing you can&rsquo;t stop thinking about.</p>
        <Btn kind="soon" wide>Residency applications open soon</Btn>
      </div>
    </div>
  );
}

function Supporters() {
  return (
    <div className="sup">
      <span className="eyebrow">Supported by</span>
      <img src={AS + 'logo/openai-logo.svg'} alt="OpenAI" style={{ height: '22px' }} />
      <img src={AS + 'logo/anthropic-logo.svg'} alt="Anthropic" style={{ height: '13px' }} />
    </div>
  );
}

Object.assign(window, { Nav, Btn, Paths, Supporters, TALLY, IMG });
