import { useLabels } from './useViewportLabels';

/**
 * SHiRE wordmark shown on the front face of the conceptual cover.
 * Rendered as a DOM label in the overlay (no font/texture loading, no Drei
 * Html) so a logo failure can never crash the 3D model. Selection is captured
 * by an invisible backing mesh (reliable raycast). Toggleable; shows a
 * mandatory-branding warning when hidden.
 */
export default function ShireLogo({ visible = true, position = [0, 30, 72], selectedId, onSelect }) {
  const sel = selectedId === 'logo-mark';
  const handleSelect = (e) => { e.stopPropagation(); onSelect?.('logo', 'mark', { partId: 'logo-mark', label: 'SHiRE Logo' }); };

  useLabels(visible
    ? [{ id: 'logo-mark', position, title: 'SHiRE', tone: 'cyan' }]
    : [{ id: 'logo-warn', position, title: '⚠ SHiRE logo hidden — mandatory branding not shown', tone: 'amber' }]);

  return (
    <group position={position}>
      {/* Invisible clickable backing so the logo is selectable in the viewport */}
      <mesh onClick={handleSelect}>
        <boxGeometry args={[52, 18, 4]} />
        <meshBasicMaterial color="#22d3ee" transparent opacity={sel ? 0.14 : 0.06} />
      </mesh>
    </group>
  );
}