ScotRail is to reduce opening hours at more than 50 ticket offices as more travellers buy online.