// Salvallantas brand logo — extracted from official SVG
// Icon-only version (the road/wave shape) for compact uses

function LogoMark({ size = 40, color = '#D9302A' }) {
  return (
    <svg width={size} height={size * 122 / 266} viewBox="0 0 266 123" fill={color} xmlns="http://www.w3.org/2000/svg">
      <path d="M237.79,121.48c0-41.66-33.31-75.07-76.31-75.07H1.52A38.28,38.28,0,0,0,34.85,75.67H160.48c27.66,0,47.82,20.55,47.82,46.57v.26h29.5a.22.22,0,0,0,0-.08c0-.29,0-.59,0-.87A.08.08,0,0,0,237.79,121.48Z"/>
      <path d="M161.48,0h-130A38.32,38.32,0,0,0,1.52,28.76h153q3.44-.26,6.94-.26a93.74,93.74,0,0,1,93.74,93.74v.26h28.5v-.26A122.24,122.24,0,0,0,161.48,0Z"/>
      <path d="M168.75,93.29H148.39a9.37,9.37,0,0,1-1.73,0H25.33c-13.54,0-23.27,12-24.84,25.36v3.85h189.9v-4.07C189,106.15,180.81,93.29,168.75,93.29Z"/>
    </svg>
  );
}

function LogoFull({ height = 70 }) {
  // Full lockup: icon + "SALVALLANTAS" + tagline
  return (
    <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
      <LogoMark size={height * 2.3} color="#D9302A" />
      <div style={{
        fontSize: height * 0.42, fontWeight: 900, color: '#0b1c30',
        letterSpacing: '0.04em', fontStyle: 'italic', marginTop: height * 0.16,
        fontFamily: '"Inter", system-ui, sans-serif',
      }}>SALVALLANT<span style={{ color: '#D9302A' }}>aps</span></div>
      <div style={{
        fontSize: height * 0.2, color: '#D9302A', fontStyle: 'italic',
        marginTop: 2, letterSpacing: '0.02em', fontWeight: 500,
      }}>Soluciones en Movimiento</div>
    </div>
  );
}


