/* ============================================================
 * sections.jsx — Hero, Cards3D, Features, Benefits, Testimonials,
 *                Pricing, FinalCTA, Footer
 * ============================================================ */

const VIDEO_HERO = "https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260502_134830_926d2233-a9a6-45e9-aaa2-28ef8beecb24.mp4";
const VIDEO_FEATURE = "https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260424_064411_9e9d7f84-9277-41f4-ab10-59172d89e6be.mp4";
const VIDEO_STATS = "https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260422_191657_800d4e1f-7ab3-41af-90b6-9bd3039eb294.mp4";
const VIDEO_TESTI = "https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260429_111347_9cf2a2b0-2c10-475b-a132-147a046b4927.mp4";
const VIDEO_PRICING = "https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260407_043131_ebe2f0b5-9acc-4a4f-b2c1-7297f1a3beb9.mp4";
const VIDEO_CTA = "https://d8j0ntlcm91z4.cloudfront.net/user_38xzZboKViGWJOttwIXH07lWA1P/hf_20260405_171521_25968ba2-b594-4b32-aab7-f6b69398a6fa.mp4";

/* ============================================================
 * Hero — mouse-scrub video, blurred intro, typewriter, action pills
 * ============================================================ */

/* Typewriter hook */
function useTypewriter(text, speed = 38, startDelay = 600) {
  const [displayed, setDisplayed] = React.useState('');
  const [done, setDone] = React.useState(false);
  React.useEffect(() => {
    let i = 0;
    let interval;
    const startTimer = setTimeout(() => {
      interval = setInterval(() => {
        i += 1;
        setDisplayed(text.slice(0, i));
        if (i >= text.length) {
          clearInterval(interval);
          setDone(true);
        }
      }, speed);
    }, startDelay);
    return () => {clearTimeout(startTimer);clearInterval(interval);};
  }, [text, speed, startDelay]);
  return { displayed, done };
}

/* Mouse-scrub background video */
function ScrubVideo({ src }) {
  const ref = React.useRef(null);
  const state = React.useRef({ prevX: null, target: 0, seeking: false });
  const SENSITIVITY = 0.8;

  React.useEffect(() => {
    const v = ref.current;
    if (!v) return;

    // Land on a well-lit frame initially (first frame may be black)
    const seekInitial = () => {
      if (v.duration) {
        const t0 = v.duration * 0.35;
        state.current.target = t0;
        try {v.currentTime = t0;} catch (e) {}
      }
    };
    if (v.readyState >= 1) seekInitial();else
    v.addEventListener('loadedmetadata', seekInitial, { once: true });

    const onSeeked = () => {
      const s = state.current;
      if (Math.abs(v.currentTime - s.target) > 0.01 && v.duration) {
        s.seeking = true;
        try {v.currentTime = s.target;} catch (e) {s.seeking = false;}
      } else {
        s.seeking = false;
      }
    };
    v.addEventListener('seeked', onSeeked);

    const onMove = (e) => {
      const s = state.current;
      if (!v.duration) return;
      if (s.prevX === null) {s.prevX = e.clientX;return;}
      const delta = e.clientX - s.prevX;
      s.prevX = e.clientX;
      let t = s.target + delta / window.innerWidth * SENSITIVITY * v.duration;
      t = Math.max(0, Math.min(v.duration, t));
      s.target = t;
      if (!s.seeking) {
        s.seeking = true;
        try {v.currentTime = t;} catch (err) {s.seeking = false;}
      }
    };
    window.addEventListener('mousemove', onMove);

    // Touch fallback: gently loop so mobile isn't a frozen frame
    let touchLoop;
    const isTouch = window.matchMedia('(hover: none)').matches;
    if (isTouch) {
      v.play?.().catch(() => {});
    }

    return () => {
      v.removeEventListener('seeked', onSeeked);
      window.removeEventListener('mousemove', onMove);
      if (touchLoop) clearInterval(touchLoop);
    };
  }, []);

  return (
    <video
      ref={ref}
      src={src}
      muted
      playsInline
      loop
      preload="auto"
      className="absolute inset-0 w-full h-full"
      style={{ objectFit: 'cover', objectPosition: '70% center' }} />);


}

function Hero() {
  const intro = useTypewriter(
    "I build small, strange, useful things.",
    45,
    250
  );
  const [pillsIn, setPillsIn] = React.useState(false);
  const [copied, setCopied] = React.useState(false);
  React.useEffect(() => {
    const t = setTimeout(() => setPillsIn(true), 150);
    return () => clearTimeout(t);
  }, []);

  const pills = [
  { label: '作品を見る', href: '#work' },
  { label: '開発中のアプリ', href: '#work' },
  { label: 'ひとことどうぞ', href: '#contact' },
  { label: 'GitHub', href: 'https://github.com/kurpsaki' }];


  const copyEmail = () => {
    navigator.clipboard?.writeText('capsulepoint.jp@gmail.com');
    setCopied(true);
    setTimeout(() => setCopied(false), 1600);
  };

  return (
    <section className="relative h-screen w-full overflow-hidden bg-black">
      {/* Scrub video bg */}
      <div className="absolute inset-0 z-0">
        <ScrubVideo src="uploads/hero-tv.mp4" />
        {/* Soften + warm tint to match marble palette */}
        <div
          className="absolute inset-0"
          style={{
            background: 'rgba(8,9,12,0.1)'
          }} />
        {/* Left legibility wash — subtle */}
        <div
          className="absolute inset-0"
          style={{
            background:
            'linear-gradient(90deg, rgba(8,9,12,0.65) 0%, rgba(8,9,12,0.25) 30%, rgba(8,9,12,0) 55%)'
          }} />
        {/* Bottom fade into marble */}
        <div
          className="absolute inset-0"
          style={{
            background:
            'linear-gradient(180deg, transparent 70%, rgba(8,9,12,0.7) 100%)'
          }} />
        {/* Subtle warm tone to reduce harshness */}
        <div
          className="absolute inset-0"
          style={{
            background: 'radial-gradient(ellipse 80% 60% at 65% 40%, rgba(180,160,140,0.04) 0%, transparent 70%)',
            mixBlendMode: 'overlay'
          }} />
        
      </div>

      <Navbar />

      {/* Content */}
      <div className="relative z-10 h-full flex flex-col justify-end pb-12 md:justify-center md:pb-0 px-5 sm:px-8 md:px-12">
        <div className="max-w-xl">
          {/* Eyebrow */}
          <div
            className="mb-4 text-[12px] tracking-[0.22em] uppercase text-white/55"
            style={{ fontWeight: 500 }}
          >
            Capsulepoint — Independent developer
          </div>

          {/* Typewriter headline */}
          <h1
            className="mb-7 text-white"
            style={{
              fontSize: 'clamp(30px, 6vw, 52px)',
              lineHeight: 1.08,
              fontWeight: 500,
              minHeight: '1.2em',
              fontFamily: 'var(--font-heading)',
              letterSpacing: '-0.02em'
            }}>
            
            {intro.displayed}
            {!intro.done &&
            <span
              className="inline-block w-[3px] h-[0.9em] bg-white align-middle ml-[3px]"
              style={{ animation: 'blink 1s step-end infinite' }} />

            }
          </h1>

          {/* Action pills */}
          <div
            className="flex flex-wrap gap-y-1"
            style={{
              opacity: pillsIn ? 1 : 0,
              transform: pillsIn ? 'translateY(0)' : 'translateY(8px)',
              transition: 'opacity 0.4s ease, transform 0.4s ease'
            }}>
            
            {pills.map((p, i) =>
            <a
              key={i}
              href={p.href}
              target={p.href.startsWith('http') ? '_blank' : undefined}
              rel={p.href.startsWith('http') ? 'noopener noreferrer' : undefined}
              className="inline-flex items-center justify-center bg-white/10 text-white border border-white/20 rounded-full text-[13px] sm:text-[15px] px-4 sm:px-5 py-[0.3em] mx-[0.2em] mb-[0.4em] hover:bg-white hover:text-black transition-colors duration-200 whitespace-nowrap">
              
                {p.label}
              </a>
            )}
            <button
              onClick={copyEmail}
              className="inline-flex items-center justify-center gap-2 sm:gap-3 bg-transparent text-white border border-white/40 rounded-full text-[13px] sm:text-[15px] px-4 sm:px-5 py-[0.3em] mx-[0.2em] mb-[0.4em] hover:bg-white hover:text-black transition-colors duration-200 whitespace-nowrap">
              
              {copied ? 'Copied!' : <>Reach me: <span className="underline underline-offset-1">capsulepoint.jp@gmail.com</span></>}
              <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" className="flex-shrink-0">
                <rect x="9" y="9" width="11" height="11" rx="2" />
                <path d="M5 15V5a2 2 0 0 1 2-2h10" />
              </svg>
            </button>
          </div>
        </div>
      </div>
    </section>);

}

