/* global React, ReactDOM */
const { useState, useEffect } = React;

const PALETTES = {
  paper: {
    name: "和紙 / Paper",
    bg: "#f4efe6",
    bg2: "#ebe4d6",
    ink: "#15140f",
    ink2: "#2a2820",
    muted: "#6b6657",
    rule: "#15140f",
    accent: "#c1322d",
    accentInk: "#fdfbf6"
  },
  ink: {
    name: "墨 / Ink",
    bg: "#0e0e0c",
    bg2: "#181815",
    ink: "#f1ece0",
    ink2: "#cfc8b6",
    muted: "#7a7466",
    rule: "#3a382f",
    accent: "#e8b14a",
    accentInk: "#0e0e0c"
  },
  jade: {
    name: "青磁 / Jade",
    bg: "#eef2ec",
    bg2: "#e2e8df",
    ink: "#0f1a17",
    ink2: "#23332e",
    muted: "#5e6e69",
    rule: "#0f1a17",
    accent: "#1f5d4c",
    accentInk: "#eef2ec"
  }
};

const TYPE_FAMILIES = {
  serif: {
    display: "'Noto Serif TC', 'Source Han Serif', Georgia, serif",
    body: "'Inter', 'Noto Sans TC', system-ui, sans-serif",
    mono: "'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace"
  },
  sans: {
    display: "'Inter Tight', 'Noto Sans TC', system-ui, sans-serif",
    body: "'Inter', 'Noto Sans TC', system-ui, sans-serif",
    mono: "'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace"
  },
  mixed: {
    display: "'Fraunces', 'Noto Serif TC', Georgia, serif",
    body: "'Inter', 'Noto Sans TC', system-ui, sans-serif",
    mono: "'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace"
  }
};

function Stamp({ children, palette }) {
  return (
    <span style={{
      display: "inline-flex", alignItems: "center", justifyContent: "center",
      fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.18em",
      textTransform: "uppercase", padding: "4px 8px",
      border: `1px solid ${palette.rule}`, color: palette.ink,
      background: "transparent", whiteSpace: "nowrap"
    }}>{children}</span>);

}

function SectionTag({ num, label, palette }) {
  return (
    <div style={{
      display: "inline-flex", alignItems: "stretch",
      fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.18em",
      textTransform: "uppercase", border: `1px solid ${palette.rule}`
    }}>
      <span style={{ background: palette.ink, color: palette.bg, padding: "5px 9px 4px" }}>{num}</span>
      <span style={{ padding: "5px 11px 4px", color: palette.ink }}>{label}</span>
    </div>);

}

function CornerTicks({ palette }) {
  const tick = { position: "absolute", width: 10, height: 10, borderColor: palette.rule, borderStyle: "solid" };
  return (
    <>
      <span style={{ ...tick, top: -1, left: -1, borderWidth: "1px 0 0 1px" }}></span>
      <span style={{ ...tick, top: -1, right: -1, borderWidth: "1px 1px 0 0" }}></span>
      <span style={{ ...tick, bottom: -1, left: -1, borderWidth: "0 0 1px 1px" }}></span>
      <span style={{ ...tick, bottom: -1, right: -1, borderWidth: "0 1px 1px 0" }}></span>
    </>);

}

function Nav({ palette }) {
  return (
    <nav style={{
      position: "sticky", top: 0, zIndex: 30,
      background: `${palette.bg}f2`, backdropFilter: "blur(8px)",
      borderBottom: `1px solid ${palette.rule}`
    }}>
      <div style={{
        maxWidth: 1320, margin: "0 auto", padding: "14px 32px",
        display: "flex", alignItems: "center", justifyContent: "space-between", gap: 24
      }}>
        <a href="#" style={{
          display: "flex", alignItems: "center", gap: 10,
          color: palette.ink, textDecoration: "none",
          fontFamily: "var(--display)", fontSize: 18, fontWeight: 600
        }}>
          <span aria-hidden style={{
            width: 22, height: 22, display: "inline-flex",
            alignItems: "center", justifyContent: "center",
            background: palette.accent, color: palette.accentInk,
            fontFamily: "var(--display)", fontSize: 13, fontWeight: 700, lineHeight: 1
          }}>印</span>
          FDE <em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500 }}>AI</em> 事務所
        </a>
        <div style={{ display: "flex", gap: 28, fontSize: 13, fontFamily: "var(--body)" }}>
          {[["#services", "服務", "Services"], ["#process", "合作流程", "Process"], ["#why", "為何選我們", "Why us"], ["#faq", "常見問題", "FAQ"]].map(([href, zh, en]) =>
          <a key={href} href={href} style={{
            color: palette.ink, textDecoration: "none",
            display: "flex", flexDirection: "column", lineHeight: 1.1
          }}>
              <span style={{ fontWeight: 500 }}>{zh}</span>
              <span style={{
              fontSize: 9, fontFamily: "var(--mono)", letterSpacing: "0.18em",
              textTransform: "uppercase", color: palette.muted, marginTop: 2
            }}>{en}</span>
            </a>
          )}
        </div>
        <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
          <Stamp palette={palette}>TW · 繁中</Stamp>
          <a href="mailto:hello@fde-ai.tw?subject=AI%20Discovery%20Call" style={{
            fontFamily: "var(--body)", fontSize: 13, fontWeight: 500,
            padding: "8px 14px", background: palette.ink, color: palette.bg,
            textDecoration: "none", border: `1px solid ${palette.ink}`
          }}>預約 30 分鐘 →</a>
        </div>
      </div>
    </nav>);

}

