/* ============ About stagger reveal ============ */
function useStaggerReveal(threshold = 0.12) {
  const ref = React.useRef(null);
  React.useEffect(() => {
    const container = ref.current;
    if (!container) return;
    // 找出所有標記 data-stagger 的子元素
    const items = container.querySelectorAll('[data-stagger]');
    items.forEach((el, i) => {
      el.style.opacity = '0';
      el.style.transform = 'translateY(28px)';
      el.style.transition = `opacity 700ms cubic-bezier(.22,.68,0,1.1) ${i * 110}ms, transform 700ms cubic-bezier(.22,.68,0,1.1) ${i * 110}ms`;
    });
    const io = new IntersectionObserver((entries) => {
      entries.forEach(e => {
        if (e.isIntersecting) {
          items.forEach(el => {
            el.style.opacity = '1';
            el.style.transform = 'none';
          });
          io.unobserve(container);
        }
      });
    }, { threshold });
    io.observe(container);
    return () => io.disconnect();
  }, []);
  return ref;
}

/* ============ About ============ */
function About() {
  const heroRef = useReveal(0.15);
  const valuesRef = useStaggerReveal(0.12);
  const statsRef = useStaggerReveal(0.18);
  const timelineRef = useReveal(0.1);

  const highlights = [
  {
    icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="26" height="26"><rect x="4" y="8" width="24" height="16" rx="1.5" /><path d="M4 13h24M10 8V6M22 8V6" /><path d="M9 18h4M19 18h4" /></svg>,
    title: "整合 MIS、GIS、BIM、AI 四大資訊技術領域"
  },
  {
    icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="26" height="26"><path d="M6 26V12l10-6 10 6v14" /><path d="M12 26v-7h8v7" /><rect x="13" y="8" width="6" height="4" rx="0.5" /></svg>,
    title: "長期參與政府機關資訊系統建置"
  },
  {
    icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="26" height="26"><circle cx="11" cy="12" r="4" /><circle cx="21" cy="12" r="4" /><path d="M3 26c0-4.418 3.582-8 8-8M21 18c4.418 0 8 3.582 8 8" /><path d="M14 20c1.657 0 3 .895 3 2s-1.343 2-3 2-3-.895-3-2 1.343-2 3-2z" fill="none" /><path d="M11 20c0 3.314 2.239 6 5 6s5-2.686 5-6" /></svg>,
    title: "服務建築師事務所、營建公司及民間企業"
  },
  {
    icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="26" height="26"><path d="M8 4h12l6 6v18a2 2 0 01-2 2H8a2 2 0 01-2-2V6a2 2 0 012-2z" /><path d="M20 4v6h6" /><path d="M11 18l3 3 6-6" /></svg>,
    title: "累積超過 450 項政府與公共資訊專案經驗"
  }];


  const values = [
  {
    icon: <svg viewBox="0 0 40 40" fill="none" stroke="currentColor" strokeWidth="1.3" width="36" height="36"><circle cx="20" cy="20" r="14" /><circle cx="20" cy="20" r="7" /><line x1="20" y1="6" x2="20" y2="2" /><line x1="20" y1="34" x2="20" y2="38" /><line x1="6" y1="20" x2="2" y2="20" /><line x1="34" y1="20" x2="38" y2="20" /></svg>,
    title: "全生命週期整合",
    desc: "從設計規劃、施工管理、竣工資料到後續營運，串聯不同階段的資訊與管理流程，讓工程資料能持續累積、延續使用，而不是隨著專案結束而中斷。"
  },
  {
    icon: <svg viewBox="0 0 40 40" fill="none" stroke="currentColor" strokeWidth="1.3" width="36" height="36"><path d="M20 4l14 6v10c0 8-6 14-14 16C12 34 6 28 6 20V10l14-6z" /><polyline points="13,20 18,25 28,15" /></svg>,
    title: "現場管理數位化",
    desc: "將人員、設備、查驗、日報、會議、工項與進度等現場作業轉為標準化數位流程，降低紙本作業、人工彙整與資訊分散所造成的管理落差。"
  },
  {
    icon: <svg viewBox="0 0 40 40" fill="none" stroke="currentColor" strokeWidth="1.3" width="36" height="36"><circle cx="20" cy="16" r="7" /><path d="M14 23l-3 12 9-5 9 5-3-12" /><line x1="20" y1="9" x2="20" y2="6" /><line x1="26" y1="11" x2="28" y2="9" /><line x1="14" y1="11" x2="12" y2="9" /></svg>,
    title: "資料可追溯、管理可持續",
    desc: "完整保留工程執行過程中的文件、紀錄、履歷與處理歷程，使資料可查詢、流程可追蹤、責任可釐清，逐步建立企業可長期運作的數位管理能力。"
  },
  {
    icon: <svg viewBox="0 0 40 40" fill="none" stroke="currentColor" strokeWidth="1.3" width="36" height="36"><path d="M6 28c4-4 8-6 14-6s10 2 14 6" /><circle cx="14" cy="16" r="5" /><circle cx="26" cy="16" r="5" /><path d="M19 16h2" /></svg>,
    title: "系統整合與長期共創",
    desc: "透過 API 串接既有 ERP、工務、設備及其他管理系統，依企業現況逐步導入，不以單一系統取代全部作業，而是協助客戶建立可擴充、可延續的整體管理架構。"
  }];


  const stats = [
  { icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28"><rect x="4" y="6" width="24" height="22" rx="1.5" /><path d="M4 12h24M10 6V3M22 6V3" /></svg>, num: "1989", label: "成立年份" },
  { icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28"><rect x="5" y="4" width="22" height="26" rx="1.5" /><path d="M10 10h12M10 15h12M10 20h8" /></svg>, num: "450+", label: "政府專案實績" },
  { icon: <svg viewBox="0 0 32 32" fill="none" stroke="currentColor" strokeWidth="1.4" width="28" height="28"><path d="M16 4l3.09 6.26L26 11.27l-5 4.87 1.18 6.86L16 20l-6.18 3.1L11 16.14 6 11.27l6.91-1.01L16 4z" /></svg>, num: "30+", label: "獲獎與肯定" }];


  const timeline = [
  { era: "1989", code: "GIS", zh: "地理資訊系統", desc: "建立台灣早期地理圖資基礎，參與多項政府空間資料庫建置。" },
  { era: "2000's", code: "BIM", zh: "建築資訊模型", desc: "導入三維建模技術，推動工程設計與施工資訊整合。" },
  { era: "2020's", code: "AI", zh: "人工智慧應用", desc: "以 LLM 與電腦視覺賦能現場管理，開啟營建業 AI 新頁。" }];


  return (
    <section className="lx-about-wrap" id="about" style={{ scrollMarginTop: "120px" }}>

      {/* ── Part 1: Hero split ── */}
      <div className="lx-about-hero lx-reveal" ref={heroRef} style={{ minHeight: "548px" }}>
        <div className="lx-about-hero-bg">
          <img src="img/about-building.webp" alt="路克索辦公大樓" />
        </div>
        <div className="lx-about-hero-content">
          <span className="lx-section-eyebrow-line lx-about-stagger" style={{ transitionDelay: "0ms" }}>ABOUT LUXOR</span>
          <h2 className="lx-about-main-title lx-about-stagger" style={{ transitionDelay: "100ms" }}>認識我們</h2>
          <p className="lx-about-sub-title lx-about-stagger" style={{ transitionDelay: "180ms" }}>三十七年技術累積，跨域服務政府與產業</p>
          <p className="lx-about-body-text lx-about-stagger" style={{ transitionDelay: "260ms" }}>
            自 1989 年起，團隊持續參與超過 450 項政府資訊專案，累積市政系統、空間資訊、建築資訊與數位治理的實務經驗。
          </p>
          <p className="lx-about-body-text lx-about-stagger" style={{ transitionDelay: "320ms" }}>
            因應不同服務市場，團隊一方面承接政府部門及公共領域專案，一方面聚焦企業、建築師事務所、營建公司及其他非政府部門的數位化需求。相同的核心成員、技術能力與專案經驗，依客戶屬性提供適合的服務模式。
          </p>
          <div className="lx-about-highlights">
            {highlights.map((h, i) =>
            <div key={i} className="lx-about-highlight lx-about-stagger" style={{ transitionDelay: `${400 + i * 90}ms` }}>
                <span className="lx-about-highlight-icon">{h.icon}</span>
                <span style={{ fontSize: "16px" }}>{h.title}</span>
              </div>
            )}
          </div>
        </div>
      </div>

      {/* ── Part 2: 我們的價值 ── */}
      <div className="lx-about-values" ref={valuesRef}>
        <div className="lx-container">
          <p className="lx-about-values-label" data-stagger style={{ fontSize: "27px" }}>路克索數位四大核心價值</p>
          <div className="lx-about-values-grid">
            {values.map((v, i) =>
            <div key={i} className="lx-about-value-card" data-stagger>
                <span className="lx-about-value-icon">{v.icon}</span>
                <h4 className="lx-about-value-title">{v.title}</h4>
                <p className="lx-about-value-desc">{v.desc}</p>
              </div>
            )}
          </div>
        </div>
      </div>

      {/* ── Part 3: Stats ── */}
      <div className="lx-about-stats-band" ref={statsRef}>
        <div className="lx-container">
          <div className="lx-about-stats-grid" style={{ minHeight: "276px" }}>
            {stats.map((s, i) =>
            <div key={i} className="lx-about-stat" data-stagger>
                <span className="lx-about-stat-icon">{s.icon}</span>
                <div className="lx-about-stat-num">{s.num}</div>
                <div className="lx-about-stat-label">{s.label}</div>
              </div>
            )}
            <div className="lx-about-stats-img" data-stagger>
              <img src="img/about-city.webp" alt="" style={{ objectFit: "cover", width: "432px" }} />
            </div>
          </div>
        </div>
      </div>

      {/* ── Part 4: GIS → BIM → AI Timeline ── */}
      <div className="lx-about-timeline lx-reveal" ref={timelineRef} style={{ minHeight: "737px" }}>
        <div className="lx-about-timeline-bg">
          <img src="img/about-gis-bim-ai.webp" alt="GIS BIM AI" />
        </div>
        <div className="lx-about-timeline-content">
          <h2 className="lx-about-timeline-title lx-about-stagger" style={{ transitionDelay: "0ms" }}>三十七年&ensp;以數位為業</h2>
          <p className="lx-about-timeline-desc lx-about-stagger" style={{ maxWidth: "700px", transitionDelay: "120ms" }}>
            自 1989 年起，路克索數位團隊為政府與公共部門提供資訊服務，累積參與超過 450 項政府專案；同一核心團隊也服務建築、營建及其他民間產業。從基礎地理圖資、GIS 系統建置，到 BIM 與 AI 應用，我們持續以穩健的技術與工程實務，陪伴公共建設與民間營造推進每一階段的數位轉型。
          </p>
          <div className="lx-about-tl-milestones-new">
            {timeline.map((t, i) =>
            <div key={i} className="lx-about-tl-item-new lx-about-stagger" style={{ transitionDelay: `${240 + i * 130}ms` }}>
                <div className="lx-about-tl-era-new">{t.era}</div>
                <div className="lx-about-tl-code-new" style={{ fontSize: "36px" }}>{t.code}</div>
                <div className="lx-about-tl-zh-new">{t.zh}</div>
                {i < timeline.length - 1 &&
              <div className="lx-about-tl-arrow-new">›</div>
              }
              </div>
            )}
          </div>
          <div className="lx-about-tl-bottom-labels">
            {timeline.map((t, i) =>
            <div key={i} className="lx-about-tl-bottom-item lx-about-stagger" style={{ transitionDelay: `${500 + i * 100}ms` }}>
                <div className="lx-about-tl-bottom-dot" style={{ background: i === 0 ? '#6b9e6b' : i === 1 ? '#5b8fc7' : '#8b7bbf' }}></div>
                <div className="lx-about-tl-bottom-code">{t.code}</div>
                <div className="lx-about-tl-bottom-zh">{t.zh}</div>
              </div>
            )}
          </div>
        </div>
      </div>

    </section>);

}
window.About = About;

/* ============ Scenarios ============ */
function Scenarios() {
  const ref = useReveal(0.2);
  const items = [
  { n: "01", t: "空間整合", d: "結合 GIS 與工程資料，整合地理環境與基礎設施資訊，建立跨尺度的空間管理基礎。" },
  { n: "02", t: "智慧建模", d: "導入 BIM 模型整合設計與施工資訊，提升專案可視化程度與協作效率。" },
  { n: "03", t: "工地管理", d: "整合現場人員、進度與巡檢資訊，透過數位平台掌握工地運作狀態。" },
  { n: "04", t: "專案掌控", d: "串聯排程、資源與執行狀況，協助管理者即時掌握專案全局。" },
  { n: "05", t: "AI 查詢", d: "以自然語言查詢工程資料與歷史紀錄，快速取得決策所需的資訊。" },
  { n: "06", t: "智慧分析", d: "運用 AI 分析工程數據，輔助風險判斷、異常偵測與決策參考。" },
  { n: "07", t: "流程串接", d: "整合跨單位作業流程與系統資料，降低溝通落差與重工成本。" },
  { n: "08", t: "履歷建構", d: "建立工程全生命週期數位履歷，讓設計、施工與維運資料完整留存與追溯。" }];

  return (
    <section className="lx-section lx-scenarios" id="scenario" style={{ padding: '140px 0 0' }}>
      <div className="lx-container">
        <div className="lx-section-head is-center lx-reveal" ref={ref} style={{ color: '#fff' }}>
          <span className="lx-section-eyebrow-line">SCENARIO · 應用場景</span>
          <h2 className="lx-section-title" style={{ color: '#fff' }}>落地於每一條產業鏈</h2>
          <p className="lx-section-sub">從公共建設到文化資產，路克索的技術走進不同場域</p>
        </div>
      </div>
      <div className="lx-container" style={{ padding: '0', maxWidth: 'none' }}>
        <div style={{ maxWidth: 'var(--lx-container-max)', margin: '0 auto', padding: '0 var(--lx-gutter)' }}>
          <div className="lx-scenarios-grid">
            {items.map((it, i) =>
            <div key={i} className="lx-scenario">
                <span className="lx-scenario-num" style={{ fontSize: "16px" }}>{it.n}</span>
                <h4 className="lx-scenario-title" style={{ color: "rgb(255, 255, 255)", fontSize: "22px" }}>{it.t}</h4>
                <p className="lx-scenario-desc" style={{ color: "rgb(220, 220, 220)" }}>{it.d}</p>
                <span className="lx-scenario-arrow">→</span>
              </div>
            )}
          </div>
        </div>
      </div>
    </section>);

}
window.Scenarios = Scenarios;
