/* global React */
// ============================================================
//  AI Lawyer — Brand emblem
//  Abstract balance-scale / column mark, built from simple
//  geometric primitives (lines + shallow arcs). Brass on navy.
// ============================================================

function Emblem({ size = 40, variant = "badge", stroke }) {
  const s = size;
  // mark drawn on a 40x40 grid
  const brass = stroke || (variant === "badge" ? "#c6a468" : "#9a7636");
  const mark = (
    <g
      fill="none"
      stroke={brass}
      strokeWidth="1.9"
      strokeLinecap="round"
      strokeLinejoin="round"
    >
      {/* central column / beam */}
      <line x1="20" y1="9.5" x2="20" y2="30.5" />
      {/* top finial */}
      <rect x="18.4" y="6.2" width="3.2" height="3.2" rx="0.6" transform="rotate(45 20 7.8)" fill={brass} stroke="none" />
      {/* cross-beam */}
      <line x1="8.5" y1="13.5" x2="31.5" y2="13.5" />
      {/* cords */}
      <line x1="9.5" y1="13.5" x2="9.5" y2="17" />
      <line x1="30.5" y1="13.5" x2="30.5" y2="17" />
      {/* left pan */}
      <path d="M5.5 17 Q9.5 23.2 13.5 17" />
      {/* right pan */}
      <path d="M26.5 17 Q30.5 23.2 34.5 17" />
      {/* base */}
      <line x1="13.5" y1="30.5" x2="26.5" y2="30.5" />
      <line x1="11" y1="33.5" x2="29" y2="33.5" />
    </g>
  );

  if (variant === "plain") {
    return (
      <svg width={s} height={s} viewBox="0 0 40 40" aria-hidden="true">
        {mark}
      </svg>
    );
  }

  // badge: navy rounded square w/ brass mark + subtle inner ring
  return (
    <svg width={s} height={s} viewBox="0 0 40 40" aria-hidden="true"
         style={{ display: "block", flex: "0 0 auto" }}>
      <defs>
        <linearGradient id="emb-navy" x1="0" y1="0" x2="0" y2="1">
          <stop offset="0" stopColor="#1c3052" />
          <stop offset="1" stopColor="#0f1d33" />
        </linearGradient>
      </defs>
      <rect x="0.75" y="0.75" width="38.5" height="38.5" rx="10"
            fill="url(#emb-navy)" stroke="rgba(198,164,104,.45)" strokeWidth="1" />
      <rect x="3.5" y="3.5" width="33" height="33" rx="8"
            fill="none" stroke="rgba(198,164,104,.16)" strokeWidth="1" />
      {mark}
    </svg>
  );
}

window.Emblem = Emblem;
