/* global React, window */

// Helper: derive initials, stripping honorific prefixes like "Dr."
function initialsOf(name) {
  const core = name.replace(/^(Dr\.|Mr\.|Ms\.)\s+/i, '').trim();
  return core.split(/\s+/).map(w => w[0]).slice(0, 2).join('').toUpperCase();
}

function Team() {
  // Co-founders — the partnership that created HCT
  const founders = [
    {
      n: 'Ofer Vicus',
      r: 'Co-Founder & Chief Executive Officer',
      own: '~29.5%',
      edu: 'Executive MBA, Northwestern Kellogg / Tel Aviv Recanati · B.Eng Industrial Engineering, University of Sunderland',
      b: "Co-founded Aduro in 2011 after three years investigating bitumen upgrading alternatives. Twenty-plus years developing and marketing innovative technologies focused on limiting environmental impact in petrochemical processes. Built the company from concept to Nasdaq listing, managing IP strategy, government programs, and industry partnerships.",
      prior: 'VP Business Development, Curapipe Systems · VP Marketing, Qualion NMR (inline spectrometers for refineries) · Head of Business Development, Terayon',
    },
    {
      n: 'Marcus Trygstad',
      r: 'Co-Founder & Principal Scientist',
      edu: 'B.A. Chemistry, St. Olaf College · Graduate training in mechanistic organic chemistry, polymer science, and chemometrics',
      b: "Co-inventor of HCT with Dr. Jhawar. Principal inventor named across Aduro's HCT and TCD patent families. Thirty-plus years applying advanced analytical chemistry to petrochemical process automation. Presented at the International Refining & Petrochemical Conference. Credits his training in organic chemistry for giving \"sight of molecules' unseeable dance.\"",
      prior: 'Consultant, Yokogawa (advanced process technology) · Product Manager, Invensys Operations Management · Roles at SpectraSensors, ABB, Emerson',
    },
  ];

  // Executive team — the operators taking HCT from pilot to commercial scale
  const executives = [
    {
      n: 'Dr. Anil Jhawar',
      r: 'Chief Scientist',
      edu: 'PhD Chemical Engineering, Western University (2011) · M.E.Sc Western University · B.Tech Nagpur University',
      b: "Company's first employee. Co-inventor of HCT with Trygstad. Co-author of patents covering core Aduro technologies. Leading the scale-up work that supports commercialization of current technologies and driving R&D on new chemistries that expand the platform.",
      prior: 'Postdoctoral Fellow at ICFAR (Institute for Chemicals and Fuels from Alternative Resources) · Research Engineer, Western University (bio-oil upgrading, pilot-scale equipment fabrication)',
      signal: 'PhD from a leading Canadian research university with postdoc work directly in alternative fuel upgrading. Co-invented the core technology.',
    },
    {
      n: 'Eric Appelman',
      r: 'Chief Revenue Officer',
      edu: 'Chemical Engineering, University of Twente (Netherlands)',
      b: "Thirty-five-year career in chemicals. Most recently EVP Business Development & CTO at Brightlands Chemelot Campus, Europe's largest industrial innovation environment for the chemical industry. During six years at Chemelot, evaluated hundreds of plastic-recycling technologies before choosing to join Aduro, calling HCT \"one of the most exciting.\" Based in the Netherlands at the FOAK site.",
      prior: 'EVP Innovation & Strategy, Perstorp · Technical Director, Sigma Coatings · Unilever (edible oils) · Non-executive director, Deflamo and Svenska Aerogel',
      signal: "Evaluated hundreds of competing technologies at Europe's premier chemical innovation campus. Chose to leave that position for Aduro. The strongest competitive due-diligence signal available.",
    },
    {
      n: 'David Weizenbach',
      r: 'Chief Operating Officer',
      edu: 'University of Alberta',
      b: "Twenty-five-plus years of leadership in heavy industry, most notably contributing to NOVA Chemicals' rise as one of the world's premier-performing polyethylene facilities. Pioneered operations strategy and alarm-management techniques now considered industry standards. Expertise spans engineering, turnarounds, reliability, automation, operations, maintenance, emergency response, and regulatory compliance.",
      signal: "Left one of the world's top polyethylene producers for Aduro. His operational expertise is exactly what's needed to take HCT from pilot to commercial scale.",
    },
    {
      n: 'Mena Beshay',
      r: 'Chief Financial Officer',
      edu: 'CPA · CMA · CPA (US) · CFE — four professional certifications · Trilingual',
      b: 'Twenty-plus years in financial leadership. Previously CFO & Global Head of Corporate Development at CloudMD Software & Services (public company), leading financial reporting, auditing, treasury, legal, and corporate development across North America and Europe.',
      prior: 'Deloitte · Ernst & Young · Domtar · Enercare',
      signal: 'Four certifications plus Big Four training. Public-company CFO experience through capital raises and corporate development.',
    },
    {
      n: 'Dr. Arturo Gomez',
      r: 'VP of Engineering',
      edu: 'PhD Chemical and Petroleum Engineering, University of Calgary · Licensed Professional Engineer (P.Eng.)',
      b: 'Twenty-plus years in process improvement, project management, and scaling chemical processes. Led teams commercializing new technologies and optimizing manufacturing for specialty chemicals, renewable fuels, and high-performance polymers. Six Sigma and Lean Manufacturing expertise.',
      prior: 'Senior engineering roles at MilliporeSigma (Merck KGaA) · Bartek Ingredients',
      signal: 'PhD + P.Eng. with specific experience scaling chemical processes from pilot to commercial. The engineering bridge between lab results and operating plants.',
    },
    {
      n: 'Dr. Birendra Adhikari',
      r: 'Head of Research & Development',
      edu: 'PhD Organic Chemistry · 30 scientific articles, papers, and book chapters',
      b: "Accomplished organic chemist with multidisciplinary expertise in organic, analytical, and applied chemistry. Central to the development and improvement of core HCT technology and discovery of innovative new chemistries that expand the platform. Named in Aduro's Nasdaq listing announcement as a key contributor to the technology.",
      signal: 'Published researcher driving both core technology improvement and new chemistry discovery for platform expansion.',
    },
  ];

  // Supporting leadership — finance, IR, marketing depth
  const supporting = [
    {
      n: 'Abe Dyck',
      r: 'Head of Corporate Development / Investor Relations',
      b: 'Co-founded Methes Energies (listed on Nasdaq via RTO) and Cleantechonomics Energy ($2M raise, waste-to-energy). Twenty-plus years across traditional and renewable energy. Has executed this commercialization journey before.',
    },
    {
      n: 'Neha Nisar',
      r: 'VP of Finance',
      b: 'Chartered Accountant. Twenty-plus years at PwC, KPMG (seven years), Marriott International, Canada Goose, and MEDNOW, where she played a pivotal role in a complex acquisition process.',
    },
    {
      n: 'Stefanie Steenhuis',
      r: 'Head of Brand & Marketing',
      b: 'International B2B marketing executive. Prior roles at IBM, Siemens, Ecolab, and ThyssenKrupp. Joined Aduro to position the brand for market entry.',
    },
  ];

  // Independent board — governance, capital markets, industry credibility
  const board = [
    {
      n: 'Marie Grönborg',
      r: 'Independent Director',
      edu: 'M.Sc. Chemical Engineering',
      b: 'Nearly three decades in chemical and clean-tech industries. CEO of TreeToTextile (sustainable fiber production). CEO of Purac (water treatment/biogas). EVP at Perstorp (specialty chemicals). Current board seats: SSAB (fossil-free steel), Permascand (green transition), Eolus (renewable energy).',
      signal: 'Three decades of chemical-industry leadership at the sustainability intersection. Board seats at companies pioneering fossil-free steel and renewable energy.',
    },
    {
      n: 'Peter Kampian',
      r: 'Independent Director · Audit Committee Chair',
      edu: 'CPA · CA · ICD.D Director Designation · Business Degree, Wilfrid Laurier University',
      b: 'Former CFO of Algonquin Income Fund (now Algonquin Power & Utilities, TSX:AQN, $10B+ utility). Led Mettrum Health Corp to public listing in 2014 and its $430M acquisition by Canopy Growth in 2017. CRO for companies navigating CCAA restructuring. Audit chair at Harborside Inc. and Red Pine Exploration.',
      signal: 'Built and sold a company for $430M. Former CFO of what became a $10B+ utility. Deep public-company financial governance experience.',
    },
    {
      n: 'James E. Scott',
      r: 'Independent Director',
      edu: 'Summa Cum Laude, Boston University School of Management (Finance & Operations Management)',
      b: 'Managing Partner of The Scott Company LLC (advisory and merchant bank) since 1998. Career started at Salomon Brothers (investment banking), then SBC Warburg in London. Managing Partner at Littlehorn Investments. Two decades of transaction, operating, and leadership experience across business scales.',
      signal: 'Salomon Brothers and SBC Warburg pedigree. Two decades running a merchant bank. Brings capital-markets expertise and deal-making experience.',
    },
  ];

  // ---------- RENDER HELPERS ----------
  const avatar = (name) => (
    <div style={{
      width: 44, height: 44, borderRadius: 6,
      background: 'linear-gradient(135deg, var(--bg-3), var(--bg-2))',
      border: '1px solid var(--line)', flexShrink: 0,
      display: 'grid', placeItems: 'center',
      fontFamily: 'var(--serif)', fontSize: 16, color: 'var(--fg-2)',
    }}>
      {initialsOf(name)}
    </div>
  );

  const FullCard = ({ p, showSignal }) => (
    <div style={{ background: 'var(--bg-1)', border: '1px solid var(--line)', borderRadius: 6, padding: 18 }}>
      <div style={{ display: 'flex', gap: 14, alignItems: 'flex-start', marginBottom: 10 }}>
        {avatar(p.n)}
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ display: 'flex', alignItems: 'baseline', gap: 8, flexWrap: 'wrap' }}>
            <div style={{ fontSize: 15, fontWeight: 500, color: 'var(--fg-0)', letterSpacing: '-0.01em' }}>{p.n}</div>
            {p.own && (
              <span className="chip" style={{ color: 'var(--warn)', borderColor: 'var(--warn)', background: 'var(--warn-bg)' }}>
                {p.own} ownership
              </span>
            )}
          </div>
          <div style={{ fontSize: 11, color: 'var(--accent)', fontFamily: 'var(--mono)', textTransform: 'uppercase', letterSpacing: '0.06em', marginTop: 2 }}>
            {p.r}
          </div>
        </div>
      </div>
      {p.edu && (
        <div style={{ fontSize: 11, color: 'var(--fg-2)', fontFamily: 'var(--mono)', marginBottom: 10, paddingBottom: 10, borderBottom: '1px solid var(--line)', lineHeight: 1.5 }}>
          {p.edu}
        </div>
      )}
      <div style={{ fontSize: 12.5, color: 'var(--fg-1)', lineHeight: 1.6, marginBottom: p.prior || (showSignal && p.signal) ? 10 : 0 }}>
        {p.b}
      </div>
      {p.prior && (
        <div style={{ fontSize: 11, color: 'var(--fg-3)', lineHeight: 1.55, marginBottom: showSignal && p.signal ? 10 : 0 }}>
          <span style={{ fontFamily: 'var(--mono)', textTransform: 'uppercase', letterSpacing: '0.06em', color: 'var(--fg-4)', marginRight: 6 }}>Prior</span>
          {p.prior}
        </div>
      )}
      {showSignal && p.signal && (
        <div style={{ marginTop: 4, padding: 10, background: 'var(--accent-bg)', borderLeft: '2px solid var(--accent)', borderRadius: 3 }}>
          <div style={{ fontSize: 10, fontFamily: 'var(--mono)', color: 'var(--accent)', textTransform: 'uppercase', letterSpacing: '0.08em', marginBottom: 4 }}>Investor Signal</div>
          <div style={{ fontSize: 12, color: 'var(--fg-1)', lineHeight: 1.55 }}>{p.signal}</div>
        </div>
      )}
    </div>
  );

  const CompactCard = ({ p }) => (
    <div style={{ background: 'var(--bg-1)', border: '1px solid var(--line)', borderRadius: 6, padding: 16 }}>
      <div style={{ fontSize: 14, color: 'var(--fg-0)', fontWeight: 500, letterSpacing: '-0.01em' }}>{p.n}</div>
      <div style={{ fontSize: 10, color: 'var(--accent)', fontFamily: 'var(--mono)', textTransform: 'uppercase', letterSpacing: '0.06em', marginTop: 2, marginBottom: 8 }}>{p.r}</div>
      <div style={{ fontSize: 12, color: 'var(--fg-2)', lineHeight: 1.55 }}>{p.b}</div>
    </div>
  );

  return (
    <div>
      <div className="prose" style={{ maxWidth: '74ch', marginBottom: 32 }}>
        <p>
          Three PhDs in chemistry and engineering. Four professional certifications on the finance side. A Kellogg MBA at the helm. A Chief Revenue Officer who evaluated hundreds of competing technologies at Europe's largest chemical-innovation campus before choosing to join. A COO from one of the world's premier polyethylene producers. Combined insider ownership of 34–36% aligns management with multi-year commercialization rather than quarter-to-quarter activity.
        </p>
      </div>

      <div className="team-stats" style={{ marginBottom: 36 }}>
        {[
          { l: 'PhDs', v: '3', s: 'Chemistry & Engineering', c: 'var(--accent)' },
          { l: 'Company Patents', v: '10+', s: '7 granted · 3 pending · CIP', c: 'var(--accent)' },
          { l: 'Insider Ownership', v: '~35%', s: 'CEO at ~29.5%', c: 'var(--warn)' },
          { l: 'Combined Experience', v: '200+ yrs', s: 'Across leadership team', c: 'var(--pos)' },
        ].map((s, i) => (
          <div key={i} className="minibox" style={{ borderTop: `2px solid ${s.c}` }}>
            <div className="card-label">{s.l}</div>
            <div className="num" style={{ fontSize: 26, color: s.c, marginTop: 4 }}>{s.v}</div>
            <div style={{ fontSize: 11, color: 'var(--fg-3)', marginTop: 4 }}>{s.s}</div>
          </div>
        ))}
      </div>

      <div className="card-label" style={{ marginBottom: 14 }}>Co-Founders</div>
      <div className="team-2col" style={{ marginBottom: 36 }}>
        {founders.map((p, i) => <FullCard key={i} p={p} showSignal={false} />)}
      </div>

      <div className="card-label" style={{ marginBottom: 14 }}>Executive Team</div>
      <div className="team-2col" style={{ marginBottom: 36 }}>
        {executives.map((p, i) => <FullCard key={i} p={p} showSignal={true} />)}
      </div>

      <div className="card-label" style={{ marginBottom: 14 }}>Supporting Leadership</div>
      <div className="team-3col" style={{ marginBottom: 36 }}>
        {supporting.map((p, i) => <CompactCard key={i} p={p} />)}
      </div>

      <div className="card-label" style={{ marginBottom: 14 }}>Independent Board of Directors</div>
      <div className="team-3col" style={{ marginBottom: 36 }}>
        {board.map((p, i) => <FullCard key={i} p={p} showSignal={true} />)}
      </div>

      <div className="rule" />

      <div className="card-label" style={{ marginBottom: 12 }}>Ownership Structure</div>
      <div className="team-stats">
        {[
          { l: 'CEO', v: '~29.5%', s: 'Ofer Vicus' },
          { l: 'Total Insiders', v: '34–36%', s: 'Management + board' },
          { l: 'Institutional', v: '~1.6%', s: 'Upside on milestones' },
          { l: 'Retail & Float', v: '~63%', s: 'High conviction base' },
        ].map((s, i) => (
          <div key={i} className="minibox">
            <div className="card-label">{s.l}</div>
            <div className="num" style={{ fontSize: 22, color: 'var(--fg-0)', marginTop: 4 }}>{s.v}</div>
            <div style={{ fontSize: 11, color: 'var(--fg-3)', marginTop: 4 }}>{s.s}</div>
          </div>
        ))}
      </div>
    </div>
  );
}

window.Team = Team;