/* ============================================================
 * Section 3 — How I Work (3D glass cards)
 * ============================================================ */
function Cards3D() {
  const cards = [
  {
    theme: 'orange',
    icon: <Icon.Code />,
    title: 'Build',
    desc: 'TypeScript + Next.js を中心に、フロントからインフラまで自分で組み上げます。'
  },
  {
    theme: 'blue',
    icon: <Icon.Palette />,
    title: 'Design',
    desc: 'Figma でワイヤーから UI まで。視覚と体験を地続きで考えます。'
  },
  {
    theme: 'green',
    icon: <Icon.Zap />,
    title: 'Ship',
    desc: '小さく出して、使いながら改善する。長く運用できる形を意識します。'
  }];


  return (
    <section id="focus" className="section">
      <div className="container">
        <div className="header" style={{ maxWidth: 760 }}>
          <div
            className="inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/55 mb-5"
            style={{ fontWeight: 400 }}>
            
            <span className="w-6 h-px bg-white/40" />
            How I Work
          </div>
          <h1 style={{ fontSize: 'clamp(34px, 4.8vw, 58px)', letterSpacing: '-0.035em', fontWeight: 500 }}>
            設計・実装・出荷を、<br />
            ひとりで地続きに。
          </h1>
          <p style={{ fontSize: 15, maxWidth: 520, marginTop: 22 }}>
            職能を切り分けず、一人で全体を見るのが好きです。
            プロトタイプの設計から運用まで、必要なら何でもやります。
          </p>
        </div>

        <div className="cards">
          {cards.map((c, i) =>
          <div className={`card ${c.theme}`} key={i}>
              <div className="depth" />
              <div className="glass" />
              <div className="card-content">
                <div className="icon-box">{c.icon}</div>
                <h2>{c.title}</h2>
                <p>{c.desc}</p>
              </div>
            </div>
          )}
        </div>

      </div>
    </section>);

}

/* ============================================================
 * Section 4 — Tech Stack (Features cards with hover video)
 * ============================================================ */
function StackCard({ icon, title, desc, tags }) {
  const [hovered, setHovered] = React.useState(false);
  return (
    <div
      className="group relative liquid-glass rounded-[28px] p-7 sm:p-8 overflow-hidden h-full"
      onMouseEnter={() => setHovered(true)}>
      
      {/* Hover video — only mounted after first hover so 4 cards don't compete for bandwidth */}
      <div
        className="absolute inset-0 transition-opacity duration-700 z-0"
        style={{ opacity: hovered ? 0.4 : 0 }}>
        
        {hovered && <VideoBackground src={VIDEO_FEATURE} />}
      </div>
      <div className="relative z-10 flex flex-col h-full">
        <div className="w-10 h-10 rounded-[10px] flex items-center justify-center mb-7 text-white/90"
        style={{ background: 'rgba(255,255,255,0.05)', border: '1px solid rgba(255,255,255,0.1)' }}>
          {icon}
        </div>
        <h3 className="text-[20px] tracking-[-0.02em] mb-2.5 text-white" style={{ fontWeight: 500 }}>
          {title}
        </h3>
        <p className="text-[13.5px] leading-[1.55] text-white/60 mb-5" style={{ fontWeight: 300 }}>
          {desc}
        </p>
        <div className="mt-auto flex flex-wrap gap-1.5">
          {tags.map((t, i) =>
          <span
            key={i}
            className="text-[11px] px-2.5 py-1 rounded-full text-white/65"
            style={{ background: 'rgba(255,255,255,0.04)', border: '1px solid rgba(255,255,255,0.08)', fontWeight: 300 }}>
            
              {t}
            </span>
          )}
        </div>
      </div>
    </div>);

}

/* ============================================================
 * Section 3.5 — Works (featured: gajest)
 * ============================================================ */
function WorksSection() {
  const apps = [
  {
    key: 'ascii-nyra',
    status: { label: 'In development', tone: 'wip' },
    title: 'ASCII Nyra',
    url: 'Android · iOS coming',
    year: '2026 — In development',
    tagline: 'ASCII で踊る、デスクトップ常駐キャラ',
    desc: 'モノクロのターミナル世界に住むキャラクター "Nyra" がスマホの画面で動いたり、コマンドに応えたりするアプリ。まず Android、将来的に iOS にも対応予定。',
    stack: ['Kotlin', 'Jetpack Compose', 'Compose Multiplatform'],
    links: [],
    icon: 'uploads/ascii-nyra-icon.png',
    roadmap: [
    { label: 'Design', state: 'done' },
    { label: 'Alpha', state: 'current' },
    { label: 'Beta', state: 'pending' },
    { label: 'Android', state: 'pending' },
    { label: 'iOS', state: 'pending' }]

  },
  {
    key: 'glistra',
    status: { label: 'In development', tone: 'wip' },
    title: 'Glistra',
    url: 'Android · iOS coming',
    year: '2026 — In development',
    tagline: '映像をグリッチ加工するビデオエディタ',
    desc: '撮った映像にデータモッシュやRGBずれ、走査線ノイズといったグリッチエフェクトをリアルタイムで重ねられるモバイル動画編集アプリ。サイバーで退廃的な質感を、指先だけで。',
    stack: ['Kotlin', 'OpenGL ES', 'GLSL Shaders', 'Media3'],
    icon: 'uploads/glistra-icon.png',
    links: [],
    roadmap: [
    { label: 'Design', state: 'done' },
    { label: 'Proto', state: 'current' },
    { label: 'Beta', state: 'pending' },
    { label: 'Android', state: 'pending' },
    { label: 'iOS', state: 'pending' }]

  }];


  return (
    <section id="work" className="relative py-20 sm:py-32 px-4 sm:px-6 lg:px-10 overflow-hidden">
      <div className="max-w-[1280px] mx-auto">
        {/* Section header */}
        <div className="flex flex-col md:flex-row md:items-end md:justify-between gap-6 mb-10 sm:mb-16">
          <div>
            <div
              className="inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/55 mb-5"
              style={{ fontWeight: 400 }}>
              
              <span className="w-6 h-px bg-white/40" />
              Selected Works
            </div>
            <h2 style={{ fontSize: 'clamp(34px, 4.4vw, 54px)', letterSpacing: '-0.035em', lineHeight: 1.04, fontWeight: 500, fontFamily: 'var(--font-heading)' }}>
              いま作っているもの、<br />
              <span className="text-white/45">運用しているもの。</span>
            </h2>
          </div>
        </div>

        {/* Group 1: Live websites */}
        <WorksGroupHeader
          eyebrow="01 / Websites"
          title="運営中のサイト"
          sub="クローラと一緒に毎日動いている Web サービス。" />
        
        <GajestFeatured />

        {/* Group 2: Apps in development */}
        <div className="mt-16 sm:mt-24">
          <WorksGroupHeader
            eyebrow="02 / Apps"
            title="開発中のアプリ"
            sub="モバイルを中心に、まだ世に出ていないけれど近いうちに出す予定のもの。" />
          
          <div className="grid grid-cols-1 md:grid-cols-2 gap-5 sm:gap-7">
            {apps.map((w) => <WorkCard key={w.key} work={w} />)}
          </div>
        </div>
      </div>
    </section>);

}

