// 青木総合会計事務所 / AOKI & PARTNERS — corporate site
// Single-file React component. Tailwind via CDN.

const { useState, useEffect, useRef, useCallback } = React;

/* ───────── helpers ───────── */

// IntersectionObserver-driven reveal
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, rootMargin: '0px 0px -40px 0px' });
    els.forEach((el) => io.observe(el));
    return () => io.disconnect();
  }, []);
}

// Count-up when element enters viewport
function CountUp({ to, duration = 1400, suffix = '', prefix = '', className = '' }) {
  const ref = useRef(null);
  const [val, setVal] = useState(0);
  useEffect(() => {
    if (!ref.current) return;
    const el = ref.current;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (!e.isIntersecting) return;
        const t0 = performance.now();
        const step = (t) => {
          const k = Math.min(1, (t - t0) / duration);
          // easeOutCubic
          const eased = 1 - Math.pow(1 - k, 3);
          setVal(Math.round(eased * to));
          if (k < 1) requestAnimationFrame(step);
        };
        requestAnimationFrame(step);
        io.unobserve(el);
      });
    }, { threshold: 0.4 });
    io.observe(el);
    return () => io.disconnect();
  }, [to, duration]);
  return <span ref={ref} className={`num-tabular ${className}`}>{prefix}{val.toLocaleString('ja-JP')}{suffix}</span>;
}

/* ───────── small atoms ───────── */

const Mark = () => (
  // simple monogram "A&P" wordmark — original mark, no real brand reference
  <span className="inline-flex items-center gap-3">
    <span className="inline-flex items-center justify-center w-9 h-9 border border-ink">
      <span className="font-mincho text-[18px] leading-none tracking-tight">青</span>
    </span>
    <span className="leading-tight">
      <span className="block font-mincho text-[17px] tracking-wider">青木総合会計事務所</span>
      <span className="block latin text-[13px] text-ink/70 -mt-0.5">Aoki &amp; Partners</span>
    </span>
  </span>
);

const SectionLabel = ({ idx, en, jp }) => (
  <div className="flex items-center gap-3 mb-6">
    <span className="mono text-[13px] tracking-[0.2em] text-ink/70">— {String(idx).padStart(2,'0')}</span>
    <span className="latin text-[18px] text-ink/90">{en}</span>
    <span className="text-ink/40">／</span>
    <span className="font-mincho text-[16px] text-ink/80">{jp}</span>
  </div>
);

const PlaceholderImage = ({ label, ratio = '4 / 5', note }) => (
  <div className="ph-stripes border border-ink/10 relative w-full" style={{ aspectRatio: ratio }} data-placeholder={label}>
    <div className="absolute inset-0 flex flex-col items-start justify-end p-4">
      <div className="mono text-[12px] text-ink/60 tracking-[0.18em]">PLACEHOLDER</div>
      <div className="font-mincho text-[16px] text-ink/80 mt-1">{label}</div>
      {note && <div className="mono text-[12px] text-ink/50 mt-2">{note}</div>}
    </div>
    <div className="absolute top-3 right-3 mono text-[12px] text-ink/40">{ratio}</div>
  </div>
);

/* ───────── nav ───────── */

const NAV = [
  { id: 'about',    jp: '私たちについて', en: 'About' },
  { id: 'services', jp: '取扱業務',     en: 'Services' },
  { id: 'reasons',  jp: '選ばれる理由',  en: 'Why Us' },
  { id: 'pricing',  jp: '料金プラン',    en: 'Pricing' },
  { id: 'flow',     jp: 'ご相談の流れ',  en: 'Flow' },
  { id: 'faq',      jp: 'よくあるご質問', en: 'FAQ' },
  { id: 'office',   jp: '事務所概要',    en: 'Office' },
  { id: 'contact',  jp: 'お問い合わせ',  en: 'Contact' },
];

function Nav() {
  const [shrunk, setShrunk] = useState(false);
  useEffect(() => {
    const onScroll = () => setShrunk(window.scrollY > 64);
    window.addEventListener('scroll', onScroll, { passive: true });
    return () => window.removeEventListener('scroll', onScroll);
  }, []);
  return (
    <header
      className={`fixed top-0 inset-x-0 z-50 nav-shrink nav-rule ${shrunk ? 'bg-paper/85 backdrop-blur' : 'bg-paper'} `}
      style={{ paddingTop: shrunk ? 10 : 18, paddingBottom: shrunk ? 10 : 18 }}
    >
      <div className="max-w-1240 mx-auto px-8 flex items-center justify-between gap-5">
        <a href="#top" className="flex items-center flex-shrink-0"><Mark /></a>
        <nav className="hidden lg:flex items-center gap-5 flex-shrink-0">
          {NAV.map(n => (
            <a key={n.id} href={`#${n.id}`} className="group flex flex-col items-start leading-none flex-shrink-0 whitespace-nowrap">
              <span className="font-mincho text-[15px] text-ink ul-link whitespace-nowrap">{n.jp}</span>
              <span className="latin text-[12px] text-ink/50 mt-0.5 whitespace-nowrap">{n.en}</span>
            </a>
          ))}
        </nav>
        <div className="flex items-center gap-3 flex-shrink-0">
          <a href="tel:0312345678" className="hidden xl:flex flex-col items-end leading-tight flex-shrink-0 whitespace-nowrap">
            <span className="mono text-[12px] text-ink/60 tracking-[0.18em] whitespace-nowrap">TEL ／ 平日 9:00–18:00</span>
            <span className="font-mincho text-[17px] num-tabular whitespace-nowrap">03-1234-5678</span>
          </a>
          <a href="#contact" className="btn-primary px-4 py-2 text-[14px] tracking-wider flex-shrink-0 whitespace-nowrap">初回相談を申し込む</a>
        </div>
      </div>
    </header>
  );
}