const TICKETS = [
{ id: "01", title: "客服 RAG 上線", meta: "shipped", state: "done", tag: "support" },
{ id: "02", title: "報價單 AI 萃取", meta: "3.2h", state: "active", tag: "ops" },
{ id: "03", title: "業務 CRM 自動填寫", meta: "82%", state: "active", tag: "sales" },
{ id: "04", title: "ERP × LLM 中介層", meta: "in progress", state: "active", tag: "infra" },
{ id: "05", title: "Eval harness v2", meta: "queued", state: "queued", tag: "qa" },
{ id: "06", title: "週度交付報告", meta: "Fri", state: "scheduled", tag: "ops" }];


function ExecutionPanel({ palette }) {
  const [tick, setTick] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setTick((t) => t + 1), 1400);
    return () => clearInterval(id);
  }, []);
  const activeIdx = tick % TICKETS.length;
  return (
    <div style={{
      position: "relative", background: palette.bg2,
      border: `1px solid ${palette.rule}`, fontFamily: "var(--mono)", color: palette.ink
    }}>
      <CornerTicks palette={palette} />
      <div style={{
        padding: "10px 14px", borderBottom: `1px solid ${palette.rule}`,
        display: "flex", justifyContent: "space-between", alignItems: "center",
        fontSize: 11, letterSpacing: "0.18em", textTransform: "uppercase", color: palette.muted
      }}>
        <span>fde-ai://execution</span>
        <span style={{ display: "flex", alignItems: "center", gap: 6 }}>
          <span style={{
            width: 7, height: 7, borderRadius: 7, background: palette.accent,
            boxShadow: `0 0 0 3px ${palette.accent}33`,
            animation: "pulse 1.6s ease-in-out infinite"
          }}></span>
          live
        </span>
      </div>
      <ul style={{ listStyle: "none", margin: 0, padding: 0 }}>
        {TICKETS.map((t, i) => {
          const active = i === activeIdx;
          return (
            <li key={t.id} style={{
              display: "grid", gridTemplateColumns: "44px 1fr 90px",
              gap: 10, alignItems: "center", padding: "12px 14px",
              borderBottom: i === TICKETS.length - 1 ? "none" : `1px solid ${palette.rule}`,
              background: active ? palette.bg : "transparent",
              transition: "background 0.4s"
            }}>
              <span style={{ fontSize: 11, color: palette.muted }}>{t.id}</span>
              <span style={{
                fontFamily: "var(--body)", fontSize: 14, color: palette.ink,
                display: "flex", alignItems: "center", gap: 8
              }}>
                <span aria-hidden style={{
                  fontFamily: "var(--mono)", fontSize: 9, letterSpacing: "0.15em",
                  textTransform: "uppercase", color: palette.muted,
                  border: `1px solid ${palette.rule}`, padding: "2px 5px"
                }}>{t.tag}</span>
                {t.title}
              </span>
              <span style={{
                textAlign: "right", fontSize: 11, letterSpacing: "0.12em",
                textTransform: "uppercase",
                color: t.state === "done" ? palette.accent : t.state === "active" ? palette.ink : palette.muted
              }}>{t.meta}</span>
            </li>);

        })}
      </ul>
      <div style={{
        padding: "10px 14px", borderTop: `1px solid ${palette.rule}`,
        display: "flex", justifyContent: "space-between",
        fontSize: 10, letterSpacing: "0.18em", textTransform: "uppercase", color: palette.muted
      }}>
        <span>cycle · week 19 · shipping</span>
        <span>hours used 41 / est 56</span>
      </div>
    </div>);

}