function WorksGroupHeader({ eyebrow, title, sub }) {
  return (
    <div className="flex items-end justify-between gap-6 mb-7 border-t border-white/10 pt-7">
      <div>
        <div className="text-[10.5px] tracking-[0.28em] uppercase text-white/40 mb-2" style={{ fontWeight: 400 }}>
          {eyebrow}
        </div>
        <h3 className="text-white" style={{ fontSize: 'clamp(22px, 2.4vw, 28px)', letterSpacing: '-0.02em', fontWeight: 500, fontFamily: 'var(--font-heading)' }}>
          {title}
        </h3>
      </div>
      <p className="hidden sm:block text-[12.5px] text-white/45 max-w-[320px] text-right leading-[1.55]" style={{ fontWeight: 300 }}>
        {sub}
      </p>
    </div>);

}

function GajestFeatured() {
  return (
    <div className="grid grid-cols-1 lg:grid-cols-[0.95fr_1.15fr] gap-10 lg:gap-14 items-stretch">
      {/* LEFT — light info card with a dark video banner on top */}
      <div className="flex flex-col">
        <div className="relative rounded-[28px] flex flex-col h-full overflow-hidden" style={{ background: "linear-gradient(180deg, #16171c 0%, #0c0d11 100%)", border: "1px solid rgba(255,255,255,0.08)", boxShadow: "0 1px 0 rgba(255,255,255,0.05) inset, 0 24px 50px rgba(0,0,0,0.28), 0 50px 90px rgba(0,0,0,0.22)" }}>
          {/* Black marble shelf + video showing through */}
          <div className="absolute inset-0 z-0">
            <div className="absolute inset-0" style={{ backgroundImage: 'url("assets/marble-black.jpg")', backgroundSize: '420px 420px', backgroundPosition: 'center', backgroundRepeat: 'repeat' }} />
            <div className="absolute inset-0" style={{ mixBlendMode: 'screen' }}>
              <GajestVideoOrFallback />
            </div>
            <div className="absolute inset-0" style={{ background: 'linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 55%, rgba(0,0,0,0.6) 100%)' }} />
          </div>

          {/* Content */}
          <div className="relative z-10 p-7 sm:p-9 flex flex-col h-full">
            <div className="flex items-center gap-3 mb-6">
              <div
                className="w-11 h-11 rounded-[12px] overflow-hidden relative flex-shrink-0"
                style={{
                  background: '#000',
                  border: '1px solid rgba(0,0,0,0.12)',
                  boxShadow: '0 8px 20px rgba(0,0,0,0.18)'
                }}>
                
                <img
                  src="uploads/gajest-logo.png"
                  alt="gajest"
                  className="absolute inset-0 w-full h-full object-cover" />
                
              </div>
              <div>
                <div className="text-[18px] text-white tracking-[-0.02em]" style={{ fontWeight: 500, fontFamily: 'var(--font-heading)' }}>gajest</div>
                <a
                  href="https://gajest.com"
                  target="_blank"
                  rel="noopener noreferrer"
                  className="text-[12px] text-white/55 hover:text-white/80 transition-colors"
                  style={{ fontWeight: 400 }}>
                  
                  gajest.com ↗
                </a>
              </div>
            </div>

            <p className="text-[15px] leading-[1.7] text-white/85 mb-6" style={{ fontWeight: 400 }}>
              メカニカルキーボード、E-Ink端末、ポータブルDAC——
              大手比較サイトでは拾われない<em style={{ fontStyle: 'italic' }}>ニッチガジェット</em>のセール情報を、
              クローラで自動収集して毎日公開しています。
            </p>
            <p className="text-[13.5px] leading-[1.7] text-white/60 mb-8" style={{ fontWeight: 400 }}>
              個人開発で 0→1。要件定義からデザイン、Next.js 14 + TypeScript の実装、
              GitHub Actions による定時クロールまでひとりで構築・運用しています。
            </p>

            {/* Tech chips */}
            <div className="mb-8">
              <div className="text-[10.5px] tracking-[0.22em] uppercase text-white/45 mb-3" style={{ fontWeight: 500 }}>
                Stack
              </div>
              <div className="flex flex-wrap gap-1.5">
                {['Next.js 14', 'TypeScript', 'Tailwind CSS', 'GitHub Actions', 'Vercel', 'Cron'].map((t, i) =>
                <span key={i} className="text-[11.5px] rounded-full text-white/80 px-2.5 py-1" style={{ fontWeight: 400 }}>
                    {t}
                  </span>
                )}
              </div>
            </div>

            {/* Mini stats */}
            <div className="grid grid-cols-3 gap-4 mt-auto pt-6 border-t border-white/15">
              <MiniStat n="2025" l="リリース年" />
              <MiniStat n="Daily" l="クロール頻度" />
              <MiniStat n="1人" l="開発・運用" />
            </div>

            <div className="mt-8 flex flex-wrap gap-2.5">
              <a
                href="https://gajest.com"
                target="_blank"
                rel="noopener noreferrer"
                className="inline-flex items-center gap-2 rounded-full cta-pearl px-5 py-2.5 text-[13px] transition-all"
                style={{ fontWeight: 500 }}>
                
                サイトを開く
                <Icon.Arrow width="13" height="13" />
              </a>
            </div>
          </div>
        </div>
      </div>

      {/* RIGHT — browser mockup */}
      <div className="relative">
        <GajestMockup />
      </div>
    </div>);

}

function MiniStat({ n, l }) {
  return (
    <div>
      <div className="text-white text-[20px] tracking-[-0.02em]" style={{ fontWeight: 600, fontFamily: 'var(--font-heading)' }}>{n}</div>
      <div className="text-[11px] text-white/50 mt-0.5" style={{ fontWeight: 400 }}>{l}</div>
    </div>);

}

