Attainability of the fractional Hardy constant with nonlocal mixed boundary conditions. Applications