Fix animation toggle and z-index calculation