Checking if matrix lightswitch is true, and add wrapper div
Judging from your code it looks like you are struggling with one of Matrix's limitations. Nesting. I have seen, and used, a number of hacks to get around this until I stumbled upon the Neo plugin. I, in fact, use it exclusively for this kind of thing; Bootstrap's and Foundation's rows and columns.... or any other flex grid system for that matter.

So this answer's kinda a non answer because I am going to point you in another direction to achieve Foundations Block Grid.

Because Neo can nest and the code is very similar to a structure using levels, you can do something like this for Foundation's Block Grid.

{% for row in entry.neoField.level(1) %}

  {% for column in row.children %}
    {% if loop.first %}&lt;div class="row small-up-1 medium-up-{{ loop.total }}"&gt;{% endif %}
        &lt;div class="column"&gt;
            {% for field in column.children %}
            stuff... (use your switch code or I prefer per-field includes)
            {% endfor %}
        &lt;/div&gt;
    {% if loop.last %}&lt;/div&gt;{% endif %}
 {% endfor %}

{% endfor %}


Will output

   &lt;div class="row small-up-1 medium-up-3"&gt;
     &lt;div class="column"&gt;
       &lt;img src="//placehold.it/300x300"&gt;
     &lt;/div&gt;
     &lt;div class="column"&gt;
       &lt;img src="//placehold.it/300x300"&gt;
     &lt;/div&gt;
     &lt;div class="column"&gt;
       &lt;img src="//placehold.it/300x300"&gt;
     &lt;/div&gt;
   &lt;/div&gt;


So in Neo I have a top level block called "Row". It has no fields, but it could, you can make it as complicated as you want adding class, background etc. This row block can only have one type of child block called "Column" again, no fields if you don't want. This "Column" block can have any number of child blocks including photo, text, video(even a Row! Inception!). For each row you add, you can have as many columns you want(zurb block grid only works to 8). The total amount of columns you add gets added to the medium-up-3 per the {{ loop.total }}.

Neo Field

Note: The code above is a simplified version. Doing the Row > Column > Row works, but the code's a little more complicated.