A court rules Scottish government ministers acted beyond their powers when churches were closed for lockdown.