{#- MOCKUP AFTER. One "Courses N" heading; each group carries its own count, so nothing repeats and nothing floats over the wrong column. -#}
<section class="ob-sec ob-crs" id="courses">
  <div class="ob-hrow"><h2 class="ob-h">Courses</h2>{% if course_count %}<em class="ob-hn">{{ course_count }}</em>{% endif %}</div>
  <div class="ob-crscard ob-card va-card">
    {% if not course_groups %}
    <p class="ob-gap">Courses not listed on the SACAA record yet.</p>
    {% else %}
    <div class="ob-cr-groups is-grid">
    {% for g in course_groups %}
      {% set more = g['items']|length > 3 %}
      <div class="ob-cr-g"{% if g.name in ('Licences', 'Ratings') %} id="{{ 'licences' if g.name == 'Licences' else 'ratings' }}"{% endif %}>
        <div class="ob-cr-gt"><h3 class="ob-cr-gh">{{ g.name }} <span class="ob-cr-n">{{ g['items']|length }}</span></h3>
          {% if more %}<button type="button" class="ob-cr-more" aria-expanded="false" aria-controls="ob-cr-r{{ loop.index0 }}"><span class="a">More</span><span class="b">Less</span></button>{% endif %}
        </div>
        <ul class="ob-cr-pills ob-cr-row" id="ob-cr-r{{ loop.index0 }}">
        {% for name in g['items'] %}
          <li class="ob-cr-pill{% if loop.index0 >= 3 %} is-more{% endif %}"{% if loop.index0 >= 3 %} hidden{% endif %}>{{ name }}</li>
        {% endfor %}
        </ul>
      </div>
    {% endfor %}
    </div>
    {% endif %}
  </div>
</section>