function Hero({ palette }) {
  return (
    <section style={{ borderBottom: `1px solid ${palette.rule}`, position: "relative", overflow: "hidden" }}>
      <div style={{
        maxWidth: 1320, margin: "0 auto", padding: "72px 32px 56px",
        display: "grid", gridTemplateColumns: "1.15fr 1fr", gap: 56, alignItems: "end"
      }}>
        <div>
          <div style={{ display: "flex", gap: 8, marginBottom: 28, flexWrap: "wrap" }}>
            <Stamp palette={palette}>按時計費</Stamp>
            <Stamp palette={palette}>無長期綁約</Stamp>
            <Stamp palette={palette}>全球企業專注</Stamp>
            <Stamp palette={palette}>AI · Automation · Data</Stamp>
          </div>
          <h1 style={{
            fontFamily: "var(--display)",
            lineHeight: 0.96, letterSpacing: "-0.02em",
            margin: 0, fontWeight: 500, color: palette.ink, fontSize: "50px"
          }}>
            把 <em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500 }}>AI</em> 真正<br />
            <span style={{ position: "relative", display: "inline-block" }}>
              <span style={{ position: "relative", zIndex: 2 }}>用進業務裡。</span>
              <svg aria-hidden width="100%" height="14" viewBox="0 0 400 14"
              preserveAspectRatio="none"
              style={{ position: "absolute", left: 0, right: 0, bottom: 6, width: "100%", height: 14, zIndex: 1 }}>
                <path d="M2 9 C 80 2, 160 14, 240 7 S 380 4, 398 8"
                stroke={palette.accent} strokeWidth="3" fill="none" strokeLinecap="round" />
              </svg>
            </span><br />
            不只是 demo,而是<br />
            <span style={{ fontStyle: "italic" }}>落地的工程交付</span>。
          </h1>
          <p style={{
            maxWidth: 540, margin: "32px 0 28px", fontSize: 17,
            lineHeight: 1.6, color: palette.ink2, fontFamily: "var(--body)"
          }}>
            FDE AI 事務所為全球企業提供按時計費的 AI 工程能力——免去全職雇用的成本與等待。從導入 LLM 到流程自動化、從資料整理到內部 AI 工具,把「AI 應該怎麼用」變成可衡量的成果。
          </p>
          <div style={{ display: "flex", gap: 12, flexWrap: "wrap", alignItems: "center" }}>
            <a href="mailto:hello@fde-ai.tw?subject=AI%20Discovery%20Call" style={{
              fontFamily: "var(--body)", fontSize: 15, fontWeight: 500,
              padding: "14px 22px", background: palette.accent, color: palette.accentInk,
              textDecoration: "none", border: `1px solid ${palette.accent}`,
              display: "inline-flex", alignItems: "center", gap: 10
            }}>預約 30 分鐘討論 <span style={{ fontFamily: "var(--mono)" }}>→</span></a>
            <a href="#services" style={{
              fontFamily: "var(--body)", fontSize: 15, fontWeight: 500,
              padding: "13px 22px", color: palette.ink, textDecoration: "none",
              border: `1px solid ${palette.rule}`,
              display: "inline-flex", alignItems: "center", gap: 10
            }}>查看服務範圍</a>
          </div>
        </div>
        <ExecutionPanel palette={palette} />
      </div>
      <div style={{
        borderTop: `1px solid ${palette.rule}`, padding: "10px 0",
        fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.22em",
        textTransform: "uppercase", color: palette.muted,
        overflow: "hidden", whiteSpace: "nowrap"
      }}>
        <div style={{ display: "inline-block", animation: "marquee 36s linear infinite" }}>
          {Array(3).fill(0).map((_, i) =>
          <span key={i}>
              &nbsp;◇&nbsp;&nbsp;LLM 導入&nbsp;&nbsp;◇&nbsp;&nbsp;RAG &amp; Knowledge&nbsp;&nbsp;◇&nbsp;&nbsp;流程自動化&nbsp;&nbsp;◇&nbsp;&nbsp;Internal Tools&nbsp;&nbsp;◇&nbsp;&nbsp;資料管線&nbsp;&nbsp;◇&nbsp;&nbsp;Vendor Triage&nbsp;&nbsp;◇&nbsp;&nbsp;Eval &amp; Guardrails&nbsp;&nbsp;◇&nbsp;&nbsp;Prompt Ops&nbsp;&nbsp;◇&nbsp;&nbsp;CRM × AI&nbsp;&nbsp;◇&nbsp;&nbsp;
            </span>
          )}
        </div>
      </div>
    </section>);

}

