Celtic inflicted a first home defeat of the season on Hamilton to reduce Aberdeen's lead at the top of the Scottish Premiership to one point.