Japan depended mostly on imported rare-earth minerals for decades. But something surprising has recently happened.