// v5 — Capability, Catalogue, Metrics, Contact CTA, Footer

// ══ 공정별 사진 — V4_CAPABILITY 순서(01~04)와 1:1 대응합니다 ══
//    null 이면 드래그앤드롭 업로드 슬롯으로 표시됩니다.
// ⚠ 이 자리는 세로형 박스(대략 3:4)입니다. 가로로 긴 사진을 넣으면
//   object-fit:cover 가 양옆을 잘라내 내용이 사라집니다. 세로 크롭을 쓰세요.
const CAP_MEDIA_5 = [
  'photos/site/inhouse-rig-clean.webp',               // 01 조립식 건물 부속자재 — 자체 제작 성형 설비
  'photos/factory/spare-cnc-interior-alt.webp', // 02 정밀 CNC선반 가공 — 선반 내부
  'photos/site/press-pca160-clean.webp',                // 03 금형 · 프레스 가공 — PCA-160 프레스
  'products/delivery-welding-bright.webp',                  // 04 용접 제작 · 조립 — 용접 작업
];

// ══ 회사 소개(Company) 배경 사진 — 히어로처럼 순차 전환됩니다 ══
const COMPANY_MEDIA_5 = [
  { src: 'photos/factory/spare-press-wide.webp',         ko: '프레스 설비', en: 'Press shop' },
  { src: 'photos/factory/spare-cnc-lathe-exterior.webp', ko: 'CNC선반 설비', en: 'CNC turning centre' },
  { src: 'photos/site/bandsaw-band.webp',                ko: 'NC 자동 절단 설비', en: 'NC cut-off saw' },
  { src: 'photos/site/weld-line-band.webp',               ko: '용접 · 성형 설비', en: 'Welding & forming line' },
];

// ═════════ CAPABILITY — numbered rows over a fixed media column ═════════
function Capability5() {
  const t = useV4(); const ko = t.lang !== 'en';
  const [act, setAct] = useState(0);
  return (
    <Sec5 id="capability" bg={D.base2}>
      <Rise>
        <Tag5>Capability</Tag5>
        <H5 style={{ marginTop: 18, maxWidth: 760 }}>
          {ko ? <>도면부터 완성품까지<br/>공정을 자체 보유합니다.</> : <>Drawing to finished part,<br/>every process in-house.</>}
        </H5>
      </Rise>

      <div className="g5-capwrap">
        <div style={{ display: 'grid', gridTemplateColumns: 'minmax(0,1fr)', gridAutoRows: '1fr', gap: 0, borderBottom: `1px solid ${D.line2}` }}>
          {V4_CAPABILITY.map((c, i) => (
            <Rise key={c.n} delay={i * .06} style={{ height: '100%' }}>
              <div
                className="g5-cap"
                onMouseEnter={() => setAct(i)}
                onFocus={() => setAct(i)}
                tabIndex={0}
                style={{
                  position: 'relative',
                  padding: 'clamp(22px,2.8vh,34px) 0 clamp(22px,2.8vh,34px) clamp(10px,1.4vw,18px)',
                  borderTop: `1px solid ${D.line2}`,
                  background: act === i ? 'rgba(237,235,231,0.03)' : 'transparent',
                  transform: act === i ? 'translateX(5px)' : 'translateX(0)',
                  transition: 'background .5s ease, transform .55s cubic-bezier(.2,.7,.3,1)',
                  outline: 'none', cursor: 'default', height: '100%',
                }}>
                {/* 활성 행 왼쪽 강조 바 — 위에서 아래로 자라납니다 */}
                <span style={{
                  position: 'absolute', left: 0, top: 0, width: 2,
                  height: act === i ? '100%' : '0%', background: D.steel,
                  transition: 'height .55s cubic-bezier(.2,.7,.3,1)',
                }}/>
                <span className="mono" style={{
                  fontSize: 12, fontWeight: 500, letterSpacing: '0.1em',
                  color: act === i ? D.steel : D.bone28, transition: 'color .5s', paddingTop: 5,
                }}>{c.n}</span>
                <h3 style={{
                  fontSize: 'clamp(18px,1.9vw,25px)', fontWeight: 700, letterSpacing: '-0.035em',
                  lineHeight: 1.24, color: act === i ? D.bone : D.bone70, transition: 'color .5s',
                }}>{ko ? c.ko : c.en}</h3>
                <p style={{
                  gridColumn: 2, marginTop: 8, fontSize: 14.5, lineHeight: 1.78,
                  color: act === i ? D.bone70 : D.bone45, transition: 'color .5s', maxWidth: 460,
                }}>
                  {ko ? c.ko2 : c.en2}
                </p>
                {/* 모바일 전용 — 각 항목 안에 해당 공정 사진을 직접 넣습니다.
                    터치 기기에는 hover가 없어 오른쪽 사진이 바뀌는 걸 볼 수 없기 때문입니다. */}
                {CAP_MEDIA_5[i] && (
                  <div className="cap-m" style={{
                    gridColumn: 2, marginTop: 16, position: 'relative',
                    aspectRatio: '16/10', overflow: 'hidden',
                    background: D.base3, border: `1px solid ${D.line2}`,
                  }}>
                    <img src={CAP_MEDIA_5[i]} alt="" loading="lazy" decoding="async"
                      style={{ width: '100%', height: '100%', objectFit: 'cover' }}/>
                  </div>
                )}
              </div>
            </Rise>
          ))}
        </div>

        <Rise delay={.12} style={{ height: '100%' }}>
          <div className="g5-capmedia" style={{ position: 'sticky', top: 88, height: '100%' }}>
            <div style={{
              position: 'relative', height: '100%', minHeight: 360, overflow: 'hidden',
              background: D.base3, border: `1px solid ${D.line2}`,
            }}>
              {CAP_MEDIA_5.map((src, i) => (
                <div key={i} style={{
                  position: 'absolute', inset: 0,
                  opacity: act === i ? 1 : 0, transition: 'opacity .7s cubic-bezier(.2,.7,.3,1)',
                  pointerEvents: act === i ? 'auto' : 'none',
                }}>
                  {src
                    ? <img src={src} alt="" loading="lazy" decoding="async" style={{
                        width: '100%', height: '100%', objectFit: 'cover',
                        transform: act === i ? 'scale(1.05)' : 'scale(1)',
                        transition: 'transform 5s cubic-bezier(.2,.7,.3,1)',
                      }}/>
                    : <Media5 id="v5-cap-weld" label={ko ? '용접 작업 사진' : 'Welding photo'} tint={0} minH="100%"/>}
                </div>
              ))}
              <div style={{
                position: 'absolute', inset: 0, pointerEvents: 'none',
                background: 'linear-gradient(to top, rgba(9,12,17,.72) 0%, rgba(9,12,17,.14) 44%, transparent 100%)',
              }}/>
              <div style={{ position: 'absolute', left: 'clamp(16px,2vw,24px)', right: 16, bottom: 'clamp(16px,2vw,22px)', pointerEvents: 'none' }}>
                <span className="mono" style={{ fontSize: 10.5, fontWeight: 500, letterSpacing: '0.2em', color: D.steel }}>
                  {V4_CAPABILITY[act].n}
                </span>
                <div style={{ marginTop: 7, fontSize: 'clamp(15px,1.5vw,19px)', fontWeight: 700, letterSpacing: '-0.032em', color: D.bone }}>
                  {ko ? V4_CAPABILITY[act].ko : V4_CAPABILITY[act].en}
                </div>
              </div>
            </div>
          </div>
        </Rise>
      </div>
    </Sec5>
  );
}