const SERVICES = [
{ no: "01", kicker: "Adopt", titleZh: "AI 落地導入", titleEn: "AI Adoption",
  body: "從 LLM 選型、RAG 架構到第一個能在公司日常用的 AI 流程,協助企業跨過「PoC 永遠停在 demo」的階段。",
  bullets: ["LLM / Vendor 選型", "RAG & 知識庫", "首個生產級用例"] },
{ no: "02", kicker: "Automate", titleZh: "流程自動化", titleEn: "Automation",
  body: "把 ERP、CRM、客服、報價、報表之間的重複操作自動化,讓人專注在判斷,把搬資料的事交給 AI Agent。",
  bullets: ["客服 / 售後 Agent", "報價 · 對單自動化", "內部後台工具"] },
{ no: "03", kicker: "Integrate", titleZh: "資料與整合交付", titleEn: "Data & Integration",
  body: "為 AI 鋪好資料地基:資料管線、API、第三方串接、評估與 Guardrails——務實、夠用、能維運。",
  bullets: ["資料管線 & ETL", "API & Webhooks", "Eval / Guardrails"] }];


function Services({ palette }) {
  return (
    <section id="services" style={{ borderBottom: `1px solid ${palette.rule}`, background: palette.bg }}>
      <div style={{ maxWidth: 1320, margin: "0 auto", padding: "96px 32px" }}>
        <div style={{
          display: "grid", gridTemplateColumns: "1fr 2fr", gap: 64,
          alignItems: "end", marginBottom: 64
        }}>
          <div><SectionTag num="01" label="Services" palette={palette} /></div>
          <h2 style={{
            fontFamily: "var(--display)", fontSize: "clamp(36px, 4.4vw, 60px)",
            lineHeight: 1.05, letterSpacing: "-0.015em",
            fontWeight: 500, margin: 0, color: palette.ink
          }}>
            為企業而生的<br />
            <em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500 }}>按時計費</em> AI 工程服務。
          </h2>
        </div>
        <p style={{
          maxWidth: 720, marginLeft: "auto", marginBottom: 48,
          fontSize: 16, color: palette.ink2,
          fontFamily: "var(--body)", lineHeight: 1.65
        }}>
          我們不接整季承包,不推大型改造,也不賣只能跑一次的 demo。只專注在一週內能被看見、能被衡量、能持續運轉的 AI 交付。
        </p>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0 }}>
          {SERVICES.map((s, i) =>
          <div key={s.no} style={{
            border: `1px solid ${palette.rule}`,
            marginLeft: i === 0 ? 0 : -1, padding: 28,
            position: "relative", background: palette.bg,
            display: "flex", flexDirection: "column", minHeight: 360
          }}>
              <div style={{
              display: "flex", justifyContent: "space-between", alignItems: "center",
              marginBottom: 28, fontFamily: "var(--mono)", fontSize: 11,
              letterSpacing: "0.18em", textTransform: "uppercase", color: palette.muted
            }}>
                <span>{s.no} / {s.kicker}</span>
                <span aria-hidden style={{
                width: 18, height: 18, borderRadius: 18,
                border: `1px solid ${palette.rule}`,
                display: "inline-flex", alignItems: "center", justifyContent: "center",
                fontSize: 9, color: palette.ink
              }}>↗</span>
              </div>
              <h3 style={{
              fontFamily: "var(--display)", fontSize: 30, lineHeight: 1.15,
              fontWeight: 500, margin: "0 0 8px", color: palette.ink,
              letterSpacing: "-0.005em"
            }}>{s.titleZh}</h3>
              <div style={{
              fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.18em",
              textTransform: "uppercase", color: palette.accent, marginBottom: 18
            }}>{s.titleEn}</div>
              <p style={{
              fontFamily: "var(--body)", fontSize: 15, lineHeight: 1.65,
              color: palette.ink2, margin: "0 0 24px"
            }}>{s.body}</p>
              <ul style={{
              listStyle: "none", margin: "auto 0 0", padding: 0,
              borderTop: `1px solid ${palette.rule}`
            }}>
                {s.bullets.map((b) =>
              <li key={b} style={{
                padding: "10px 0", borderBottom: `1px dashed ${palette.rule}`,
                fontFamily: "var(--mono)", fontSize: 12,
                letterSpacing: "0.05em", color: palette.ink,
                display: "flex", alignItems: "center", gap: 10
              }}>
                    <span style={{ color: palette.accent }}>＋</span> {b}
                  </li>
              )}
              </ul>
            </div>
          )}
        </div>
      </div>
    </section>);

}

