// Shared content + utilities used by all variations.
// Exports to window for cross-file visibility in Babel standalone.

const PROJECTS = [
  { name: "GITA",           desc: "Ghost In The Assistant — wake/command playback that triggers Siri, Alexa, Google or anything else.", url: "/gita/", lang: "Protocol", featured: true },
  { name: "TealClaw",       desc: "BYOK voice dashboard PWA — bring your own keys, zero server, total privacy.", url: "https://github.com/Snail3D/tealclaw", lang: "HTML", featured: true },
  { name: "OpenFlow",       desc: "Typing by voice, locally. Input to any text field without the cloud.", url: "https://github.com/Snail3D/OpenFlow", lang: "Python" },
  { name: "gameforge",      desc: "Autonomous multi-agent game factory powered by local LLMs on Apple Silicon.", url: "https://github.com/Snail3D/gameforge", lang: "Local-LLM" },
  { name: "PoofMicro",      desc: "Making micro-controller development reeeeally easy.", url: "https://github.com/Snail3D/PoofMicro", lang: "Python" },
  { name: "liltrAIner",     desc: "Karpathy-style autoresearch for fine-tuning local LLMs on Apple Silicon.", url: "https://github.com/Snail3D/liltrAIner", lang: "Training" },
  { name: "PanHandler",     desc: "Pro CAD-grade measurement app for iOS/Android. Measure from photos with a coin.", url: "https://github.com/Snail3D/PanHandler", lang: "React-Native" },
  { name: "SnailShell",     desc: "The AI agent that builds its own interface — local-first agent harness.", url: "https://github.com/Snail3D/SnailShell", lang: "Agent" },
  { name: "EspTree",        desc: "LinkTree clone for nerds and tightwads.", url: "https://github.com/Snail3D/EspTree", lang: "ESP32" },
  { name: "Mesh-Master",    desc: "Enhanced MESH-AI with persistent memory and better performance.", url: "https://github.com/Snail3D/Mesh-Master", lang: "Mesh" },
  { name: "formedskill",    desc: "Guided-form skill framework for LLMs — 3B models score 100% on tasks they previously failed.", url: "https://github.com/Snail3D/formedskill", lang: "Skill" },
  { name: "EsPong",         desc: "Two-player Pong on an ESP32 — play from your phone over WiFi, no app needed.", url: "https://github.com/Snail3D/EsPong", lang: "ESP32" },
];

const GAMES = [
  { name: "Neon Pong",        desc: "4-player neon pong with AI opponents.", url: "https://Snail3D.github.io/snail-arcade/games/neon-pong/index.html",        tag: "arcade" },
  { name: "Snail Snake",      desc: "Classic snake with a snail twist.",      url: "https://Snail3D.github.io/snail-arcade/games/snail-snake/index.html",      tag: "classic" },
  { name: "Space Invaders",   desc: "Defend Earth. Retro shooter.",            url: "https://Snail3D.github.io/snail-arcade/games/space-invaders/index.html",   tag: "shooter" },
  { name: "Hang-On",          desc: "1985 arcade racing clone.",               url: "https://Snail3D.github.io/snail-arcade/games/hang-on/index.html",          tag: "racing"  },
  { name: "Donkey Kong Mobile",desc: "DK platforming on the go.",              url: "https://Snail3D.github.io/snail-arcade/games/donkey-kong-mobile/index.html",tag: "platformer" },
  { name: "Battleship Blitz", desc: "Naval combat strategy.",                  url: "https://Snail3D.github.io/snail-arcade/games/battleship-blitz/index.html", tag: "strategy" },
  { name: "Snail Tetris",     desc: "Classic block stacking, neon cyberpunk.", url: "https://Snail3D.github.io/snail-arcade/games/tetris/index.html",           tag: "puzzle"  },
  { name: "NotBlast",         desc: "Match blocks, clear lines, score big.",   url: "https://Snail3D.github.io/snail-arcade/games/notblast/index.html",         tag: "puzzle"  },
];

const VIDEOS = [
  { id: "ihgD3Kk9lM8", title: "Live Demo TealClaw.ai",                                                   url: "https://www.youtube.com/watch?v=ihgD3Kk9lM8", new: true  },
  { id: "Elco7uLhIpg", title: "Drive with me as I ramble about TealClaw.ai and the state of things",     url: "https://www.youtube.com/watch?v=Elco7uLhIpg"  },
  { id: "Rl0xUBHZXTs", title: "Local AI modeling + Local AI controlled 3D printing — meet 2028",        url: "https://www.youtube.com/watch?v=Rl0xUBHZXTs"  },
  { id: "jfmJ3jGTz_A", title: "I Taught Him AI in 6 Hours… Then He Built THIS.",                        url: "https://www.youtube.com/watch?v=jfmJ3jGTz_A"  },
  { id: "4m2vPWR_q5I", title: "Watch Ralph build Ralph Mode Live! Autonomously.",                       url: "https://www.youtube.com/watch?v=4m2vPWR_q5I"  },
  { id: "jUSTMvqf3eQ", title: "Making Ralph easier than picking your nose.",                            url: "https://www.youtube.com/watch?v=jUSTMvqf3eQ"  },
];