function GajestMockup() {
  const deals = [
  { cat: 'Mech Keyboard', title: 'Keychron Q1 Pro QMK/VIA', old: '¥36,800', now: '¥27,600', off: '-25%', shop: 'Amazon JP', hot: true },
  { cat: 'E-Ink', title: 'BOOX Go 7 7インチ電子書籍リーダー', old: '¥38,800', now: '¥31,040', off: '-20%', shop: '楽天市場' },
  { cat: 'Audio', title: 'FiiO BTR17 ポータブルDAC/AMP', old: '¥42,000', now: '¥33,600', off: '-20%', shop: 'e☆イヤホン' }];


  return (
    <div
      className="relative rounded-[28px] overflow-hidden h-full min-h-[560px]"
      style={{
        border: '1px solid rgba(255,255,255,0.08)',
        boxShadow:
          '0 1px 0 rgba(255,255,255,0.05) inset, 0 24px 50px rgba(0,0,0,0.28), 0 50px 90px rgba(0,0,0,0.22)'
      }}>
      
      {/* Black marble base inside the glass frame */}
      <div
        className="absolute inset-0 z-0"
        style={{
          backgroundImage: 'url("assets/marble-black.jpg")',
          backgroundSize: '480px 480px',
          backgroundPosition: 'center',
          backgroundRepeat: 'repeat'
        }} />
      
      <div
        className="absolute inset-0 z-0"
        style={{
          background:
          'linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.45) 60%, rgba(0,0,0,0.55) 100%)'
        }} />
      
      <div className="relative z-10">
      {/* Browser chrome */}
      <div
          className="flex items-center gap-3 px-4 py-3 border-b border-white/[0.06]"
          style={{ background: 'rgba(255,255,255,0.02)' }}>
          
        <div className="flex items-center gap-1.5">
          <span className="w-2.5 h-2.5 rounded-full" style={{ background: '#ff5f56' }} />
          <span className="w-2.5 h-2.5 rounded-full" style={{ background: '#ffbd2e' }} />
          <span className="w-2.5 h-2.5 rounded-full" style={{ background: '#27c93f' }} />
        </div>
        <div
            className="flex-1 mx-2 px-3 py-1.5 rounded-md text-[11px] text-white/55 flex items-center gap-2"
            style={{ background: 'rgba(255,255,255,0.04)', fontWeight: 300 }}>
            
          <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
            <rect x="3" y="11" width="18" height="11" rx="2" />
            <path d="M7 11V7a5 5 0 0 1 10 0v4" />
          </svg>
          gajest.com
        </div>
        <div className="text-[10px] text-white/35 uppercase tracking-[0.2em]">live</div>
      </div>

      {/* App content */}
      <div className="p-6 sm:p-7">
        <div className="flex items-center justify-between mb-6">
          <div className="flex items-center gap-2.5">
            <div
                className="w-7 h-7 rounded-[8px] overflow-hidden relative flex-shrink-0"
                style={{
                  background: '#000',
                  border: '1px solid rgba(255,255,255,0.15)',
                  boxShadow: '0 4px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.12)'
                }}>
                
              <img
                  src="uploads/gajest-logo.png"
                  alt="gajest"
                  className="absolute inset-0 w-full h-full object-cover" />
                
            </div>
            <span className="text-white text-[15px] tracking-[-0.02em]" style={{ fontWeight: 500 }}>gajest</span>
          </div>
          <div className="hidden sm:flex items-center gap-5 text-[11.5px] text-white/55" style={{ fontWeight: 300 }}>
            <span className="text-white">セール</span>
            <span>カテゴリ</span>
            <span>新着</span>
            <span>About</span>
          </div>
        </div>

        <div className="mb-5 flex items-end justify-between">
          <div>
            <div className="text-[10.5px] tracking-[0.22em] uppercase text-white/40 mb-1.5" style={{ fontWeight: 400 }}>
              本日のセール · 2026/05/28
            </div>
            <h3 className="text-white text-[20px] sm:text-[22px] tracking-[-0.02em]" style={{ fontWeight: 500 }}>
              ニッチガジェット 24 件
            </h3>
          </div>
          <div className="text-[11px] text-white/40 hidden sm:flex items-center gap-1.5">
            <span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
            12 分前に更新
          </div>
        </div>

        <div className="flex gap-1.5 mb-5 overflow-x-auto pb-1">
          {['All', 'Keyboard', 'E-Ink', 'Audio', 'Mouse', 'NAS', 'SBC'].map((c, i) =>
            <span
              key={c}
              className="text-[11px] px-3 py-1 rounded-full whitespace-nowrap"
              style={{
                background: i === 0 ? 'white' : 'rgba(255,255,255,0.04)',
                color: i === 0 ? '#0a0b10' : 'rgba(255,255,255,0.7)',
                border: i === 0 ? 'none' : '1px solid rgba(255,255,255,0.08)',
                fontWeight: i === 0 ? 500 : 300
              }}>
              
              {c}
            </span>
            )}
        </div>

        <div className="space-y-2.5">
          {deals.map((d, i) =>
            <div
              key={i}
              className="rounded-xl p-3.5 flex items-center gap-3.5 relative overflow-hidden"
              style={{ background: 'rgba(255,255,255,0.025)', border: '1px solid rgba(255,255,255,0.06)' }}>
              
              <div
                className="w-14 h-14 rounded-lg flex-shrink-0 flex items-center justify-center"
                style={{
                  background:
                  i === 0 ? 'linear-gradient(135deg, #2a2a35, #14141a)' :
                  i === 1 ? 'linear-gradient(135deg, #1a2533, #0f1620)' :
                  'linear-gradient(135deg, #2a1a33, #150a1f)',
                  border: '1px solid rgba(255,255,255,0.06)'
                }}>
                
                {i === 0 &&
                <div className="grid grid-cols-5 gap-[2px]">
                    {Array.from({ length: 15 }).map((_, k) =>
                  <span key={k} className="w-1 h-1 rounded-[1px] bg-white/40" />
                  )}
                  </div>
                }
                {i === 1 &&
                <div className="w-7 h-9 rounded-[2px] flex items-center justify-center"
                style={{ background: 'rgba(230,225,210,0.92)' }}>
                    <div className="flex flex-col gap-[2px]">
                      <span className="w-4 h-[1.5px] bg-black/55" />
                      <span className="w-3 h-[1.5px] bg-white/40" />
                      <span className="w-4 h-[1.5px] bg-black/50" />
                    </div>
                  </div>
                }
                {i === 2 &&
                <div className="flex items-end gap-[2px] h-6">
                    {[3, 7, 5, 9, 4, 8, 6, 10, 5].map((h, k) =>
                  <span key={k} className="w-[2px] rounded-full bg-white/45" style={{ height: h * 2 }} />
                  )}
                  </div>
                }
              </div>

              <div className="min-w-0 flex-1">
                <div className="flex items-center gap-2 mb-1">
                  <span className="text-[9.5px] tracking-[0.16em] uppercase text-white/45" style={{ fontWeight: 400 }}>
                    {d.cat}
                  </span>
                  {d.hot &&
                  <span
                    className="text-[9px] px-1.5 py-0.5 rounded-sm tracking-wide uppercase"
                    style={{ background: 'linear-gradient(135deg, #ff7a18, #ff3d00)', color: 'white', fontWeight: 500 }}>
                    
                      Hot
                    </span>
                  }
                </div>
                <div className="text-white text-[12.5px] leading-[1.3] truncate"
                style={{ fontWeight: 400 }} title={d.title}>
                  {d.title}
                </div>
                <div className="text-[10.5px] text-white/45 mt-1" style={{ fontWeight: 300 }}>
                  {d.shop}
                </div>
              </div>

              <div className="text-right flex-shrink-0">
                <div className="text-[10px] text-white/40 line-through" style={{ fontWeight: 300 }}>{d.old}</div>
                <div className="text-white text-[15px] tracking-[-0.02em]" style={{ fontWeight: 600 }}>{d.now}</div>
                <div
                  className="text-[10px] mt-0.5 inline-block px-1.5 py-0.5 rounded"
                  style={{ color: '#ff8a3d', background: 'rgba(255,89,30,0.12)', border: '1px solid rgba(255,89,30,0.25)', fontWeight: 500 }}>
                  
                  {d.off}
                </div>
              </div>
            </div>
            )}
        </div>

        <div
            className="mt-5 rounded-xl p-3.5 flex items-center justify-between gap-3 text-[10.5px] text-white/60"
            style={{ background: 'rgba(255,255,255,0.025)', border: '1px solid rgba(255,255,255,0.06)', fontWeight: 300 }}>
            
          <PipelineNode label="Crawl" sub="GitHub Actions" />
          <span className="flex-1 h-px bg-white/10" />
          <PipelineNode label="Normalize" sub="TypeScript" />
          <span className="flex-1 h-px bg-white/10" />
          <PipelineNode label="Publish" sub="Next.js 14" />
        </div>

        <div className="mt-3 flex items-center justify-between text-[10.5px] text-white/40" style={{ fontWeight: 300 }}>
          <span>毎日 09:00 JST に自動実行</span>
          <span className="inline-flex items-center gap-1">
            すべて見る
            <Icon.Arrow width="10" height="10" />
          </span>
        </div>
      </div>
      </div>
    </div>);

}

