But the gradient always start from the centre to the outskirts of the buffer. Is there a way to have it homogeneously go from the "top" of the buffer (i.e. from the line), to the bottom of the buffer? Best option would be to have the gradient go from dark close to the shore to clearer close to the bottom of the buffer.
Using the geometry generator based on a line I was able to create the following:
The idea is: Create a transparent buffer (10 %) to one side of the line (hopefully all you lines have been drawn in the same direction). This is done by
$geometry is the line in this case, 50 is the width of the buffer in layer units and 25 is how many segments a quarter-circle should be represented by.
Then I duplicated this symbology-layer and made the copy a bit more narrow (45 m in this case). And so on, until I reached 5 m width. The result has isolines in it, but if you make your steps small enough, they will become nigh invisible.
This is a Line-based approach using Array of offset (parallel) lines tool in the
QGIS Processing Toolbox > Vector Creation.
(1) Start the tool and set number of features, say
100 lines at
1.0 m (or -1m to make them the right-side) step distance.
(2) The tool will produce
Offset lines layer. Set
Graduated symbol using the
(3) The output would be like below. As we are working on lines, benefit of this approach would be seen when you have narrow kinks.
Updated: to improve my original answer, you can do as follows: create a buffer from your shoreline. This Buffer-polygon must be behind your land-polygon. If you than style the buffer with shapeburst symbol layer type, you just have to select a color ramp and set a distance. That's all, see here:
Have you tried Shapeburst symbol layer type? What you want to achieve is easier to realise with that rendering style. However, even than you have the gradient coming form all lines of the polygon coming... set the last color to transparent and set a fixed distance. To hide the color on the opposite side, consider creating an additional layer on top of it to mask the gradient form the opposite side.
You have in the background your layer for the ocean in a set color. Use the same color as second color in the gradient of your shapeburst on top ot the ocean-layer and use again the same color as 3rd color with 100% transparency. The mask-layer on the top is again in the same color. Together with the mask-layer on top, it could look like this (the thin dotted line is just to indicate the polygon-shape of the mask-layer):