Germany grapples with far-right surge as AfD wins state election