Several $\gamma$-ray binaries have been recently detected by the High-Energy
Stereoscopy Array (H.E.S.S.) and the Major Atmospheric Imaging Cerenkov (MAGIC)
telescope. In at least two cases, their nature is unknown. In this paper we aim
to provide the details of a theoretical model of close $\gamma$-ray binaries
containing a young energetic pulsar as compact object, earlier presented in
recent Letters. This model includes a detailed account of the system geometry,
the angular dependence of processes such as Klein-Nishina inverse Compton and
$\gamma\gamma$ absorption in the anisotropic radiation field of the massive
star, and a Monte Carlo simulation of leptonic cascading. We present and derive
the used formulae and give all details about their numerical implementation,
particularly, on the computation of cascades. In this model, emphasis is put in
the processes occurring in the pulsar wind zone of the binary, since, as we
show, opacities in this region can be already important for close systems. We
provide a detailed study on all relevant opacities and geometrical dependencies
along the orbit of binaries, exemplifying with the case of LS 5039. This is
used to understand the formation of the very high-energy lightcurve and phase
dependent spectrum. For the particular case of LS 5039, we uncover an
interesting behavior of the magnitude representing the shock position in the
direction to the observer along the orbit, and analyze its impact in the
predictions. We show that in the case of LS 5039, the H.E.S.S. phenomenology is
matched by the presented model, and explore the reasons why this happens while
discussing future ways of testing the model.Comment: 62 pages, 31 figures, accepted for publication in Astroparticle
Physics. Results unchanged from previous version, more discussion adde