const STEPS = [
{ no: "STEP 01", titleZh: "探索", titleEn: "Discovery",
  body: "了解業務痛點、現有系統與資料、AI 可介入的位置,判斷是否真的是我們能解、值得解的問題。" },
{ no: "STEP 02", titleZh: "時數估算", titleEn: "Scoping",
  body: "以小時為單位估算工作量,提出一份透明、可對照的執行計畫——不跳數字、不藏假設。" },
{ no: "STEP 03", titleZh: "執行", titleEn: "Build",
  body: "短週期交付,每週看到實際運作的版本——不是只有週報,是真的能在公司內被使用。" },
{ no: "STEP 04", titleZh: "移交", titleEn: "Handover",
  body: "留下文件、評估腳本與下一步建議,必要時提供後續維運,讓你的團隊能完整接手。" }];


function Process({ palette }) {
  return (
    <section id="process" style={{ borderBottom: `1px solid ${palette.rule}`, background: palette.bg2 }}>
      <div style={{ maxWidth: 1320, margin: "0 auto", padding: "96px 32px" }}>
        <div style={{
          display: "grid", gridTemplateColumns: "1fr 2fr", gap: 64,
          alignItems: "end", marginBottom: 64
        }}>
          <div><SectionTag num="02" label="How we work" palette={palette} /></div>
          <h2 style={{
            fontFamily: "var(--display)", fontSize: "clamp(36px, 4.4vw, 60px)",
            lineHeight: 1.05, fontWeight: 500, margin: 0, color: palette.ink,
            letterSpacing: "-0.015em"
          }}>
            一個短、透明、<em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500 }}>可驗收</em><br />的合作循環。
          </h2>
        </div>
        <div style={{
          display: "grid", gridTemplateColumns: "repeat(4, 1fr)",
          border: `1px solid ${palette.rule}`, background: palette.bg
        }}>
          {STEPS.map((s, i) =>
          <div key={s.no} style={{
            padding: 28,
            borderRight: i === STEPS.length - 1 ? "none" : `1px solid ${palette.rule}`,
            position: "relative", minHeight: 280
          }}>
              <div style={{
              fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.22em",
              textTransform: "uppercase", color: palette.muted,
              marginBottom: 20, display: "flex", alignItems: "center", gap: 10
            }}>
                <span style={{
                width: 22, height: 22, borderRadius: 22,
                background: palette.ink, color: palette.bg,
                display: "inline-flex", alignItems: "center", justifyContent: "center", fontSize: 10
              }}>{String(i + 1).padStart(2, "0")}</span>
                {s.no}
              </div>
              <h3 style={{
              fontFamily: "var(--display)", fontSize: 28, lineHeight: 1.1,
              fontWeight: 500, margin: "0 0 4px", color: palette.ink
            }}>{s.titleZh}</h3>
              <div style={{
              fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.18em",
              textTransform: "uppercase", color: palette.accent, marginBottom: 16
            }}>{s.titleEn}</div>
              <p style={{
              fontFamily: "var(--body)", fontSize: 14.5, lineHeight: 1.65,
              color: palette.ink2, margin: 0
            }}>{s.body}</p>
              {i < STEPS.length - 1 &&
            <span aria-hidden style={{
              position: "absolute", right: -10, top: "50%",
              transform: "translateY(-50%)", width: 20, height: 20,
              background: palette.bg, color: palette.ink,
              border: `1px solid ${palette.rule}`,
              display: "inline-flex", alignItems: "center", justifyContent: "center",
              fontFamily: "var(--mono)", fontSize: 10, zIndex: 1
            }}>→</span>
            }
            </div>
          )}
        </div>
      </div>
    </section>);

}

const POINTS = [
{ big: "0→1", titleZh: "天數,而非季度", titleEn: "Days, not quarters",
  body: "把積壓的 AI 想法從 backlog 推到 shipped,以天為單位移動——不是排進下一個 OKR 才開工。" },
{ big: "24h", titleZh: "一日內回覆計畫", titleEn: "Plan within 24h",
  body: "告訴我們最卡的一兩件事,24 小時內提出可執行的時數方案——不畫大餅、不發樣板提案。" },
{ big: "1:1", titleZh: "商業優先", titleEn: "Outcome-first",
  body: "每一小時都對應到投資回報、風險降低或營運影響——我們不為了用 AI 而用 AI。" }];


