Phase transitions in layered crystals