// Sister sites — the other sites the same team runs (FDE Taiwan, 地端世界,
// 韓國旅客行銷). One homepage section plus a footer row. Kept in its own file
// so it drops onto any homepage version unchanged. Spec shared by all four
// sites: Research FDE/network/SPEC.md (outside this repo).

const SISTER_UTM_SOURCE = 'painpoint';

const SISTER_SITES = {
  zh: {
    eyebrow: '姊妹網站',
    title: '我們的其他服務',
    lede: '從 AI 工程到韓國行銷，同一個團隊經營。',
    footerLabel: '姊妹網站',
    sites: [
      {
        key: 'fde', name: 'FDE Taiwan', icon: 'assets/sister-sites/fde.png',
        url: 'https://fdetaiwan.com/zh/',
        pitch: '台北資深 AI 工程團隊，直接進駐你的公司。',
        bullets: ['派駐工程師，與你的團隊一起開發', '固定範圍 AI 專案，2–6 週交付', '線上預約 30 分鐘諮詢'],
        cta: '前往 FDE Taiwan',
      },
      {
        key: 'onprem', name: '地端世界', icon: 'assets/sister-sites/onprem.svg',
        url: 'https://onpremworld.com/zh-tw',
        pitch: '哪個開源模型能在哪張顯示卡、哪台 Mac 上跑、跑多快。',
        bullets: ['附來源的地端 LLM 規格與實測', '台灣與美國硬體價格，每日新聞', '地端 AI 硬體與私有 AI 建置（報價制）'],
        cta: '前往地端世界',
      },
      {
        key: 'korea', name: '韓國旅客行銷', icon: 'assets/sister-sites/korea.svg',
        url: 'https://korea.chanshuo.tw/',
        pitch: '讓你的品牌成為韓國旅客的首選。',
        bullets: ['真實韓國用戶撰寫 NAVER Cafe、NAVER Blog 內容', '打造韓國搜尋曝光與口碑', '服務台灣、新加坡、馬來西亞、香港品牌'],
        cta: '前往韓國旅客行銷',
      },
    ],
  },
  en: {
    eyebrow: 'Sister sites',
    title: 'More from our team',
    lede: 'Other services we run, from AI engineering to Korean marketing.',
    footerLabel: 'Sister sites',
    sites: [
      {
        key: 'fde', name: 'FDE Taiwan', icon: 'assets/sister-sites/fde.png',
        url: 'https://fdetaiwan.com/',
        pitch: 'Senior, AI-native engineers from Taipei, embedded in your team.',
        bullets: ['Forward-deployed engineering inside your company', 'Fixed-scope AI projects shipped in 2–6 weeks', 'Book a 30-minute call'],
        cta: 'Visit FDE Taiwan',
      },
      {
        key: 'onprem', name: 'OnPrem World', icon: 'assets/sister-sites/onprem.svg',
        url: 'https://onpremworld.com/en',
        pitch: 'Which open-source model runs on which GPU or Mac, and how fast.',
        bullets: ['Sourced specs and benchmarks for local LLMs', 'Hardware prices in Taiwan and the US, plus daily news', 'On-prem AI hardware and private AI builds, by quote'],
        cta: 'Visit OnPrem World',
      },
      {
        key: 'korea', name: 'Korea Traveler Marketing', icon: 'assets/sister-sites/korea.svg',
        // Chinese-only site.
        url: 'https://korea.chanshuo.tw/',
        pitch: 'Make your brand the first choice for Korean travelers.',
        bullets: ['NAVER Cafe and NAVER Blog posts by real Korean users', 'Korean search visibility and word of mouth', 'For brands in Taiwan, Singapore, Malaysia and Hong Kong'],
        cta: 'Visit Korea Traveler Marketing',
      },
    ],
  },
  es: {
    eyebrow: 'Sitios hermanos',
    title: 'Más de nuestro equipo',
    lede: 'Otros servicios que operamos, de ingeniería de IA a marketing en Corea.',
    footerLabel: 'Sitios hermanos',
    sites: [
      {
        key: 'fde', name: 'FDE Taiwan', icon: 'assets/sister-sites/fde.png',
        url: 'https://fdetaiwan.com/',
        pitch: 'Ingenieros sénior de IA desde Taipéi, integrados en tu equipo.',
        bullets: ['Ingenieros que trabajan dentro de tu empresa', 'Proyectos de IA de alcance fijo en 2–6 semanas', 'Agenda una llamada de 30 minutos'],
        cta: 'Ir a FDE Taiwan',
      },
      {
        key: 'onprem', name: 'OnPrem World', icon: 'assets/sister-sites/onprem.svg',
        url: 'https://onpremworld.com/en',
        pitch: 'Qué modelo de código abierto corre en qué GPU o Mac, y a qué velocidad.',
        bullets: ['Especificaciones y pruebas de LLM locales, con fuentes', 'Precios de hardware en Taiwán y EE. UU., y noticias diarias', 'Hardware de IA local y despliegues privados, bajo cotización'],
        cta: 'Ir a OnPrem World',
      },
      {
        key: 'korea', name: 'Korea Traveler Marketing', icon: 'assets/sister-sites/korea.svg',
        // Chinese-only site.
        url: 'https://korea.chanshuo.tw/',
        pitch: 'Haz de tu marca la primera opción de los viajeros coreanos.',
        bullets: ['Publicaciones en NAVER Cafe y NAVER Blog escritas por usuarios coreanos reales', 'Visibilidad en buscadores coreanos y recomendaciones', 'Para marcas de Taiwán, Singapur, Malasia y Hong Kong'],
        cta: 'Ir a Korea Traveler Marketing',
      },
    ],
  },
};