function Why({ palette }) {
  return (
    <section id="why" style={{ borderBottom: `1px solid ${palette.rule}`, background: palette.bg }}>
      <div style={{ maxWidth: 1320, margin: "0 auto", padding: "96px 32px" }}>
        <div style={{
          display: "grid", gridTemplateColumns: "1fr 2fr", gap: 64,
          alignItems: "end", marginBottom: 64
        }}>
          <div><SectionTag num="03" label="Why FDE AI" palette={palette} /></div>
          <h2 style={{
            fontFamily: "var(--display)", fontSize: "clamp(36px, 4.4vw, 60px)",
            lineHeight: 1.05, fontWeight: 500, margin: 0, color: palette.ink,
            letterSpacing: "-0.015em"
          }}>
            用 <em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500 }}>更少的承諾</em> ,<br />
            換更高的執行確定性。
          </h2>
        </div>
        <p style={{
          maxWidth: 720, marginLeft: "auto", marginBottom: 48, fontSize: 16,
          color: palette.ink2, fontFamily: "var(--body)", lineHeight: 1.65
        }}>
          你不需要多聘一位 AI 工程師,也不需要等三個月的招募循環,更不需要簽一份綁三年的顧問合約。你只需要有人把事情做完。
        </p>
        <div style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0 }}>
          {POINTS.map((p, i) =>
          <div key={p.big} style={{
            border: `1px solid ${palette.rule}`,
            marginLeft: i === 0 ? 0 : -1, padding: 32,
            background: palette.bg, minHeight: 280,
            display: "flex", flexDirection: "column", justifyContent: "space-between"
          }}>
              <div style={{
              fontFamily: "var(--display)", fontSize: 88, lineHeight: 0.95,
              fontWeight: 500, fontStyle: "italic", color: palette.accent,
              letterSpacing: "-0.04em"
            }}>{p.big}</div>
              <div>
                <h3 style={{
                fontFamily: "var(--display)", fontSize: 24, lineHeight: 1.2,
                fontWeight: 500, margin: "0 0 4px", color: palette.ink
              }}>{p.titleZh}</h3>
                <div style={{
                fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.18em",
                textTransform: "uppercase", color: palette.muted, marginBottom: 14
              }}>{p.titleEn}</div>
                <p style={{
                fontFamily: "var(--body)", fontSize: 14.5, lineHeight: 1.65,
                color: palette.ink2, margin: 0
              }}>{p.body}</p>
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

const FAQ = [
{ q: "合作的最小規模是多少?", a: "通常從 10 小時起,適合一次性的修復或小型自動化;若是 RAG、Agent 或整合交付,多半落在 40–120 小時的區間。無最低月費、無長期綁約。" },
{ q: "你們在哪些技術堆疊上工作?", a: "主流 AI / Web / 雲端技術:OpenAI、Anthropic、Gemini、本地 LLM;Python、TypeScript、Postgres、pgvector;AWS / GCP / Azure;以及常見 SaaS 的 API(HubSpot、Salesforce、LINE、SAP、Notion、Zapier)。不熟的技術會在探索階段直接告訴你。" },
{ q: "資料安全與合規呢?", a: "可簽署客戶 NDA 或採用我們的標準版本;憑證以最小權限授權,專案結束後清除。如有個資法、金管會或客戶內部資安要求,請在探索階段告知,我們可協助規劃地端、私有雲或 Azure OpenAI / Bedrock 等部署方式。" },
{ q: "時數如何追蹤與回報?", a: "每週提供時數明細與對應交付項目,任何異常在超出預估 15% 前會先告知,絕不事後追加費用。" },
{ q: "我的公司還沒準備好用 AI,怎麼辦?", a: "這其實是最常見的起點。第一次合作通常會花 5–10 小時,先盤點資料、流程與最值得切入的場景,然後再決定要不要往下走——不會推銷不該做的事。" },
{ q: "和傳統顧問或 SI 廠商有什麼不同?", a: "我們不開大型專案、不派 PM 顧問,也不只交一份簡報。是工程師直接對接、按小時收費、按週交可運作版本。適合需要快速看到結果、又不想被綁定的全球企業。" }];


function FaqSection({ palette }) {
  const [open, setOpen] = useState(0);
  return (
    <section id="faq" style={{ borderBottom: `1px solid ${palette.rule}`, background: palette.bg2 }}>
      <div style={{ maxWidth: 1320, margin: "0 auto", padding: "96px 32px" }}>
        <div style={{
          display: "grid", gridTemplateColumns: "1fr 2fr", gap: 64,
          alignItems: "end", marginBottom: 56
        }}>
          <div><SectionTag num="04" label="FAQ" palette={palette} /></div>
          <h2 style={{
            fontFamily: "var(--display)", fontSize: "clamp(36px, 4.4vw, 60px)",
            lineHeight: 1.05, fontWeight: 500, margin: 0, color: palette.ink,
            letterSpacing: "-0.015em"
          }}>常見問題。</h2>
        </div>
        <div style={{ display: "grid", gridTemplateColumns: "1fr 2fr", gap: 64 }}>
          <p style={{
            fontFamily: "var(--body)", fontSize: 15, lineHeight: 1.7,
            color: palette.ink2, margin: 0
          }}>
            選擇按時計費的 AI 夥伴前,這些是你該先釐清的事。找不到答案?直接寫信給我們,通常 24 小時內回覆。
          </p>
          <ul style={{ listStyle: "none", margin: 0, padding: 0 }}>
            {FAQ.map((item, i) => {
              const isOpen = i === open;
              return (
                <li key={i} style={{
                  borderTop: `1px solid ${palette.rule}`,
                  borderBottom: i === FAQ.length - 1 ? `1px solid ${palette.rule}` : "none"
                }}>
                  <button onClick={() => setOpen(isOpen ? -1 : i)} style={{
                    width: "100%", textAlign: "left", padding: "22px 0",
                    background: "transparent", border: "none", cursor: "pointer",
                    display: "flex", alignItems: "center", justifyContent: "space-between", gap: 24,
                    color: palette.ink, fontFamily: "var(--display)", fontSize: 22, fontWeight: 500
                  }}>
                    <span style={{ display: "flex", gap: 18, alignItems: "baseline" }}>
                      <span style={{
                        fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.18em",
                        color: palette.muted
                      }}>Q.0{i + 1}</span>
                      {item.q}
                    </span>
                    <span aria-hidden style={{
                      width: 32, height: 32, border: `1px solid ${palette.rule}`,
                      display: "inline-flex", alignItems: "center", justifyContent: "center",
                      fontFamily: "var(--mono)", fontSize: 14, flexShrink: 0,
                      background: isOpen ? palette.accent : "transparent",
                      color: isOpen ? palette.accentInk : palette.ink,
                      transition: "all 0.2s"
                    }}>{isOpen ? "–" : "+"}</span>
                  </button>
                  <div style={{
                    maxHeight: isOpen ? 400 : 0, overflow: "hidden",
                    transition: "max-height 0.3s ease, padding 0.3s ease",
                    paddingBottom: isOpen ? 22 : 0
                  }}>
                    <p style={{
                      fontFamily: "var(--body)", fontSize: 15, lineHeight: 1.7,
                      color: palette.ink2, margin: 0,
                      paddingRight: 56, paddingLeft: 64
                    }}>{item.a}</p>
                  </div>
                </li>);

            })}
          </ul>
        </div>
      </div>
    </section>);

}

function CTA({ palette }) {
  return (
    <section style={{ borderBottom: `1px solid ${palette.rule}`, background: palette.ink, color: palette.bg, position: "relative" }}>
      <div style={{
        maxWidth: 1320, margin: "0 auto", padding: "96px 32px",
        display: "grid", gridTemplateColumns: "1.6fr 1fr", gap: 56, alignItems: "end"
      }}>
        <div>
          <div style={{
            fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.22em",
            textTransform: "uppercase", color: palette.accent, marginBottom: 28
          }}>◇ 開始合作</div>
          <h2 style={{
            fontFamily: "var(--display)",
            lineHeight: 0.98, fontWeight: 500, margin: 0, color: palette.bg,
            letterSpacing: "-0.02em", fontSize: "50px"
          }}>
            不想承擔全職 AI 團隊<br />
            的成本,又
            <em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500, fontSize: "50px" }}>需要把事做完</em>?
          </h2>
        </div>
        <div>
          <p style={{
            fontFamily: "var(--body)", fontSize: 16, lineHeight: 1.65,
            color: palette.ink2, margin: "0 0 28px"
          }}>
            告訴我們你最卡的一到兩件事。我們會在 24 小時內回覆一份按時數計算的行動方案——不需要先簽約。
          </p>
          <div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
            <a href="mailto:hello@fde-ai.tw?subject=AI%20Discovery%20Call" style={{
              fontFamily: "var(--body)", fontSize: 15, fontWeight: 500,
              padding: "16px 22px", background: palette.accent, color: palette.accentInk,
              textDecoration: "none", border: `1px solid ${palette.accent}`,
              display: "flex", alignItems: "center", justifyContent: "space-between"
            }}>預約 30 分鐘探索 <span style={{ fontFamily: "var(--mono)" }}>→</span></a>
            <a href="mailto:hello@fde-ai.tw?subject=AI%20Hourly%20Inquiry" style={{
              fontFamily: "var(--body)", fontSize: 15, fontWeight: 500,
              padding: "15px 22px", color: palette.bg, textDecoration: "none",
              border: `1px solid ${palette.bg}55`,
              display: "flex", alignItems: "center", justifyContent: "space-between"
            }}>寄信給我們 <span style={{ fontFamily: "var(--mono)" }}>↗</span></a>
          </div>
        </div>
      </div>
    </section>);

}

