/**
 * Color utility functions
 */

/**
 * Converts a hex color + opacity (0-1) to an rgba string.
 * Handles 3-digit and 6-digit hex colors.
 */
export function withOpacity(hex: string, opacity: number): string {
  const clean = hex.replace('#', '')
  const full = clean.length === 3
    ? clean.split('').map(c => c + c).join('')
    : clean
  const r = parseInt(full.substring(0, 2), 16)
  const g = parseInt(full.substring(2, 4), 16)
  const b = parseInt(full.substring(4, 6), 16)
  return `rgba(${r},${g},${b},${opacity})`
}
