// Components for Motawea portfolio

const { useState, useEffect, useRef, useMemo } = React;

// ===== Data =====
const ROLES = [
  "Lead Unity Engineer",
  "Unity Certified Professional",
  "AR/VR Engineer",
  "Engineering Manager",
];

const SERVICES = [
  { glyph: "◈", title: "Game Development", desc: "Unity expert with 12+ years creating immersive games and simulations across mobile, PC, and console platforms." },
  { glyph: "◐", title: "XR Development", desc: "Advanced AR/VR solutions for entertainment, education, and enterprise using cutting-edge XR technologies." },
  { glyph: "▣", title: "Technical Leadership", desc: "Engineering management, architecture design, team guidance, and strategic technical decision-making." },
  { glyph: "⬢", title: "Optimization", desc: "Performance profiling, code review, memory management, and asset optimization for maximum efficiency." },
];

const EDUCATION = [
  { date: "2026", title: "Unity Certified Professional Programmer", org: "Unity Technologies", desc: "Unity's highest-level programming certification — engine internals, scalable framework design, memory management, and technical leadership." },
  { date: "2023", title: "Unity Certified Expert Programmer", org: "Unity Technologies", desc: "Advanced certification: deep C# expertise, system architecture, performance optimization, production Unity development." },
  { date: "2013", title: "B.Eng. Computers & Control Systems", org: "Mansoura University", desc: "Strong foundation in computer science, algorithms, and systems design." },
];

const EXPERIENCE = [
  { date: "Aug 2023 — Present", title: "Lead Unity Engineer", org: "Visionaries FZ-LLC · Dubai", desc: "Led technical architecture for a simulation project with 3 engineers, 1 tester, 1 artist. Optimized 600+ active NPCs from 25→60 FPS. Released on Steam with 85% positive reviews and an educational edition adopted by three UAE universities." },
  { date: "Nov 2022 — Aug 2023", title: "AR Developer / EM", org: "Pretia Technologies · Tokyo", desc: "Led entertainment & media division of 5 engineers. Delivered 5+ AR products, implemented advanced AR mechanics, evaluated 15+ technical proposals for architectural feasibility." },
  { date: "May 2020 — Nov 2022", title: "Lead Unity Engineer", org: "Backlot Studio · California", desc: "Led team of 8 engineers building a collaborative filmmaking app. Designed Addressables system managing 2TB+ assets while keeping the app under 1GB. Built custom Editor tooling reducing integration by 16 hours per scene." },
  { date: "2018 — 2020", title: "Senior Unity Developer", org: "Ground Fall Games / Elibre DMCC", desc: "Shipped a VR MOBA with AI systems and Photon networking; built interior-design tools with custom editor automation." },
];

const SKILLS = [
  { name: "Unity Engine", v: 95 },
  { name: "C# Programming", v: 95 },
  { name: "Game Architecture", v: 90 },
  { name: "XR (AR/VR)", v: 85 },
  { name: "OOP / Design Patterns", v: 92 },
  { name: "Performance Optimization", v: 92 },
  { name: "Addressables", v: 85 },
  { name: "Photon Networking", v: 80 },
  { name: "Azure Cloud Services", v: 70 },
  { name: "Custom Editor Tools", v: 85 },
];