function Footer({ palette }) {
  return (
    <footer style={{ background: palette.bg, color: palette.ink }}>
      <div style={{
        maxWidth: 1320, margin: "0 auto", padding: "64px 32px 28px",
        display: "grid", gridTemplateColumns: "2fr 1fr 1fr 1fr", gap: 48
      }}>
        <div>
          <div style={{
            fontFamily: "var(--display)", fontSize: 22, fontWeight: 600,
            marginBottom: 14, display: "flex", alignItems: "center", gap: 10
          }}>
            <span aria-hidden style={{
              width: 26, height: 26, background: palette.accent, color: palette.accentInk,
              fontFamily: "var(--display)", fontSize: 14, fontWeight: 700,
              display: "inline-flex", alignItems: "center", justifyContent: "center"
            }}>印</span>
            FDE <em style={{ fontStyle: "italic", color: palette.accent, fontWeight: 500 }}>AI</em> 事務所
          </div>
          <p style={{
            maxWidth: 360, fontSize: 14, lineHeight: 1.65,
            color: palette.ink2, fontFamily: "var(--body)", margin: 0
          }}>
            為全球企業而生的按時計費 AI 工程夥伴。把 AI 從「應該要用」變成「真的在用」。
          </p>
        </div>
        {[
        { h: "Services", zh: "服務", items: [["AI 落地導入", "#services"], ["流程自動化", "#services"], ["資料與整合交付", "#services"]] },
        { h: "Company", zh: "我們", items: [["合作流程", "#process"], ["為何選我們", "#why"], ["常見問題", "#faq"]] },
        { h: "Contact", zh: "聯絡", items: [["hello@fde-ai.tw", "mailto:hello@fde-ai.tw"], ["LINE @fde-ai", "#"], ["台北 · 線上協作", "#"]] }].
        map((col) =>
        <div key={col.h}>
            <div style={{
            fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.22em",
            textTransform: "uppercase", color: palette.muted, marginBottom: 14
          }}>{col.h} · {col.zh}</div>
            <ul style={{
            listStyle: "none", margin: 0, padding: 0,
            display: "flex", flexDirection: "column", gap: 8
          }}>
              {col.items.map(([label, href]) =>
            <li key={label}>
                  <a href={href} style={{
                fontFamily: "var(--body)", fontSize: 14,
                color: palette.ink, textDecoration: "none"
              }}>{label}</a>
                </li>
            )}
            </ul>
          </div>
        )}
      </div>
      <div style={{
        borderTop: `1px solid ${palette.rule}`, maxWidth: 1320, margin: "0 auto",
        padding: "20px 32px", display: "flex", justifyContent: "space-between",
        fontFamily: "var(--mono)", fontSize: 11, letterSpacing: "0.18em",
        textTransform: "uppercase", color: palette.muted
      }}>
        <span>© 2026 FDE AI 事務所</span>
        <span>Built for the World · 全球協作</span>
      </div>
    </footer>);

}

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "palette": "paper",
  "typography": "serif"
} /*EDITMODE-END*/;