// ── Ícono de Rodando (17/11/2026, opción D · dos caídas; franjas escalonadas): pin cortado por la S del logo ──
// Rojo de marca #D9302A solo para el logo; acciones siguen en azul.
// A 24 px o menos se usa solo el pin (las franjas no se distinguen).
const RODANDO_ROJO = '#D9302A';
// Ícono elegido (17/11/2026): franjas escalonadas (la del medio sobresale). La versión con las franjas alineadas como el logo queda en RODANDO_SVG_ALINEADO.
const RODANDO_SVG_ALINEADO = '<defs><mask id="__ID__s" maskUnits="userSpaceOnUse" x="-10" y="-32" width="292" height="186"><rect x="-10" y="-32" width="292" height="186" fill="#fff"/><path d="M215,122.5 L257.78,66.95 A54,54 0 1 0 172.22,66.95 Z" fill="#000" stroke="#000" stroke-width="26" stroke-linejoin="round"/></mask><mask id="__ID__p" maskUnits="userSpaceOnUse" x="-10" y="-32" width="292" height="186"><rect x="-10" y="-32" width="292" height="186" fill="#fff"/><g transform="translate(6,0)"><path d="M1.52,1 H161.48 A121.2,121.2 0 0 1 282.68,122.5 H0.49 Z" fill="#000"/><g fill="#fff"><path d="M237.79,121.48c0-41.66-33.31-75.07-76.31-75.07H1.52A38.28,38.28,0,0,0,34.85,75.67H160.48c27.66,0,47.82,20.55,47.82,46.57v.26h29.5c0-.29,0-.59,0-.87Z"/><path d="M161.48,0h-130A38.32,38.32,0,0,0,1.52,28.76h153q3.44-.26,6.94-.26a93.74,93.74,0,0,1,93.74,93.74v.26h28.5v-.26A122.24,122.24,0,0,0,161.48,0Z"/><path d="M168.75,93.29H148.39a9.37,9.37,0,0,1-1.73,0H25.33c-13.54,0-23.27,12-24.84,25.36v3.85h189.9v-4.07C189,106.15,180.81,93.29,168.75,93.29Z"/></g></g><circle cx="215" cy="34" r="19.439999999999998" fill="#000"/></mask></defs><g mask="url(#__ID__s)"><path d="M1.52,28.76 A38.32,38.32 0 0 1 31.48,0 H215 V28.76 Z"/><path d="M1.52,46.41 H215 V75.67 H34.85 A38.28,38.28 0 0 1 1.52,46.41 Z"/></g><path d="M25.33,93.29 H174.75 C186.81,93.29 195,106.15 196.39,118.43 V122.5 H0.49 V118.65 C2.06,105.29 11.790000000000001,93.29 25.33,93.29 Z"/><path d="M215,122.5 L257.78,66.95 A54,54 0 1 0 172.22,66.95 Z" mask="url(#__ID__p)"/>';
const RODANDO_SVG_ESCALONADO = '<defs><mask id="__ID__s" maskUnits="userSpaceOnUse" x="-10" y="-32" width="292" height="186"><rect x="-10" y="-32" width="292" height="186" fill="#fff"/><path d="M215,122.5 L257.78,66.95 A54,54 0 1 0 172.22,66.95 Z" fill="#000" stroke="#000" stroke-width="26" stroke-linejoin="round"/></mask><mask id="__ID__p" maskUnits="userSpaceOnUse" x="-10" y="-32" width="292" height="186"><rect x="-10" y="-32" width="292" height="186" fill="#fff"/><g transform="translate(6,0)"><path d="M1.52,1 H161.48 A121.2,121.2 0 0 1 282.68,122.5 H0.49 Z" fill="#000"/><g fill="#fff"><path d="M237.79,121.48c0-41.66-33.31-75.07-76.31-75.07H1.52A38.28,38.28,0,0,0,34.85,75.67H160.48c27.66,0,47.82,20.55,47.82,46.57v.26h29.5c0-.29,0-.59,0-.87Z"/><path d="M161.48,0h-130A38.32,38.32,0,0,0,1.52,28.76h153q3.44-.26,6.94-.26a93.74,93.74,0,0,1,93.74,93.74v.26h28.5v-.26A122.24,122.24,0,0,0,161.48,0Z"/><path d="M168.75,93.29H148.39a9.37,9.37,0,0,1-1.73,0H25.33c-13.54,0-23.27,12-24.84,25.36v3.85h189.9v-4.07C189,106.15,180.81,93.29,168.75,93.29Z"/></g></g><circle cx="215" cy="34" r="19.439999999999998" fill="#000"/></mask></defs><g mask="url(#__ID__s)"><path d="M46,28.76 A38.32,38.32 0 0 1 75.96000000000001,0 H215 V28.76 Z"/><path d="M1.5,46.41 H215 V75.67 H34.83 A38.28,38.28 0 0 1 1.5,46.41 Z"/></g><path d="M94.84,93.29 H174.75 C186.81,93.29 195,106.15 196.39,118.43 V122.5 H70 V118.65 C71.57,105.29 81.3,93.29 94.84,93.29 Z"/><path d="M215,122.5 L257.78,66.95 A54,54 0 1 0 172.22,66.95 Z" mask="url(#__ID__p)"/>';
const RODANDO_PIN = 'M215,122.5 L257.78,66.95 A54,54 0 1 0 172.22,66.95 Z M195.56,34 a19.44,19.44 0 1,0 38.88,0 a19.44,19.44 0 1,0 -38.88,0 Z';
// ── Interruptor del ícono (17/11/2026): 'escalonado' (actual) o 'alineado' (franjas como el logo de Salvallantas).
// Cambiar esta sola línea cambia el ícono en toda la app, la animación de entrada y las imágenes de la pestaña/celular.
const RODANDO_VARIANTE = 'escalonado';
const RODANDO_SVG = RODANDO_VARIANTE === 'alineado' ? RODANDO_SVG_ALINEADO : RODANDO_SVG_ESCALONADO;
if (RODANDO_VARIANTE === 'alineado') {
  // Las imágenes de la pestaña y del celular de la versión alineada están en icons/alineado/
  document.querySelectorAll('link[rel~="icon"], link[rel="apple-touch-icon"]').forEach((l) => {
    const h = l.getAttribute('href') || '';
    if (h.startsWith('icons/') && !h.startsWith('icons/alineado/')) l.setAttribute('href', h.replace('icons/', 'icons/alineado/'));
  });
}
let _rodandoId = 0;
function RodandoIcon({ height = 40, color = RODANDO_ROJO }) {
  const [id] = React.useState(() => 'rdm' + (++_rodandoId));
  const w = Math.round(height * 272 / 146);
  const html = `<svg width="${w}" height="${height}" viewBox="0 -22 272 146" fill="${color}" aria-hidden="true">${RODANDO_SVG.replace(/__ID__/g, id)}</svg>`;
  return <span style={{ display: 'inline-flex', lineHeight: 0, flex: 'none' }} dangerouslySetInnerHTML={{ __html: html }} />;
}
function RodandoPin({ height = 20, color = RODANDO_ROJO }) {
  return (
    <svg width={Math.round(height * 112 / 147)} height={height} viewBox="159 -22 112 147" aria-hidden="true" style={{ flex: 'none' }}>
      <path d={RODANDO_PIN} fill={color} fillRule="evenodd" />
    </svg>
  );
}
// Cuadro rojo con el ícono en blanco (pin y franjas; solo pin si el cuadro mide 24 px o menos)
function RodandoTile({ size = 30, radius, shadow }) {
  const r = radius != null ? radius : Math.round(size * 0.24);
  return (
    <span style={{ width: size, height: size, borderRadius: r, background: RODANDO_ROJO, display: 'grid', placeItems: 'center', flex: 'none', boxShadow: shadow || 'none' }}>
      {size <= 24 ? <RodandoPin height={Math.round(size * 0.66)} color="#fff" /> : <RodandoIcon height={Math.round(size * 0.44)} color="#fff" />}
    </span>
  );
}

Object.assign(window, { LogoMark, LogoFull, RODANDO_ROJO, RODANDO_VARIANTE, RodandoIcon, RodandoPin, RodandoTile });