/* ───────── hero ───────── */

function Hero() {
  return (
    <section id="top" className="pt-36 pb-24 border-b rule">
      <div className="max-w-1240 mx-auto px-8 grid grid-cols-12 gap-10 items-end">
        {/* left rail — magazine masthead */}
        <div className="col-span-12 lg:col-span-7">
          <div className="reveal">
            <div className="flex items-center gap-4 mb-10">
              <span className="mono text-[13px] tracking-[0.22em] text-ink/70">VOL. 25 ／ TAX ACCOUNTANTS</span>
              <span className="hairline w-16 inline-block" />
              <span className="latin text-[16px] text-ink/70">Tokyo, Japan</span>
            </div>

            <h1 className="display text-[clamp(40px,6vw,84px)] leading-[1.12]">
              数字の向こうの、<br/>
              事業を見る。
            </h1>

            <div className="flex items-center gap-4 mt-8">
              <span className="hairline w-10 inline-block" />
              <p className="font-mincho text-[17px] md:text-[17px] text-ink/85 leading-[1.9]">
                中小企業の経営者と並走する、創業25年の総合会計事務所。
              </p>
            </div>

            <div className="flex flex-wrap items-center gap-4 mt-12">
              <a href="#contact" className="btn-primary px-6 py-4 text-[15px] tracking-[0.14em] inline-flex items-center gap-3">
                初回相談（無料）を申し込む
                <span className="latin text-[16px]">→</span>
              </a>
              <a href="#pricing" className="btn-ghost px-6 py-4 text-[15px] tracking-[0.14em] inline-flex items-center gap-3">
                資料を請求する
                <span className="latin text-[16px]">→</span>
              </a>
              <span className="mono text-[12px] text-ink/55 tracking-[0.18em] ml-2">＊オンライン面談可</span>
            </div>
          </div>
        </div>

        {/* portrait placeholder */}
        <div className="col-span-12 lg:col-span-5 reveal">
          <div className="relative">
            <PlaceholderImage label="代表 ／ 青木 健一郎 のポートレート" ratio="4 / 5" note="A4縦・自然光・グレー背景・正面" />
            <div className="absolute -bottom-3 -left-3 bg-paper border border-ink px-3 py-2">
              <div className="mono text-[12px] text-ink/60 tracking-[0.18em]">FIG.01</div>
              <div className="font-mincho text-[14px]">代表税理士 ／ 青木 健一郎</div>
            </div>
          </div>
        </div>
      </div>

      {/* trust bar */}
      <div className="max-w-1240 mx-auto px-8 mt-20 reveal">
        <div className="grid grid-cols-2 md:grid-cols-4 border-t border-b rule">
          {[
            { en: 'EST.',                  num: 1999, suffix: '',    jp: '創業1999' },
            { en: 'CLIENTS',               num: 320,  suffix: '社',   jp: '顧問先' },
            { en: 'LICENSED 10Y+',         num: 100,  suffix: '%',   jp: '税理士登録10年以上' },
            { en: 'TAX AUDIT RESPONSE',    num: 100,  suffix: '%',   jp: '法人税務調査対応' },
          ].map((t, i) => (
            <div key={i} className={`py-7 px-2 md:px-6 ${i!==0 ? 'md:border-l rule' : ''} ${i>1 ? '' : 'border-b md:border-b-0 rule'}`}>
              <div className="mono text-[12px] text-ink/55 tracking-[0.2em]">{t.en}</div>
              <div className="display text-[34px] md:text-[40px] mt-3 leading-none">
                <CountUp to={t.num} suffix={t.suffix} />
              </div>
              <div className="font-mincho text-[14px] text-ink/75 mt-3">{t.jp}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ───────── about ───────── */

function About() {
  return (
    <section id="about" className="py-28 border-b rule">
      <div className="max-w-1240 mx-auto px-8 grid grid-cols-12 gap-10">
        <div className="col-span-12 lg:col-span-4 reveal">
          <SectionLabel idx={2} en="About / Philosophy" jp="私たちについて" />
          <PlaceholderImage label="代表執務風景" ratio="3 / 4" note="ペン・万年筆・帳簿・横位置でも可" />
        </div>

        <div className="col-span-12 lg:col-span-8 reveal">
          <h2 className="display text-[clamp(28px,3.6vw,46px)] leading-[1.3]">
            税務署のための仕事ではなく、<br/>
            <span className="text-bordeaux">事業のための仕事</span>を。
          </h2>

          <div className="mt-10 grid md:grid-cols-2 gap-10 text-ink/85">
            <p className="font-mincho text-[17px] leading-[2.05]">
              私たちは、申告書を期日通りに提出することを仕事の終わりだとは考えていません。
              数字は、経営者が次の一手を決めるための材料です。月次決算の数字を読み解き、
              資金繰り、人材投資、設備投資、そして事業承継——経営の意思決定に静かに伴走する
              ことこそが、税理士の本分だと考えています。
            </p>
            <p className="font-mincho text-[17px] leading-[2.05]">
              創業から四半世紀、青木総合会計事務所は、業歴の浅い創業期の法人から、
              代替わりを迎える老舗企業まで、320社の歩みに寄り添ってきました。
              派手な提案より、続けられる仕組みを。流行のSaaSより、貴社に合う運用を。
              静かで地に足のついた仕事を、これからも積み重ねていきます。
            </p>
          </div>

          {/* signature */}
          <div className="mt-12 flex items-center gap-6">
            <div className="latin text-[28px] text-ink/85" style={{ fontStyle:'italic' }}>K. Aoki</div>
            <div className="hairline w-16" />
            <div className="font-mincho text-[14px] text-ink/70">代表税理士 ／ 青木 健一郎（税理士登録番号 第98765号）</div>
          </div>
        </div>
      </div>
    </section>
  );
}

/* ───────── services ───────── */

const SERVICES = [
  {
    no: '01',
    en: 'Corporate Tax Advisory',
    jp: '法人税務顧問',
    body: '月次決算と税務顧問を軸に、法人税・消費税・地方税まで一貫してご支援。年商1億円までの中小企業を中心に、資金繰りと意思決定を併走します。',
    tags: ['月次決算', '税務申告', '節税スキーム', '税務調査対応'],
  },
  {
    no: '02',
    en: 'Sole Proprietor / Freelance',
    jp: '個人事業主・フリーランス支援',
    body: '青色申告から法人成りの判断まで、ライフステージごとに最適解は変わります。記帳代行に頼らず、ご自身で経営を読める状態を目指します。',
    tags: ['青色申告', 'インボイス', '法人成り判断', '節税相談'],
  },
  {
    no: '03',
    en: 'Inheritance / Succession',
    jp: '相続・事業承継',
    body: '経営者の高齢化に伴う事業承継は、税務だけでなく株式・組織・想いの整理が必要です。提携先の弁護士・司法書士と連携し10年単位で設計します。',
    tags: ['相続税申告', '株式承継', 'M&A基本合意', '生前対策'],
  },
  {
    no: '04',
    en: 'Startup / Financing',
    jp: '創業・融資サポート',
    body: '日本政策金融公庫・制度融資・補助金まで、創業期に必要な資金調達を金融機関視点から設計。創業計画書の壁打ちから決算3期目までを伴走します。',
    tags: ['創業計画書', '日本公庫', '制度融資', '補助金'],
  },
];

function Services() {
  return (
    <section id="services" className="py-28 border-b rule">
      <div className="max-w-1240 mx-auto px-8">
        <div className="reveal">
          <SectionLabel idx={3} en="Services" jp="取扱業務" />
          <div className="grid grid-cols-12 gap-10 mb-14">
            <h2 className="col-span-12 lg:col-span-7 display text-[clamp(28px,3.6vw,44px)] leading-[1.3]">
              四つの軸で、企業の生涯に伴走する。
            </h2>
            <p className="col-span-12 lg:col-span-5 font-mincho text-[16px] text-ink/75 leading-[2] lg:pt-3">
              事務所のサービスは、創業から承継までを一気通貫で扱うために、四つの領域に整理されています。
              いずれも、経営者の隣で意思決定の材料を整える仕事です。
            </p>
          </div>
        </div>

        <div className="grid grid-cols-1 md:grid-cols-2 border-t border-l rule">
          {SERVICES.map((s, i) => (
            <article key={s.no} className="border-b border-r rule p-8 md:p-10 card-hover reveal min-h-[300px] flex flex-col">
              <div className="flex items-baseline justify-between">
                <span className="latin text-[40px] text-bordeaux leading-none">{s.no}</span>
                <span className="mono text-[12px] text-ink/55 tracking-[0.2em]">{s.en}</span>
              </div>
              <h3 className="display text-[24px] mt-6">{s.jp}</h3>
              <p className="font-mincho text-[13.5px] text-ink/80 leading-[2] mt-4">{s.body}</p>
              <div className="mt-auto pt-8 flex flex-wrap gap-2">
                {s.tags.map(t => (
                  <span key={t} className="text-[13px] tracking-wider border border-ink/40 px-2.5 py-1 text-ink/80">{t}</span>
                ))}
              </div>
            </article>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ───────── reasons ───────── */

const REASONS = [
  {
    no: '01',
    en: 'Monthly review',
    jp: '月次面談で経営判断に伴走',
    body: '月に一度、必ず数字を一緒に読みます。決算は一年に一度ではなく、十二回の積み上げです。先月との差分から、次の一手を見定めます。',
    foot: '月次面談 ／ 60–90分',
  },
  {
    no: '02',
    en: '24h response',
    jp: 'レスポンス24時間以内',
    body: '質問は寝かさない。営業日中であれば、原則24時間以内に一次回答をお返しします。重要な経営判断を、待ち時間で止めません。',
    foot: 'メール ／ チャット ／ 電話',
  },
  {
    no: '03',
    en: 'Cloud accounting',
    jp: 'クラウド会計の導入支援込み',
    body: 'freee／マネーフォワードの導入から運用定着まで、顧問契約に含まれます。属人化した経理から、誰が見てもわかる経理へ。',
    foot: 'freee ／ Money Forward 認定',
  },
];

function Reasons() {
  return (
    <section id="reasons" className="py-28 bg-paper2/40 border-b rule">
      <div className="max-w-1240 mx-auto px-8">
        <div className="reveal grid grid-cols-12 gap-10 mb-14 items-end">
          <div className="col-span-12 lg:col-span-7">
            <SectionLabel idx={4} en="Why Us" jp="選ばれる理由" />
            <h2 className="display text-[clamp(28px,3.6vw,44px)] leading-[1.3]">
              三つの約束として、明文化しています。
            </h2>
          </div>
          <p className="col-span-12 lg:col-span-5 font-mincho text-[16px] text-ink/75 leading-[2]">
            選んでいただくからには、選び続けていただける理由が必要です。
            事務所として全員が守る運用ルールを、三点に絞って公開しています。
          </p>
        </div>

        <div className="grid grid-cols-1 md:grid-cols-3 gap-8">
          {REASONS.map((r, i) => (
            <div key={r.no} className="reveal border-t border-ink pt-8 flex flex-col" style={{ transitionDelay: `${i*80}ms` }}>
              <div className="flex items-center justify-between">
                <span className="latin text-[44px] text-ink leading-none">{r.no}</span>
                <span className="mono text-[12px] text-ink/55 tracking-[0.2em]">— {r.en}</span>
              </div>
              <h3 className="display text-[22px] mt-6 leading-[1.5]">{r.jp}</h3>
              <p className="font-mincho text-[13.5px] text-ink/80 leading-[2] mt-4">{r.body}</p>
              <div className="mono text-[12px] text-ink/55 tracking-[0.18em] mt-8">{r.foot}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ───────── pricing ───────── */

const PLANS = [
  {
    key: 'startup',
    label: 'Startup',
    jp:    'スタートアップ',
    price: '¥20,000',
    unit:  '／月〜',
    target:'創業3期目までの法人 ／ 個人事業主',
    items: [
      '月次決算（クラウド会計／自社入力）',
      '法人税・消費税・地方税 申告',
      'メール／チャット相談 無制限',
      'クラウド会計 初期設定 1回',
      'インボイス・電子帳簿保存法 対応',
    ],
    excluded: ['月次訪問面談', '税務調査立会い（別途）'],
    recommended: false,
  },
  {
    key: 'standard',
    label: 'Standard',
    jp:    'スタンダード',
    price: '¥40,000',
    unit:  '／月〜',
    target:'年商5,000万〜3億円の法人',
    items: [
      'スタートアップの全機能を含む',
      '月次面談（60–90分／オンライン可）',
      '記帳代行（仕訳500件まで）',
      '資金繰り表 月次更新',
      '税務調査立会い 年1回まで含む',
      '年末調整・法定調書 作成',
    ],
    excluded: [],
    recommended: true,
  },
  {
    key: 'enterprise',
    label: 'Enterprise',
    jp:    'エンタープライズ',
    price: '個別',
    unit:  'お見積り',
    target:'年商3億円超 ／ 複数拠点 ／ M&A検討中',
    items: [
      'スタンダードの全機能を含む',
      '月次面談（経営会議出席を含む）',
      '連結決算・グループ通算制度 対応',
      'M&A・組織再編 税務デューデリジェンス',
      '事業承継 10年計画の策定',
      '専任税理士＋スタッフのチーム体制',
    ],
    excluded: [],
    recommended: false,
  },
];

function Pricing() {
  return (
    <section id="pricing" className="py-28 border-b rule">
      <div className="max-w-1240 mx-auto px-8">
        <div className="reveal grid grid-cols-12 gap-10 mb-14 items-end">
          <div className="col-span-12 lg:col-span-7">
            <SectionLabel idx={5} en="Pricing" jp="料金プラン" />
            <h2 className="display text-[clamp(28px,3.6vw,44px)] leading-[1.3]">
              料金は、迷わず比較できる三つの型で。
            </h2>
          </div>
          <p className="col-span-12 lg:col-span-5 font-mincho text-[16px] text-ink/75 leading-[2]">
            月額顧問料は事業規模と運用の手数で決まります。途中でのプラン変更も柔軟に対応します。
            記載のない費用は、原則発生しません。
          </p>
        </div>

        <div className="grid grid-cols-1 lg:grid-cols-3 gap-0 border rule">
          {PLANS.map((p, i) => (
            <div key={p.key} className={`reveal p-10 flex flex-col ${i!==0 ? 'lg:border-l rule' : ''} ${p.recommended ? 'bg-ink text-paper relative' : ''}`}>
              {p.recommended && (
                <div className="absolute -top-3 left-10 bg-bordeaux text-paper px-3 py-1 mono text-[12px] tracking-[0.2em]">
                  RECOMMENDED ／ 推奨
                </div>
              )}
              <div className="flex items-baseline justify-between">
                <div>
                  <div className={`latin text-[22px] ${p.recommended ? 'text-paper/80' : 'text-ink/70'}`}>{p.label}</div>
                  <div className="display text-[26px] mt-1">{p.jp}</div>
                </div>
                <div className={`mono text-[12px] tracking-[0.2em] ${p.recommended ? 'text-paper/60' : 'text-ink/55'}`}>0{i+1}</div>
              </div>

              <div className="mt-6 flex items-baseline gap-2">
                <span className="display text-[36px] num-tabular">{p.price}</span>
                <span className={`font-mincho text-[16px] ${p.recommended ? 'text-paper/75' : 'text-ink/70'}`}>{p.unit}</span>
              </div>
              <div className={`font-mincho text-[12.5px] mt-3 ${p.recommended ? 'text-paper/75' : 'text-ink/70'}`}>{p.target}</div>

              <div className={`hairline mt-8 mb-6 ${p.recommended ? 'bg-paper/40' : ''}`} style={p.recommended ? { background:'#f5f1e8', opacity:.4 } : {}} />

              <ul className="space-y-3">
                {p.items.map(it => (
                  <li key={it} className="flex gap-3 items-start">
                    <span className={`mt-[7px] inline-block w-3 h-px ${p.recommended ? 'bg-paper' : 'bg-ink'}`} />
                    <span className={`font-mincho text-[15px] leading-[1.85] ${p.recommended ? 'text-paper/95' : 'text-ink/85'}`}>{it}</span>
                  </li>
                ))}
                {p.excluded.map(it => (
                  <li key={it} className="flex gap-3 items-start opacity-60">
                    <span className={`mt-[7px] inline-block w-3 h-px ${p.recommended ? 'bg-paper' : 'bg-ink'}`} />
                    <span className={`font-mincho text-[12.5px] leading-[1.85] line-through ${p.recommended ? 'text-paper/80' : 'text-ink/70'}`}>{it}</span>
                  </li>
                ))}
              </ul>

              <a
                href="#contact"
                className={`mt-10 inline-flex items-center justify-between py-3 px-4 text-[14px] tracking-[0.14em]
                  ${p.recommended ? 'bg-bordeaux text-paper border border-bordeaux hover:bg-bordeaux2' : 'btn-ghost'}`}
              >
                このプランで相談する <span className="latin">→</span>
              </a>
            </div>
          ))}
        </div>

        <p className="mono text-[12px] text-ink/55 tracking-[0.18em] mt-6">
          ＊価格はすべて税抜表示。決算料は別途、月額顧問料の4〜6ヶ月分を目安としています。
        </p>
      </div>
    </section>
  );
}

/* ───────── flow ───────── */

const FLOW = [
  { no: '01', jp: '無料相談',  en: 'Initial consultation', body: 'オンラインまたは来所にて、現状の課題と背景を伺います。所要40分。費用は発生しません。', meta: '所要 40分／オンライン可' },
  { no: '02', jp: 'ヒアリング', en: 'Hearing',              body: '直近3期分の決算書と試算表を拝見し、業務の手数と論点を整理します。NDA可。',           meta: '資料お預かり ／ NDA対応' },
  { no: '03', jp: 'ご提案',    en: 'Proposal',              body: '担当税理士の体制・サービス内容・費用を、書面でご提案します。比較検討のお時間も尊重します。', meta: '提案書 ／ 見積書' },
  { no: '04', jp: 'ご契約',    en: 'Engagement',            body: '契約書を取り交わし、初月のキックオフ面談で運用設計を行います。最短で翌月から稼働します。',  meta: '最短 ご相談から2週間' },
];

function Flow() {
  return (
    <section id="flow" className="py-28 bg-paper2/40 border-b rule">
      <div className="max-w-1240 mx-auto px-8">
        <div className="reveal mb-14">
          <SectionLabel idx={6} en="Flow" jp="ご相談の流れ" />
          <h2 className="display text-[clamp(28px,3.6vw,44px)] leading-[1.3]">
            ご相談から契約まで、平均2週間。
          </h2>
        </div>

        <div className="grid grid-cols-1 md:grid-cols-4 gap-0 border-t rule">
          {FLOW.map((f, i) => (
            <div key={f.no} className={`reveal py-10 px-2 md:px-6 ${i!==0 ? 'md:border-l rule' : ''} relative`} style={{ transitionDelay: `${i*70}ms` }}>
              {i < FLOW.length-1 && (
                <span className="hidden md:block absolute right-[-7px] top-[44px] latin text-ink/40 text-[18px]">→</span>
              )}
              <div className="flex items-center justify-between">
                <span className="latin text-[40px] text-ink">{f.no}</span>
                <span className="mono text-[12px] text-ink/55 tracking-[0.2em]">{f.en}</span>
              </div>
              <h3 className="display text-[20px] mt-5">{f.jp}</h3>
              <p className="font-mincho text-[15px] text-ink/80 leading-[2] mt-3">{f.body}</p>
              <div className="mono text-[12px] text-ink/55 tracking-[0.18em] mt-6 pt-4 border-t rule">{f.meta}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

/* ───────── faq ───────── */

const FAQS = [
  {
    q: '顧問料以外に追加費用はかかりますか？',
    a: '原則として、月額顧問料に含まれていないものは「決算料」「税務調査立会い（スタートアッププランの場合）」「相続・事業承継などのスポット案件」のみです。記帳代行や年末調整は、プランに応じて顧問料内で対応しています。事前にお見積りをお出ししますので、想定外の費用が発生することはありません。',
  },
  {
    q: '既存の税理士からの切り替えは可能ですか？',
    a: 'はい、毎年30社ほど切り替えのご相談をいただいています。期中での引き継ぎでも、過年度の申告書と試算表をお預かりすれば問題なく対応可能です。前任の税理士事務所とのやり取りも、ご希望があれば代行します。',
  },
  {
    q: '月次訪問は必須ですか？',
    a: 'いいえ、必須ではありません。スタンダードプラン以上では月次面談が含まれますが、オンライン（Google Meet／Zoom）でも実施できます。地方の経営者様にも数多くご支援しており、対面にこだわらない運用設計をしています。',
  },
  {
    q: 'クラウド会計は未導入でも大丈夫ですか？',
    a: '大丈夫です。むしろ未導入の段階からご相談いただいた方が、貴社の業態に合った導入設計ができます。freee／マネーフォワードのいずれにも対応しており、初期設定・運用ルール作りまで顧問契約に含めています。',
  },
  {
    q: '相続のみのスポット相談は受けていますか？',
    a: '受けています。顧問契約のないお客様からの相続税申告のみのご依頼も、年30件ほどお受けしています。料金は、財産総額に応じた個別見積りです。初回相談は無料ですので、まずはご状況をお聞かせください。',
  },
];

function FAQ() {
  return (
    <section id="faq" className="py-28 border-b rule">
      <div className="max-w-1240 mx-auto px-8 grid grid-cols-12 gap-10">
        <div className="col-span-12 lg:col-span-4 reveal">
          <SectionLabel idx={7} en="FAQ" jp="よくあるご質問" />
          <h2 className="display text-[clamp(28px,3vw,38px)] leading-[1.3]">
            よくお寄せいただく<br/>五つのご質問。
          </h2>
          <p className="font-mincho text-[13.5px] text-ink/75 leading-[2] mt-6">
            その他のご質問は、お問い合わせフォームよりお気軽にお寄せください。
            原則24時間以内にご返信いたします。
          </p>
        </div>

        <div className="col-span-12 lg:col-span-8">
          <div className="border-t rule">
            {FAQS.map((f, i) => (
              <details key={i} className="reveal border-b rule group" style={{ transitionDelay: `${i*40}ms` }}>
                <summary className="py-6 flex items-start gap-6">
                  <span className="latin text-[20px] text-bordeaux flex-none">Q.{String(i+1).padStart(2,'0')}</span>
                  <span className="font-mincho text-[16px] text-ink/95 flex-1 leading-[1.7]">{f.q}</span>
                  <span className="chev mt-2 inline-block w-3 h-3 border-r border-b border-ink rotate-45 flex-none" />
                </summary>
                <div className="pb-7 pl-[60px] pr-10 font-mincho text-[16px] text-ink/80 leading-[2.05]">
                  {f.a}
                </div>
              </details>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

/* ───────── office ───────── */

function Office() {
  const rows = [
    ['事務所名',     '青木総合会計事務所 ／ AOKI &amp; PARTNERS'],
    ['代表者',       '青木 健一郎（税理士）'],
    ['税理士登録番号', '第 98765 号（東京税理士会 麹町支部）'],
    ['所属税理士会',  '東京税理士会 ／ 日本税理士会連合会'],
    ['加入保険',     '税理士職業賠償責任保険（三井住友海上 ／ 上限 1億円）'],
    ['設立',         '1999年4月（個人事務所として開業 ／ 2008年 税理士法人化）'],
    ['所在地',       '〒102-0083  東京都千代田区麹町3-1-1  麹町MTビル 6F'],
    ['アクセス',     '東京メトロ有楽町線「麹町」駅 1番出口 徒歩2分 ／ JR四ツ谷駅 徒歩8分'],
    ['営業時間',     '平日 9:00 – 18:00（土日祝休 ／ 事前予約で時間外面談可）'],
    ['提携専門家',   '弁護士 ／ 司法書士 ／ 社会保険労務士 ／ 中小企業診断士'],
  ];
  return (
    <section id="office" className="py-28 border-b rule">
      <div className="max-w-1240 mx-auto px-8 grid grid-cols-12 gap-10">
        <div className="col-span-12 lg:col-span-7 reveal">
          <SectionLabel idx={8} en="Office" jp="事務所概要" />
          <h2 className="display text-[clamp(28px,3vw,40px)] leading-[1.3]">
            事務所概要 ／ Profile
          </h2>

          <dl className="mt-10 border-t rule">
            {rows.map(([k, v], i) => (
              <div key={k} className="grid grid-cols-12 py-5 border-b rule">
                <dt className="col-span-4 mono text-[12px] text-ink/55 tracking-[0.2em] pt-1">{String(i+1).padStart(2,'0')} ／ {k}</dt>
                <dd className="col-span-8 font-mincho text-[16px] text-ink/90 leading-[1.9]" dangerouslySetInnerHTML={{ __html: v }} />
              </div>
            ))}
          </dl>
        </div>

        <div className="col-span-12 lg:col-span-5 reveal">
          <div className="ph-stripes border border-ink/15 relative w-full" style={{ aspectRatio: '4 / 5' }} data-placeholder="アクセスマップ／麹町駅周辺">
            {/* faux map graphic */}
            <svg viewBox="0 0 400 500" className="absolute inset-0 w-full h-full" aria-hidden>
              <g stroke="#1a2942" strokeOpacity="0.35" fill="none">
                <line x1="0" y1="160" x2="400" y2="120" strokeWidth="1.4"/>
                <line x1="0" y1="320" x2="400" y2="350" strokeWidth="1.2"/>
                <line x1="120" y1="0" x2="160" y2="500" strokeWidth="1"/>
                <line x1="280" y1="0" x2="320" y2="500" strokeWidth="0.8"/>
                <line x1="40" y1="0" x2="60" y2="500" strokeWidth="0.6" strokeDasharray="3 4"/>
                <rect x="170" y="200" width="80" height="60" strokeOpacity="0.25"/>
                <rect x="60" y="380" width="80" height="40" strokeOpacity="0.2"/>
                <rect x="270" y="60" width="60" height="50" strokeOpacity="0.2"/>
              </g>
              <g>
                <circle cx="210" cy="230" r="10" fill="#7a2e2e"/>
                <circle cx="210" cy="230" r="22" fill="none" stroke="#7a2e2e" strokeOpacity="0.4"/>
                <line x1="210" y1="230" x2="210" y2="195" stroke="#7a2e2e" strokeWidth="1.5"/>
              </g>
            </svg>
            <div className="absolute top-4 left-4 mono text-[12px] text-ink/60 tracking-[0.18em]">FIG.02 ／ ACCESS</div>
            <div className="absolute bottom-4 left-4 right-4 bg-paper border border-ink p-4">
              <div className="font-mincho text-[15px]">麹町MTビル 6F</div>
              <div className="mono text-[12px] text-ink/60 tracking-[0.16em] mt-1">35.6843, 139.7407</div>
            </div>
          </div>
          <a href="#" className="mt-4 inline-flex items-center gap-2 mono text-[13px] tracking-[0.18em] text-ink/80 ul-link">
            GOOGLE MAPS で開く <span className="latin">→</span>
          </a>
        </div>
      </div>
    </section>
  );
}

/* ───────── contact ───────── */

function Contact() {
  const [form, setForm] = useState({
    name: '', company: '', email: '', tel: '', plan: '未定', subject: '', body: '', agree: false,
  });
  const [submitted, setSubmitted] = useState(false);
  const [errors, setErrors] = useState({});

  const update = (k) => (e) => {
    const v = e.target.type === 'checkbox' ? e.target.checked : e.target.value;
    setForm({ ...form, [k]: v });
    if (errors[k]) setErrors({ ...errors, [k]: undefined });
  };

  const onSubmit = (e) => {
    e.preventDefault();
    const er = {};
    if (!form.name)    er.name = 'お名前をご入力ください';
    if (!form.email || !/.+@.+\..+/.test(form.email)) er.email = 'メールアドレスをご確認ください';
    if (!form.body)    er.body = 'ご相談内容をご入力ください';
    if (!form.agree)   er.agree = '個人情報の取り扱いへの同意が必要です';
    setErrors(er);
    if (Object.keys(er).length === 0) setSubmitted(true);
  };

  if (submitted) {
    return (
      <section id="contact" className="py-32 bg-ink text-paper">
        <div className="max-w-1240 mx-auto px-8 reveal">
          <div className="latin text-[18px] text-paper/70">— Thank you</div>
          <h2 className="display text-[clamp(32px,4vw,52px)] mt-4">お問い合わせを承りました。</h2>
          <p className="font-mincho text-[17px] text-paper/85 leading-[2] mt-6 max-w-2xl">
            {form.name} 様、ご連絡をありがとうございます。担当の税理士より、原則24時間以内にご返信いたします。
            お急ぎの場合は、平日 9:00 – 18:00 にお電話（03-1234-5678）にてご連絡ください。
          </p>
          <button
            onClick={() => { setSubmitted(false); setForm({ name:'',company:'',email:'',tel:'',plan:'未定',subject:'',body:'',agree:false }); }}
            className="mt-10 inline-flex border border-paper px-5 py-3 text-[14px] tracking-[0.14em] hover:bg-paper hover:text-ink transition"
          >
            別件で再度送信する
          </button>
        </div>
      </section>
    );
  }

  return (
    <section id="contact" className="py-28 bg-ink text-paper">
      <div className="max-w-1240 mx-auto px-8 grid grid-cols-12 gap-10">
        <div className="col-span-12 lg:col-span-5 reveal">
          <div className="flex items-center gap-3 mb-6">
            <span className="mono text-[13px] tracking-[0.2em] text-paper/65">— 09</span>
            <span className="latin text-[18px] text-paper/85">Contact</span>
            <span className="text-paper/40">／</span>
            <span className="font-mincho text-[16px] text-paper/85">お問い合わせ</span>
          </div>

          <h2 className="display text-[clamp(30px,3.6vw,46px)] leading-[1.3]">
            まずは、<span className="text-bordeaux/95" style={{ color:'#c98686' }}>40分の対話</span>から。
          </h2>

          <p className="font-mincho text-[16px] text-paper/80 leading-[2] mt-6">
            ご相談内容を簡単にお書き添えください。担当税理士から、24時間以内に一次返信を差し上げます。
            個人情報は厳格に管理し、ご相談以外の目的では使用いたしません。
          </p>

          <div className="mt-12 border-t border-paper/20 pt-8 space-y-4">
            <div>
              <div className="mono text-[12px] tracking-[0.2em] text-paper/55">TEL</div>
              <div className="display text-[26px] num-tabular mt-1">03-1234-5678</div>
              <div className="mono text-[12px] tracking-[0.18em] text-paper/55 mt-1">平日 9:00 – 18:00</div>
            </div>
            <div>
              <div className="mono text-[12px] tracking-[0.2em] text-paper/55">EMAIL</div>
              <div className="font-mincho text-[17px] mt-1">contact@aoki-partners.example.jp</div>
            </div>
          </div>
        </div>

        <form onSubmit={onSubmit} className="col-span-12 lg:col-span-7 reveal">
          <div className="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-7">
            <Field label="お名前" required value={form.name} onChange={update('name')} error={errors.name} placeholder="例：青木 健一郎" />
            <Field label="会社名 ／ 屋号" value={form.company} onChange={update('company')} placeholder="例：株式会社サンプル商事" />
            <Field label="メールアドレス" required value={form.email} onChange={update('email')} error={errors.email} placeholder="example@your-company.jp" type="email" />
            <Field label="お電話番号" value={form.tel} onChange={update('tel')} placeholder="03-1234-5678" type="tel" />

            <div className="md:col-span-2">
              <Label k="ご検討中のプラン" />
              <div className="flex flex-wrap gap-2 mt-2">
                {['未定','スタートアップ','スタンダード','エンタープライズ','スポット相談'].map(p => (
                  <button type="button" key={p}
                    onClick={() => setForm({ ...form, plan: p })}
                    className={`text-[14px] tracking-wider px-3 py-2 border ${form.plan===p ? 'bg-paper text-ink border-paper' : 'border-paper/40 text-paper/85 hover:border-paper'}`}
                  >{p}</button>
                ))}
              </div>
            </div>

            <Field label="件名" value={form.subject} onChange={update('subject')} className="md:col-span-2" placeholder="例：法人成りについてご相談したい" />

            <div className="md:col-span-2">
              <Label k="ご相談内容" required />
              <textarea
                rows={6}
                value={form.body}
                onChange={update('body')}
                placeholder="現状の業種・年商規模・課題などを差し支えのない範囲でお書きください。"
                className={`w-full mt-2 bg-transparent border-b ${errors.body ? 'border-bordeaux' : 'border-paper/30'} focus:border-paper outline-none py-3 font-mincho text-[16px] leading-[1.9] text-paper`}
              />
              {errors.body && <Err>{errors.body}</Err>}
            </div>

            <div className="md:col-span-2 mt-2">
              <label className="flex items-start gap-3 cursor-pointer">
                <input type="checkbox" className="ck mt-1" style={{ borderColor:'#f5f1e8' }} checked={form.agree} onChange={update('agree')} />
                <span className="font-mincho text-[15px] text-paper/85 leading-[1.9]">
                  <a href="#" className="ul-link">個人情報の取り扱い</a>に同意の上で送信します。<span className="text-bordeaux" style={{ color:'#c98686' }}>＊必須</span>
                </span>
              </label>
              {errors.agree && <Err>{errors.agree}</Err>}
            </div>

            <div className="md:col-span-2 flex items-center justify-between mt-6">
              <p className="mono text-[12px] tracking-[0.18em] text-paper/55 max-w-md">
                ＊送信前に、上記の内容に誤りがないことをご確認ください。
              </p>
              <button type="submit" className="inline-flex items-center gap-3 bg-paper text-ink px-7 py-4 text-[14px] tracking-[0.16em] hover:bg-bordeaux hover:text-paper transition-colors">
                送信する <span className="latin">→</span>
              </button>
            </div>
          </div>
        </form>
      </div>
    </section>
  );
}

const Label = ({ k, required }) => (
  <div className="flex items-baseline gap-2">
    <span className="mono text-[12px] tracking-[0.2em] text-paper/65">{k.toUpperCase ? '' : ''}</span>
    <span className="font-mincho text-[14px] text-paper/85">{k}</span>
    {required && <span className="mono text-[12px] text-bordeaux" style={{ color:'#c98686' }}>＊必須</span>}
  </div>
);

const Err = ({ children }) => (
  <div className="mt-2 mono text-[12px] tracking-[0.16em]" style={{ color:'#c98686' }}>{children}</div>
);

function Field({ label, required, value, onChange, error, placeholder, type='text', className='' }) {
  return (
    <div className={className}>
      <Label k={label} required={required} />
      <input
        type={type}
        value={value}
        onChange={onChange}
        placeholder={placeholder}
        className={`w-full mt-2 bg-transparent border-b ${error ? 'border-bordeaux' : 'border-paper/30'} focus:border-paper outline-none py-3 font-mincho text-[16px] text-paper placeholder:text-paper/35`}
      />
      {error && <Err>{error}</Err>}
    </div>
  );
}

/* ───────── footer ───────── */

function Footer() {
  return (
    <footer className="bg-paper2/60 border-t rule">
      <div className="max-w-1240 mx-auto px-8 py-20 grid grid-cols-12 gap-10">
        <div className="col-span-12 md:col-span-5">
          <Mark />
          <div className="latin text-[16px] text-ink/70 mt-4 ml-12">Tax Accountants Since 1999</div>
          <p className="font-mincho text-[12.5px] text-ink/70 leading-[2] mt-8 max-w-md">
            私たちは、申告書を正確に書くことを当然のこととし、
            その先にある経営者の意思決定を支えることを仕事としています。
          </p>
        </div>

        <div className="col-span-6 md:col-span-3">
          <div className="mono text-[12px] tracking-[0.2em] text-ink/55 mb-4">SITE MAP</div>
          <ul className="space-y-2">
            {NAV.map(n => (
              <li key={n.id}><a href={`#${n.id}`} className="font-mincho text-[15px] text-ink/85 ul-link">{n.jp}</a></li>
            ))}
          </ul>
        </div>

        <div className="col-span-6 md:col-span-2">
          <div className="mono text-[12px] tracking-[0.2em] text-ink/55 mb-4">LEGAL</div>
          <ul className="space-y-2">
            <li><a href="#" className="font-mincho text-[15px] text-ink/85 ul-link">プライバシーポリシー</a></li>
            <li><a href="#" className="font-mincho text-[15px] text-ink/85 ul-link">特定商取引法に基づく表記</a></li>
            <li><a href="#" className="font-mincho text-[15px] text-ink/85 ul-link">情報セキュリティ方針</a></li>
            <li><a href="#" className="font-mincho text-[15px] text-ink/85 ul-link">採用情報</a></li>
          </ul>
        </div>

        <div className="col-span-12 md:col-span-2">
          <div className="mono text-[12px] tracking-[0.2em] text-ink/55 mb-4">CONTACT</div>
          <div className="font-mincho text-[15px] text-ink/85">03-1234-5678</div>
          <div className="mono text-[12px] text-ink/55 tracking-[0.16em] mt-1">平日 9:00 – 18:00</div>
          <div className="font-mincho text-[14px] text-ink/85 mt-4 break-all">contact@aoki-partners.example.jp</div>
        </div>
      </div>

      <div className="border-t rule">
        <div className="max-w-1240 mx-auto px-8 py-6 flex flex-col md:flex-row items-start md:items-center justify-between gap-3">
          <div className="mono text-[12px] tracking-[0.16em] text-ink/60">
            ©︎ 1999–2026 AOKI &amp; PARTNERS Tax Accountants Office. ALL RIGHTS RESERVED.
          </div>
          <div className="mono text-[12px] tracking-[0.16em] text-ink/55">
            REGISTERED ／ TOKYO CPTA #98765 ／ KOJIMACHI BRANCH
          </div>
        </div>
      </div>
    </footer>
  );
}

/* ───────── app ───────── */

function App() {
  useReveal();
  return (
    <div className="bg-paper text-ink">
      <Nav />
      <main>
        <Hero />
        <About />
        <Services />
        <Reasons />
        <Pricing />
        <Flow />
        <FAQ />
        <Office />
        <Contact />
      </main>
      <Footer />
    </div>
  );
}

ReactDOM.createRoot(document.getElementById('app')).render(<App />);
