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

// ============================================================
// Shared style — palette swap
// ============================================================
const PALETTES = {
  navy:     { primary: '#1e3a5f', primaryDark: '#142845', accent: '#c8a67b', accentDark: '#a8865c', bg: '#faf9f6', ink: '#1c1c1c', name: 'Heritage Navy' },
  charcoal: { primary: '#1a1a1a', primaryDark: '#000000', accent: '#b8956a', accentDark: '#947249', bg: '#f6f4ee', ink: '#1a1a1a', name: 'Modern Charcoal' },
  forest:   { primary: '#2d3e2c', primaryDark: '#1a2618', accent: '#a89576', accentDark: '#86755a', bg: '#f7f5ee', ink: '#1f261d', name: 'Forest Craftsman' },
};

function applyPalette(name) {
  const p = PALETTES[name] || PALETTES.navy;
  const r = document.documentElement;
  r.style.setProperty('--primary', p.primary);
  r.style.setProperty('--primary-dark', p.primaryDark);
  r.style.setProperty('--accent', p.accent);
  r.style.setProperty('--accent-dark', p.accentDark);
  r.style.setProperty('--bg', p.bg);
  r.style.setProperty('--ink', p.ink);
}

// ============================================================
// Reveal-on-scroll hook
// ============================================================
function useReveal() {
  useEffect(() => {
    const els = document.querySelectorAll('.reveal');
    const io = new IntersectionObserver((entries) => {
      entries.forEach(e => {
        if (e.isIntersecting) {
          e.target.classList.add('in');
          io.unobserve(e.target);
        }
      });
    }, { threshold: 0.12 });
    els.forEach(el => io.observe(el));
    return () => io.disconnect();
  });
}

// ============================================================
// NAV
// ============================================================
function Nav() {
  const [scrolled, setScrolled] = useState(false);
  const [open, setOpen] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 40);
    window.addEventListener('scroll', onScroll);
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  const links = [
    ['会社案内', '#about'],
    ['事業内容', '#services'],
    ['施工事例', '#works'],
    ['お客様の声', '#voice'],
    ['よくある質問', '#faq'],
    ['アクセス', '#access'],
  ];
  return (
    <header style={{
      position: 'fixed', top: 0, left: 0, right: 0, zIndex: 50,
      transition: 'background .35s ease, box-shadow .35s ease, padding .35s ease',
      background: scrolled ? 'rgba(255,255,255,0.96)' : 'transparent',
      boxShadow: scrolled ? '0 1px 0 rgba(0,0,0,0.06)' : 'none',
      backdropFilter: scrolled ? 'saturate(140%) blur(12px)' : 'none',
      WebkitBackdropFilter: scrolled ? 'saturate(140%) blur(12px)' : 'none',
    }}>
      <div className="wrap" style={{
        display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        height: scrolled ? 64 : 84,
        transition: 'height .35s ease',
      }}>
        <a href="#top" aria-label="株式会社 天野工務店 トップへ" style={{
          display: 'flex', alignItems: 'center', gap: 12,
          color: scrolled ? 'var(--ink)' : '#fff',
        }}>
          <LogoMark color={scrolled ? 'var(--primary)' : '#fff'} accent="var(--accent)" />
          <span style={{ fontFamily: 'var(--serif)', fontSize: 19, fontWeight: 600, letterSpacing: '0.08em' }}>
            天野工務店
          </span>
        </a>

        {/* Desktop nav */}
        <nav className="nav-desktop" style={{ display: 'flex', alignItems: 'center', gap: 28 }}>
          {links.map(([label, href]) => (
            <a key={href} href={href} style={{
              fontSize: 13, fontWeight: 500, letterSpacing: '0.08em',
              color: scrolled ? 'var(--ink)' : '#fff',
              opacity: 0.92,
            }}>{label}</a>
          ))}
          <a href="#contact" style={{
            padding: '12px 22px',
            background: 'var(--accent)',
            color: '#fff',
            fontSize: 13, fontWeight: 600, letterSpacing: '0.08em',
            borderRadius: 2,
          }}>お問い合わせ</a>
        </nav>

        {/* Mobile toggle */}
        <button className="nav-mobile-btn" onClick={() => setOpen(!open)} aria-label="メニュー" style={{
          display: 'none',
          background: 'transparent', border: 'none', padding: 8,
          color: scrolled ? 'var(--ink)' : '#fff',
        }}>
          <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6">
            {open ? <><line x1="5" y1="5" x2="19" y2="19" /><line x1="19" y1="5" x2="5" y2="19" /></>
            : <><line x1="3" y1="7" x2="21" y2="7" /><line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="17" x2="21" y2="17" /></>}
          </svg>
        </button>
      </div>

      {/* Mobile drawer */}
      {open && (
        <div style={{
          background: '#fff', borderTop: '1px solid var(--line)',
          padding: '12px 20px 24px',
        }}>
          {links.map(([label, href]) => (
            <a key={href} href={href} onClick={() => setOpen(false)} style={{
              display: 'block', padding: '14px 0', borderBottom: '1px solid var(--line)',
              color: 'var(--ink)', fontSize: 15,
            }}>{label}</a>
          ))}
          <a href="#contact" onClick={() => setOpen(false)} style={{
            display: 'block', marginTop: 16, padding: '14px',
            background: 'var(--accent)', color: '#fff', textAlign: 'center',
            fontWeight: 600, letterSpacing: '0.08em',
          }}>お問い合わせ</a>
        </div>
      )}

      <style>{`
        @media (max-width: 880px) {
          .nav-desktop { display: none !important; }
          .nav-mobile-btn { display: block !important; }
        }
      `}</style>
    </header>
  );
}

function LogoMark({ color = '#fff', accent = '#c8a67b' }) {
  return (
    <svg width="34" height="34" viewBox="0 0 40 40" fill="none">
      {/* roof + frame mark */}
      <path d="M6 18 L20 6 L34 18" stroke={color} strokeWidth="1.6" strokeLinejoin="miter" />
      <rect x="11" y="18" width="18" height="16" stroke={color} strokeWidth="1.6" />
      <line x1="20" y1="18" x2="20" y2="34" stroke={accent} strokeWidth="1.6" />
      <line x1="11" y1="26" x2="29" y2="26" stroke={accent} strokeWidth="1.6" />
    </svg>
  );
}

