// site-marks.jsx — the three candidate logo SYMBOLS, all accent-driven so the
// Tweaks accent recolors them. Paired with the Exo 2 wordmark in nav/footer.
// Exports: MarkAperture, MarkBracketFrame, SiteMark. (MarkRing comes from marks.jsx.)

function _arc(cx, cy, r, a0, a1) {
  const rad = (d) => (d * Math.PI) / 180;
  const x0 = (cx + r * Math.cos(rad(a0))).toFixed(2), y0 = (cy + r * Math.sin(rad(a0))).toFixed(2);
  const x1 = (cx + r * Math.cos(rad(a1))).toFixed(2), y1 = (cy + r * Math.sin(rad(a1))).toFixed(2);
  const large = (a1 - a0) % 360 > 180 ? 1 : 0;
  return `M${x0} ${y0} A${r} ${r} 0 ${large} 1 ${x1} ${y1}`;
}

// Unified aperture — four arc segments with gaps; the bottom-right segment is accented.
// Thicker stroke + wider gaps (±26° sweep ⇒ ~38° gaps) for a bolder, clearer mark.
function MarkAperture({ s = 26, c = '#0a2a6b', a = '#e8a900' }) {
  const segs = [45, 135, 225, 315]; // segment centers (y-down)
  const accentCenter = 45;           // bottom-right
  return (
    <svg width={s} height={s} viewBox="0 0 80 80" fill="none" aria-hidden="true">
      {segs.map((mid) => (
        <path key={mid} d={_arc(40, 40, 28, mid - 26, mid + 26)} stroke={mid === accentCenter ? a : c}
          strokeWidth="11" strokeLinecap="round" fill="none" />
      ))}
    </svg>
  );
}

// Bracket frame — two square brackets around a filled accent node.
function MarkBracketFrame({ s = 26, c = '#0a2a6b', a = '#e8a900' }) {
  return (
    <svg width={s} height={s} viewBox="0 0 80 80" fill="none" aria-hidden="true">
      <path d="M31 14 L22 14 L22 66 L31 66" stroke={c} strokeWidth="5" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M49 14 L58 14 L58 66 L49 66" stroke={c} strokeWidth="5" strokeLinecap="round" strokeLinejoin="round" />
      <circle cx="40" cy="40" r="9" fill={a} />
    </svg>
  );
}

// Selector used in nav/footer. kind: 'Ring' | 'Aperture' | 'Bracket'
function SiteMark({ kind = 'Ring', s = 26, c = '#0a2a6b', a = '#e8a900' }) {
  if (kind === 'Aperture') return <MarkAperture s={s} c={c} a={a} />;
  if (kind === 'Bracket') return <MarkBracketFrame s={s} c={c} a={a} />;
  return <MarkRing s={s} c={c} a={a} />;
}

// ── Department marks (from the brand-architecture family) ─────────
// development = brackets + node · research = spark · procurement = package
// w/ inbound arrow · funding = upward arrow. c = line color, a = accent.
function DeptIcon({ name, c = '#ffffff', a = '#f2b705', size = 30 }) {
  const common = { width: size, height: size, fill: 'none' };
  if (name === 'development') return (
    <svg {...common} viewBox="70 181 45 48">
      <path d="M83.5 187 L74.5 187 L74.5 223 L83.5 223" stroke={c} strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" />
      <path d="M101.5 187 L110.5 187 L110.5 223 L101.5 223" stroke={c} strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" />
      <circle cx="92.5" cy="205" r="5" fill={a} />
    </svg>
  );
  if (name === 'research') return (
    <svg {...common} viewBox="240 184 35 40">
      <line x1="257.5" y1="200" x2="257.5" y2="188" stroke={a} strokeWidth="4" strokeLinecap="round" />
      <line x1="261.83" y1="202.5" x2="272.22" y2="196.5" stroke={c} strokeWidth="4" strokeLinecap="round" />
      <line x1="261.83" y1="207.5" x2="272.22" y2="213.5" stroke={c} strokeWidth="4" strokeLinecap="round" />
      <line x1="257.5" y1="210" x2="257.5" y2="222" stroke={c} strokeWidth="4" strokeLinecap="round" />
      <line x1="253.17" y1="207.5" x2="242.78" y2="213.5" stroke={c} strokeWidth="4" strokeLinecap="round" />
      <line x1="253.17" y1="202.5" x2="242.78" y2="196.5" stroke={c} strokeWidth="4" strokeLinecap="round" />
    </svg>
  );
  if (name === 'procurement') return (
    <svg {...common} viewBox="412 60 56 60">
      <rect x="417" y="64.5" width="46" height="13" rx="3" stroke={c} strokeWidth="3" fill="none" />
      <rect x="417" y="83.5" width="46" height="13" rx="3" stroke={c} strokeWidth="3" fill="none" />
      <rect x="417" y="102.5" width="46" height="13" rx="3" stroke={c} strokeWidth="3" fill="none" />
      <circle cx="425" cy="71" r="3" fill={a} />
      <circle cx="425" cy="90" r="3" fill={c} />
      <circle cx="425" cy="109" r="3" fill={c} />
      <line x1="450" y1="69" x2="458" y2="69" stroke={c} strokeWidth="1.5" strokeLinecap="round" />
      <line x1="450" y1="73" x2="458" y2="73" stroke={c} strokeWidth="1.5" strokeLinecap="round" />
      <line x1="450" y1="88" x2="458" y2="88" stroke={c} strokeWidth="1.5" strokeLinecap="round" />
      <line x1="450" y1="92" x2="458" y2="92" stroke={c} strokeWidth="1.5" strokeLinecap="round" />
      <line x1="450" y1="107" x2="458" y2="107" stroke={c} strokeWidth="1.5" strokeLinecap="round" />
      <line x1="450" y1="111" x2="458" y2="111" stroke={c} strokeWidth="1.5" strokeLinecap="round" />
    </svg>
  );
  if (name === 'funding') return (
    <svg {...common} viewBox="573 183 29 44">
      <line x1="575.5" y1="224" x2="599.5" y2="224" stroke={c} strokeWidth="4" strokeLinecap="round" />
      <line x1="587.5" y1="224" x2="587.5" y2="192" stroke={c} strokeWidth="4" strokeLinecap="round" />
      <polygon points="581,199 594,199 587.5,186" fill={a} />
    </svg>
  );
  if (name === 'secured') return (
    <svg {...common} viewBox="402 50 41 40">
      <circle cx="422.5" cy="70" r="18" stroke={c} strokeWidth="3.5" fill="none" />
      <path d="M415 70 L420.5 76 L431 62" stroke={a} strokeWidth="4" strokeLinecap="round" strokeLinejoin="round" fill="none" />
    </svg>
  );
  return null;
}

Object.assign(window, { MarkAperture, MarkBracketFrame, SiteMark, DeptIcon });
