Happened to me too.
is something weird with the X series.
Beginning last year my X switched off showing the battery and lightning logo on screen but even plugged in it didn’t charge so got a replacement probably something wrong with the battery or software I don’t know.
Yesterday my Xs Max switched off I was feeling it hot and then when come back from WC it was totally dead so I plugged in it and nothing it didn’t even show the battery empty symbol even in the wireless charger pad was showing the light like if charging then this morning after all night charging it was on with 20% battery.
very very weird happening to so many people,I really hope Apple find the problem or do a replacement program as is no fear .