const PROJECTS = [
  {
    id: "BH-01",
    slug: "business-heroes",
    name: "Business Heroes",
    tag: "Games",
    filter: "games",
    mono: "BH",
    role: "Lead Unity Engineer / CTO",
    org: "Visionaries FZ-LLC",
    period: "Aug 2023 — Present",
    oneliner: "Business education simulation with realistic financial systems, released on Steam.",
    stats: [
      { sv: "600+", sk: "Active NPCs" },
      { sv: "25→60", sk: "FPS Optimized" },
      { sv: "85%", sk: "Positive Reviews" },
    ],
    tags: ["Unity", "C#", "Advanced OOP", "Simulation", "Addressables", "Optimization"],
    bullets: [
      "Led technical architecture for a simulation project with <b>3 engineers, 1 tester, 1 artist</b>.",
      "<b>Optimized 600+ active NPCs</b> improving FPS from 25 to 60 via ECS-aware patterns and draw-call reduction.",
      "<b>Released on Steam with 85% positive reviews</b>; delivered an educational edition adopted by three UAE universities.",
      "Designed a persistence layer that survives save-state migrations across content patches.",
    ],
    thumb: "images/portfolio/BusinessHeroes/Thumbnail.png",
    videos: ["oNkXIbadk84"],
    gallery: [
      "images/portfolio/BusinessHeroes/1.jpg",
      "images/portfolio/BusinessHeroes/2.jpg",
      "images/portfolio/BusinessHeroes/3.jpg",
      "images/portfolio/BusinessHeroes/4.jpg",
      "images/portfolio/BusinessHeroes/5.jpg",
      "images/portfolio/BusinessHeroes/6.jpg",
      "images/portfolio/BusinessHeroes/7.jpg",
      "images/portfolio/BusinessHeroes/8.jpg",
    ],
    link: "https://businessheroes.cool/",
  },
  {
    id: "PR-02",
    slug: "pretia-ar",
    name: "Pretia AR Platform",
    tag: "XR/VR",
    filter: "xr",
    mono: "AR",
    role: "AR Developer / EM",
    org: "Pretia Technologies",
    period: "Nov 2022 — Aug 2023",
    oneliner: "AR cloud framework and commercial AR products for entertainment & media.",
    stats: [
      { sv: "5+", sk: "AR Products" },
      { sv: "5", sk: "Engineers Led" },
      { sv: "15+", sk: "Proposals Vetted" },
    ],
    tags: ["Unity", "AR", "AR Cloud", "Leadership", "XR", "iOS / Android"],
    bullets: [
      "Led entertainment and media division of <b>5 engineers</b>.",
      "Delivered <b>5+ AR products</b> and implemented advanced AR mechanics on top of Pretia's cloud framework.",
      "Evaluated <b>15+ technical proposals</b> for architectural feasibility across client engagements.",
      "Built AR interaction prototypes for brands, tuned for public-space tracking stability.",
    ],
    thumb: "images/portfolio/PretiaAR/Thumbnail.jpg",
    videos: ["bv3x5AkH__0", "H3NqJqs3JxA"],
    gallery: [],
    link: "https://corporate.pretiaar.com/",
  },
  {
    id: "BL-03",
    slug: "backlot",
    name: "Backlot Studio",
    tag: "Tools",
    filter: "tools",
    mono: "BL",
    role: "Lead Unity Engineer / Technical Lead",
    org: "Backlot Studio",
    period: "May 2020 — Nov 2022",
    oneliner: "Multi-platform collaborative filmmaking app with 2TB of streamed assets in under 1GB install.",
    stats: [
      { sv: "8", sk: "Engineers Led" },
      { sv: "2TB+", sk: "Assets Managed" },
      { sv: "16h", sk: "Saved / Scene" },
    ],
    tags: ["Unity", "Addressables", "Multi-platform", "Custom Editor", "Pipeline"],
    bullets: [
      "Led team of <b>8 engineers</b> building a collaborative filmmaking application.",
      "Designed Addressables system managing <b>2TB+ of assets</b> while keeping the installed app under 1GB.",
      "Built custom Editor tooling that <b>reduced scene integration by 16 hours</b> per scene.",
      "Architected streaming, pre-fetch, and fallback logic for cross-platform parity.",
    ],
    thumb: "images/portfolio/BacklotStudio/Thumbnail.jpg",
    videos: ["CCYGpVJOOVc"],
    gallery: [
      "images/portfolio/BacklotStudio/1.jpg",
      "images/portfolio/BacklotStudio/2.jpg",
      "images/portfolio/BacklotStudio/3.jpg",
      "images/portfolio/BacklotStudio/4.jpg",
      "images/portfolio/BacklotStudio/5.jpg",
    ],
    link: "https://www.backlot.studio/",
  },
];

const SOCIALS = [
  { k: "DC", url: "https://discord.com/users/motawea", title: "Discord" },
  { k: "FL", url: "https://www.freelancer.com/u/mohammedmotawea", title: "Freelancer" },
  { k: "YT", url: "https://www.youtube.com/@GameDev4Arab", title: "YouTube" },
  { k: "BE", url: "https://www.behance.net/mohammed-motawea", title: "Behance" },
];

const NAV = [
  { id: "home",    label: "Home",      glyph: "◈", num: "01" },
  { id: "about",   label: "About",     glyph: "◐", num: "02" },
  { id: "resume",  label: "Resume",    glyph: "▣", num: "03" },
  { id: "portfolio", label: "Portfolio", glyph: "⬢", num: "04" },
  { id: "contact", label: "Contact",   glyph: "✉", num: "05" },
];

// ===== Utility =====
function useRotatingText(items, interval = 2200) {
  const [i, setI] = useState(0);
  useEffect(() => {
    const t = setInterval(() => setI(x => (x + 1) % items.length), interval);
    return () => clearInterval(t);
  }, [items, interval]);
  return items[i];
}

function useClock() {
  const [t, setT] = useState(new Date());
  useEffect(() => {
    const id = setInterval(() => setT(new Date()), 1000);
    return () => clearInterval(id);
  }, []);
  return t;
}

function pad(n) { return n.toString().padStart(2, "0"); }

Object.assign(window, {
  ROLES, SERVICES, EDUCATION, EXPERIENCE, SKILLS, PROJECTS, SOCIALS, NAV,
  useRotatingText, useClock, pad,
});
