// ============================================================
// ESTUDIO RETÓRICA · Logo real
// ============================================================

const getRetoricaAssetUrl = (assetPath = '') => {
  const normalized = String(assetPath || '').replace(/^\/+/, '');
  const baseTag = document.querySelector('base');
  const baseHref = baseTag?.getAttribute('href') || '/';
  return new URL(normalized, window.location.origin + baseHref).toString();
};

const RetoricaLogo = ({ size = 220, inverse = false, markOnly = false }) => {
  const src = getRetoricaAssetUrl('assets/retorica-logo.png');
  if (markOnly) {
    return (
      <span
        aria-label="Retórica"
        style={{
          display: 'inline-flex',
          width: size * 0.24,
          height: size * 0.24,
          borderRadius: 14,
          alignItems: 'center',
          justifyContent: 'center',
          background: inverse ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.04)',
          overflow: 'hidden',
          padding: 6,
        }}
      >
        <img src={src} alt="Retórica" style={{ width: '100%', height: 'auto' }}/>
      </span>
    );
  }

  return (
    <img
      src={src}
      alt="Retórica"
      style={{
        width: size,
        height: 'auto',
        display: 'block',
        filter: inverse ? 'none' : 'none',
      }}
    />
  );
};

Object.assign(window, { RetoricaLogo, getRetoricaAssetUrl });
