// Shared small utilities & icon wrapper.

function Icon({ name, size = 20, color = "currentColor", strokeWidth = 2 }) {
  const ref = React.useRef(null);
  React.useEffect(() => {
    if (ref.current && window.lucide) {
      ref.current.innerHTML = "";
      const iconData = window.lucide.icons[name] || window.lucide.icons.Circle;
      const svg = window.lucide.createElement(iconData);
      svg.setAttribute("width", size);
      svg.setAttribute("height", size);
      svg.setAttribute("stroke", color);
      svg.setAttribute("stroke-width", strokeWidth);
      ref.current.appendChild(svg);
    }
  }, [name, size, color, strokeWidth]);
  return <span ref={ref} style={{ display: "inline-flex", lineHeight: 0 }} />;
}

function Wordmark({ dark = false, size = 22 }) {
  return (
    <span className={`wordmark ${dark ? "dark" : ""}`} style={{ fontSize: size }}>
      <span className="th">TH</span><span className="suffix">data</span>
    </span>
  );
}

function Eyebrow({ children }) {
  return (
    <span className="eyebrow">
      <span className="eyebrow-dot"></span>{children}
    </span>
  );
}

// Fake brand logos (lookalike russian enterprise wordmarks)
function BrandLogo({ name, color = "#82BB5D" }) {
  const logos = {
    sber:   <svg viewBox="0 0 120 32" width="100" height="28" fill="none"><circle cx="16" cy="16" r="12" stroke={color} strokeWidth="3" strokeDasharray="55 10" transform="rotate(-25 16 16)"/><text x="36" y="22" fontFamily="Montserrat" fontWeight="700" fontSize="16" fill={color}>Банк24</text></svg>,
    mts:    <svg viewBox="0 0 100 32" width="80" height="28" fill="none"><rect x="2" y="6" width="28" height="20" rx="4" stroke={color} strokeWidth="2.5"/><text x="8" y="21" fontFamily="Montserrat" fontWeight="800" fontSize="11" fill={color}>М</text><text x="38" y="22" fontFamily="Montserrat" fontWeight="700" fontSize="14" fill={color}>ТелеСвязь</text></svg>,
    yandex: <svg viewBox="0 0 120 32" width="100" height="28" fill="none"><circle cx="14" cy="16" r="11" fill={color}/><text x="11" y="21" fontFamily="Montserrat" fontWeight="800" fontSize="14" fill="white">Я</text><text x="32" y="22" fontFamily="Montserrat" fontWeight="600" fontSize="14" fill={color}>Ритейл</text></svg>,
    ozon:   <svg viewBox="0 0 120 32" width="100" height="28" fill="none"><text x="0" y="22" fontFamily="Montserrat" fontWeight="700" fontSize="16" fill={color}>О</text><text x="14" y="22" fontFamily="Montserrat" fontWeight="400" fontSize="16" fill={color}>ЗОН-Логистик</text></svg>,
    tinkoff:<svg viewBox="0 0 120 32" width="100" height="28" fill="none"><rect x="2" y="4" width="24" height="24" rx="4" fill={color}/><text x="8" y="22" fontFamily="Montserrat" fontWeight="800" fontSize="14" fill="white">Т</text><text x="32" y="22" fontFamily="Montserrat" fontWeight="600" fontSize="15" fill={color}>банк</text></svg>,
    vtb:    <svg viewBox="0 0 100 32" width="90" height="28" fill="none"><text x="0" y="22" fontFamily="Montserrat" fontWeight="800" fontSize="18" fill={color}>ВТС</text><text x="40" y="22" fontFamily="Montserrat" fontWeight="300" fontSize="16" fill={color}>Групп</text></svg>,
  };
  return logos[name] || null;
}

Object.assign(window, { Icon, Wordmark, Eyebrow, BrandLogo });