const DEVOTIONALS = [
  { title: "Strength for Today", verse: "Lamentations 3:23",  quote: "Great is your faithfulness.", ref: "Daily mercy for daily work. Build with patience, serve with humility, and trust Him in the small steps." },
  { title: "Faithful in Little", verse: "Luke 16:10",          quote: "Whoever is faithful in very little is faithful also in much.", ref: "Every clean print, every refactor, every small kindness is practice for bigger stewardship." },
  { title: "Work as Worship",    verse: "Colossians 3:23",     quote: "Whatever you do, work heartily, as for the Lord.", ref: "Maker work can be worship when it is done with integrity, generosity, and gratitude." },
  { title: "Faith in Process",   verse: "Philippians 1:6",     quote: "He who began a good work in you will carry it to completion.", ref: "Layer by layer. Iteration by iteration. The Maker is patient with His makers." },
  { title: "Serve First",        verse: "Mark 10:45",          quote: "The Son of Man came not to be served but to serve.", ref: "The goal of the build is not the build. It is the people it helps." },
];

const VERSES = [
  "Colossians 3:23 · Whatever you do, work heartily, as for the Lord.",
  "Philippians 1:6 · He who began a good work in you will carry it to completion.",
  "Psalm 127:1 · Unless the Lord builds the house, they labor in vain who build it.",
  "Proverbs 16:3 · Commit your work to the Lord, and your plans will be established.",
  "Ecclesiastes 3:1 · For everything there is a season.",
  "1 Corinthians 10:31 · Whether you eat or drink, do all to the glory of God.",
  "Galatians 6:9 · Let us not grow weary in doing good.",
  "Lamentations 3:23 · Great is your faithfulness; his mercies are new every morning.",
];

const LINKS = {
  github:   "https://github.com/Snail3D",
  youtube:  "https://youtube.com/@RealSnail3D",
  discord:  "https://discord.gg/GH7FWzyTGc",
  makerworld: "https://makerworld.com/en/@RealSnail3D",
  arcade:   "https://github.com/Snail3D/snail-arcade",
};

// Snail shell SVG symbol (used everywhere)
const SnailGlyph = ({ size = 28, stroke = "currentColor", strokeWidth = 1.6 }) => (
  <svg viewBox="0 0 64 64" width={size} height={size} fill="none" stroke={stroke} strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
    {/* body */}
    <path d="M6 48 H42" />
    <path d="M42 48 c6 0 10 -4 10 -10" />
    <circle cx="48" cy="22" r="2" fill={stroke} stroke="none" />
    {/* shell spiral */}
    <path d="M34 34 m-18 0 a18 18 0 1 0 36 0 a18 18 0 1 0 -36 0" />
    <path d="M34 34 m-12 0 a12 12 0 1 0 24 0 a12 12 0 1 0 -24 0" />
    <path d="M34 34 m-6 0 a6 6 0 1 0 12 0 a6 6 0 1 0 -12 0" />
    {/* antennae */}
    <path d="M48 20 l2 -6" />
    <path d="M54 22 l4 -4" />
  </svg>
);

// Scripture ticker — shows if body[data-scripture="on"]
const ScriptureTicker = () => {
  const [i, setI] = React.useState(0);
  const [show, setShow] = React.useState(document.body.dataset.scripture !== "off");
  React.useEffect(() => {
    const id = setInterval(() => setI(x => (x+1) % VERSES.length), 7000);
    const mo = new MutationObserver(() => setShow(document.body.dataset.scripture !== "off"));
    mo.observe(document.body, { attributes: true, attributeFilter: ["data-scripture"] });
    return () => { clearInterval(id); mo.disconnect(); };
  }, []);
  if (!show) return null;
  return (
    <div style={{
      position: 'fixed', bottom: 0, left: 0, right: 0, zIndex: 80,
      padding: '8px 16px', background: 'linear-gradient(to top, rgba(10,10,20,0.95), rgba(10,10,20,0))',
      fontFamily: 'var(--mono)', fontSize: 11, color: 'var(--muted)', letterSpacing: '0.06em',
      display: 'flex', justifyContent: 'center', alignItems: 'center', gap: 12, pointerEvents: 'none',
    }}>
      <span style={{ color: 'var(--cyan)', opacity: .8 }}>◆</span>
      <span key={i} style={{ animation: 'verseFade 7s ease' }}>{VERSES[i]}</span>
    </div>
  );
};

// Inject keyframes once
if (!document.getElementById('shared-keyframes')) {
  const s = document.createElement('style');
  s.id = 'shared-keyframes';
  s.textContent = `
    @keyframes verseFade { 0% { opacity: 0; transform: translateY(4px); } 10%,90% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-4px); } }
    @keyframes spinSlow { to { transform: rotate(360deg); } }
    @keyframes drift { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
    @keyframes scan { 0% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
    @keyframes blink { 50% { opacity: 0; } }
    @keyframes glowPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(0,240,255,0.5); } 50% { box-shadow: 0 0 32px 2px rgba(0,240,255,0.3); } }
    @keyframes shellRotate { to { transform: translate(-50%,-50%) rotate(360deg); } }
    @keyframes trailDash { to { stroke-dashoffset: 0; } }
    @keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
  `;
  document.head.appendChild(s);
}

Object.assign(window, { PROJECTS, GAMES, VIDEOS, DEVOTIONALS, VERSES, LINKS, SnailGlyph, ScriptureTicker });
