Lawyers told ministers schools trans guidance was 'high risk'