// Shared building blocks for culina top-page variants.
// Each variant file exposes a single component via window.*

// Culina logo mark — four-way good motif. Auto-switches per theme.
const CulinaMark = ({ size = 28, color, variant }) => {
  const ctx = React.useContext(window.ThemeContext || React.createContext({ mode: 'light' }));
  const inferredVariant = variant || (
    color === '#fff' || color === 'white' ? 'light'
    : (ctx.mode === 'dark' ? 'light' : 'dark')
  );
  const base = (typeof window !== 'undefined' && window.__ASSET_BASE__) || './';
  const src = base + (inferredVariant === 'light' ? 'assets/logo.png' : 'assets/logo-dark.png');
  return (
    <img src={src} alt="Culina" width={size} height={size}
      style={{ display: 'inline-block', verticalAlign: 'middle', objectFit: 'contain' }} />
  );
};

const CulinaWordmark = ({ color = 'currentColor', size = 22, variant }) => {
  const v = variant || (color === '#fff' || color === 'white' ? 'light' : 'dark');
  return (
    <span style={{ display: 'inline-flex', alignItems: 'center', gap: 10, color, fontSize: size, letterSpacing: '0.02em' }}>
      <CulinaMark size={size * 1.3} variant={v} />
      <span style={{ fontFamily: "'Inter', sans-serif", fontWeight: 500, letterSpacing: '0.08em' }}>Culina</span>
    </span>
  );
};

// Image placeholder with monospace label
const ImgPH = ({ label, ratio = '16/10', tone = 'warm', style, children }) => {
  const bg = tone === 'dark' ? '#0b0b0a' : tone === 'warm' ? '#efeae1' : '#f1efe9';
  const fg = tone === 'dark' ? '#8a8a85' : '#8a8275';
  return (
    <div style={{
      aspectRatio: ratio,
      background: `repeating-linear-gradient(135deg, ${bg}, ${bg} 6px, ${tone === 'dark' ? '#111' : '#e7e0d3'} 6px, ${tone === 'dark' ? '#111' : '#e7e0d3'} 7px)`,
      color: fg,
      fontFamily: "'JetBrains Mono', ui-monospace, monospace",
      fontSize: 11,
      display: 'flex', alignItems: 'center', justifyContent: 'center',
      padding: 16,
      textAlign: 'center',
      letterSpacing: '0.04em',
      ...style,
    }}>
      {children || <span>[ {label} ]</span>}
    </div>
  );
};

// Services list — shared source of truth
const SERVICES = [
  { id: 'curecipe',   kana: 'キュレシピ', name: 'Curecipe',   tag: 'プロ向けレシピ・職人技術アーカイブ・育成', tagEn: 'Professional recipes, craft archive, and training', desc: '' },
  { id: 'culinfc',    kana: 'キュリネフシー', name: 'CuliNFC',    tag: 'NFC真正性証明・保証・履歴・ストーリー表示', tagEn: 'NFC proof of authenticity, warranty, history, and story display', desc: '' },
  { id: 'curegi',     kana: 'キュレジ', name: 'Curegi',     tag: 'レジ・顧客管理・店舗売上管理・リピート施策', tagEn: 'POS, customer management, sales tracking, and retention measures', desc: '' },
  { id: 'culiec',     kana: 'キュリーシー', name: 'CuliEC',     tag: 'EC・予約・在庫管理・受注管理の半自動化', tagEn: 'Semi-automated e-commerce, reservations, inventory, and orders', desc: '' },
  { id: 'culimanage', kana: 'キュリマネージ', name: 'Culimanage', tag: '経営伴走・事業管理・資金繰り・補助金・PM支援', tagEn: 'Management support, business control, cash flow, subsidies, and PM', desc: '' },
  { id: 'culicareer', kana: 'キュリキャリア', name: 'Culicareer', tag: '人材紹介・職人就職斡旋・採用支援', tagEn: 'Talent placement, maker employment matching, and recruiting support', desc: '' },
  { id: 'culimedia',  kana: 'キュリメディア', name: 'Culimedia',  tag: 'ブランディング・SNS・Web・動画・発信支援', tagEn: 'Branding, social, web, video, and communication support', desc: '' },
  { id: 'culimarche', kana: 'キュリマルシェ', name: 'Culimarché', tag: '一流の器・道具・貴重食材・修理受付・販売', tagEn: 'Fine tableware, tools, rare ingredients, repair requests, and sales', desc: '' },
];

const FOUR_GOODS = [
  { kanji: '買い手', yomi: 'かいて', en: 'For the Buyer',   desc: '食卓の向こう側の、誰か。' },
  { kanji: '売り手', yomi: 'うりて', en: 'For the Seller',  desc: '持続する事業の、手応え。' },
  { kanji: '世間',   yomi: 'せけん', en: 'For the World',   desc: '地域・環境・次の世代へ。' },
  { kanji: '作り手', yomi: 'つくりて', en: 'For the Maker', desc: '職人の矜持を、事業の中心に。' },
];

const NEWS = [
  { date: '2026.04.18', tag: 'Product', title: 'Curecipe v3.2 — AI栄養素推定エンジンをリリース' },
  { date: '2026.03.02', tag: 'News',    title: 'CuliNFC、老舗和菓子屋「松月堂」に導入' },
  { date: '2026.02.14', tag: 'Event',   title: '飲食店開業セミナー @ 渋谷 開催報告' },
  { date: '2026.01.20', tag: 'Company', title: '本社オフィスを渋谷桜丘へ移転いたしました' },
];

// Expose
Object.assign(window, { CulinaMark, CulinaWordmark, ImgPH, SERVICES, FOUR_GOODS, NEWS });
