I sadly couldnt find the link/article explain this, so you'd have to trust my word (and memory - at least until I find the link... I think its burried in some patch notes).

Anyways, here is how it works:
Leadership will be passed doen to the next highste ranked member that has been active within the last 30 days.
If there is more than one, it will pass down to the one thats currently online.
If there is more than one, it will pass down to the one thats been in the FC longer.
(Those two might be reversed... not a 100% sure, I'll do some digging)
If non of the "first officers" meet the criteria (aka: all have been away for longer than the leader), it will pass down to the next lower tier and so on and so on.

Online-status is only relevant when it comes to a tie between two members of the same rank - the system will prefer the person thats online over the one thats offline. It will also prefer the person who logged in last - or at least thats my assumption from personal experience (I was part of a guild that I founded with 3 friends - one left as at somepoint, but when our leader went inactive for over a month leadership got passed to me even though the other friend had the same rank than I did and had been in the FC for the same time, but I had been on the day before, while he had taken a week-break of his own. So it either was random or, what I consider more likely, had taken into account that I had been the more active person)