In case you haven't stumbled upon it
https://www.openrailwaymap.org/
I used it recently to find a land and sea route from Southampton to Marrakesh, along with Google maps faint representation of ferry lines, Google doesn't have public transit directions for the trains in Morocco shrug