# Recipe DAG — easy flatbreads (no yoghurt)
# Source: BBC Food "easy flatbreads" (from a screenshot; instructions paraphrased, quantities as
# published). Changes: plain flour only (the original allows wholemeal); the optional 30-minute
# rest is mentioned in the knead step rather than modelled as a step.
#
# Schema notes:
#   - Scales from 2 to 8 breads (yield options). Ingredients marked `scale: linear` scale with
#     the count; the per-bread products and steps (ids with $i) are repeated once per bread.
#   - One pan, threaded through the graph as products (pan_0 → pan_1 → …), so the breads cook
#     one at a time; the remaining dough is threaded the same way (balls_0 → balls_1 → …).
#     The last bread's spare outputs (balls_$n, pan_$n) are simply unused.
#   - Each bread is cook (lay in) + flip, so the flip is a real hands-on moment. Each next ball
#     is rolled while the previous bread cooks.
#   - Durations: "15s", "5m", "1h", or {min, expected, max}.

recipe:
  id: easy_flatbreads
  code: easy-flatbreads   # short URL: /easy-flatbreads
  category: Sides
  title: Easy flatbreads
  yield: { servings: 4, unit: flatbread, options: [2, 3, 4, 5, 6, 7, 8] }

resources:
  cook:          { kind: cook,   capacity: 1 }
  hob:           { kind: hob,    capacity: 1 }
  pan:           { kind: vessel, capacity: 1, fits: { amount: 1, unit: flatbread } }
  bowl:          { kind: vessel, capacity: 1 }
  rolling_pin:   { kind: tool,   capacity: 1 }
  kitchen_paper: { kind: tool,   capacity: 1 }
  tongs:         { kind: tool,   capacity: 1 }
  foil:          { kind: tool,   capacity: 1 }

products:
  flour:         { kind: ingredient, qty: { amount: 200, unit: g, scale: linear }, name: plain flour }
  salt:          { kind: ingredient, qty: { amount: 0.25, unit: tsp, scale: linear } }
  water:         { kind: ingredient, qty: { amount: 100, unit: ml, scale: linear }, name: warm water }
  oil:           { kind: ingredient, qty: { amount: 2, unit: tbsp, scale: linear }, name: "oil (olive, sunflower or vegetable)" }
  pan_oil:       { kind: ingredient, name: "a little extra oil, for the pan" }
  dusting_flour: { kind: ingredient, name: "a little flour, for the surface" }

  rough_dough:  { kind: intermediate, name: rough dough, state: "shaggy, just combined", vessel: bowl, hold: { max: 30m } }
  dough:        { kind: intermediate, name: kneaded dough, state: soft and smooth, vessel: bowl, hold: { max: 1h, then: "fine; a 30-minute rest is optional" } }
  balls_0:      { kind: intermediate, name: $n dough ball(s), hold: { max: 1h } }
  pan_0:        { kind: intermediate, name: "hot pan, lightly oiled", vessel: pan }
  balls_$i:     { kind: intermediate, name: remaining dough balls, hold: { max: 1h } }
  pan_$i:       { kind: intermediate, name: "hot pan, free again", vessel: pan }
  fb_raw_$i:    { kind: intermediate, name: "flatbread $i, rolled", hold: { max: 20m } }
  fb_half_$i:   { kind: intermediate, name: "flatbread $i, one side done", vessel: pan }
  fb_$i:        { kind: intermediate, name: "flatbread $i, cooked", state: wrapped to keep warm, hold: { max: 20m } }
  flatbreads:   { kind: final, state: "warm, stacked" }

steps:
  mix_dough:
    title: Mix the dough
    text: Put the flour and salt in a large bowl. Trickle in the warm water bit by bit, mixing as you go.
    inputs: [flour, salt, water]
    outputs: [rough_dough]
    phases: [{ kind: active, duration: 2m }]
    done_when: it comes together into a rough dough
    uses: [bowl]
    time_scale: fixed

  knead:
    title: Add the oil and knead
    text: Add the oil and knead for 5 minutes, in the bowl or on a clean surface. If it's too sticky add a little more flour; if it's too dry add a splash of water. You can cook straight away, or leave the dough to stand for about 30 minutes if you have time.
    inputs: [rough_dough, oil]
    outputs: [dough]
    phases: [{ kind: active, duration: 6m }]
    done_when: soft, smooth and not sticky
    time_scale: fixed

  divide:
    title: Divide into balls
    text: Divide the dough into $n equal ball(s).
    inputs: [dough]
    outputs: [balls_0]
    phases: [{ kind: active, duration: 1m }]
    time_scale: linear

  heat_pan:
    title: Heat and oil the pan
    text: Put a large frying pan over a medium heat. Rub a little oil over the surface with a sheet of kitchen paper.
    inputs: [pan_oil]
    outputs: [pan_0]
    phases:
      - { kind: active, duration: 30s }
      - { kind: passive, duration: 2m }
    uses: [hob, pan, kitchen_paper]
    time_scale: fixed

  roll_$i:
    title: Roll flatbread $i
    text: Roll out the next ball the same way.
    first:
      title: Roll the first flatbread
      text: On a clean surface, roll out one ball with a rolling pin. Keep picking it up and turning it so it doesn't stick. Use only a little flour on the surface, as too much dries the dough out. It doesn't need to be a perfect circle.
    inputs: [balls_$prev, dusting_flour]
    outputs: [fb_raw_$i, balls_$i]
    phases: [{ kind: active, duration: 1.5m }]
    done_when: thin and roughly round
    uses: [rolling_pin]
    time_scale: fixed

  cook_$i:
    title: Cook flatbread $i
    text: Lay flatbread $i in the hot pan.
    inputs: [fb_raw_$i, pan_$prev]
    outputs: [fb_half_$i]
    phases:
      - { kind: active, duration: 15s }
      - { kind: passive, duration: 2m, timer: true }
    done_when: it puffs up a little
    uses: [hob, pan]
    time_scale: fixed

  flip_$i:
    title: Flip flatbread $i
    text: Turn it over and cook the other side, then add it to the warm stack.
    first:
      text: Turn it over with tongs and cook the other side, then lift it out and wrap it in foil or a clean tea towel to keep warm.
    inputs: [fb_half_$i]
    outputs: [fb_$i, pan_$i]
    phases:
      - { kind: active, duration: 15s }
      - { kind: passive, duration: 2m, timer: true }
    done_when: lighter in colour with a few brown spots
    uses: [hob, pan, tongs, foil]
    time_scale: fixed

  serve:
    title: Serve
    text: Unwrap the stack and serve the flatbreads warm.
    inputs: [fb_$all]
    outputs: [flatbreads]
    phases: [{ kind: active, duration: 30s }]
    time_scale: fixed
