  We present 20 epochs of optical spectroscopy obtained with the GTC-10.4m
telescope across the bright discovery outburst of the black hole candidate
Swift J1727.8-162. The spectra cover the main accretion states and are
characterised by the presence of hydrogen and helium emission lines, commonly
observed in these objects. They show complex profiles, including double-peaks,
but also blue-shifted absorptions (with blue-edge velocities of 1150 km/s),
broad emission wings and flat-top profiles, which are usual signatures of
accretion disc winds. Moreover, red-shifted absorptions accompanied by blue
emission excesses suggest the presence of inflows in at least two epochs,
although a disc origin cannot be ruled out. Using pre-outburst imaging from
Pan-STARRS, we identify a candidate quiescent optical counterpart with a
magnitude of g = 20.8. This implies an outburst optical amplitude of DV = 7.7,
supporting an estimated orbital period of 7.6 h, which favours an early K-type
companion star. Employing various empirical methods we derive a distance to the
source of d = 2.7 +- 0.3 kpc, corresponding to a Galactic Plane elevation of z
= 0.48 +- 0.05 kpc. Based on these findings, we propose that Swift J1727.8-162
is a nearby black hole X-ray transient that exhibited complex signatures of
optical inflows and outflows throughout its discovery outburst.