function PipelineNode({ label, sub }) {
  return (
    <div className="flex flex-col items-center text-center min-w-0">
      <span className="text-white text-[12px] tracking-[-0.01em]" style={{ fontWeight: 500 }}>{label}</span>
      <span className="text-[9.5px] text-white/40 tracking-[0.05em] mt-0.5">{sub}</span>
    </div>);

}

function WorkCard({ work }) {
  return (
    <article className="relative rounded-[28px] overflow-hidden flex flex-col" style={{ background: "linear-gradient(180deg, rgba(30,32,38,0.6) 0%, rgba(22,24,30,0.55) 100%)", backdropFilter: "blur(24px) saturate(1.2)", WebkitBackdropFilter: "blur(24px) saturate(1.2)", border: "1px solid rgba(255,255,255,0.1)", boxShadow: "0 1px 0 rgba(255,255,255,0.06) inset, 0 24px 50px rgba(0,0,0,0.28), 0 50px 90px rgba(0,0,0,0.22)" }}>
      {/* Visual — light warm media area with the app icon */}
      <div
        className="relative w-full overflow-hidden"
        style={{
          aspectRatio: '4 / 3',
          background: '#181a1f'
        }}>
        {/* Black marble texture */}
        <div className="absolute inset-0" style={{
          backgroundImage: 'url("assets/marble-black.jpg")',
          backgroundSize: '380px 380px',
          backgroundPosition: 'center',
          backgroundRepeat: 'repeat',
          opacity: 0.7
        }} />
        <div className="absolute inset-0" style={{
          background: 'radial-gradient(ellipse 70% 60% at 50% 50%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.3) 100%)'
        }} />
        {work.key === 'gajest' && <GajestVideoOrFallback />}
        {work.icon &&
        <div className="absolute inset-0 z-[1]">
            {/* Soft glow behind the icon */}
            <div
            className="absolute inset-0"
            style={{
              background:
              'radial-gradient(ellipse 55% 45% at 50% 48%, rgba(255,255,255,0.06) 0%, transparent 70%)'
            }} />
          
            {/* Sharp foreground icon */}
            <div className="absolute inset-0 flex items-center justify-center">
              <img
              src={work.icon}
              alt={work.title}
              className="w-[42%] aspect-square object-cover rounded-[22px]"
              style={{
                boxShadow:
                '0 22px 50px rgba(0,0,0,0.55),' +
                '0 6px 16px rgba(0,0,0,0.4)',
                border: '1px solid rgba(255,255,255,0.12)'
              }} />
            
            </div>
          </div>
        }
        {/* status pill (light) */}
        <div className="absolute top-4 left-4 z-10">
          <span
            className="inline-flex items-center gap-1.5 pl-2 pr-3 py-1 rounded-full text-[10.5px] tracking-[0.16em] uppercase"
            style={{ background: 'rgba(0,0,0,0.45)', border: '1px solid rgba(255,255,255,0.15)', color: '#ffffff', backdropFilter: 'blur(8px)', fontWeight: 500 }}
          >
            <span className="relative inline-flex h-1.5 w-1.5 rounded-full" style={{ background: work.status.tone === 'live' ? '#4dffae' : '#c8a4ff' }} />
            {work.status.label}
          </span>
        </div>
      </div>

      {/* Body */}
      <div className="relative p-7 sm:p-8 flex flex-col flex-1">
        <div className="text-[10.5px] tracking-[0.18em] uppercase text-white/40 mb-2.5" style={{ fontWeight: 500 }}>
          {work.year}
        </div>
        <h3 className="text-white text-[22px] tracking-[-0.025em] leading-none mb-1.5" style={{ fontWeight: 600, fontFamily: 'var(--font-heading)' }}>
          {work.title}
        </h3>
        <div className="text-[12.5px] text-white/55 mb-5 tracking-[-0.005em]" style={{ fontWeight: 400 }}>
          {work.url}
        </div>

        <p className="text-[14.5px] leading-[1.7] text-white/80 mb-3" style={{ fontWeight: 400 }}>
          {work.tagline}
        </p>
        <p className="text-[13px] leading-[1.7] text-white/55 mb-7" style={{ fontWeight: 400 }}>
          {work.desc}
        </p>

        {/* Roadmap mini-strip — only for items still in development */}
        {work.status.tone === 'wip' && work.roadmap &&
        <div
          className="rounded-xl p-3.5 mb-7 -mt-2"
          style={{
            background: 'rgba(255,255,255,0.025)',
            border: '1px solid rgba(255,255,255,0.08)'
          }}>
          
            <div className="text-[10px] tracking-[0.22em] uppercase text-white/40 mb-2.5" style={{ fontWeight: 500 }}>
              Roadmap
            </div>
            <div className="flex items-center gap-1">
              {work.roadmap.map((step, i) =>
            <React.Fragment key={i}>
                  <div className="flex flex-col items-center flex-1 min-w-0">
                    <span
                  className="w-2 h-2 rounded-full mb-1.5"
                  style={{
                    background:
                    step.state === 'done' ? '#4dffae' :
                    step.state === 'current' ? '#c8a4ff' :
                    'rgba(255,255,255,0.2)',
                    boxShadow:
                    step.state === 'current' ? '0 0 8px rgba(200,164,255,0.6)' : 'none'
                  }} />
                
                    <span
                  className="text-[10px] text-center leading-tight"
                  style={{
                    color: step.state === 'pending' ? 'rgba(255,255,255,0.35)' : 'rgba(255,255,255,0.7)',
                    fontWeight: step.state === 'current' ? 500 : 300
                  }}>
                  
                      {step.label}
                    </span>
                  </div>
                  {i < work.roadmap.length - 1 &&
              <span
                className="h-px flex-shrink-0 self-start mt-1"
                style={{
                  width: 24,
                  background:
                  work.roadmap[i + 1].state !== 'pending' ?
                  'rgba(77,255,174,0.4)' :
                  'rgba(255,255,255,0.08)'
                }} />

              }
                </React.Fragment>
            )}
            </div>
          </div>
        }

        {/* Tech chips */}
        <div className="flex flex-wrap gap-1.5 mb-7 mt-auto">
          {work.stack.map((t, i) =>
          <span key={i} className="text-[11px] rounded-full text-white/75 px-2.5 py-1" style={{ fontWeight: 400 }}>
              {t}
            </span>
          )}
        </div>

        {/* Links */}
        {work.links.length > 0 &&
        <div className="flex flex-wrap gap-2">
            {work.links.map((l, i) =>
          <a
            key={i}
            href={l.href}
            target="_blank"
            rel="noopener noreferrer"
            className="inline-flex items-center gap-2 rounded-full cta-pearl px-5 py-2.5 text-[13px] transition-all"
            style={{ fontWeight: 500 }}>
            
                {l.label}
                <Icon.Arrow width="13" height="13" />
              </a>
          )}
          </div>
        }
      </div>
    </article>);

}