// ============================================================
// HERO
// ============================================================
function Hero() {
  return (
    <section id="top" data-screen-label="01 Hero" style={{
      position: 'relative', minHeight: '100vh', color: '#fff',
      display: 'flex', alignItems: 'flex-end',
      overflow: 'hidden', background: '#0e0e0e',
    }}>
      {/* Background image */}
      <div style={{
        position: 'absolute', inset: 0,
        backgroundImage: "url('https://images.unsplash.com/photo-1600585154340-be6161a56a0c?w=2000&q=80')",
        backgroundSize: 'cover', backgroundPosition: 'center',
        filter: 'brightness(0.55)',
      }} aria-hidden="true" />
      {/* Gradient overlay for legibility */}
      <div style={{
        position: 'absolute', inset: 0,
        background: 'linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.15) 35%, rgba(0,0,0,0.7) 100%)',
      }} aria-hidden="true" />

      {/* corner mark */}
      <div style={{
        position: 'absolute', top: 110, right: 32,
        fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
        fontSize: 14, letterSpacing: '0.2em', opacity: 0.7,
      }}>
        Est. 1965 — Tokyo, Japan
      </div>

      <div className="wrap" style={{ position: 'relative', paddingBottom: 110, paddingTop: 160, width: '100%' }}>
        <div style={{
          display: 'inline-flex', alignItems: 'center', gap: 12,
          fontSize: 12, letterSpacing: '0.3em', marginBottom: 28, opacity: 0.85,
        }}>
          <span style={{ width: 36, height: 1, background: 'var(--accent)' }} />
          <span>AMANO KOUMUTEN — SINCE 1965</span>
        </div>

        <h1 style={{
          fontFamily: 'var(--serif)',
          fontSize: 'clamp(40px, 7vw, 88px)',
          fontWeight: 500,
          lineHeight: 1.2,
          letterSpacing: '0.04em',
          margin: '0 0 28px',
          maxWidth: '14ch',
        }}>
          一棟、一棟に<br />
          職人の手と、<br />
          <span style={{ color: 'var(--accent)' }}>誠実</span>を。
        </h1>

        <p style={{
          fontSize: 'clamp(15px, 1.4vw, 18px)',
          maxWidth: 540, lineHeight: 1.95, margin: '0 0 44px',
          opacity: 0.92,
        }}>
          東京・杉並を拠点に、半世紀。<br />
          新築から大規模リフォームまで、<br />
          住まう人と街に寄り添う家づくりを続けています。
        </p>

        <div style={{ display: 'flex', gap: 16, flexWrap: 'wrap' }}>
          <a href="#contact" style={{
            display: 'inline-flex', alignItems: 'center', gap: 10,
            padding: '18px 32px',
            background: 'var(--accent)', color: '#fff',
            fontSize: 14, fontWeight: 600, letterSpacing: '0.12em',
          }}>
            無料相談・お見積り
            <Arrow />
          </a>
          <a href="#works" style={{
            display: 'inline-flex', alignItems: 'center', gap: 10,
            padding: '18px 32px',
            border: '1px solid rgba(255,255,255,0.5)', color: '#fff',
            fontSize: 14, fontWeight: 500, letterSpacing: '0.12em',
          }}>
            施工事例を見る
            <Arrow />
          </a>
        </div>
      </div>

      {/* Scroll indicator */}
      <div style={{
        position: 'absolute', bottom: 28, left: '50%', transform: 'translateX(-50%)',
        fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
        fontSize: 12, letterSpacing: '0.3em', opacity: 0.7,
        display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 12,
      }}>
        <span>SCROLL</span>
        <span style={{ width: 1, height: 40, background: 'rgba(255,255,255,0.6)' }} />
      </div>
    </section>
  );
}

function Arrow({ color = 'currentColor' }) {
  return (
    <svg width="20" height="10" viewBox="0 0 24 10" fill="none">
      <line x1="0" y1="5" x2="22" y2="5" stroke={color} strokeWidth="1.4" />
      <path d="M17 1 L22 5 L17 9" stroke={color} strokeWidth="1.4" fill="none" />
    </svg>
  );
}

// ============================================================
// SECTION TITLE
// ============================================================
function SectionTitle({ kicker, jp, en, align = 'left', light = false }) {
  return (
    <div className="reveal" style={{ textAlign: align, marginBottom: 56 }}>
      <div style={{
        fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
        fontSize: 13, letterSpacing: '0.3em',
        color: 'var(--accent)', marginBottom: 16,
      }}>
        — {kicker}
      </div>
      <h2 style={{
        fontFamily: 'var(--serif)',
        fontSize: 'clamp(28px, 4vw, 44px)',
        fontWeight: 500, letterSpacing: '0.06em',
        lineHeight: 1.3, margin: 0,
        color: light ? '#fff' : 'var(--ink)',
      }}>{jp}</h2>
      {en && <div style={{
        fontFamily: 'var(--latin-serif)',
        fontSize: 14, letterSpacing: '0.2em', marginTop: 10,
        color: light ? 'rgba(255,255,255,0.6)' : 'var(--ink-mute)',
      }}>{en}</div>}
    </div>
  );
}

// ============================================================
// ABOUT
// ============================================================
function About() {
  return (
    <section id="about" data-screen-label="02 About" style={{ padding: '140px 0 120px' }}>
      <div className="wrap">
        <div style={{
          display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 80, alignItems: 'center',
        }} className="about-grid">
          <div className="reveal">
            <img
              src="https://images.unsplash.com/photo-1504307651254-35680f356dfd?w=1200&q=80"
              alt="天野工務店の職人が住宅の建築現場で作業する様子"
              style={{ width: '100%', height: 560, objectFit: 'cover' }}
            />
          </div>
          <div>
            <SectionTitle kicker="ABOUT" jp="家を建てるとは、" en="" />
            <h3 className="reveal" style={{
              fontFamily: 'var(--serif)', fontSize: 'clamp(20px, 2.2vw, 26px)',
              fontWeight: 500, lineHeight: 1.8, letterSpacing: '0.04em',
              margin: '0 0 32px', color: 'var(--primary)',
            }}>
              暮らしを編むこと。<br />
              街と、世代を、繋ぐこと。
            </h3>
            <p className="reveal" style={{ fontSize: 15.5, lineHeight: 2.1, marginBottom: 20, color: 'var(--ink-soft)' }}>
              1965年の創業以来、半世紀以上にわたり杉並の地で、住まいづくりに向き合ってまいりました。<br />
              代々受け継がれた職人の技と、現代の暮らしに応える設計力。その両輪で、ご家族一人ひとりに寄り添う家を、一棟ずつ丁寧に建てています。
            </p>
            <p className="reveal" style={{ fontSize: 15.5, lineHeight: 2.1, marginBottom: 40, color: 'var(--ink-soft)' }}>
              建てて終わりではなく、住み始めてからが本当のお付き合い。アフターメンテナンスまで、地域に根ざした工務店だからこそできる、長いお付き合いをお約束します。
            </p>

            <div className="reveal" style={{
              display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 24,
              padding: '32px 0', borderTop: '1px solid var(--line)', borderBottom: '1px solid var(--line)',
            }}>
              <Stat n="60" unit="年" label="創業からの歩み" />
              <Stat n="1200" unit="棟+" label="施工実績" />
              <Stat n="98" unit="%" label="お客様満足度" />
            </div>
          </div>
        </div>
      </div>

      <style>{`
        @media (max-width: 880px) {
          .about-grid { grid-template-columns: 1fr !important; gap: 48px !important; }
          .about-grid img { height: 380px !important; }
        }
      `}</style>
    </section>
  );
}

