By what year had Portugal established itself as an independent kingdom