Interfaces in inhomogeneous media: pinning, hysteresis, and facets