Can it be done with CSS? Grouping categories on category page

These theme-component may do what you want. Or be a good base to look at code to get ideas.

“Modern Category + Group boxes” as used in the Air Theme works well.