// The NADBA association seal — three style variants exposed via tweaks.
// Kept geometric: circles, rectangles, text on a path. No illustrative SVG.

function Seal({ variant = "circular", size = 120, color = "currentColor", accent }) {
  const c = color;
  const a = accent || color;
  const id = React.useId();
  const ringId = `ring-${id}`;

  if (variant === "monogram") {
    return (
      <svg width={size} height={size} viewBox="0 0 120 120" aria-label="NADBA seal">
        <circle cx="60" cy="60" r="58" fill="none" stroke={c} strokeWidth="1.2" />
        <circle cx="60" cy="60" r="52" fill="none" stroke={c} strokeWidth="0.6" />
        <g fontFamily="Libre Caslon Text, Georgia, serif" fontWeight="700"
           textAnchor="middle" fill={c}>
          <text x="60" y="74" fontSize="52" letterSpacing="-2">N</text>
        </g>
        <text x="60" y="98" fontFamily="IBM Plex Mono, monospace" fontSize="6.5"
              letterSpacing="2.5" textAnchor="middle" fill={c}>
          MMXXVI
        </text>
        <line x1="22" y1="86" x2="36" y2="86" stroke={c} strokeWidth="0.8" />
        <line x1="84" y1="86" x2="98" y2="86" stroke={c} strokeWidth="0.8" />
      </svg>
    );
  }

  if (variant === "crest") {
    return (
      <svg width={size} height={size} viewBox="0 0 120 120" aria-label="NADBA crest">
        {/* shield */}
        <path d="M60 6 L106 18 L106 60 Q106 92 60 114 Q14 92 14 60 L14 18 Z"
              fill="none" stroke={c} strokeWidth="1.4" />
        <path d="M60 14 L100 24 L100 60 Q100 86 60 105 Q20 86 20 60 L20 24 Z"
              fill="none" stroke={c} strokeWidth="0.6" />
        {/* chief bar */}
        <rect x="20" y="24" width="80" height="14" fill={c} />
        <text x="60" y="35" fontFamily="IBM Plex Mono, monospace" fontSize="6.5"
              letterSpacing="3" textAnchor="middle" fill="var(--bg)">
          MMXXVI
        </text>
        {/* pales (vertical stripes — read as schemas/columns) */}
        <rect x="34" y="46" width="6" height="36" fill={c} opacity="0.85" />
        <rect x="46" y="46" width="6" height="36" fill="none" stroke={c} strokeWidth="1" />
        <rect x="58" y="46" width="6" height="36" fill={c} opacity="0.55" />
        <rect x="70" y="46" width="6" height="36" fill="none" stroke={c} strokeWidth="1" />
        <rect x="82" y="46" width="6" height="36" fill={c} opacity="0.85" />
        {/* base diamond */}
        <rect x="55" y="89" width="10" height="10" fill={c} transform="rotate(45 60 94)" />
      </svg>
    );
  }

  // circular (default): rotunda stamp with text on path
  return (
    <svg width={size} height={size} viewBox="0 0 120 120" aria-label="NADBA seal">
      <defs>
        <path id={ringId}
              d="M 60,60 m -45,0 a 45,45 0 1,1 90,0 a 45,45 0 1,1 -90,0" />
      </defs>
      <circle cx="60" cy="60" r="58" fill="none" stroke={c} strokeWidth="1.4" />
      <circle cx="60" cy="60" r="54" fill="none" stroke={c} strokeWidth="0.6" />
      <circle cx="60" cy="60" r="33" fill="none" stroke={c} strokeWidth="0.8" />

      {/* radial tick marks */}
      {Array.from({ length: 36 }).map((_, i) => {
        const angle = (i / 36) * 2 * Math.PI;
        const r1 = 50, r2 = 54;
        const x1 = 60 + Math.cos(angle) * r1;
        const y1 = 60 + Math.sin(angle) * r1;
        const x2 = 60 + Math.cos(angle) * r2;
        const y2 = 60 + Math.sin(angle) * r2;
        return <line key={i} x1={x1} y1={y1} x2={x2} y2={y2} stroke={c} strokeWidth="0.6" opacity="0.6" />;
      })}

      <text fontFamily="IBM Plex Mono, monospace" fontSize="6.5"
            letterSpacing="3" fill={c} fontWeight="500">
        <textPath href={`#${ringId}`} startOffset="0%">
          · NATIONAL ASSOCIATION OF NOT DATABASE ADMINISTRATORS · EST · MMXXVI ·
        </textPath>
      </text>

      {/* center monogram */}
      <text x="60" y="68" fontFamily="Libre Caslon Text, Georgia, serif"
            fontWeight="700" fontSize="24" letterSpacing="0"
            textAnchor="middle" fill={c}>
        NADBA
      </text>
      <text x="60" y="80" fontFamily="Libre Caslon Text, Georgia, serif"
            fontStyle="italic" fontSize="7" letterSpacing="2"
            textAnchor="middle" fill={a}>
        veritas in absentia
      </text>
    </svg>
  );
}

window.Seal = Seal;