// ═════════ CATALOGUE ═════════
function Catalogue5() {
  const t = useV4(); const ko = t.lang !== 'en';
  const [cat, setCat] = useState('all');
  const [open, setOpen] = useState(null);

  // 전체 보기: 카테고리 순서대로, 같은 카테고리 안에서는 V4_PRODUCTS 에 적은 순서 그대로 보여줍니다.
  // (상부→중간→하부 같은 설치 위치 순서가 사진 유무보다 중요합니다)
  const catOrder = id => V4_CATS.findIndex(c => c.id === id);
  const sorted = [...V4_PRODUCTS].sort((a, b) => catOrder(a.cat) - catOrder(b.cat));
  const list = cat === 'all' ? sorted : sorted.filter(p => p.cat === cat);
  const count = id => id === 'all' ? V4_PRODUCTS.length : V4_PRODUCTS.filter(p => p.cat === id).length;

  return (
    <>
      <Sec5 id="products">
        <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: 32, flexWrap: 'wrap' }}>
          <Rise>
            <Tag5>Products</Tag5>
            <H5 style={{ marginTop: 18 }}>
              {ko ? <>제품 · 규격.</> : <>Products & specs.</>}
            </H5>
            <p style={{ marginTop: 18, maxWidth: 480, fontSize: 15, lineHeight: 1.78, color: D.bone45 }}>
              {ko
                ? <>규격품과 주문제작 품목을 함께 정리했습니다.<br/>품목을 선택하면 규격을 확인하실 수 있습니다.</>
                : 'Stock items and made-to-order parts. Select any item to see its specification.'}
            </p>
          </Rise>
          <Rise delay={.08}>
            <div className="mono" style={{ fontSize: 12, letterSpacing: '0.16em', textTransform: 'uppercase', color: D.bone70 }}>
              {String(list.length).padStart(2, '0')} {ko ? '품목' : 'items'}
            </div>
          </Rise>
        </div>

        {/* filter row */}
        <Rise delay={.1}>
          <div className="g5-filter" style={{ gap: 0, marginTop: 'clamp(32px,4vh,52px)', marginBottom: 'clamp(24px,3vh,36px)', borderTop: `1px solid ${D.line2}`, borderBottom: `1px solid ${D.line2}` }}>
            {V4_CATS.map(c => {
              const on = cat === c.id;
              return (
                <button key={c.id} onClick={() => setCat(c.id)} style={{
                  position: 'relative', padding: '17px 22px', cursor: 'pointer', minHeight: 48,
                  fontSize: 13.5, fontWeight: on ? 600 : 500, letterSpacing: '-0.015em',
                  color: on ? D.bone : D.bone45, transition: 'color .35s',
                  display: 'inline-flex', alignItems: 'center', gap: 9, whiteSpace: 'nowrap',
                }}>
                  {ko ? c.ko : c.en}
                  <span className="mono" style={{ fontSize: 10, color: on ? D.steel : D.bone70, transition: 'color .35s' }}>
                    {String(count(c.id)).padStart(2, '0')}
                  </span>
                  <span style={{
                    position: 'absolute', left: 0, right: 0, bottom: -1, height: 2,
                    background: D.steel, transform: on ? 'scaleX(1)' : 'scaleX(0)',
                    transformOrigin: 'left', transition: 'transform .45s cubic-bezier(.2,.7,.3,1)',
                  }}/>
                </button>
              );
            })}
          </div>
        </Rise>

        <div className="g5-cat">
          {list.map((p, i) => (
            <Rise key={p.ko} delay={Math.min(i, 10) * .035} y={20}>
              <CatTile5 p={p} ko={ko} onOpen={() => setOpen(p)}/>
            </Rise>
          ))}
        </div>
      </Sec5>

      {open && <ProductModal5 p={open} ko={ko} onClose={() => setOpen(null)}/>}
    </>
  );
}

