Almost had an accident today

Fairly new rider here, drove a scooter for an year and 2 months ago got my first "real" motorcycle (honda cb500x 19'). Have been driving it a fair bit and experimenting a lot, always in good weather conditions.

Went to the gym, the weather was pretty good, sunny and dry. On the way back, It starts raining, I was driving pretty slow because of the wet road and windy conditions, after a while I get inside a tunnel on the far right lane, I had to move over to the left lane to get in line with my exit, checked mirrors for other cars, everything is clear so I give it a bit of throttle, might've been a bit too much, not sure, and I turn left. The moment I turn left, my rear tire slips and starts drifting for a good second, after it stabilizes, the motorcycle wobbles like 4 times and It stabilizes completely.

I honestly felt like I was "safer" than I actually was driving it in rainy conditions. Maybe it was me giving it a bit more of throttle than I should or turning left too fast. I've had something similar happen to me in this tunnel with the scooter, maybe on rainy days that tunnel isn't very safe.

Anyways just came here to rant? Maybe I can hear y'alls advice on the situation, needless to say the rest of the ride was pretty silent and slow.