Changing flexbox automatically with the right aspect ratio


I’m building a website that needs to showcase videos that all have different aspect ratios in a CMS list and I was wondering if there is a way to build a flexbox where all the videos are 1:1 ratio next to each other but when clicking on a particular video, the video would adjust to it’s correct aspect ratio pushing the other items away in the flexbox kind of like when you do a 2x grow or shrink transition with flex but in this case the 1:1 video would go to a 16:9 ratio pushing the other videos.
I know how to correctly adjust for aspect ratio so I don’t need help with that but I would like to keep a nice grid layout and not have a lot of video’s with all different aspect ratios, only on clicking a video it should automatically transition to it’s correct aspect ratio.

Here is my public share link: LINK
(how to access public share link)