function CatTile5({ p, ko, onOpen }) {
  const [h, setH] = useState(false);
  const [f, setF] = useState(0);
  const has = (p.images?.length || 0) > 0;

  useEffect(() => {
    if (!h || !has || p.images.length < 2) return;
    const id = setInterval(() => setF(v => (v + 1) % p.images.length), 900);
    return () => clearInterval(id);
  }, [h, has]);

  return (
    <button onClick={onOpen} onMouseEnter={() => setH(true)} onMouseLeave={() => { setH(false); setF(0); }}
      style={{ display: 'block', width: '100%', textAlign: 'left', cursor: 'pointer' }}>
      <div style={{
        position: 'relative', width: '100%', aspectRatio: '1/1', overflow: 'hidden',
        background: D.base2, border: `1px solid ${h ? D.line : D.line2}`, transition: 'border-color .4s',
      }}>
        {has ? p.images.map((src, n) => (
          <img key={src} src={src} alt="" loading="lazy" decoding="async" style={{
            position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover',
            opacity: n === f ? 1 : 0, transition: 'opacity .5s ease',
            transform: h ? 'scale(1.04)' : 'scale(1)',
            transitionProperty: 'opacity, transform', transitionDuration: '.5s, 1.6s',
          }}/>
        )) : (
          <div style={{ position: 'absolute', inset: 0, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
            <span style={{ fontSize: 15, fontWeight: 700, letterSpacing: '-0.04em', color: D.bone28 }}>
              태성<span style={{ opacity: .6 }}>ENG</span>
            </span>
          </div>
        )}
        {p.top && (
          <span className="mono" style={{
            position: 'absolute', top: 9, left: 9, zIndex: 2,
            fontSize: 9, fontWeight: 700, letterSpacing: '0.12em',
            padding: '3px 7px', background: D.steel, color: '#fff',
          }}>TOP</span>
        )}
        <span className="mono" style={{
          position: 'absolute', bottom: 9, right: 9, zIndex: 2, whiteSpace: 'nowrap',
          fontSize: 9.5, fontWeight: 600, letterSpacing: '0.06em',
          padding: '4px 8px',
          background: h ? D.steel : 'rgba(11,15,20,.78)',
          color: h ? '#fff' : D.bone70,
          border: `1px solid ${h ? 'transparent' : D.line2}`,
          transition: 'all .35s',
        }}>{has ? (ko ? `사진 ${p.images.length}` : `${p.images.length} photos`) : (ko ? '준비중' : 'soon')}</span>
      </div>
      <div style={{ paddingTop: 11 }}>
        <h3 style={{ fontSize: 14, fontWeight: 600, letterSpacing: '-0.022em', lineHeight: 1.32, color: h ? D.bone : D.bone70, transition: 'color .3s' }}>
          {ko ? p.ko : p.en}
        </h3>
        <div className="mono" style={{
          marginTop: 5, fontSize: 11, letterSpacing: '0.07em', textTransform: 'uppercase',
          color: D.bone45, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis',
        }}>{[p.size, ko ? p.mat : p.matEn].filter(Boolean).join(' · ')}</div>
      </div>
    </button>
  );
}

// ═════════ PRODUCT MODAL — photo viewer ═════════
function ProductModal5({ p, ko, onClose }) {
  const imgs = p.images || [];
  const has = imgs.length > 0;
  const n = imgs.length;
  const [f, setF] = useState(0);
  const stripRef = useRef(null);

  const go = d => { if (n > 1) setF(v => (v + d + n) % n); };

  useEffect(() => {
    const k = e => {
      if (e.key === 'Escape') onClose();
      if (e.key === 'ArrowLeft') { e.preventDefault(); if (n > 1) setF(v => (v - 1 + n) % n); }
      if (e.key === 'ArrowRight') { e.preventDefault(); if (n > 1) setF(v => (v + 1) % n); }
    };
    window.addEventListener('keydown', k);
    document.body.style.overflow = 'hidden';
    return () => { window.removeEventListener('keydown', k); document.body.style.overflow = ''; };
  }, [onClose, n]);

  // 활성 썸네일이 항상 보이도록 스트립을 이동
  useEffect(() => {
    const el = stripRef.current;
    if (!el) return;
    const th = el.children[f];
    if (!th) return;
    const target = th.offsetLeft - (el.clientWidth - th.clientWidth) / 2;
    el.scrollTo({ left: Math.max(0, target), behavior: 'smooth' });
  }, [f]);

  // 모바일 스와이프
  const sx = useRef(null);
  const onTS = e => { sx.current = e.touches[0].clientX; };
  const onTE = e => {
    if (sx.current == null) return;
    const dx = e.changedTouches[0].clientX - sx.current;
    if (Math.abs(dx) > 44) go(dx < 0 ? 1 : -1);
    sx.current = null;
  };

  return (
    <div onClick={onClose} style={{
      position: 'fixed', inset: 0, zIndex: 200, background: 'rgba(6,9,13,.9)',
      backdropFilter: 'blur(8px)', display: 'flex', alignItems: 'center', justifyContent: 'center',
      padding: 'clamp(12px,3vw,48px)',
    }}>
      <div onClick={e => e.stopPropagation()} className="g5-modal" style={{
        width: '100%', maxWidth: 1120, height: 'min(88vh, 760px)',
        background: D.base2, border: `1px solid ${D.line}`, overflow: 'hidden',
      }}>
        {/* ── 사진 뷰어 ── */}
        <div style={{ position: 'relative', display: 'flex', flexDirection: 'column', minHeight: 0, background: D.base }}>
          {has ? (
            <>
              {/* 메인 이미지 — 잘리지 않게 전체를 보여줍니다 */}
              <div
                onClick={() => go(1)} onTouchStart={onTS} onTouchEnd={onTE}
                style={{
                  position: 'relative', flex: 1, minHeight: 0, overflow: 'hidden',
                  cursor: n > 1 ? 'pointer' : 'default',
                }}>
                {imgs.map((src, k) => (
                  <img key={src} src={src} alt="" decoding="async" style={{
                    position: 'absolute', inset: 0, width: '100%', height: '100%',
                    objectFit: 'contain', padding: 'clamp(10px,1.6vw,22px)',
                    opacity: k === f ? 1 : 0, transition: 'opacity .35s ease',
                  }}/>
                ))}

                {/* 장수 표시 */}
                <span className="mono" style={{
                  position: 'absolute', top: 14, left: 14, zIndex: 3,
                  fontSize: 11, fontWeight: 600, letterSpacing: '0.1em',
                  padding: '6px 11px', background: 'rgba(11,15,20,.8)',
                  border: `1px solid ${D.line2}`, color: D.bone70, pointerEvents: 'none',
                }}>{String(f + 1).padStart(2, '0')} / {String(n).padStart(2, '0')}</span>

                {n > 1 && (
                  <>
                    <ModalArrow5 dir="prev" onClick={e => { e.stopPropagation(); go(-1); }} ko={ko}/>
                    <ModalArrow5 dir="next" onClick={e => { e.stopPropagation(); go(1); }} ko={ko}/>
                  </>
                )}
              </div>

              {/* ── 썸네일 스트립 — 가로로만 스크롤, 사진을 가리지 않음 ── */}
              {n > 1 && (
                <div ref={stripRef} className="g5-strip" style={{
                  display: 'flex', gap: 6, flexWrap: 'nowrap', overflowX: 'auto', overflowY: 'hidden',
                  padding: 'clamp(10px,1.2vw,14px)', borderTop: `1px solid ${D.line2}`,
                  background: D.base2, flexShrink: 0,
                }}>
                  {imgs.map((src, k) => (
                    <button key={src} onClick={() => setF(k)} aria-label={`${k + 1}`} style={{
                      flexShrink: 0, width: 58, height: 58, padding: 0, cursor: 'pointer', overflow: 'hidden',
                      border: `1.5px solid ${k === f ? D.steel : 'transparent'}`,
                      opacity: k === f ? 1 : .5, transition: 'opacity .3s, border-color .3s',
                      background: D.base,
                    }}>
                      <img src={src} alt="" loading="lazy" decoding="async" style={{ width: '100%', height: '100%', objectFit: 'cover' }}/>
                    </button>
                  ))}
                </div>
              )}
            </>
          ) : (
            <div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 12 }}>
              <span style={{ fontSize: 22, fontWeight: 700, letterSpacing: '-0.045em', color: D.bone28 }}>태성<span style={{ opacity: .6 }}>ENG</span></span>
              <span className="mono" style={{ fontSize: 10, letterSpacing: '0.2em', textTransform: 'uppercase', color: D.bone28 }}>
                {ko ? '사진 준비중' : 'Photo coming'}
              </span>
            </div>
          )}
        </div>

        {/* info */}
        <div style={{ padding: 'clamp(22px,2.6vw,36px)', overflowY: 'auto', minHeight: 0 }}>
          <div style={{ display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 16 }}>
            <Tag5>{V4_CATS.find(c => c.id === p.cat) ? (ko ? V4_CATS.find(c => c.id === p.cat).ko : V4_CATS.find(c => c.id === p.cat).en) : 'Product'}</Tag5>
            <button onClick={onClose} aria-label="close" style={{ padding: 12, margin: -12, cursor: 'pointer', color: D.bone45, lineHeight: 0 }}>
              <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round"><path d="M18 6 6 18M6 6l12 12"/></svg>
            </button>
          </div>
          <h3 style={{ marginTop: 16, fontSize: 'clamp(23px,2.6vw,34px)', fontWeight: 700, letterSpacing: '-0.042em', lineHeight: 1.14, color: D.bone }}>
            {ko ? p.ko : p.en}
          </h3>
          <div style={{ marginTop: 28, borderTop: `1px solid ${D.line2}` }}>
            {[[ko?'규격':'Size', p.size], [ko?'소재':'Material', ko?p.mat:p.matEn], [ko?'표면처리':'Finish', ko?p.fin:p.finEn], [ko?'박스입수':'Per box', p.pack]].map(([a, b]) => b ? (
              <div key={a} style={{ display: 'grid', gridTemplateColumns: '92px 1fr', gap: 16, padding: '13px 0', borderBottom: `1px solid ${D.line2}` }}>
                <span className="mono" style={{ fontSize: 12, letterSpacing: '0.12em', textTransform: 'uppercase', color: D.bone45 }}>{a}</span>
                <span style={{ fontSize: 14, fontWeight: 500, color: D.bone70 }}>{b}</span>
              </div>
            ) : null)}
          </div>
          <div style={{ marginTop: 26 }}>
            <B5 href="#contact" onClick={onClose} tone="solid">{ko ? '이 품목 문의' : 'Inquire'}</B5>
          </div>
        </div>
      </div>
    </div>
  );
}

