First it finds the tags a post is assigned to, then tries to find other posts using that same tag. If it gets enough posts, it stops. Otherwise, it checks the category for more posts to finish out the total number of related posts we are going to show (three, in this example).
We shall use CSS Grid with Flexbox fallback for arranging the related posts in columns.