function GajestVideoOrFallback() {
  const videoRef = React.useRef(null);
  const [status, setStatus] = React.useState('playing');

  React.useEffect(() => {
    const v = videoRef.current;
    if (!v) return;
    const onError = () => setStatus('error');
    v.addEventListener('error', onError);
    const hardTimeout = setTimeout(() => {
      if (v.readyState < 2) setStatus('error');
    }, 12000);
    return () => {
      v.removeEventListener('error', onError);
      clearTimeout(hardTimeout);
    };
  }, []);

  return (
    <div className="absolute inset-0">
      <video
        ref={videoRef}
        src="uploads/gajestHERO-ascii.mp4"
        autoPlay
        muted
        loop
        playsInline
        preload="auto"
        className="absolute inset-0 w-full h-full object-cover"
        style={{ mixBlendMode: 'screen' }} />
      
      {status === 'error' &&
      <div
        className="absolute inset-0 flex items-center justify-center"
        style={{
          background:
          'radial-gradient(ellipse at 30% 20%, rgba(255,122,24,0.35), transparent 55%),' +
          'radial-gradient(ellipse at 75% 80%, rgba(255,61,0,0.32), transparent 55%),' +
          'linear-gradient(135deg, #1a1108 0%, #0a0805 100%)'
        }}>
        
          <div className="relative z-10 flex flex-col items-center text-center px-6">
            <div
            className="w-16 h-16 rounded-[18px] flex items-center justify-center mb-5"
            style={{
              background: 'linear-gradient(135deg, #ff7a18 0%, #ff3d00 60%, #d61f00 100%)',
              boxShadow: '0 12px 32px rgba(255,89,30,0.45), inset 0 1px 0 rgba(255,255,255,0.35)'
            }}>
            
              <span className="text-white text-[34px] leading-none" style={{ fontWeight: 600, letterSpacing: '-0.06em' }}>
                g
              </span>
            </div>
            <div className="text-white text-[22px] tracking-[-0.025em]" style={{ fontWeight: 500 }}>
              gajest.com
            </div>
            <div className="mt-2 text-[12px] text-white/55 max-w-[260px] leading-[1.5]" style={{ fontWeight: 300 }}>
              ニッチガジェットのセール情報を毎日自動収集
            </div>
          </div>
        </div>
      }
    </div>);

}

function StatusPill({ tone, label }) {
  const dotColor = tone === 'live' ? '#4dffae' : '#c8a4ff';
  return (
    <div
      className="inline-flex items-center gap-1.5 pl-2 pr-3 py-1 rounded-full text-[10.5px] tracking-[0.18em] uppercase text-white"
      style={{
        background: 'rgba(0,0,0,0.45)',
        backdropFilter: 'blur(8px)',
        border: '1px solid rgba(255,255,255,0.12)',
        fontWeight: 500
      }}>
      
      <span className="relative flex h-1.5 w-1.5">
        {tone === 'live' &&
        <span className="absolute inline-flex h-full w-full rounded-full opacity-75 animate-ping"
        style={{ background: dotColor }} />
        }
        <span className="relative inline-flex h-1.5 w-1.5 rounded-full" style={{ background: dotColor }} />
      </span>
      {label}
    </div>);

}

function StackSection() {
  return (
    <section id="stack" className="relative py-20 sm:py-32 px-4 sm:px-6 lg:px-10 overflow-hidden">
      <span className="chapter-numeral" aria-hidden="true">02</span>
      <div className="max-w-[1280px] mx-auto">
        <div className="flex flex-col md:flex-row md:items-end md:justify-between gap-8 mb-14">
          <div>
            <div
              className="inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/55 mb-5"
              style={{ fontWeight: 400 }}>
              
              <span className="w-6 h-px bg-white/40" />
              Tech Stack
            </div>
            <h2 style={{ fontSize: 'clamp(34px, 4.4vw, 54px)', letterSpacing: '-0.035em', lineHeight: 1.04, fontWeight: 500 }}>
              枯れた技術で、堅く速く。<br />
              新しい技術で、未来へ。
            </h2>
          </div>
          <p className="max-w-[380px] text-[14.5px] leading-[1.55] text-white/55" style={{ fontWeight: 300 }}>
            派手さよりも、運用 3 年後にチームが幸せでいられる選定を。
            必要なら AI・LLM もプロダクトに溶け込ませます。
          </p>
        </div>

        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-5">
          <StackCard
            icon={<Icon.Code width="20" height="20" />}
            title="Frontend"
            desc="型と速度を妥協しないUI。状態とアクセシビリティに強い実装を。"
            tags={['Next.js', 'React', 'TypeScript', 'Tailwind', 'Three.js']} />
          
          <StackCard
            icon={<Icon.Server width="20" height="20" />}
            title="Backend"
            desc="tRPC / GraphQL でフロントと型を共有。Postgres を中心に堅実に。"
            tags={['Node', 'Hono', 'Postgres', 'Prisma', 'Redis']} />
          
          <StackCard
            icon={<Icon.Cloud width="20" height="20" />}
            title="Infra"
            desc="Cloudflare と AWS を組み合わせ、初期費用を抑えてスケールへ。"
            tags={['Cloudflare', 'AWS', 'Vercel', 'Terraform', 'Docker']} />
          
          <StackCard
            icon={<Icon.Sparkles width="20" height="20" />}
            title="AI / LLM"
            desc="Claude / OpenAI を組み込んだ実用的なエージェント・自動化を。"
            tags={['Claude', 'OpenAI', 'LangChain', 'Vector DB', 'RAG']} />
          
        </div>
      </div>
    </section>);

}

/* ============================================================
 * Section 5 — Benefits (split with stats card)
 * ============================================================ */
function BenefitsSection() {
  const points = [
  { k: 'No 中間マージン', v: '受託会社を挟まない直接契約。同じ予算でも 1.5 倍の手数で動けます。' },
  { k: 'No スイッチング', v: '途中で人が変わらない。最初の打ち合わせから本番リリースまで同一担当。' },
  { k: 'No ブラックボックス', v: 'Linear と GitHub をすべて共有。意思決定の過程も全公開。' },
  { k: 'No 過剰提案', v: '「作らない」提案も含めて、本当に必要なものだけを設計します。' }];


  return (
    <section id="why" className="relative py-20 sm:py-32 px-4 sm:px-6 lg:px-10 overflow-hidden">
      <div className="max-w-[1280px] mx-auto grid grid-cols-1 lg:grid-cols-[1fr_1.05fr] gap-10 lg:gap-16 items-center">
        {/* Left */}
        <div>
          <div
            className="inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/55 mb-5"
            style={{ fontWeight: 400 }}>
            
            <span className="w-6 h-px bg-white/40" />
            Why solo
          </div>
          <h2 style={{ fontSize: 'clamp(32px, 4vw, 48px)', letterSpacing: '-0.035em', lineHeight: 1.06, fontWeight: 500 }}>
            個人で動くから、<br />
            速くて、柔軟で、強い。
          </h2>
          <p className="mt-6 max-w-[440px] text-[15px] leading-[1.6] text-white/60" style={{ fontWeight: 300 }}>
            5 人のチームで 3 ヶ月かかることが、1 人で 6 週間で終わることがあります。
            意思決定が短く、コミュニケーションコストがゼロだからです。
          </p>

          <ul className="mt-9 space-y-5">
            {points.map((p, i) =>
            <li key={i} className="flex gap-4">
                <span
                className="flex-shrink-0 mt-1 w-5 h-5 rounded-full inline-flex items-center justify-center text-black"
                style={{ background: 'white' }}>
                
                  <Icon.Check width="12" height="12" />
                </span>
                <div>
                  <div className="text-[15px] text-white" style={{ fontWeight: 500 }}>{p.k}</div>
                  <div className="text-[13.5px] text-white/55 mt-0.5" style={{ fontWeight: 300 }}>{p.v}</div>
                </div>
              </li>
            )}
          </ul>
        </div>

        {/* Right: stats card */}
        <div className="relative liquid-glass rounded-[32px] overflow-hidden aspect-[4/4.6] sm:aspect-[5/4.4] lg:aspect-auto lg:h-[640px]">
          <div className="absolute inset-0 z-0">
            <VideoBackground src={VIDEO_STATS} opacity={0.5} />
          </div>
          <div
            className="absolute inset-0 z-[1]"
            style={{
              background:
              'linear-gradient(180deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.35) 50%, rgba(0,0,0,0.7) 100%)'
            }} />
          
          <div className="relative z-10 h-full flex flex-col justify-between p-8 sm:p-10">
            <div>
              <div className="text-[11px] uppercase tracking-[0.28em] text-white/65 flex items-center gap-2" style={{ fontWeight: 400 }}>
                <Icon.Dot width="8" height="8" />
                Career snapshot
              </div>
              <h3 className="mt-6 text-[22px] leading-[1.3] text-white max-w-[340px]"
              style={{ fontWeight: 500, letterSpacing: '-0.02em' }}>
                7 年で 24 のプロダクトを<br />
                世に出してきました。
              </h3>
            </div>

            <div className="grid grid-cols-2 gap-y-9 gap-x-6">
              <Stat big="24" unit="prod" label="個人開発・受託で 0→1 立ち上げ" />
              <Stat big="¥1.2B" unit="ARR" label="支援先の累計 ARR" />
              <Stat big="7" unit="yrs" label="フルスタック実務歴" />
              <Stat big="92%" unit="" label="再依頼率" />
            </div>
          </div>
        </div>
      </div>
    </section>);

}