// ── 사진 이전/다음 버튼 (터치 영역 52px) ──
function ModalArrow5({ dir, onClick, ko }) {
  const [h, setH] = useState(false);
  const next = dir === 'next';
  return (
    <button onClick={onClick} onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)}
      aria-label={next ? (ko ? '다음 사진' : 'Next') : (ko ? '이전 사진' : 'Previous')}
      style={{
        position: 'absolute', top: '50%', transform: 'translateY(-50%)', zIndex: 3,
        [next ? 'right' : 'left']: 'clamp(8px,1.2vw,16px)',
        width: 52, height: 52, display: 'flex', alignItems: 'center', justifyContent: 'center',
        cursor: 'pointer', color: h ? D.base : D.bone,
        background: h ? D.bone : 'rgba(11,15,20,.72)',
        border: `1px solid ${h ? D.bone : D.line2}`,
        backdropFilter: 'blur(8px)', transition: 'background .3s, color .3s, border-color .3s',
      }}>
      <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"
        style={{ transform: next ? 'none' : 'rotate(180deg)' }}>
        <path d="M5 12h13M12 5.5 18.5 12 12 18.5"/>
      </svg>
    </button>
  );
}

// ═════════ COMPANY — metrics band ═════════
function Company5() {
  const t = useV4(); const ko = t.lang !== 'en';
  const rows = [
    { v: <>2022</>, k: ko ? '설립' : 'Founded', s: ko ? '년' : '' },
    { v: <><CountUp to={300}/>+</>, k: ko ? '연간 납품' : 'Annual jobs', s: ko ? '건' : '' },
    { v: <><CountUp to={33}/></>, k: ko ? '취급 품목' : 'Line items', s: '' },
    { v: <><CountUp to={4}/></>, k: ko ? '자체 공정' : 'In-house', s: '' },
  ];
  return (
    <Sec5 id="company" bg={D.base2}>
      <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: 32, flexWrap: 'wrap', marginBottom: 'clamp(24px,3vh,36px)' }}>
        <Rise>
          <Tag5>Company</Tag5>
          <H5 style={{ marginTop: 14, maxWidth: 700 }}>
            {ko ? <>오래 쓰는 부품을<br/>오래 만들어 왔습니다.</> : <>Parts made to last,<br/>made for a long time.</>}
          </H5>
        </Rise>
        <Rise delay={.1}>
          <p style={{ maxWidth: 480, fontSize: 14.5, lineHeight: 1.72, color: D.bone45 }}>
            {ko
              ? <>태성ENG는 조립식 건축 부속자재와 정밀 금속가공을 함께 다뤄 왔습니다.<br/>반복 납품 고객과의 관계가 품질의 기준입니다.</>
              : 'Taesung Engineering has worked across prefab building components and precision metalwork. Repeat customers set our quality bar.'}
          </p>
        </Rise>
      </div>

      {/* ══ 회사 소개 밴드 사진 — COMPANY_MEDIA_5 배열이 순차 전환됩니다 ══ */}
      <Rise delay={.1}>
        <CompanyBand5 ko={ko}/>
      </Rise>

      <Rise delay={.14}>
        <div className="g5-metrics" style={{ borderTop: `1px solid ${D.line}` }}>
          {rows.map((r, i) => (
            <div key={i} style={{
              padding: 'clamp(18px,2.2vh,26px) clamp(16px,2vw,32px) clamp(18px,2.2vh,26px) 0',
              borderRight: i < rows.length - 1 ? `1px solid ${D.line2}` : 'none',
            }}>
              <div style={{ fontSize: 'clamp(26px,3vw,42px)', fontWeight: 700, letterSpacing: '-0.05em', lineHeight: 1, color: D.bone }}>
                {r.v}<span style={{ fontSize: '.4em', marginLeft: 4, color: D.bone45, letterSpacing: '-0.02em' }}>{r.s}</span>
              </div>
              <div className="mono" style={{ marginTop: 9, fontSize: 12, letterSpacing: '0.14em', textTransform: 'uppercase', color: D.bone70 }}>{r.k}</div>
            </div>
          ))}
        </div>
      </Rise>
    </Sec5>
  );
}