function App() {
  const [tweaks, setTweak] = window.useTweaks(TWEAK_DEFAULTS);
  const palette = PALETTES[tweaks.palette] || PALETTES.paper;
  const type = TYPE_FAMILIES[tweaks.typography] || TYPE_FAMILIES.serif;

  useEffect(() => {
    const r = document.documentElement;
    r.style.setProperty("--bg", palette.bg);
    r.style.setProperty("--ink", palette.ink);
    r.style.setProperty("--display", type.display);
    r.style.setProperty("--body", type.body);
    r.style.setProperty("--mono", type.mono);
    document.body.style.background = palette.bg;
    document.body.style.color = palette.ink;
  }, [palette, type]);

  const TP = window.TweaksPanel;
  const TS = window.TweakSection;
  const TR = window.TweakRadio;

  return (
    <>
      <Nav palette={palette} />
      <Hero palette={palette} />
      <Services palette={palette} />
      <Process palette={palette} />
      <Why palette={palette} />
      <FaqSection palette={palette} />
      <CTA palette={palette} />
      <Footer palette={palette} />
      {TP &&
      <TP title="Tweaks">
          <TS title="色調 Palette">
            <TR value={tweaks.palette} onChange={(v) => setTweak("palette", v)}
          options={[
          { value: "paper", label: "和紙" },
          { value: "ink", label: "墨" },
          { value: "jade", label: "青磁" }]
          } />
          </TS>
          <TS title="字體 Typography">
            <TR value={tweaks.typography} onChange={(v) => setTweak("typography", v)}
          options={[
          { value: "serif", label: "明朝" },
          { value: "sans", label: "黑體" },
          { value: "mixed", label: "混排" }]
          } />
          </TS>
        </TP>
      }
    </>);

}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);