Subgame-perfect Equilibria in Mean-payoff Games (journal version) (Logical Methods in Computer Science, 2023)