// ── 회사 소개 밴드: 설비 사진 순차 전환 ──
function CompanyBand5({ ko }) {
  const [i, setI] = useState(0);
  const [pause, setPause] = useState(false);
  const n = COMPANY_MEDIA_5.length;
  useEffect(() => {
    if (pause) return;
    const id = setInterval(() => setI(v => (v + 1) % n), 4200);
    return () => clearInterval(id);
  }, [pause, n]);
  return (
    <div
      onMouseEnter={() => setPause(true)} onMouseLeave={() => setPause(false)}
      style={{
        position: 'relative', marginBottom: 'clamp(24px,3vh,36px)',
        overflow: 'hidden', border: `1px solid ${D.line2}`, background: D.base3,
      }}>
      <div className="g5-band" style={{ position: 'relative', width: '100%' }}>
        {COMPANY_MEDIA_5.map((m, k) => (
          <img key={m.src} src={m.src} alt="" loading="lazy" decoding="async" style={{
            position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover',
            opacity: k === i ? 1 : 0,
            transform: k === i ? 'scale(1.04)' : 'scale(1)',
            transition: 'opacity 1.1s cubic-bezier(.2,.7,.3,1), transform 5.4s linear',
          }}/>
        ))}
      </div>
      <div style={{
        position: 'absolute', inset: 0, pointerEvents: 'none',
        background: 'linear-gradient(to right, rgba(9,12,17,.86) 0%, rgba(9,12,17,.42) 48%, rgba(9,12,17,.14) 100%)',
      }}/>
      <div style={{
        position: 'absolute', left: 'clamp(20px,3vw,44px)', bottom: 'clamp(20px,3vw,36px)',
        right: 'clamp(20px,3vw,44px)', display: 'flex', alignItems: 'flex-end',
        justifyContent: 'space-between', gap: 24, flexWrap: 'wrap',
      }}>
        <div style={{ pointerEvents: 'none' }}>
          <span className="mono" style={{ fontSize: 10.5, fontWeight: 500, letterSpacing: '0.2em', textTransform: 'uppercase', color: D.steel }}>
            In-house Equipment
          </span>
          <div style={{ marginTop: 8, fontSize: 'clamp(17px,2vw,26px)', fontWeight: 700, letterSpacing: '-0.038em', color: D.bone, maxWidth: 540 }}>
            {ko ? 'CNC선반 · 프레스 · 용접 설비를 자체 보유' : 'CNC turning, press and welding — all in-house'}
          </div>
          <div className="mono" style={{ marginTop: 7, fontSize: 11.5, letterSpacing: '0.06em', color: D.bone45 }}>
            {String(i + 1).padStart(2, '0')} — {ko ? COMPANY_MEDIA_5[i].ko : COMPANY_MEDIA_5[i].en}
          </div>
        </div>
        <div style={{ display: 'flex', gap: 0, marginLeft: -10 }}>
          {COMPANY_MEDIA_5.map((m, k) => (
            /* 터치 영역은 48px, 보이는 막대는 3px — 현장에서 장갑 끼고도 눌립니다 */
            <button key={m.src} onClick={() => setI(k)} aria-label={ko ? m.ko : m.en}
              style={{
                display: 'flex', alignItems: 'center', justifyContent: 'center',
                minHeight: 48, padding: '0 10px', border: 'none', background: 'transparent',
                cursor: 'pointer',
              }}>
              <span style={{
                display: 'block', width: k === i ? 34 : 14, height: 3,
                background: k === i ? D.bone : 'rgba(237,235,231,.28)',
                transition: 'all .5s cubic-bezier(.2,.7,.3,1)',
              }}/>
            </button>
          ))}
        </div>
      </div>
    </div>
  );
}

// ╔══════════════════════════════════════════════════════════╗
// ║  문의 폼 수신 설정 — 여기를 설정해야 실제로 메일이 옵니다  ║
// ╚══════════════════════════════════════════════════════════╝
//
// 가장 쉬운 방법 — Formspree (무료, 서버 필요 없음, 5분 소요)
//   1) https://formspree.io 가입 → New Form 생성 → 회사 메일 입력
//   2) 발급받은 주소(예: https://formspree.io/f/abcdwxyz)를 아래 FORM_ENDPOINT 에 붙여넣기
//   3) 끝. 문의가 오면 회사 메일로 바로 도착합니다.
//      (Formspree 설정에서 'Autoresponder'를 켜면 고객에게 자동 회신도 나갑니다)
//
// 대안 — 구글 시트로 받기: Apps Script 웹앱 URL을 같은 자리에 넣으면 됩니다.
//
// 빈 값('')으로 두면 전송 없이 완료 화면만 보여줍니다(데모 모드).
const FORM_ENDPOINT = 'https://formspree.io/f/mwlplbjq';

// 개인정보 보유기간 — 개인정보처리방침(privacy.html)과 반드시 일치시키세요
const PRIVACY_RETENTION = '3년';

