Coarse-Grained Surface Energies and Temperature-Induced Anchoring Transitions in Nematic Liquid Crystals