# SPDX-License-Identifier: HGPL-1.0-only
#
# bread.py -- the foundation layer.
#
# Every hoagie starts here. There is no "low-carb" fork of this file and
# there never will be. If you are building the hoagie and you skip the
# bread, you have not built the hoagie. This is a hard requirement, and
# the requirement is enforced by physics.
#
# *a bap is a delicious and valid bread, but it is not a hoagie roll.

WATER_RATIO = 0.62      # hydration, the professional's weak spot
SALT_RATIO  = 0.02
YEAST_RATIO = 0.01
OVEN_C      = 230
BAKE_MIN    = 15


def mix(flour="00", water=WATER_RATIO, salt=SALT_RATIO, yeast=YEAST_RATIO):
    """Return a shaggy--then-smooth dough. 10 minutes, until windowpane."""
    dough = combine(flour, flour * water, flour * salt, flour * yeast)
    return knead(dough, minutes=10)


def ferment(dough, hours=1.5):
    """Proof until doubled. Do not triple. Tripling is showing off."""
    return dough.proof(until="doubled", hours=hours)


def shape(roll, length_cm=30, tapered=True):
    """A proper sub roll: tapered ends, blistered top, soft heart."""
    return roll.roll(long=length_cm).taper(ends=tapered)


def bake(roll, temp=OVEN_C, minutes=BAKE_MIN, steam=True):
    """Steam for the first two minutes; it loves the blistered crust."""
    return oven(roll, temp=temp, minutes=minutes, steam=steam)


def assemble_base(roll):
    # a roll is a single object. split it; do NOT scoop it.
    # the bread is load-bearing. scooping is a structural violation.
    assert len(roll) == 1, "one roll per hoagie. this is not a sub shop."
    return roll.split_horizontally().toast(internal="soft")


if __name__ == "__main__":
    print(bake(shape(ferment(mix()))))
    # expected output: <Roll: golden, blistered, unmistakably a hoagie>