// ═════════ CONTACT — direct, actionable ═════════
function Contact5() {
  const t = useV4(); const ko = t.lang !== 'en';
  const [sent, setSent] = useState(false);
  const [sending, setSending] = useState(false);
  const [err, setErr] = useState('');
  const [agree, setAgree] = useState(false);
  const [toast, setToast] = useState(false);
  const [f, setF] = useState({ name: '', corp: '', tel: '', item: '', qty: '', msg: '' });
  const set = (k, v) => setF(p => ({ ...p, [k]: v }));

  // 클립보드 복사 — 주소는 v5-core.jsx 상단의 TSENG_EMAIL 하나만 고치면 됩니다
  const copyMail = async () => {
    try {
      await navigator.clipboard.writeText(TSENG_EMAIL);
    } catch {
      const ta = document.createElement('textarea');
      ta.value = TSENG_EMAIL; ta.style.position = 'fixed'; ta.style.opacity = '0';
      document.body.appendChild(ta); ta.select();
      try { document.execCommand('copy'); } catch {}
      document.body.removeChild(ta);
    }
    setToast(true);
    setTimeout(() => setToast(false), 2200);
  };

  const inp = {
    width: '100%', padding: '14px 15px', fontSize: 16, fontFamily: 'inherit',
    background: D.base, color: D.bone, border: `1px solid ${D.line2}`,
    outline: 'none', transition: 'border-color .3s',
  };
  const lab = {
    display: 'block', marginBottom: 7, fontSize: 10.5, fontWeight: 500,
    letterSpacing: '0.14em', textTransform: 'uppercase', color: D.bone70,
  };
  const onFocus = e => { e.target.style.borderColor = D.steel; };
  const onBlur  = e => { e.target.style.borderColor = D.line2; };

  // ══ 폼 전송 ══
  const submit = async e => {
    e.preventDefault();
    setErr('');
    if (!f.name.trim() || !f.tel.trim()) {
      setErr(ko ? '담당자명과 연락처를 입력해주세요.' : 'Name and phone are required.');
      return;
    }
    if (!agree) {
      setErr(ko ? '개인정보 수집·이용에 동의해주세요.' : 'Please agree to the privacy terms.');
      return;
    }
    if (!FORM_ENDPOINT) { setSent(true); return; }   // 데모 모드
    setSending(true);
    try {
      const res = await fetch(FORM_ENDPOINT, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
        body: JSON.stringify({
          담당자명: f.name, 회사명: f.corp, 연락처: f.tel,
          품목: f.item, 수량: f.qty, 요청내용: f.msg,
          개인정보동의: '동의함',
          _subject: `[태성ENG 견적문의] ${f.corp || f.name} — ${f.item || '문의'}`,
        }),
      });
      if (!res.ok) throw new Error('send failed');
      setSent(true);
    } catch {
      setErr(ko
        ? '전송에 실패했습니다. 잠시 후 다시 시도하시거나 전화로 연락주세요.'
        : 'Sending failed. Please retry or call us.');
    } finally {
      setSending(false);
    }
  };

  const channels = [
    {
      k: ko ? '전화' : 'Phone', v: '031-962-3951',
      sub: ko ? '평일 08:30 – 18:00' : 'Mon–Fri 08:30–18:00',
      href: 'tel:0319623951',
      icon: <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 1 .3 1.9.6 2.8a2 2 0 0 1-.5 2.1L8.1 9.8a16 16 0 0 0 6 6l1.2-1.1a2 2 0 0 1 2.1-.5c.9.3 1.8.5 2.8.6a2 2 0 0 1 1.8 2.1z"/>,
    },
    {
      k: ko ? '이메일' : 'Email', v: TSENG_EMAIL,
      sub: ko ? '도면 첨부 시 검토 후 회신' : 'Attach a drawing for review',
      href: `mailto:${TSENG_EMAIL}`,
      icon: <><rect x="2" y="4" width="20" height="16" rx="2"/><path d="m2 7 10 6 10-6"/></>,
    },
    {
      // 주소는 v5-sections-3.jsx 의 TSENG_PLACE 한 곳에서 관리합니다
      k: ko ? '공장' : 'Works', v: ko ? TSENG_PLACE.addr : TSENG_PLACE.addrEn,
      sub: ko ? '방문 상담은 사전 연락 부탁드립니다' : 'Please call ahead to visit',
      href: null,
      icon: <><path d="M20 10c0 6-8 12-8 12s-8-6-8-12a8 8 0 0 1 16 0z"/><circle cx="12" cy="10" r="3"/></>,
    },
  ];

  return (
    <Sec5 id="contact" bg={D.base}>
      <Rise>
        <Tag5>Contact</Tag5>
        <H5 style={{ marginTop: 16, maxWidth: 780 }}>
          {ko ? <>도면을 보내주시면<br/>가능 여부부터 답합니다.</> : <>Send the drawing.<br/>We answer feasibility first.</>}
        </H5>
      </Rise>

      <div className="g5-ct">
        {/* ── 왼쪽: 연락 수단 + 도면 안내 ── */}
        <Rise delay={.06}>
          <p style={{ fontSize: 15, lineHeight: 1.75, color: D.bone45 }}>
            {ko
              ? <>품목·수량·희망 납기와 함께 도면을 보내주세요.<br/>도면 준비가 어려우시면 먼저 문의 주셔도 됩니다.</>
              : 'Send the item, volume, target date and a drawing. If a drawing is hard to prepare, contact us first.'}
          </p>

          {/* 연락 수단 — 한 줄씩 */}
          <div style={{ marginTop: 26, borderTop: `1px solid ${D.line2}` }}>
            {channels.map(c => <Channel5 key={c.k} c={c}/>)}
          </div>

          {/* 도면 보내기 — 압축된 안내 */}
          <div style={{
            marginTop: 20, padding: '18px 20px',
                    background: 'rgba(76,122,207,0.09)', borderLeft: `3px solid ${D.steel}`,
          }}>
            <div style={{ fontSize: 14, fontWeight: 700, letterSpacing: '-0.025em', color: D.bone }}>
              {ko ? '도면 · 자재 내역서가 있으시면' : 'Have drawings or a material list?'}
            </div>
            <p style={{ marginTop: 8, fontSize: 13.5, lineHeight: 1.7, color: D.bone70 }}>
              {ko
                ? '견적 요청서로 먼저 기본 내용을 접수하시고, 파일은 메일로 보내주세요. 더 빠르고 정확한 견적이 가능합니다.'
                : 'Submit the form first, then email the files — it makes the quote faster and more accurate.'}
            </p>
            <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, marginTop: 14 }}>
              <CalloutBtn5 onClick={copyMail} solid>
                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round">
                  <rect x="9" y="9" width="12" height="12" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
                </svg>
                {ko ? '주소 복사' : 'Copy email'}
              </CalloutBtn5>
              <CalloutBtn5 href={`mailto:${TSENG_EMAIL}`}>
                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round" strokeLinejoin="round">
                  <rect x="2" y="4" width="20" height="16" rx="2"/><path d="m2 7 10 6 10-6"/>
                </svg>
                {ko ? '메일 보내기' : 'Open mail app'}
              </CalloutBtn5>
            </div>
          </div>
        </Rise>

        {/* ── 오른쪽: 입력 폼 ── */}
        <Rise delay={.12}>
          <div style={{ padding: 'clamp(22px,2.4vw,32px)', background: D.base, border: `1px solid ${D.line2}` }}>
          {sent ? (
            <div style={{ padding: 'clamp(28px,5vh,64px) 0', textAlign: 'center' }}>
              <div style={{ display: 'inline-flex', width: 46, height: 46, alignItems: 'center', justifyContent: 'center', border: `1px solid ${D.steel}`, color: D.steel, marginBottom: 18 }}>
                <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
              </div>
              <h3 style={{ fontSize: 20, fontWeight: 700, letterSpacing: '-0.035em', color: D.bone }}>
                {ko ? '문의가 접수되었습니다.' : 'Your inquiry was received.'}
              </h3>
              <p style={{ marginTop: 10, fontSize: 14.5, lineHeight: 1.75, color: D.bone45 }}>
                {ko ? '내용 확인 후 담당자가 연락드립니다. 급하신 건은 전화로 주시면 빠릅니다.' : 'We will get back to you after reviewing. For urgent matters, a call is faster.'}
              </p>
              <p style={{ marginTop: 14, fontSize: 14, lineHeight: 1.75, color: D.bone45 }}>
                {ko ? <>도면 파일은 <a href={`mailto:${TSENG_EMAIL}`} style={{ color: D.bone, borderBottom: `1px solid ${D.steel}` }}>{TSENG_EMAIL}</a> 로 보내주세요.</>
                     : <>Email drawings to <a href={`mailto:${TSENG_EMAIL}`} style={{ color: D.bone, borderBottom: `1px solid ${D.steel}` }}>{TSENG_EMAIL}</a>.</>}
              </p>
            </div>
          ) : (
            <>
              <div className="mono" style={{ fontSize: 10.5, letterSpacing: '0.18em', textTransform: 'uppercase', color: D.bone70, marginBottom: 18 }}>
                {ko ? '견적 요청서' : 'Quote request'}
              </div>
              <div className="g5-form">
                <div>
                  <label style={lab}>{ko ? '담당자명' : 'Name'}</label>
                  <input className="f5" style={inp} onFocus={onFocus} onBlur={onBlur} value={f.name} onChange={e => set('name', e.target.value)} placeholder={ko ? '홍길동' : 'Your name'}/>
                </div>
                <div>
                  <label style={lab}>{ko ? '회사명' : 'Company'}</label>
                  <input className="f5" style={inp} onFocus={onFocus} onBlur={onBlur} value={f.corp} onChange={e => set('corp', e.target.value)} placeholder={ko ? '(주)000' : 'Company'}/>
                </div>
                <div>
                  <label style={lab}>{ko ? '연락처' : 'Phone'}</label>
                  <input className="f5" type="tel" inputMode="tel" style={inp} onFocus={onFocus} onBlur={onBlur} value={f.tel} onChange={e => set('tel', e.target.value)} placeholder="010-0000-0000"/>
                </div>
              </div>
              <div className="g5-form" style={{ marginTop: 14 }}>
                <div>
                  <label style={lab}>{ko ? '품목' : 'Item'}</label>
                  <input className="f5" style={inp} onFocus={onFocus} onBlur={onBlur} value={f.item} onChange={e => set('item', e.target.value)} placeholder={ko ? '예) 크랭크로라, 앵글 가공' : 'e.g. crank roller'}/>
                </div>
                <div>
                  <label style={lab}>{ko ? '수량' : 'Quantity'}</label>
                  <input className="f5" style={inp} onFocus={onFocus} onBlur={onBlur} value={f.qty} onChange={e => set('qty', e.target.value)} placeholder={ko ? '예) 500개' : 'e.g. 500 pcs'}/>
                </div>
              </div>
              <div style={{ marginTop: 14 }}>
                <label style={lab}>{ko ? '요청 내용' : 'Details'}</label>
                <textarea className="f5" rows={3} style={{ ...inp, resize: 'vertical' }} onFocus={onFocus} onBlur={onBlur}
                  value={f.msg} onChange={e => set('msg', e.target.value)}
                  placeholder={ko ? '규격, 소재, 희망 납기 등을 적어주세요.' : 'Spec, material, target date…'}/>
              </div>

              {/* ══ 개인정보 수집·이용 동의 (개인정보보호법상 필수) ══
                  수집 항목·목적·보유기간은 privacy.html 의 내용과 반드시 일치해야 합니다.
                  보유기간을 바꾸려면 파일 상단의 PRIVACY_RETENTION 상수를 수정하세요. */}
              <div style={{ marginTop: 16, padding: '14px 16px', background: D.base2, border: `1px solid ${agree ? D.steel : D.line2}`, transition: 'border-color .3s' }}>
                <label style={{ display: 'flex', alignItems: 'flex-start', gap: 11, cursor: 'pointer', minHeight: 44 }}>
                  <input type="checkbox" checked={agree} onChange={e => setAgree(e.target.checked)}
                    style={{ width: 21, height: 21, marginTop: 2, flexShrink: 0, accentColor: D.steel, cursor: 'pointer' }}/>
                  <span style={{ fontSize: 14, lineHeight: 1.65, color: D.bone70 }}>
                    {ko ? <>
                      <strong style={{ color: D.bone, fontWeight: 700 }}>(필수)</strong> 개인정보 수집·이용에 동의합니다.{' '}
                      <a href="privacy.html" target="_blank" rel="noopener" style={{ color: D.bone, borderBottom: `1px solid ${D.steel}` }}>전문</a>
                    </> : <>
                      <strong style={{ color: D.bone, fontWeight: 700 }}>(Required)</strong> I agree to the collection and use of my personal information.{' '}
                      <a href="privacy.html" target="_blank" rel="noopener" style={{ color: D.bone, borderBottom: `1px solid ${D.steel}` }}>Policy</a>
                    </>}
                  </span>
                </label>
                <div className="mono" style={{ marginTop: 9, paddingTop: 9, borderTop: `1px solid ${D.line2}`, fontSize: 12, lineHeight: 1.7, color: D.bone45 }}>
                  {ko
                    ? <>담당자명·회사명·연락처·문의내용 · 견적 회신 목적 · {PRIVACY_RETENTION} 보관 · 거부 시 온라인 접수만 제한되며 전화 상담은 가능합니다.</>
                    : <>Name, company, phone, message · for quotation · retained 3 years</>}
                </div>
              </div>

              {/* ══ 구글 리캡차(reCAPTCHA v2) ══
                  사이트 키가 적용되어 실제 위젯이 표시됩니다.
                  · 키를 바꿀 때는 아래 data-sitekey 값만 교체하세요.
                  · 위젯 스크립트는 index.html 의 <head> 에서 불러옵니다.
                  · 등록된 도메인: taesung-eng.co.kr / www / xn--o39a.com / taesung-eng.vercel.app
                    도메인이 바뀌면 https://www.google.com/recaptcha/admin 에서 추가해야 합니다. */}
              <div style={{ marginTop: 14 }}>
                <div className="g-recaptcha" data-sitekey="6LeV38gtAAAAAKCWx8v_zwtwdK0PFE-QIM6FR11Z" data-theme="dark"></div>
              </div>
              <div style={{ marginTop: 18, display: 'flex', alignItems: 'center', gap: 16, flexWrap: 'wrap' }}>
                <B5 href="#contact" tone="solid" size="lg" onClick={submit}>
                  {sending ? (ko ? '전송 중…' : 'Sending…') : (ko ? '문의 보내기' : 'Send inquiry')}
                </B5>
                {err && (
                  <span role="alert" style={{ fontSize: 14, fontWeight: 600, color: '#E8836B', letterSpacing: '-0.015em' }}>
                    {err}
                  </span>
                )}
              </div>
            </>
          )}
          </div>
        </Rise>
      </div>

      {/* 복사 완료 토스트 */}
      <div aria-live="polite" style={{
        position: 'fixed', left: '50%', bottom: 92, zIndex: 400,
        transform: `translateX(-50%) translateY(${toast ? '0' : '14px'})`,
        opacity: toast ? 1 : 0, pointerEvents: 'none',
        transition: 'opacity .3s ease, transform .3s cubic-bezier(.2,.7,.3,1)',
        display: 'flex', alignItems: 'center', gap: 10,
        padding: '13px 20px', background: D.bone, color: D.base,
        fontSize: 14, fontWeight: 600, letterSpacing: '-0.02em',
        boxShadow: '0 12px 34px rgba(0,0,0,.45)', whiteSpace: 'nowrap',
      }}>
        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.2" strokeLinecap="round" strokeLinejoin="round"><path d="M20 6 9 17l-5-5"/></svg>
        {ko ? '이메일 주소가 복사되었습니다' : 'Email address copied'}
      </div>
    </Sec5>
  );
}

