// Deterministische Farbe aus einem beliebigen String (z. B. Kategorie-Namen)
// — dieselbe Kategorie bekommt so immer dieselbe Farbe, ohne dass Rakku sie
// manuell zuweisen muss. Genutzt für Kategorie-Badges in Admin-Listen (FAQ,
// Blog, Conventions).
export function stringToHue(input: string): number {
  let hash = 0;
  for (let i = 0; i < input.length; i++) {
    hash = (hash << 5) - hash + input.charCodeAt(i);
    hash |= 0;
  }
  return Math.abs(hash) % 360;
}

export function categoryBadgeStyle(input: string): { borderColor: string; color: string } {
  const hue = stringToHue(input || "default");
  return {
    borderColor: `hsl(${hue}, 55%, 55%, 0.4)`,
    color: `hsl(${hue}, 65%, 70%)`,
  };
}
