Intercalation-driven ferroelectric-to-ferroelastic conversion in a layered hybrid perovskite crystal