// Home page — /

const HOME_LINES = [
  { t: [{ s: 'const ', c: 'keyword' }, { s: 'adithya', c: 'fn' }, { s: ' = {', c: 'key' }] },
  { t: [{ s: '  role: ', c: 'key' }, { s: "'fpga + hardware'", c: 'string' }, { s: ',', c: 'key' }] },
  { t: [{ s: '  now: ', c: 'key' }, { s: "'kaleideo space'", c: 'string' }, { s: ',', c: 'key' }] },
  { t: [{ s: '  before: ', c: 'key' }, { s: "['isro', 'polytechnique', 'libre-space']", c: 'list' }, { s: ',', c: 'key' }] },
  { t: [{ s: '  loves: ', c: 'key' }, { s: "'where abstractions leak'", c: 'string' }, { s: ',', c: 'key' }] },
  { t: [{ s: '  city: ', c: 'key' }, { s: "'bengaluru'", c: 'string' }, { s: ',', c: 'key' }] },
  { t: [{ s: '};', c: 'key' }] },
  { t: [] },
  { t: [{ s: 'adithya', c: 'fn' }, { s: '.', c: 'key' }, { s: 'ship', c: 'keyword' }, { s: '()', c: 'key' }, { s: ';', c: 'key' }, { s: '   // ← typing now', c: 'comment' }] },
];

// Each employer lists this many projects here; the rest are on its own page.
const HOME_PROJECTS_PER_ORG = 3;
const HOME_POSTS = 5;

function HomePage() {
  return (
    <div className="page" data-page="home">
      <section className="hero">
        <div className="hero-text">
          <h1>Hi! I’m Adithya, a hardware and FPGA engineer.</h1>
          <p className="lede">
            I make silicon fly to space, and write about the parts that don’t quite work yet. These days that means
            FPGAs for Earth-observation payloads at <a className="link-accent" href="/experience/kaleideo/">KaleidEO</a>,
            after three years on flight hardware at <a className="link-accent" href="/experience/isro/">ISRO</a>.
          </p>
          <div className="dev-only dev-box">
            <span className="kicker">[DEV] PAGE</span> /index · 92% built · 100% left to build
            {BUILD && <> · last edit {BUILD.hash} · {timeAgo(BUILD.time)}</>}
          </div>
        </div>

        {/* Shown only in sudo dev mode (type `sudo` anywhere). */}
        <div className="hero-side dev-only">
          <CodeWindow file="adithya.tsx" lines={HOME_LINES} />
        </div>
      </section>

      <section className="section">
        <h2 className="section-title">Experience</h2>
        <ul className="exp">
          {ORGS.map((org) => {
            const projects = projectsForOrg(org.id);
            const more = projects.length - HOME_PROJECTS_PER_ORG;
            return (
              <li key={org.id}>
                <div className="exp-head">
                  <a className="exp-name plain-link" href={`/experience/${org.id}/`}>{org.name}</a>
                  <span className="dates">{fmtWindow(org.window)}</span>
                </div>
                <div className="exp-role">{org.role}</div>
                <ul className="exp-projects">
                  {projects.slice(0, HOME_PROJECTS_PER_ORG).map((proj) => (
                    <li key={proj.id}><a className="plain-link" href={`/experience/${proj.id}/`}>{proj.name}</a></li>
                  ))}
                  {more > 0 && (
                    <li><a className="more-link" href={`/experience/${org.id}/`}>and {more} more</a></li>
                  )}
                </ul>
              </li>
            );
          })}
        </ul>
      </section>

      <section className="section">
        <h2 className="section-title">Writing</h2>
        <ul className="dated">
          {POSTS.slice(0, HOME_POSTS).map((p) => (
            <li key={p.id}>
              <span className="date">{p.date}</span>
              <a className="plain-link" href={`/writing/${p.id}/`}>{p.title}</a>
            </li>
          ))}
        </ul>
        <a className="more-link" href="/writing/">All {POSTS.length} posts →</a>
      </section>

      <div className="dev-only dev-box">
        <span className="kicker">[dev] utilisation</span>
        {[
          { k: '/', v: '92%' },
          { k: '/writing', v: '78%' },
          { k: 'iprune', v: '— · imported' },
        ].map((r, i) => (
          <div key={i} style={{ display: 'flex', justifyContent: 'space-between', marginTop: 4 }}>
            <span style={{ color: 'var(--sk-carrot-strong)' }}>{r.k}</span>
            <span style={{ color: 'var(--sk-ink-soft)' }}>{r.v}</span>
          </div>
        ))}
      </div>
    </div>
  );
}

Object.assign(window, { HomePage });
