/* Shared building blocks: logo, icons, image placeholders */

// Compass "A" mark inside a circle — simple geometric shapes only
function LogoMark({ size = 38, color = "currentColor" }) {
  return (
    <svg className="logo-mark" width={size} height={size} viewBox="0 0 48 48" fill="none">
      <circle cx="24" cy="24" r="22" stroke={color} strokeWidth="1.4" />
      <path d="M24 9 L34 33 L24 27 L14 33 Z" stroke={color} strokeWidth="1.4" strokeLinejoin="round" fill="none" />
      <circle cx="24" cy="24" r="2.4" fill={color} />
    </svg>
  );
}

function Brand({ className, color = "#1b2230" }) {
  return (
    <div className={className}>
      <LogoMark color={color} />
      <div className="name" style={{ color }}>
        コンパス会計社
        <small>COMPASS-TAX</small>
      </div>
    </div>
  );
}

/* --- icons (simple line/stroke) --- */
const I = {
  phone: (p) => (
    <svg width={p?.s || 18} height={p?.s || 18} viewBox="0 0 24 24" fill="none" stroke={p?.c || "currentColor"} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8.1 9.8a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.8 2.1z" />
    </svg>
  ),
  mail: (p) => (
    <svg width={p?.s || 18} height={p?.s || 18} viewBox="0 0 24 24" fill="none" stroke={p?.c || "currentColor"} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">
      <rect x="2.5" y="4.5" width="19" height="15" rx="1.5" />
      <path d="M3 6l9 6 9-6" />
    </svg>
  ),
  fb: () => (
    <svg width="14" height="14" viewBox="0 0 24 24" fill="#fff"><path d="M14 8.5V6.8c0-.8.2-1.3 1.4-1.3H17V2.6C16.7 2.5 15.7 2.4 14.6 2.4c-2.4 0-4 1.4-4 4.1V8.5H8V12h2.6v9H14v-9h2.5l.4-3.5H14z"/></svg>
  ),
  line: () => (
    <svg width="16" height="16" viewBox="0 0 24 24" fill="#fff"><path d="M12 3C6.9 3 3 6.3 3 10.4c0 3.7 3.4 6.8 7.9 7.3.3.1.7.2.8.5.1.3 0 .7 0 .9l-.1.8c0 .2-.2.9.8.5s5.4-3.2 7.3-5.4h0c1.3-1.4 2-2.9 2-4.6C20.7 6.3 16.8 3 12 3z"/></svg>
  ),
  calc: () => (
    <svg width="40" height="40" viewBox="0 0 48 48" fill="none" stroke="#16263f" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <rect x="11" y="6" width="26" height="36" rx="2.5" />
      <rect x="15.5" y="10.5" width="17" height="7" rx="1" />
      <circle cx="17" cy="24" r="1.1" fill="#16263f"/><circle cx="24" cy="24" r="1.1" fill="#16263f"/><circle cx="31" cy="24" r="1.1" fill="#16263f"/>
      <circle cx="17" cy="30" r="1.1" fill="#16263f"/><circle cx="24" cy="30" r="1.1" fill="#16263f"/><circle cx="31" cy="30" r="1.1" fill="#16263f"/>
      <circle cx="17" cy="36" r="1.1" fill="#16263f"/><circle cx="24" cy="36" r="1.1" fill="#16263f"/><circle cx="31" cy="36" r="1.1" fill="#16263f"/>
    </svg>
  ),
  people: () => (
    <svg width="44" height="40" viewBox="0 0 52 44" fill="none" stroke="#16263f" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <circle cx="26" cy="14" r="6.5" />
      <path d="M14 38c0-6.6 5.4-11 12-11s12 4.4 12 11" />
      <circle cx="11" cy="18" r="4.6" /><path d="M3 36c0-4.2 2.8-7.4 7-8" />
      <circle cx="41" cy="18" r="4.6" /><path d="M49 36c0-4.2-2.8-7.4-7-8" />
    </svg>
  ),
  chart: () => (
    <svg width="40" height="40" viewBox="0 0 48 48" fill="none" stroke="#16263f" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
      <rect x="8" y="28" width="7" height="14" rx="1" />
      <rect x="20.5" y="20" width="7" height="22" rx="1" />
      <rect x="33" y="10" width="7" height="32" rx="1" />
    </svg>
  ),
  chev: (p) => (
    <svg width={p?.s || 16} height={p?.s || 16} viewBox="0 0 24 24" fill="none" stroke={p?.c || "currentColor"} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"><path d="M9 6l6 6-6 6" /></svg>
  ),
};