// ── 안내 박스 전용 소형 버튼 ──
function CalloutBtn5({ children, onClick, href, solid }) {
  const [h, setH] = useState(false);
  const Tag = href ? 'a' : 'button';
  return (
    <Tag href={href} onClick={onClick}
      onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)}
      style={{
        display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 8,
        minHeight: 48, padding: '12px 18px', cursor: 'pointer',
        fontSize: 13.5, fontWeight: 600, letterSpacing: '-0.015em', fontFamily: 'inherit',
        background: solid ? (h ? D.bone : D.steel) : (h ? 'rgba(237,235,231,0.09)' : 'transparent'),
        color: solid ? (h ? D.base : '#fff') : D.bone,
        border: solid ? '1px solid transparent' : `1px solid ${h ? D.bone : D.line}`,
        transition: 'all .35s cubic-bezier(.2,.7,.3,1)',
      }}>{children}</Tag>
  );
}

// 연락 수단 한 줄 — 아이콘 · 라벨 · 값이 가로로 놓입니다
function Channel5({ c }) {
  const [h, setH] = useState(false);
  const Tag = c.href ? 'a' : 'div';
  return (
    <Tag href={c.href || undefined}
      onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)}
      style={{
        display: 'grid', gridTemplateColumns: '20px minmax(0,1fr)', gap: 14,
        alignItems: 'start', padding: '15px 0', minHeight: 48,
        borderBottom: `1px solid ${D.line2}`,
        cursor: c.href ? 'pointer' : 'default',
      }}>
      <span style={{ display: 'inline-flex', paddingTop: 2, color: h && c.href ? D.steel : D.bone28, transition: 'color .35s' }}>
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">{c.icon}</svg>
      </span>
      <span style={{ minWidth: 0 }}>
        <span className="mono" style={{ display: 'block', fontSize: 10, letterSpacing: '0.16em', textTransform: 'uppercase', color: D.bone70 }}>{c.k}</span>
        <span style={{ display: 'block', marginTop: 5, fontSize: 15.5, fontWeight: 600, letterSpacing: '-0.028em', color: h && c.href ? D.bone : D.bone70, transition: 'color .35s', wordBreak: 'break-word' }}>{c.v}</span>
        <span style={{ display: 'block', marginTop: 4, fontSize: 12.5, lineHeight: 1.55, color: D.bone70 }}>{c.sub}</span>
      </span>
    </Tag>
  );
}