function Stat({ n, unit, label }) {
  return (
    <div>
      <div style={{
        fontFamily: 'var(--serif)',
        fontSize: 'clamp(28px, 3.5vw, 40px)',
        fontWeight: 500, color: 'var(--primary)',
        letterSpacing: '0.02em', lineHeight: 1,
      }}>
        {n}<span style={{ fontSize: '0.55em', marginLeft: 4, color: 'var(--accent)' }}>{unit}</span>
      </div>
      <div style={{ fontSize: 12, marginTop: 10, color: 'var(--ink-mute)', letterSpacing: '0.1em' }}>{label}</div>
    </div>
  );
}

// ============================================================
// PHILOSOPHY / 代表挨拶
// ============================================================
function Philosophy() {
  return (
    <section style={{
      background: 'var(--primary)', color: '#fff',
      padding: '120px 0', position: 'relative', overflow: 'hidden',
    }}>
      <div aria-hidden="true" style={{
        position: 'absolute', top: -100, right: -100, width: 400, height: 400,
        border: '1px solid rgba(255,255,255,0.06)', borderRadius: '50%',
      }} />
      <div aria-hidden="true" style={{
        position: 'absolute', bottom: -200, left: -200, width: 600, height: 600,
        border: '1px solid rgba(255,255,255,0.04)', borderRadius: '50%',
      }} />
      <div className="wrap" style={{ position: 'relative' }}>
        <div style={{
          display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 80, alignItems: 'center',
        }} className="philo-grid">
          <div className="reveal">
            <div style={{
              fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
              fontSize: 13, letterSpacing: '0.3em', color: 'var(--accent)', marginBottom: 16,
            }}>— MESSAGE</div>
            <h2 style={{
              fontFamily: 'var(--serif)', fontSize: 'clamp(28px, 4vw, 42px)',
              fontWeight: 500, letterSpacing: '0.08em',
              lineHeight: 1.4, margin: 0,
            }}>
              代表<br />ご挨拶
            </h2>
          </div>
          <div className="reveal">
            <p style={{
              fontFamily: 'var(--serif)', fontSize: 'clamp(18px, 2vw, 22px)',
              lineHeight: 2.1, letterSpacing: '0.04em', margin: '0 0 32px',
            }}>
              「いい家とは、暮らす人が一番、心地よくいられる家。」<br />
              祖父から受け継いだこの言葉を、私たちは今も大切にしています。
            </p>
            <p style={{ fontSize: 15, lineHeight: 2.1, opacity: 0.9, marginBottom: 16 }}>
              流行や派手さではなく、その家のご家族が、十年、二十年、三十年と過ごしたときに、心からよかったと思える住まい。それを目指して、設計から施工、アフターメンテナンスまで、一棟一棟、自分たちの目と手で確かめながら造り続けています。
            </p>
            <p style={{ fontSize: 15, lineHeight: 2.1, opacity: 0.9, marginBottom: 32 }}>
              地域に根ざし、お客様と長くお付き合いさせていただくこと。それが、私たち天野工務店の何よりの誇りです。
            </p>
            <div style={{ display: 'flex', alignItems: 'baseline', gap: 16 }}>
              <span style={{ fontSize: 13, opacity: 0.7, letterSpacing: '0.1em' }}>代表取締役</span>
              <span style={{ fontFamily: 'var(--serif)', fontSize: 22, letterSpacing: '0.15em' }}>天野 健司</span>
            </div>
          </div>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .philo-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
        }
      `}</style>
    </section>
  );
}

// ============================================================
// SERVICES
// ============================================================
function Services() {
  const items = [
    {
      no: '01',
      en: 'NEW BUILD',
      jp: '新築・注文住宅',
      desc: '土地探しから設計、施工までワンストップ。ご家族の暮らしに合わせた一邸を、構造から仕上げまで丁寧に。',
      tags: ['注文住宅', '木造軸組', '長期優良住宅'],
      img: 'https://images.unsplash.com/photo-1600566753190-17f0baa2a6c3?w=1200&q=80',
      alt: '天野工務店が施工した木造軸組工法の新築注文住宅の外観',
    },
    {
      no: '02',
      en: 'RENOVATION',
      jp: 'リフォーム・リノベーション',
      desc: 'キッチン・浴室の部分改修から、間取りを変える大規模リノベまで。住み慣れた家を、これからの暮らしに合わせて。',
      tags: ['水回り', 'フルリノベ', '耐震補強'],
      img: 'https://images.unsplash.com/photo-1556909114-f6e7ad7d3136?w=1200&q=80',
      alt: 'リフォーム後の明るく開放的なリビング・ダイニングキッチン',
    },
    {
      no: '03',
      en: 'MAINTENANCE',
      jp: 'メンテナンス・修繕',
      desc: '雨漏り、屋根・外壁の補修から、ちょっとした建付けの調整まで。建てた後も、長くお付き合いします。',
      tags: ['外装補修', '定期点検', '緊急対応'],
      img: 'https://images.unsplash.com/photo-1581094288338-2314dddb7ece?w=1200&q=80',
      alt: '住宅の外壁・屋根のメンテナンス作業を行う職人',
    },
  ];
  return (
    <section id="services" data-screen-label="03 Services" style={{ padding: '140px 0 120px', background: 'var(--bg)' }}>
      <div className="wrap">
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', flexWrap: 'wrap', gap: 24, marginBottom: 64 }}>
          <SectionTitle kicker="SERVICES" jp="私たちができること" en="Our Services" />
          <p className="reveal" style={{ maxWidth: 420, fontSize: 14, lineHeight: 2, color: 'var(--ink-soft)', margin: 0 }}>
            新築から、リフォーム、日々のメンテナンスまで。住まいに関わるすべてを、一貫してお任せいただけます。
          </p>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 40 }} className="services-grid">
          {items.map((s, i) => (
            <article key={s.no} className="reveal" style={{ background: '#fff', transition: 'transform .4s ease' }}
              onMouseEnter={(e) => e.currentTarget.style.transform = 'translateY(-6px)'}
              onMouseLeave={(e) => e.currentTarget.style.transform = ''}>
              <div style={{ position: 'relative', overflow: 'hidden', aspectRatio: '4/3' }}>
                <img src={s.img} alt={s.alt} style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
                <div style={{
                  position: 'absolute', top: 16, left: 16,
                  fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
                  fontSize: 13, letterSpacing: '0.2em', color: '#fff',
                  textShadow: '0 1px 6px rgba(0,0,0,0.4)',
                }}>{s.en}</div>
              </div>
              <div style={{ padding: '32px 28px 36px' }}>
                <div style={{ display: 'flex', alignItems: 'baseline', gap: 16, marginBottom: 16 }}>
                  <span style={{
                    fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
                    fontSize: 30, color: 'var(--accent)',
                  }}>{s.no}</span>
                  <h3 style={{ fontFamily: 'var(--serif)', fontSize: 22, fontWeight: 500, margin: 0, letterSpacing: '0.04em' }}>
                    {s.jp}
                  </h3>
                </div>
                <p style={{ fontSize: 14, lineHeight: 2, color: 'var(--ink-soft)', marginBottom: 20 }}>{s.desc}</p>
                <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
                  {s.tags.map(t => (
                    <span key={t} style={{
                      fontSize: 11, padding: '4px 10px',
                      border: '1px solid var(--line)', color: 'var(--ink-mute)',
                      letterSpacing: '0.08em',
                    }}>{t}</span>
                  ))}
                </div>
              </div>
            </article>
          ))}
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .services-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
        }
      `}</style>
    </section>
  );
}

