{#
/**
 * @file
 * Timeline of declared election results, grouped by date.
 *
 * Variables:
 *   - groups: array of date groups, each containing:
 *     - date: formatted date string (e.g. "Friday 5th July 2026")
 *     - rows: array of row data, each containing:
 *       - time: formatted time string (e.g. "00:08")
 *       - area: area name
 *       - area_url: URL to the area result page
 *       - seats: total number of seats in the area
 *       - elected: number of winners declared
 *       - content: render array for the candidates list
 */
#}
{% for group in groups %}

  {% if group.date %}
    <h2 class="election-timeline__date-heading">{{ group.date }}</h2>
  {% endif %}

  {% for row in group.rows %}
    <article class="election-timeline__area">

      <header class="election-timeline__area-header">
        <div class="election-timeline__area-heading">
          <time class="election-timeline__time" datetime="{{ row.datetime }}">{{ row.time }}</time>
          <h3 class="election-timeline__area-name"><a class="election-timeline__area-link" href="{{ row.area_url }}">{{ row.area }}</a></h3>
        </div>
        <span class="election-timeline__seats">
          {{ row.seats }} {{ row.seats == 1 ? 'seat'|t : 'seats'|t }}
          {% if row.elected == row.seats %}
            {{ 'elected'|t }}
          {% elseif row.elected > 0 %}
            - {{ row.elected }} {{ 'elected'|t }}
          {% endif %}
        </span>
      </header>

      <div class="election-timeline__candidates">
        {{ row.content }}
      </div>

    </article>
  {% endfor %}

{% endfor %}