// ═════════ FOOTER ═════════
// ══ 회사 법적 정보 — 실제 정보로 교체하세요 ══
const TSENG_LEGAL = {
  name: '태성ENG',
  ceo: '정승준',
  regNo: '677-04-02709',
  address: '경기도 고양시 일산동구 은마길79번길 81, A동 일부(설문동)',  // v5-sections-3.jsx 의 TSENG_PLACE.addr 과 동일하게 유지하세요
  tel: '031-962-3951',
  email: TSENG_EMAIL,
};

function Footer5() {
  const t = useV4(); const ko = t.lang !== 'en';
  const L = TSENG_LEGAL;
  const cols = [
    { h: ko ? '사업분야' : 'Scope', items: [[ko?'조립식 건축 부속자재':'Building components', '#pillars'], [ko?'정밀 금속가공':'Metal fabrication', '#capability'], [ko?'주문제작':'Custom work', '#contact']] },
    { h: ko ? '제품' : 'Products', items: [[ko?'로라 · 베어링':'Rollers', '#products'], [ko?'복차 · 주행부품':'Casters', '#products'], [ko?'S/B · 브라켓':'Stoppers & brackets', '#products'], [ko?'도어 부속':'Door hardware', '#products'], [ko?'건축 부속자재':'Building parts', '#products'], [ko?'가공 · 제작':'Fabrication', '#products']] },
    { h: ko ? '회사' : 'Company', items: [[ko?'회사소개':'About', '#company'], [ko?'제작 문의':'Contact', '#contact']] },
  ];
  return (
    <footer style={{ background: D.base, borderTop: `1px solid ${D.line2}`, paddingTop: 'clamp(52px,7vh,84px)', paddingBottom: 32 }}>
      <div style={{ maxWidth: 1400, margin: '0 auto', padding: '0 clamp(20px,4vw,60px)' }}>
        <div className="g5-foot">
          <div>
            <div style={{ display: 'flex', alignItems: 'baseline', gap: 10 }}>
              <span style={{ fontSize: 24, fontWeight: 700, letterSpacing: '-0.05em', color: D.bone }}>태성ENG</span>
              <span className="mono" style={{ fontSize: 9.5, letterSpacing: '0.2em', color: D.bone28, textTransform: 'uppercase' }}>Taesung Eng</span>
            </div>
            <p style={{ marginTop: 18, maxWidth: 320, fontSize: 14, lineHeight: 1.8, color: D.bone45 }}>
              {ko
                ? '조립식 건축 부속자재 제조와 정밀 금속가공. 도면 기반 주문제작을 상시 접수합니다.'
                : 'Prefab building components and precision metal fabrication. Drawing-based custom orders always welcome.'}
            </p>
          </div>
          {cols.map(c => (
            <div key={c.h}>
              <div className="mono" style={{ fontSize: 10.5, letterSpacing: '0.18em', textTransform: 'uppercase', color: D.bone70, marginBottom: 18 }}>{c.h}</div>
              <ul style={{ listStyle: 'none', display: 'grid', gap: 11 }}>
                {c.items.map(([label, href]) => (
                  <li key={label}><FootLink5 href={href}>{label}</FootLink5></li>
                ))}
              </ul>
            </div>
          ))}
        </div>

        {/* ══ 사업자 정보 — 상호/대표자/등록번호/주소/연락처 ══ */}
        <div style={{
          marginTop: 'clamp(40px,5vh,60px)', paddingTop: 28, borderTop: `1px solid ${D.line2}`,
          display: 'flex', flexWrap: 'wrap', gap: '8px 22px',
        }}>
          {[
            [ko ? '상호' : 'Company', L.name],
            [ko ? '대표' : 'CEO', L.ceo],
            [ko ? '사업자등록번호' : 'Reg. No.', L.regNo],
            [ko ? '주소' : 'Address', L.address],
            [ko ? '대표번호' : 'Tel', L.tel],
            [ko ? '이메일' : 'Email', L.email],
          ].map(([k, v]) => (
            <span key={k} className="mono" style={{ fontSize: 12, letterSpacing: '0.02em', color: D.bone45 }}>
              {k} <span style={{ color: D.bone70 }}>{v}</span>
            </span>
          ))}
        </div>

        <div style={{
          marginTop: 24, paddingTop: 24, borderTop: `1px solid ${D.line2}`,
          display: 'flex', justifyContent: 'space-between', gap: 20, flexWrap: 'wrap',
        }}>
          <span className="mono" style={{ fontSize: 10.5, letterSpacing: '0.1em', color: D.bone45 }}>© 2026 {L.name.toUpperCase()}</span>
          {/* ══ 이용약관 · 개인정보처리방침 — 실제 페이지 경로로 href 교체 ══ */}
          <div style={{ display: 'flex', gap: 20 }}>
            <FootLink5 href="terms.html">{ko ? '이용약관' : 'Terms of Service'}</FootLink5>
            <FootLink5 href="privacy.html">{ko ? '개인정보처리방침' : 'Privacy Policy'}</FootLink5>
          </div>
        </div>
      </div>
    </footer>
  );
}
function FootLink5({ children, href }) {
  const [h, setH] = useState(false);
  return (
    <a href={href} onMouseEnter={() => setH(true)} onMouseLeave={() => setH(false)}
      style={{ fontSize: 14, color: h ? D.bone : D.bone45, transition: 'color .3s' }}>{children}</a>
  );
}

Object.assign(window, { Capability5, Catalogue5, CatTile5, ProductModal5, ModalArrow5, Company5, CompanyBand5, Contact5, Channel5, CalloutBtn5, Footer5, FootLink5 });