// ============================================================
// WORKS / 施工事例 with Before / After slider
// ============================================================
function Works() {
  const works = [
    {
      cat: 'リノベーション',
      title: '築40年戸建を、光あふれる二世帯住宅へ',
      area: '東京都杉並区', year: '2024', type: 'フルリノベ',
      img: 'https://images.unsplash.com/photo-1600210492493-0946911123ea?w=1400&q=80',
      alt: 'フルリノベーション後の白を基調とした明るい二世帯住宅のリビング',
    },
    {
      cat: '新築',
      title: '木の温もりを感じる、夫婦のための平屋',
      area: '東京都練馬区', year: '2024', type: '注文住宅',
      img: 'https://images.unsplash.com/photo-1600585154526-990dced4db0d?w=1400&q=80',
      alt: '木の温もりを感じる平屋の新築注文住宅の外観',
    },
    {
      cat: 'リフォーム',
      title: '使いやすさを追求した、回遊型キッチン',
      area: '東京都中野区', year: '2023', type: '水回り',
      img: 'https://images.unsplash.com/photo-1556909114-f6e7ad7d3136?w=1400&q=80',
      alt: 'リフォーム後の使いやすい回遊型アイランドキッチン',
    },
    {
      cat: '新築',
      title: '中庭を囲む、コの字型の家',
      area: '東京都世田谷区', year: '2023', type: '注文住宅',
      img: 'https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?w=1400&q=80',
      alt: '中庭を囲むコの字型の現代的な新築住宅',
    },
    {
      cat: 'リノベーション',
      title: 'マンションを、ヴィンテージスタイルに',
      area: '東京都新宿区', year: '2023', type: 'マンション改修',
      img: 'https://images.unsplash.com/photo-1600121848594-d8644e57abab?w=1400&q=80',
      alt: 'ヴィンテージスタイルにリノベーションされたマンションリビング',
    },
    {
      cat: 'リフォーム',
      title: '老朽化した浴室を、ホテルライクな空間へ',
      area: '東京都杉並区', year: '2023', type: '水回り',
      img: 'https://images.unsplash.com/photo-1552321554-5fefe8c9ef14?w=1400&q=80',
      alt: 'リフォーム後のホテルライクな浴室・サニタリースペース',
    },
  ];

  const [filter, setFilter] = useState('すべて');
  const cats = ['すべて', '新築', 'リフォーム', 'リノベーション'];
  const filtered = filter === 'すべて' ? works : works.filter(w => w.cat === filter);

  return (
    <section id="works" data-screen-label="04 Works" style={{ padding: '140px 0 120px' }}>
      <div className="wrap">
        <SectionTitle kicker="WORKS" jp="施工事例" en="Construction Examples" />

        {/* Featured Before / After */}
        <div className="reveal" style={{
          background: '#fff', marginBottom: 80, overflow: 'hidden',
          boxShadow: '0 4px 28px rgba(0,0,0,0.04)',
        }}>
          <div style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr' }} className="featured-grid">
            <BeforeAfter
              before="https://images.unsplash.com/photo-1558618666-fcd25c85cd64?w=1400&q=80"
              after="https://images.unsplash.com/photo-1600210492486-724fe5c67fb0?w=1400&q=80"
              beforeAlt="リフォーム前の暗く狭く感じる古いリビング"
              afterAlt="リフォーム後の明るく開放的なリビング"
            />
            <div style={{ padding: '56px 48px', display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
              <div style={{
                fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
                fontSize: 13, letterSpacing: '0.3em', color: 'var(--accent)', marginBottom: 12,
              }}>FEATURED — BEFORE / AFTER</div>
              <h3 style={{ fontFamily: 'var(--serif)', fontSize: 'clamp(22px, 2.4vw, 30px)', fontWeight: 500, lineHeight: 1.5, margin: '0 0 20px', letterSpacing: '0.04em' }}>
                築35年の戸建てが、<br />光あふれる住まいへ。
              </h3>
              <p style={{ fontSize: 14, lineHeight: 2, color: 'var(--ink-soft)', margin: '0 0 28px' }}>
                南向きの大開口と吹抜けを新設。間取りの大胆な変更で、家族が自然に集まる開放的なリビングへと生まれ変わりました。スライダーを動かして変化をご覧ください。
              </p>
              <dl style={{ margin: 0, display: 'grid', gridTemplateColumns: 'auto 1fr', gap: '10px 24px', fontSize: 13 }}>
                <dt style={{ color: 'var(--ink-mute)', letterSpacing: '0.1em' }}>所在地</dt><dd style={{ margin: 0 }}>東京都杉並区</dd>
                <dt style={{ color: 'var(--ink-mute)', letterSpacing: '0.1em' }}>工事種別</dt><dd style={{ margin: 0 }}>フルリノベーション</dd>
                <dt style={{ color: 'var(--ink-mute)', letterSpacing: '0.1em' }}>工期</dt><dd style={{ margin: 0 }}>約4ヶ月</dd>
                <dt style={{ color: 'var(--ink-mute)', letterSpacing: '0.1em' }}>竣工</dt><dd style={{ margin: 0 }}>2024年</dd>
              </dl>
            </div>
          </div>
        </div>

        {/* Filter tabs */}
        <div className="reveal" style={{ display: 'flex', gap: 8, marginBottom: 40, flexWrap: 'wrap' }}>
          {cats.map(c => (
            <button key={c} onClick={() => setFilter(c)} style={{
              padding: '10px 20px',
              background: filter === c ? 'var(--primary)' : 'transparent',
              color: filter === c ? '#fff' : 'var(--ink)',
              border: '1px solid ' + (filter === c ? 'var(--primary)' : 'var(--line)'),
              fontSize: 13, letterSpacing: '0.08em',
              transition: 'all .2s ease',
            }}>{c}</button>
          ))}
        </div>

        {/* Grid */}
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 32 }} className="works-grid">
          {filtered.map((w, i) => (
            <article key={w.title} className="reveal" style={{ cursor: 'pointer' }}>
              <div style={{ overflow: 'hidden', aspectRatio: '4/3', marginBottom: 18 }}>
                <img src={w.img} alt={w.alt} style={{
                  width: '100%', height: '100%', objectFit: 'cover',
                  transition: 'transform .6s ease',
                }}
                  onMouseEnter={e => e.currentTarget.style.transform = 'scale(1.05)'}
                  onMouseLeave={e => e.currentTarget.style.transform = ''}
                />
              </div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 12, fontSize: 11, letterSpacing: '0.15em', marginBottom: 10 }}>
                <span style={{ color: 'var(--accent)' }}>{w.cat}</span>
                <span style={{ color: 'var(--ink-mute)' }}>—</span>
                <span style={{ color: 'var(--ink-mute)' }}>{w.area} / {w.year}</span>
              </div>
              <h3 style={{ fontFamily: 'var(--serif)', fontSize: 18, fontWeight: 500, margin: 0, lineHeight: 1.6, letterSpacing: '0.04em' }}>
                {w.title}
              </h3>
            </article>
          ))}
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .featured-grid { grid-template-columns: 1fr !important; }
          .works-grid { grid-template-columns: 1fr !important; gap: 36px !important; }
        }
        @media (min-width: 881px) and (max-width: 1100px) {
          .works-grid { grid-template-columns: repeat(2, 1fr) !important; }
        }
      `}</style>
    </section>
  );
}

function BeforeAfter({ before, after, beforeAlt, afterAlt }) {
  const [pos, setPos] = useState(50);
  const ref = useRef(null);
  const dragging = useRef(false);

  const update = (clientX) => {
    if (!ref.current) return;
    const rect = ref.current.getBoundingClientRect();
    const p = Math.max(0, Math.min(100, ((clientX - rect.left) / rect.width) * 100));
    setPos(p);
  };
  const start = (e) => {
    dragging.current = true;
    const cx = e.touches ? e.touches[0].clientX : e.clientX;
    update(cx);
  };
  const move = (e) => {
    if (!dragging.current) return;
    const cx = e.touches ? e.touches[0].clientX : e.clientX;
    update(cx);
  };
  const end = () => { dragging.current = false; };

  useEffect(() => {
    window.addEventListener('mousemove', move);
    window.addEventListener('mouseup', end);
    window.addEventListener('touchmove', move);
    window.addEventListener('touchend', end);
    return () => {
      window.removeEventListener('mousemove', move);
      window.removeEventListener('mouseup', end);
      window.removeEventListener('touchmove', move);
      window.removeEventListener('touchend', end);
    };
  }, []);

  return (
    <div
      ref={ref}
      onMouseDown={start}
      onTouchStart={start}
      style={{
        position: 'relative', userSelect: 'none', overflow: 'hidden',
        aspectRatio: '4/3', cursor: 'ew-resize', background: '#000',
      }}
    >
      <img src={after} alt={afterAlt} style={{
        position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover',
      }} draggable="false" />
      <div style={{
        position: 'absolute', inset: 0, overflow: 'hidden',
        clipPath: `inset(0 ${100 - pos}% 0 0)`,
      }}>
        <img src={before} alt={beforeAlt} style={{
          width: '100%', height: '100%', objectFit: 'cover',
        }} draggable="false" />
      </div>

      {/* Labels */}
      <div style={{
        position: 'absolute', top: 18, left: 18,
        padding: '6px 14px', background: 'rgba(0,0,0,0.7)', color: '#fff',
        fontSize: 11, letterSpacing: '0.25em', fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
      }}>BEFORE</div>
      <div style={{
        position: 'absolute', top: 18, right: 18,
        padding: '6px 14px', background: 'var(--accent)', color: '#fff',
        fontSize: 11, letterSpacing: '0.25em', fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
      }}>AFTER</div>

      {/* Handle */}
      <div style={{
        position: 'absolute', top: 0, bottom: 0, left: `${pos}%`,
        width: 2, background: '#fff', transform: 'translateX(-1px)',
        boxShadow: '0 0 12px rgba(0,0,0,0.3)',
      }}>
        <div style={{
          position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)',
          width: 44, height: 44, borderRadius: '50%', background: '#fff',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          boxShadow: '0 4px 16px rgba(0,0,0,0.3)',
        }}>
          <svg width="20" height="14" viewBox="0 0 20 14" fill="none">
            <path d="M6 1 L1 7 L6 13 M14 1 L19 7 L14 13" stroke="var(--primary)" strokeWidth="1.6" />
          </svg>
        </div>
      </div>
    </div>
  );
}

// ============================================================
// VOICE / お客様の声
// ============================================================
function Voice() {
  const reviews = [
    {
      name: 'K. 様', area: '杉並区', type: '新築注文住宅',
      stars: 5,
      text: '土地探しから親身に相談に乗っていただき、想像以上の家を建てていただきました。打ち合わせの一つ一つに丁寧に対応いただき、職人さんも本当に誠実な方ばかり。建てた後の点検も安心です。',
    },
    {
      name: 'M. 様', area: '練馬区', type: 'フルリノベーション',
      stars: 5,
      text: '古い実家を二世帯にリノベーションしていただきました。古い家の良さを残しつつ、現代の暮らしに合わせた間取りに。両親も大変喜んでおり、本当にお願いしてよかったです。',
    },
    {
      name: 'T. 様', area: '中野区', type: '水回りリフォーム',
      stars: 5,
      text: 'キッチンと浴室のリフォームをお願いしました。予算の中で最善の提案をいただき、工期も予定通り。何より、お見積りが明朗で安心してお任せできました。',
    },
    {
      name: 'S. 様', area: '世田谷区', type: '新築注文住宅',
      stars: 5,
      text: 'こだわりの平屋を建てたいという要望に、何度も図面を引き直しながら付き合っていただきました。完成した家は本当に住み心地が良く、毎日が楽しいです。',
    },
  ];

  return (
    <section id="voice" data-screen-label="05 Voice" style={{ padding: '140px 0 120px', background: 'var(--bg)' }}>
      <div className="wrap">
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end', flexWrap: 'wrap', gap: 24, marginBottom: 56 }}>
          <SectionTitle kicker="VOICE" jp="お客様の声" en="Customer Voices" />
          <div className="reveal" style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
            <GoogleG />
            <div>
              <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                <Stars n={5} />
                <strong style={{ fontFamily: 'var(--latin-serif)', fontSize: 22 }}>4.9</strong>
              </div>
              <div style={{ fontSize: 12, color: 'var(--ink-mute)', marginTop: 2 }}>Google口コミ・124件のレビュー</div>
            </div>
          </div>
        </div>

        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 28 }} className="voice-grid">
          {reviews.map((r, i) => (
            <article key={i} className="reveal" style={{
              background: '#fff', padding: '36px 36px 32px',
              borderTop: '2px solid var(--accent)',
            }}>
              <Stars n={r.stars} />
              <p style={{ fontFamily: 'var(--serif)', fontSize: 16, lineHeight: 2, margin: '20px 0 24px', letterSpacing: '0.02em' }}>
                「{r.text}」
              </p>
              <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', paddingTop: 20, borderTop: '1px solid var(--line)' }}>
                <div>
                  <div style={{ fontWeight: 600, fontSize: 14 }}>{r.name}</div>
                  <div style={{ fontSize: 12, color: 'var(--ink-mute)', marginTop: 2 }}>{r.area}・{r.type}</div>
                </div>
                <GoogleG size={20} />
              </div>
            </article>
          ))}
        </div>

        <div className="reveal" style={{ textAlign: 'center', marginTop: 48 }}>
          <a href="#" style={{
            display: 'inline-flex', alignItems: 'center', gap: 12,
            fontSize: 13, letterSpacing: '0.1em',
            paddingBottom: 4, borderBottom: '1px solid var(--ink)',
          }}>
            Google口コミをすべて見る
            <Arrow />
          </a>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .voice-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

function Stars({ n = 5 }) {
  return (
    <div style={{ display: 'flex', gap: 2 }} aria-label={`評価 ${n} / 5`}>
      {[1,2,3,4,5].map(i => (
        <svg key={i} width="16" height="16" viewBox="0 0 16 16" fill={i <= n ? '#f5b400' : '#e5e5e5'}>
          <path d="M8 1 L10 6 L15 6.5 L11 10 L12.5 15 L8 12.5 L3.5 15 L5 10 L1 6.5 L6 6 Z" />
        </svg>
      ))}
    </div>
  );
}
function GoogleG({ size = 24 }) {
  return (
    <svg width={size} height={size} viewBox="0 0 48 48">
      <path fill="#4285F4" d="M45.12 24.5c0-1.56-.14-3.06-.4-4.5H24v8.51h11.84c-.51 2.75-2.06 5.08-4.39 6.64v5.52h7.11c4.16-3.83 6.56-9.47 6.56-16.17z"/>
      <path fill="#34A853" d="M24 46c5.94 0 10.92-1.97 14.56-5.33l-7.11-5.52c-1.97 1.32-4.49 2.1-7.45 2.1-5.73 0-10.58-3.87-12.31-9.07H4.34v5.7C7.96 41.07 15.4 46 24 46z"/>
      <path fill="#FBBC05" d="M11.69 28.18C11.25 26.86 11 25.45 11 24s.25-2.86.69-4.18v-5.7H4.34C2.85 17.09 2 20.45 2 24c0 3.55.85 6.91 2.34 9.88l7.35-5.7z"/>
      <path fill="#EA4335" d="M24 10.75c3.23 0 6.13 1.11 8.41 3.29l6.31-6.31C34.91 4.18 29.93 2 24 2 15.4 2 7.96 6.93 4.34 14.12l7.35 5.7c1.73-5.2 6.58-9.07 12.31-9.07z"/>
    </svg>
  );
}

// ============================================================
// FAQ
// ============================================================
function FAQ() {
  const items = [
    { q: '相談や見積りは無料ですか？', a: 'はい、初回のご相談・現地調査・お見積りはすべて無料です。お電話または問い合わせフォームより、お気軽にご連絡ください。' },
    { q: '小さなリフォームでも依頼できますか？', a: 'もちろんです。蛇口の交換、網戸の張替えといった小さな工事から、フルリノベーションまで、住まいに関わるご相談はすべてお受けしています。' },
    { q: '工事中の家の中は片付けが必要ですか？', a: '工事範囲によって異なります。事前にご説明と養生計画を共有しますので、ご不安な点はお気軽にお尋ねください。家具の移動なども一緒にお手伝いいたします。' },
    { q: '保証やアフターサービスはありますか？', a: '当社施工物件には、最長10年の構造保証と、定期点検（1年・2年・5年・10年）をお付けしています。建てた後も、長くお付き合いさせていただきます。' },
    { q: '対応エリアを教えてください', a: '東京都杉並区を拠点に、中野区・練馬区・世田谷区・新宿区を中心に対応しております。それ以外の地域もご相談ください。' },
    { q: '住宅ローンの相談もできますか？', a: '提携の金融機関のご紹介や、資金計画のシミュレーションも承っております。お気軽にご相談ください。' },
  ];
  const [open, setOpen] = useState(0);
  return (
    <section id="faq" data-screen-label="06 FAQ" style={{ padding: '140px 0 120px' }}>
      <div className="wrap" style={{ maxWidth: 960 }}>
        <SectionTitle kicker="FAQ" jp="よくあるご質問" en="Frequently Asked Questions" align="center" />
        <div style={{ borderTop: '1px solid var(--line)' }}>
          {items.map((it, i) => {
            const isOpen = open === i;
            return (
              <div key={i} className="reveal" style={{ borderBottom: '1px solid var(--line)' }}>
                <button onClick={() => setOpen(isOpen ? -1 : i)} style={{
                  width: '100%', display: 'flex', alignItems: 'center', gap: 24,
                  padding: '28px 0', background: 'transparent', border: 'none',
                  textAlign: 'left', fontSize: 'inherit', color: 'inherit',
                }}>
                  <span style={{
                    fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
                    fontSize: 22, color: 'var(--accent)', minWidth: 30,
                  }}>Q.</span>
                  <span style={{ flex: 1, fontFamily: 'var(--serif)', fontSize: 17, fontWeight: 500, letterSpacing: '0.02em' }}>
                    {it.q}
                  </span>
                  <span style={{
                    width: 32, height: 32, borderRadius: '50%',
                    border: '1px solid var(--line)',
                    display: 'flex', alignItems: 'center', justifyContent: 'center',
                    transition: 'all .3s ease',
                    transform: isOpen ? 'rotate(45deg)' : 'none',
                    background: isOpen ? 'var(--primary)' : 'transparent',
                    color: isOpen ? '#fff' : 'var(--ink)',
                  }}>
                    <svg width="12" height="12" viewBox="0 0 12 12" fill="none">
                      <line x1="6" y1="1" x2="6" y2="11" stroke="currentColor" strokeWidth="1.4" />
                      <line x1="1" y1="6" x2="11" y2="6" stroke="currentColor" strokeWidth="1.4" />
                    </svg>
                  </span>
                </button>
                <div style={{
                  maxHeight: isOpen ? 280 : 0, overflow: 'hidden',
                  transition: 'max-height .5s cubic-bezier(.2,.7,.2,1)',
                }}>
                  <div style={{ display: 'flex', gap: 24, padding: '0 0 32px 0', paddingLeft: 0 }}>
                    <span style={{
                      fontFamily: 'var(--latin-serif)', fontStyle: 'italic',
                      fontSize: 22, color: 'var(--ink-mute)', minWidth: 30,
                    }}>A.</span>
                    <p style={{ flex: 1, margin: 0, fontSize: 14.5, lineHeight: 2, color: 'var(--ink-soft)' }}>
                      {it.a}
                    </p>
                  </div>
                </div>
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

// ============================================================
// ACCESS / Google Map
// ============================================================
function Access({ mapEmbed }) {
  return (
    <section id="access" data-screen-label="07 Access" style={{ padding: '140px 0 120px', background: 'var(--bg)' }}>
      <div className="wrap">
        <SectionTitle kicker="ACCESS" jp="アクセス・会社概要" en="Access & Company" />
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.3fr', gap: 56 }} className="access-grid">
          <div className="reveal">
            <h3 style={{ fontFamily: 'var(--serif)', fontSize: 22, fontWeight: 500, margin: '0 0 24px', letterSpacing: '0.05em', color: 'var(--primary)' }}>
              株式会社 天野工務店
            </h3>
            <dl style={{ margin: 0, fontSize: 14, lineHeight: 2 }}>
              {[
                ['所在地', '〒166-0000 東京都杉並区○○町1-2-3'],
                ['電話', '03-0000-0000'],
                ['FAX', '03-0000-0001'],
                ['営業時間', '9:00 – 18:00（日曜・祝日定休）'],
                ['代表者', '天野 健司'],
                ['設立', '1965年（昭和40年）'],
                ['事業内容', '新築工事、リフォーム・リノベーション工事、不動産売買仲介'],
                ['建設業許可', '東京都知事許可（般-○○）第○○○○○○号'],
              ].map(([k, v]) => (
                <div key={k} style={{ display: 'grid', gridTemplateColumns: '100px 1fr', gap: 24, padding: '14px 0', borderBottom: '1px solid var(--line)' }}>
                  <dt style={{ color: 'var(--ink-mute)', fontSize: 12, letterSpacing: '0.1em', alignSelf: 'center' }}>{k}</dt>
                  <dd style={{ margin: 0, color: 'var(--ink)' }}>{v}</dd>
                </div>
              ))}
            </dl>
          </div>
          <div className="reveal access-map" style={{ minHeight: 460 }}
            dangerouslySetInnerHTML={{ __html: mapEmbed.replace(/width="600"/, 'width="100%"').replace(/height="450"/, 'height="100%"') }}
          />
        </div>
      </div>
      <style>{`
        .access-map iframe { width: 100% !important; height: 100% !important; min-height: 460px; border: 0; filter: grayscale(0.15); }
        @media (max-width: 880px) {
          .access-grid { grid-template-columns: 1fr !important; gap: 32px !important; }
          .access-map { min-height: 360px !important; }
        }
      `}</style>
    </section>
  );
}

// ============================================================
// CONTACT
// ============================================================
function Contact() {
  const [sent, setSent] = useState(false);
  const [form, setForm] = useState({ name: '', email: '', phone: '', type: '新築', message: '' });
  const submit = (e) => { e.preventDefault(); setSent(true); setTimeout(() => setSent(false), 4000); };

  const field = {
    width: '100%', padding: '16px 0', background: 'transparent',
    border: 'none', borderBottom: '1px solid rgba(255,255,255,0.3)',
    color: '#fff', fontSize: 15, outline: 'none',
  };
  const label = { fontSize: 12, letterSpacing: '0.15em', color: 'rgba(255,255,255,0.7)' };

  return (
    <section id="contact" data-screen-label="08 Contact" style={{
      background: 'var(--primary-dark)', color: '#fff', padding: '140px 0', position: 'relative',
    }}>
      <div className="wrap" style={{ maxWidth: 1080 }}>
        <div style={{ display: 'grid', gridTemplateColumns: '1fr 1.2fr', gap: 80 }} className="contact-grid">
          <div>
            <SectionTitle kicker="CONTACT" jp="お問い合わせ" en="Get In Touch" light={true} />
            <p className="reveal" style={{ fontSize: 15, lineHeight: 2, opacity: 0.85, marginBottom: 40 }}>
              ご相談・お見積りはすべて無料です。<br />
              新築・リフォーム、どんな小さなことでも、<br />
              お気軽にお問い合わせください。
            </p>
            <div className="reveal" style={{ paddingTop: 32, borderTop: '1px solid rgba(255,255,255,0.15)' }}>
              <div style={{ fontSize: 11, letterSpacing: '0.2em', opacity: 0.6, marginBottom: 8 }}>お電話でのご相談</div>
              <a href="tel:0300000000" style={{
                fontFamily: 'var(--latin-serif)', fontSize: 38, color: 'var(--accent)',
                letterSpacing: '0.05em', display: 'inline-block',
              }}>03 — 0000 — 0000</a>
              <div style={{ fontSize: 12, opacity: 0.7, marginTop: 6 }}>平日・土曜 9:00 – 18:00</div>
            </div>
          </div>

          <form onSubmit={submit} className="reveal" style={{ display: 'flex', flexDirection: 'column', gap: 28 }}>
            <div>
              <div style={label}>お名前 *</div>
              <input required value={form.name} onChange={e => setForm({...form, name: e.target.value})} style={field} />
            </div>
            <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 28 }} className="contact-row">
              <div>
                <div style={label}>メールアドレス *</div>
                <input type="email" required value={form.email} onChange={e => setForm({...form, email: e.target.value})} style={field} />
              </div>
              <div>
                <div style={label}>お電話番号</div>
                <input type="tel" value={form.phone} onChange={e => setForm({...form, phone: e.target.value})} style={field} />
              </div>
            </div>
            <div>
              <div style={{ ...label, marginBottom: 12 }}>ご相談内容</div>
              <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
                {['新築', 'リフォーム', 'リノベーション', 'メンテナンス', 'その他'].map(t => (
                  <button key={t} type="button" onClick={() => setForm({...form, type: t})} style={{
                    padding: '10px 18px',
                    background: form.type === t ? 'var(--accent)' : 'transparent',
                    border: '1px solid ' + (form.type === t ? 'var(--accent)' : 'rgba(255,255,255,0.3)'),
                    color: '#fff', fontSize: 13, letterSpacing: '0.08em',
                  }}>{t}</button>
                ))}
              </div>
            </div>
            <div>
              <div style={label}>ご質問・ご要望</div>
              <textarea rows="4" value={form.message} onChange={e => setForm({...form, message: e.target.value})} style={{ ...field, resize: 'vertical', minHeight: 80 }} />
            </div>
            <label style={{ display: 'flex', alignItems: 'center', gap: 10, fontSize: 12, opacity: 0.8, cursor: 'pointer' }}>
              <input type="checkbox" required style={{ accentColor: 'var(--accent)' }} />
              <a href="#privacy" style={{ borderBottom: '1px solid currentColor' }}>プライバシーポリシー</a>に同意する
            </label>
            <button type="submit" style={{
              padding: '20px', background: 'var(--accent)', color: '#fff',
              border: 'none', fontSize: 14, fontWeight: 600, letterSpacing: '0.2em',
              display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 14,
            }}>
              {sent ? '送信しました。ありがとうございます。' : 'お問い合わせを送信する'}
              {!sent && <Arrow />}
            </button>
          </form>
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .contact-grid { grid-template-columns: 1fr !important; gap: 56px !important; }
          .contact-row { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

// ============================================================
// FOOTER + PRIVACY
// ============================================================
function Footer() {
  return (
    <footer style={{ background: '#0e0e0e', color: '#fff' }}>
      <div className="wrap" style={{ padding: '80px 32px 40px' }}>
        <div style={{
          display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', gap: 40, paddingBottom: 60,
          borderBottom: '1px solid rgba(255,255,255,0.1)',
        }} className="footer-grid">
          <div>
            <div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 20 }}>
              <LogoMark color="#fff" accent="var(--accent)" />
              <span style={{ fontFamily: 'var(--serif)', fontSize: 19, fontWeight: 600, letterSpacing: '0.08em' }}>
                天野工務店
              </span>
            </div>
            <p style={{ fontSize: 13, lineHeight: 1.9, opacity: 0.65, margin: 0, maxWidth: 360 }}>
              一棟、一棟に職人の手と、誠実を。<br />
              東京・杉並を拠点とする、地域密着の工務店です。
            </p>
          </div>
          <FooterCol title="サイトマップ" links={[['会社案内','#about'],['事業内容','#services'],['施工事例','#works'],['お客様の声','#voice']]} />
          <FooterCol title="サポート" links={[['よくある質問','#faq'],['アクセス','#access'],['お問い合わせ','#contact'],['プライバシーポリシー','#privacy']]} />
          <div>
            <div style={{ fontSize: 12, letterSpacing: '0.2em', opacity: 0.5, marginBottom: 18 }}>CONTACT</div>
            <a href="tel:0300000000" style={{ fontFamily: 'var(--latin-serif)', fontSize: 22, color: 'var(--accent)', display: 'block', marginBottom: 6 }}>
              03 — 0000 — 0000
            </a>
            <div style={{ fontSize: 12, opacity: 0.6 }}>平日・土曜 9:00 – 18:00</div>
          </div>
        </div>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', paddingTop: 30, fontSize: 12, opacity: 0.5, flexWrap: 'wrap', gap: 16 }}>
          <span style={{ fontFamily: 'var(--latin-serif)', letterSpacing: '0.2em' }}>© 2026 AMANO KOUMUTEN CO., LTD. ALL RIGHTS RESERVED.</span>
          <span style={{ fontFamily: 'var(--latin-serif)', fontStyle: 'italic', letterSpacing: '0.2em' }}>Crafted in Tokyo</span>
        </div>
      </div>

      {/* Privacy Policy section */}
      <PrivacyPolicy />

      <style>{`
        @media (max-width: 880px) {
          .footer-grid { grid-template-columns: 1fr 1fr !important; gap: 40px 32px !important; }
        }
        @media (max-width: 540px) {
          .footer-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </footer>
  );
}

