This is Patricia McKillip's renowned Riddle Master trilogy. It includes The Riddle Master of Hed, Heir of Sea and Fire and Harpist in the Wind.