How to separate WordPress loop into sections

In one of my recent projects, the client wanted to create a homepage with several different layouts for groups of posts. Normally this is not a problem – you can just create several loops, reset them, and you can get any imaginable layout. But this was a different pair of boots – the homepage consisted of several sections, with widget areas in between, while each section (there were three sections of posts) had a different layout. Moreover, the second and every other page of posts had a different layout again. I’m sure there are couple of ways to achieve this, but I found the method with counter as the most convenient one.

In my example below, you will find some registered widget areas and some classes that were specific for this project. Also, on the first page, I set a different number of posts on the homepage and for the other pages. In any case, here is the code, feel free to use it if you find any of use of it 🙂