function sisterHref(url, placement) {
  const u = new URL(url);
  u.searchParams.set('utm_source', SISTER_UTM_SOURCE);
  u.searchParams.set('utm_medium', 'referral');
  u.searchParams.set('utm_campaign', 'sister_sites');
  u.searchParams.set('utm_content', placement);
  return u.toString();
}

function SisterSites({ lang }) {
  const s = SISTER_SITES[lang] || SISTER_SITES.zh;
  return (
    <section id="sister-sites" className="section section-tight">
      <div className="wrap">
        <div className="section-head">
          <div className="eyebrow">{s.eyebrow}</div>
          <div>
            <h2 className="h-1">{s.title}</h2>
            <p className="lede" style={{ marginTop: 20 }}>{s.lede}</p>
          </div>
        </div>
        <div className="sister-grid">
          {s.sites.map((site) => (
            <article key={site.key} className="sister-card">
              <img className="sister-icon" src={site.icon} alt="" width="48" height="48" />
              <h3 className="sister-name">{site.name}</h3>
              <p className="sister-pitch">{site.pitch}</p>
              <ul className="sister-bullets">
                {site.bullets.map((b) => <li key={b}>{b}</li>)}
              </ul>
              <a className="btn btn-ghost sister-cta" href={sisterHref(site.url, 'section')} target="_blank" rel="noopener">
                {site.cta} <Arrow size={12} />
              </a>
            </article>
          ))}
        </div>
      </div>
    </section>
  );
}

function SisterSitesRow({ lang }) {
  const s = SISTER_SITES[lang] || SISTER_SITES.zh;
  return (
    <nav className="sister-row" aria-label={s.footerLabel}>
      <span className="mono sister-row-label">{s.footerLabel}</span>
      <ul>
        {s.sites.map((site) => (
          <li key={site.key}>
            <a href={sisterHref(site.url, 'footer')} target="_blank" rel="noopener">
              <img src={site.icon} alt="" width="22" height="22" />
              {site.name}
            </a>
          </li>
        ))}
      </ul>
    </nav>
  );
}

Object.assign(window, { SisterSites, SisterSitesRow });
