// KentyLabs brand mark — PRISM K (final).
// The letter K drawn as a prism diagram: an ink incoming beam (stem), a
// refractive vertex, and two refracted rays carrying the brand spectrum
// (warm rising, cool falling, faint amber middle).
// Exports keep the legacy Orbits* names so existing call sites keep working.

const PRISM_SPECTRUM = ['#cf4b2c', '#f2a45c', '#2f5fd0']; // warm · amber · cool

let _wpid = 0;

// Primary spectral mark. `size` (number) sets px dimensions; otherwise fills.
function OrbitsMark({ ink = '#14181f', accent, spectrum = PRISM_SPECTRUM, stroke = 11, size, mono = false }) {
  const uid = React.useMemo(() => `wpk${_wpid++}`, []);
  const dim = size || '100%';
  return (
    <svg viewBox="0 0 200 200" width={dim} height={dim} style={{ display: 'block' }} aria-label="KentyLabs">
      <defs>
        <linearGradient id={`${uid}_w`} x1="0" x2="1" y1="0" y2="0">
          <stop offset="0%" stopColor={spectrum[0]} stopOpacity="1" />
          <stop offset="100%" stopColor={spectrum[0]} stopOpacity="0.35" />
        </linearGradient>
        <linearGradient id={`${uid}_c`} x1="0" x2="1" y1="0" y2="0">
          <stop offset="0%" stopColor={spectrum[2]} stopOpacity="1" />
          <stop offset="100%" stopColor={spectrum[2]} stopOpacity="0.35" />
        </linearGradient>
      </defs>
      {/* incoming beam — vertical stem */}
      <line x1="62" y1="36" x2="62" y2="164" stroke={ink} strokeWidth={stroke} strokeLinecap="square" />
      {/* refractive vertex */}
      <polygon points="62,84 62,116 80,100" fill={ink} />
      {/* upper refracted ray — warm */}
      <line x1="62" y1="100" x2="150" y2="50" stroke={mono ? ink : `url(#${uid}_w)`} strokeWidth={stroke} strokeLinecap="square" />
      {/* middle wavelength — faint amber (hidden in mono) */}
      {!mono && <line x1="62" y1="100" x2="150" y2="100" stroke={spectrum[1]} strokeWidth={stroke * 0.5} strokeLinecap="square" opacity="0.55" />}
      {/* lower refracted ray — cool */}
      <line x1="62" y1="100" x2="150" y2="150" stroke={mono ? ink : `url(#${uid}_c)`} strokeWidth={stroke} strokeLinecap="square" />
    </svg>
  );
}

// Horizontal primary lockup
function OrbitsLockup({ ink = '#14181f', accent, spectrum = PRISM_SPECTRUM, wordColor, size = 1, gap, mono = false }) {
  return (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: (gap ?? 16) * size, lineHeight: 1 }}>
      <div style={{ width: 86 * size, height: 86 * size, flexShrink: 0 }}>
        <OrbitsMark ink={ink} spectrum={spectrum} mono={mono} />
      </div>
      <div style={{
        fontFamily: '"Space Grotesk", system-ui, sans-serif',
        fontSize: 56 * size, fontWeight: 500,
        letterSpacing: '-0.035em',
        color: wordColor || ink,
      }}>kentylabs</div>
    </div>
  );
}

// Stacked lockup — mark above wordmark, for square crops
function OrbitsStackedLockup({ ink = '#14181f', accent, spectrum = PRISM_SPECTRUM, wordColor, size = 1 }) {
  return (
    <div style={{ display: 'inline-flex', flexDirection: 'column', alignItems: 'center', gap: 14 * size, lineHeight: 1 }}>
      <div style={{ width: 92 * size, height: 92 * size }}>
        <OrbitsMark ink={ink} spectrum={spectrum} />
      </div>
      <div style={{
        fontFamily: '"Space Grotesk", system-ui, sans-serif',
        fontSize: 28 * size, fontWeight: 500,
        letterSpacing: '-0.02em', color: wordColor || ink,
      }}>kentylabs</div>
    </div>
  );
}

// Legal lockup (rare — for footers, invoices)
function OrbitsLegalLockup({ ink = '#14181f', accent, spectrum = PRISM_SPECTRUM, size = 1 }) {
  return (
    <div style={{ display: 'inline-flex', alignItems: 'center', gap: 14 * size, lineHeight: 1 }}>
      <div style={{ width: 56 * size, height: 56 * size }}>
        <OrbitsMark ink={ink} spectrum={spectrum} stroke={13} />
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
        <div style={{ fontFamily: '"Space Grotesk", sans-serif', fontSize: 22 * size, fontWeight: 500, letterSpacing: '-0.03em', color: ink }}>kentylabs</div>
        <div style={{ fontFamily: '"JetBrains Mono", monospace', fontSize: 10 * size, color: ink, opacity: 0.55, letterSpacing: '0.06em', textTransform: 'uppercase' }}>s.r.o. · bratislava</div>
      </div>
    </div>
  );
}

Object.assign(window, {
  PRISM_SPECTRUM,
  OrbitsMark, OrbitsLockup, OrbitsStackedLockup, OrbitsLegalLockup,
  // clean aliases
  PrismKMark: OrbitsMark, PrismKLockup: OrbitsLockup,
});