/* Image box.
   - Pass `src` to show a real photo (object-fit: cover) over a fallback gradient.
   - Without `src`, renders the tunable dark/professional gradient + monospace caption. */
function Img({ tone = "deskDark", cap, src, alt, style }) {
  const tones = {
    deskDark: "radial-gradient(120% 90% at 78% 38%, rgba(150,120,60,.20), transparent 42%), linear-gradient(115deg,#0c1118 0%,#172033 46%,#0e141d 100%)",
    office:   "linear-gradient(135deg,#2a3340 0%,#384556 60%,#222a36 100%)",
    glassA:   "linear-gradient(160deg,#222a38 0%,#36414f 55%,#1c232f 100%)",
    glassB:   "linear-gradient(160deg,#2c3543 0%,#434d5b 60%,#252c38 100%)",
    people:   "linear-gradient(160deg,#3a4350 0%,#252d39 100%)",
    cityLight:"radial-gradient(90% 80% at 70% 30%, rgba(200,180,140,.28), transparent 45%), linear-gradient(150deg,#cfd6dd 0%,#9fb0bf 45%,#5d6b7a 100%)",
    buildingDark: "linear-gradient(160deg,#16223a 0%,#28344e 55%,#101a2c 100%)",
  };
  let bg = tones[tone] || tones.deskDark;
  if (tone === "office") bg = "linear-gradient(135deg,#2a3340 0%,#384556 60%,#222a36 100%)";
  return (
    <div className="ph" style={{ backgroundImage: bg, ...style }}>
      {src && <img className="ph-img" src={src} alt={alt || ""} loading="lazy" />}
      <div style={{ position: "absolute", inset: 0, backgroundImage: "repeating-linear-gradient(135deg, rgba(255,255,255,.018) 0 2px, transparent 2px 9px)" }} />
      {cap && !src && <span className="ph-cap">{cap}</span>}
    </div>
  );
}

/* Footer — shared between both designs (variant "A" | "B") */
function Footer({ variant = "A" }) {
  const links = ["会社案内", "サービス案内", "採用情報", "お知らせ", "お問い合わせ", "プライバシーポリシー"];
  const info = variant === "A"
    ? ["eコンパス税理士・社会保険労務士オフィス"]
    : ["税理士・社会保険労務士オフィス"];
  return (
    <footer className="ft">
      <div className="ft-wrap">
        <div className="ft-brand">
          <div className="ft-row">
            <LogoMark color="#fff" size={40} />
            <div className="name">コンパス会計社<small>COMPASS-TAX</small></div>
          </div>
          <div className="ft-info">
            <span className="co">株式会社コンパス会計社</span><br />
            {info[0]}<br />
            〒169-0075 東京都新宿区高田馬場4-3-7 KSビル2F<br />
            TEL.03-6279-3375
          </div>
        </div>
        {variant === "A" ? (
          <div className="ft-links">
            {links.map((l) => <a key={l} href="#">{l}</a>)}
          </div>
        ) : (
          <div className="B-ftlinks">
            {links.map((l) => <a key={l} href="#">{l}</a>)}
          </div>
        )}
        {variant === "A" && <div />}
        <div className="ft-top">
          <a href="#top"><span className="up" />{variant === "A" ? "TOP" : "PAGE TOP"}</a>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { LogoMark, Brand, Img, I, Footer });