function Stat({ big, unit, label }) {
  return (
    <div>
      <div className="flex items-baseline gap-1.5">
        <span className="text-white" style={{ fontSize: 'clamp(40px, 5vw, 60px)', letterSpacing: '-0.04em', fontWeight: 500, lineHeight: 1 }}>
          {big}
        </span>
        {unit &&
        <span className="text-white/55 text-[14px] uppercase tracking-[0.1em]" style={{ fontWeight: 300 }}>
            {unit}
          </span>
        }
      </div>
      <div className="mt-2 text-[12.5px] text-white/55 leading-[1.4]" style={{ fontWeight: 300 }}>
        {label}
      </div>
    </div>);

}

/* ============================================================
 * Section 6 — Testimonials (3 cards, single shared video)
 * ============================================================ */
function TestimonialsSection() {
  const [hover, setHover] = React.useState(-1);
  const items = [
  {
    quote: '0→1 でこの速度と完成度を出せる個人を、僕は他に知りません。MVP リリース後に投資家ピッチが一気通貫で進みました。',
    name: '田中 慧',
    role: 'Recursive Inc. / Co-founder'
  },
  {
    quote: 'デザインと実装の往復が同じ人の中で完結するので、議論が圧倒的に早い。意思決定 1 回でデプロイまで行きます。',
    name: 'Sarah Chen',
    role: 'Helpfeel / Head of Product'
  },
  {
    quote: '「作らない」提案を最初にもらえたのが嬉しかった。結果、半分の予算で本質的な課題だけ解決できました。',
    name: '小林 直哉',
    role: 'Algomatic / CEO'
  }];


  return (
    <section id="voice" className="relative py-20 sm:py-32 px-4 sm:px-6 lg:px-10 overflow-hidden">
      <div className="max-w-[1280px] mx-auto">
        <div className="flex flex-col md:flex-row md:items-end md:justify-between gap-6 mb-14">
          <div>
            <div className="inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/55 mb-5"
            style={{ fontWeight: 400 }}>
              <span className="w-6 h-px bg-white/40" />
              Client Voices
            </div>
            <h2 style={{ fontSize: 'clamp(34px, 4.4vw, 54px)', letterSpacing: '-0.035em', lineHeight: 1.04, fontWeight: 500 }}>
              一緒に動いた人たちの、<br />
              本音の声を。
            </h2>
          </div>
        </div>

        <div className="grid grid-cols-1 md:grid-cols-3 gap-4 sm:gap-5">
          {items.map((t, i) =>
          <div
            key={i}
            onMouseEnter={() => setHover(i)}
            className="relative liquid-glass rounded-[28px] p-7 sm:p-9 overflow-hidden min-h-[340px] flex flex-col">
            
              <div
              className="absolute inset-0 z-0 transition-opacity duration-700"
              style={{ opacity: hover === i ? 0.5 : 0 }}>
              
                {hover === i && <VideoBackground src={VIDEO_TESTI} />}
              </div>
              <div
              className="absolute inset-0 z-[1]"
              style={{
                background:
                'linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.4) 100%)',
                opacity: hover === i ? 1 : 0,
                transition: 'opacity 0.7s'
              }} />
            
              <div className="relative z-10 flex flex-col h-full">
                <div className="text-[28px] leading-none text-white/35 mb-4" style={{ fontWeight: 300 }}>“</div>
                <p className="text-[15px] leading-[1.65] text-white/85" style={{ fontWeight: 300 }}>
                  {t.quote}
                </p>
                <div className="mt-auto pt-7 flex items-center gap-3">
                  <div
                  className="w-9 h-9 rounded-full flex-shrink-0 flex items-center justify-center text-[12px] text-white/80"
                  style={{
                    background: 'linear-gradient(145deg, rgba(255,255,255,0.18), rgba(255,255,255,0.04))',
                    border: '1px solid rgba(255,255,255,0.12)',
                    fontWeight: 500
                  }}>
                  
                    {t.name[0]}
                  </div>
                  <div>
                    <div className="text-[13.5px] text-white" style={{ fontWeight: 500 }}>{t.name}</div>
                    <div className="text-[11.5px] text-white/55 mt-0.5" style={{ fontWeight: 300 }}>{t.role}</div>
                  </div>
                </div>
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

/* ============================================================
 * Section 7 — Pricing
 * ============================================================ */
function PriceCard({ tier, price, unit, blurb, features, ctaLabel, accent }) {
  return (
    <div className="relative liquid-glass rounded-[32px] overflow-hidden p-8 sm:p-10 min-h-[560px] flex flex-col">
      <div className="absolute inset-0 z-0">
        <VideoBackground src={VIDEO_PRICING} opacity={0.4} />
      </div>
      <div
        className="absolute inset-0 z-[1]"
        style={{
          background:
          'linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.55) 100%)'
        }} />
      
      <div className="relative z-10 flex flex-col h-full">
        <div className="flex items-center justify-between">
          <span className="text-[12px] tracking-[0.22em] uppercase text-white/65" style={{ fontWeight: 400 }}>
            {tier}
          </span>
          {accent &&
          <span
            className="text-[11px] px-2.5 py-1 rounded-full text-black"
            style={{ background: 'white', fontWeight: 500 }}>
            
              人気
            </span>
          }
        </div>

        <div className="mt-7 flex items-baseline gap-2">
          <span className="text-white" style={{ fontSize: 'clamp(48px, 6vw, 70px)', letterSpacing: '-0.04em', lineHeight: 1, fontWeight: 500 }}>
            {price}
          </span>
          <span className="text-white/55 text-[14px]" style={{ fontWeight: 300 }}>{unit}</span>
        </div>
        <p className="mt-5 text-[14px] text-white/65 leading-[1.55] max-w-[340px]" style={{ fontWeight: 300 }}>
          {blurb}
        </p>

        <ul className="mt-8 space-y-3.5">
          {features.map((f, i) =>
          <li key={i} className="flex items-start gap-3 text-[13.5px] text-white/85" style={{ fontWeight: 300 }}>
              <span className="flex-shrink-0 w-4 h-4 mt-1 rounded-full bg-white/15 inline-flex items-center justify-center">
                <Icon.Check width="10" height="10" className="text-white" />
              </span>
              {f}
            </li>
          )}
        </ul>

        <a
          href="#contact"
          className={
          'mt-auto pt-9 inline-flex items-center justify-center gap-2 rounded-full px-6 py-3.5 text-[14px] transition-colors ' + (
          accent ?
          'cta-pearl hover:bg-white/90' :
          'liquid-glass text-white')
          }
          style={{ fontWeight: 500 }}>
          
          <span className="relative z-10 inline-flex items-center gap-2">
            {ctaLabel}
            <Icon.Arrow width="14" height="14" />
          </span>
        </a>
      </div>
    </div>);

}

function PricingSection() {
  return (
    <section id="pricing" className="relative py-20 sm:py-32 px-4 sm:px-6 lg:px-10 overflow-hidden">
      <div className="max-w-[1280px] mx-auto">
        <div className="text-center mb-14 max-w-[640px] mx-auto">
          <div
            className="inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/55 mb-5"
            style={{ fontWeight: 400 }}>
            
            <span className="w-6 h-px bg-white/40" />
            Engagement
            <span className="w-6 h-px bg-white/40" />
          </div>
          <h2 style={{ fontSize: 'clamp(34px, 4.4vw, 54px)', letterSpacing: '-0.035em', lineHeight: 1.04, fontWeight: 500 }}>
            ふたつの関わり方。
          </h2>
          <p className="mt-5 text-[15px] text-white/60 leading-[1.6]" style={{ fontWeight: 300 }}>
            短期で集中する Sprint と、中長期で伴走する Embed。<br className="hidden sm:block" />
            どちらも稼働は週 3〜4 日。同時並行は最大 2 社まで。
          </p>
        </div>

        <div className="grid grid-cols-1 md:grid-cols-2 gap-5 sm:gap-7">
          <PriceCard
            tier="Sprint"
            price="¥1.8M"
            unit="/ 6 週間"
            blurb="MVP を 6 週間で世に出す全力疾走プラン。要件定義から本番リリースまで一気通貫で。"
            features={[
            '0→1 プロダクトの設計・実装・出荷',
            'デザインから API、インフラまで一人で',
            '週次デモ + Linear で透明に進行',
            'リリース後 2 週間の保守を含む',
            '追加 Sprint への切り替え可']
            }
            ctaLabel="Sprint を依頼する" />
          
          <PriceCard
            tier="Embed"
            price="¥1.2M"
            unit="/ 月"
            blurb="あなたのチームの「実質 CTO」として、3〜6 ヶ月間、内側から伴走します。"
            features={[
            '週 3〜4 日のフルスタック稼働',
            '採用面接・技術選定・コードレビュー',
            '社内向け勉強会・ペアプロ',
            'チーム移管を前提とした設計',
            '最低契約 3 ヶ月、いつでも解約可']
            }
            ctaLabel="Embed を相談する"
            accent />
          
        </div>

        <p className="mt-10 text-center text-[12.5px] text-white/45" style={{ fontWeight: 300 }}>
          スタートアップ・自社プロダクト企業に限り 20% OFF。
          初回 30 分の面談は完全無料です。
        </p>
      </div>
    </section>);

}

/* ============================================================
 * Section 8 — Final CTA
 * ============================================================ */
function FinalCTA() {
  return (
    <section id="contact" className="relative py-20 sm:py-32 px-4 sm:px-6 lg:px-10 overflow-hidden">
      <div className="max-w-[1280px] mx-auto">
        <div className="relative liquid-glass rounded-[42px] overflow-hidden px-6 py-20 sm:px-14 sm:py-32 lg:py-40 text-center">
          <div className="relative z-10 max-w-[820px] mx-auto text-center">
            <div
              className="relative z-10 inline-flex items-center gap-2 text-[11px] tracking-[0.28em] uppercase text-white/65 mb-7"
              style={{ fontWeight: 500 }}>
              
              <span className="w-6 h-px bg-white/40" />
              Contact
              <span className="w-6 h-px bg-black/40" />
            </div>
            <h2
              className="relative z-10 text-white"
              style={{
                fontSize: 'clamp(40px, 6vw, 88px)',
                letterSpacing: '-0.04em',
                lineHeight: 0.98,
                fontWeight: 500,
                fontFamily: 'var(--font-heading)',
                textShadow: '0 2px 24px rgba(0,0,0,0.45)'
              }}>
              
              Say <em style={{ fontStyle: 'italic', fontWeight: 400 }}>hello</em>.
            </h2>
            <p
              className="relative z-10 mt-7 max-w-[480px] mx-auto text-[15px] sm:text-[16.5px] leading-[1.55] text-white/70"
              style={{ fontWeight: 400 }}>
              
              作っているものへの感想や、面白いプロジェクトのお誘いは
              <br className="hidden sm:block" />
              いつでも歓迎です。気軽にどうぞ。
            </p>

            <div className="relative z-10 mt-10 flex flex-wrap items-center justify-center gap-3">
              <a
                href="https://github.com/kurpsaki"
                target="_blank"
                rel="noopener noreferrer"
                className="inline-flex items-center gap-2 rounded-full cta-pearl px-7 py-3.5 text-[14px] transition-all"
                style={{ fontWeight: 500 }}>
                
                <Icon.Github width="15" height="15" />
                GitHub
              </a>
              <a
                href="https://x.com"
                target="_blank"
                rel="noopener noreferrer"
                className="liquid-glass rounded-full px-7 py-3.5 text-[14px] text-white inline-flex items-center gap-2"
                style={{ fontWeight: 500 }}>
                
                <Icon.Twitter width="14" height="14" />
                X / Twitter
              </a>
              <a
                href="mailto:capsulepoint.jp@gmail.com"
                className="liquid-glass rounded-full px-7 py-3.5 text-[14px] text-white inline-flex items-center gap-2"
                style={{ fontWeight: 500 }}>
                
                <Icon.Mail width="14" height="14" />
                Email
              </a>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

/* ============================================================
 * Section 9 — Footer
 * ============================================================ */
function Footer() {
  return (
    <footer className="px-4 sm:px-6 lg:px-10 pb-10 pt-16 border-t border-white/5" style={{ backgroundColor: '#000', color: 'rgba(255,255,255,0.7)' }}>
      <div className="max-w-[1280px] mx-auto flex flex-col sm:flex-row items-start sm:items-center justify-between gap-8">
        {/* Brand */}
        <div className="flex items-center gap-2.5">
          <svg width="20" height="20" viewBox="0 0 256 256">
            <path
              d="M 256 256 L 128 256 L 0 128 L 128 128 Z M 256 128 L 128 128 L 0 0 L 128 0 Z"
              fill="white" />
          </svg>
          <span className="text-[15px] text-white tracking-[-0.02em]" style={{ fontWeight: 500 }}>Capsulepoint</span>
          <span className="text-[12px] text-white/40 ml-3" style={{ fontWeight: 300 }}>© 2026</span>
        </div>

        {/* Socials */}
        <div className="flex items-center gap-2.5 text-white/60">
          <a href="https://github.com/kurpsaki" target="_blank" rel="noopener noreferrer" className="w-9 h-9 rounded-full flex items-center justify-center hover:bg-white/10 hover:text-white transition-colors" style={{ border: '1px solid rgba(255,255,255,0.1)' }}>
            <Icon.Github width="15" height="15" />
          </a>
          <a href="https://x.com" target="_blank" rel="noopener noreferrer" className="w-9 h-9 rounded-full flex items-center justify-center hover:bg-white/10 hover:text-white transition-colors" style={{ border: '1px solid rgba(255,255,255,0.1)' }}>
            <Icon.Twitter width="13" height="13" />
          </a>
          <a href="mailto:capsulepoint.jp@gmail.com" className="w-9 h-9 rounded-full flex items-center justify-center hover:bg-white/10 hover:text-white transition-colors" style={{ border: '1px solid rgba(255,255,255,0.1)' }}>
            <Icon.Mail width="15" height="15" />
          </a>
        </div>
      </div>
    </footer>);

}

function FooterCol() {return null; /* deprecated */}

/* Expose */
Object.assign(window, {
  Hero, Cards3D, WorksSection, StackSection, BenefitsSection, TestimonialsSection,
  PricingSection, FinalCTA, Footer
});