function FooterCol({ title, links }) {
  return (
    <div>
      <div style={{ fontSize: 12, letterSpacing: '0.2em', opacity: 0.5, marginBottom: 18 }}>{title.toUpperCase()}</div>
      <ul style={{ listStyle: 'none', padding: 0, margin: 0, display: 'flex', flexDirection: 'column', gap: 12 }}>
        {links.map(([l, h]) => (
          <li key={h}><a href={h} style={{ fontSize: 13, opacity: 0.8 }}>{l}</a></li>
        ))}
      </ul>
    </div>
  );
}

function PrivacyPolicy() {
  const [open, setOpen] = useState(false);
  return (
    <div id="privacy" style={{ borderTop: '1px solid rgba(255,255,255,0.1)' }}>
      <div className="wrap" style={{ padding: '20px 32px' }}>
        <button onClick={() => setOpen(!open)} style={{
          width: '100%', display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          background: 'transparent', border: 'none', color: '#fff', padding: '12px 0',
          fontSize: 13, letterSpacing: '0.1em', opacity: 0.8,
        }}>
          <span>プライバシーポリシー</span>
          <span style={{ transform: open ? 'rotate(180deg)' : 'none', transition: 'transform .3s' }}>
            <svg width="12" height="8" viewBox="0 0 12 8" fill="none"><path d="M1 1 L6 6 L11 1" stroke="currentColor" strokeWidth="1.4" /></svg>
          </span>
        </button>
        {open && (
          <div style={{ padding: '20px 0 40px', fontSize: 12.5, lineHeight: 2, opacity: 0.7, maxWidth: 880 }}>
            <p style={{ marginTop: 0 }}>株式会社天野工務店（以下「当社」）は、お客様の個人情報の保護を重要な責務と考え、以下の方針に基づき適切に取り扱います。</p>
            <p><strong>1. 個人情報の取得</strong><br />当社は、適法かつ公正な手段により、必要な範囲で個人情報を取得します。</p>
            <p><strong>2. 利用目的</strong><br />取得した個人情報は、お見積り・ご相談への対応、工事の実施、アフターメンテナンス、お知らせの送付の目的でのみ利用します。</p>
            <p><strong>3. 第三者提供</strong><br />ご本人の同意なく、第三者へ個人情報を提供することはありません（法令に基づく場合を除く）。</p>
            <p><strong>4. 安全管理</strong><br />個人情報の漏えい、滅失、毀損の防止のため、適切な安全管理措置を講じます。</p>
            <p><strong>5. 開示・訂正・削除</strong><br />ご本人からの個人情報の開示、訂正、削除のご請求には、合理的な範囲で速やかに対応します。</p>
            <p><strong>6. お問い合わせ</strong><br />本ポリシーに関するお問い合わせは、当社問い合わせ窓口までご連絡ください。</p>
            <p style={{ marginBottom: 0, fontSize: 11.5, opacity: 0.6 }}>制定日：2026年1月1日 ／ 株式会社 天野工務店</p>
          </div>
        )}
      </div>
    </div>
  );
}

// ============================================================
// Export to window for app.jsx
// ============================================================
Object.assign(window, {
  PALETTES, applyPalette, useReveal,
  Nav, Hero, About, Philosophy, Services, Works, Voice, FAQ, Access, Contact, Footer,
});
