{% import "macros.html" as m %}
{% if not view.ok %}
  {{ m.absence(view) }}
{% elif view.single %}
  {# Honest single-/no-snapshot message — never a faked delta (spec §4.10). #}
  <div class="empty empty--no-data fw-absence">
    <div class="empty__icon">⏱</div>
    <p class="empty__title">{{ view.title }}</p>
    <p class="empty__desc">{{ view.reason }}</p>
    {% if view.commit %}<p class="fw-absence__state mono">current snapshot @ {{ view.commit }}</p>{% endif %}
  </div>
{% elif view.has_changes %}
  <p class="lead fw-lede">What moved between the two most recent committed
  <span class="mono">generated/</span> snapshots — <span class="mono">{{ view.old_commit }}</span> →
  <span class="mono">{{ view.new_commit }}</span>. {{ m.derived() }} (structural delta).</p>

  {% if view.transitions %}
  <section class="card fw-panel">
    <header class="fw-panel__head"><h2 class="card__title fw-panel__title">Task state transitions</h2>
      <span class="fw-spacer"></span><span class="fw-panel__note mono">{{ view.transitions|length }}</span></header>
    <div class="fw-delta">
      {% for t in view.transitions %}
      <div class="fw-delta__row">
        <span class="pill">{{ t.id }}</span>
        <span class="fw-delta__title">{{ t.title }}</span>
        <span class="fw-delta__move">{{ m.tstate(t['from']) }}<span class="fw-arrow">→</span>{{ m.tstate(t.to) }}</span>
      </div>
      {% endfor %}
    </div>
  </section>
  {% endif %}

  {% if view.stage_moves %}
  <section class="card fw-panel">
    <header class="fw-panel__head"><h2 class="card__title fw-panel__title">Roadmap moves</h2>
      <span class="fw-spacer"></span><span class="fw-panel__note mono">{{ view.stage_moves|length }}</span></header>
    <div class="fw-delta">
      {% for s in view.stage_moves %}
      <div class="fw-delta__row">
        <span class="fw-delta__title">{{ s.label }}</span>
        {% if s.from_state != s.to_state %}<span class="fw-delta__move">{{ m.tstate(s.from_state) }}<span class="fw-arrow">→</span>{{ m.tstate(s.to_state) }}</span>{% endif %}
        {% if s.from_progress != s.to_progress %}<span class="mono fw-delta__pct">{{ (s.from_progress * 100)|round|int }}% → {{ (s.to_progress * 100)|round|int }}%</span>{% endif %}
      </div>
      {% endfor %}
    </div>
  </section>
  {% endif %}

  {% if view.new_tasks or view.closed_tasks or view.new_suggestions or view.closed_suggestions %}
  <section class="card fw-panel">
    <header class="fw-panel__head"><h2 class="card__title fw-panel__title">Opened &amp; closed</h2></header>
    <div class="fw-delta">
      {% for t in view.new_tasks %}<div class="fw-delta__row"><span class="fw-delta__badge fw-delta__badge--new">+ task</span><span class="pill">{{ t.id }}</span><span class="fw-delta__title">{{ t.title }}</span>{{ m.tstate(t.state) }}</div>{% endfor %}
      {% for t in view.closed_tasks %}<div class="fw-delta__row"><span class="fw-delta__badge fw-delta__badge--gone">− task</span><span class="pill">{{ t.id }}</span><span class="fw-delta__title">{{ t.title }}</span></div>{% endfor %}
      {% for s in view.new_suggestions %}<div class="fw-delta__row"><span class="fw-delta__badge fw-delta__badge--new">+ suggestion</span><span class="pill">{{ s.id }}</span><span class="fw-delta__title">{{ s.title }}</span></div>{% endfor %}
      {% for s in view.closed_suggestions %}<div class="fw-delta__row"><span class="fw-delta__badge fw-delta__badge--gone">− suggestion</span><span class="pill">{{ s.id }}</span><span class="fw-delta__title">{{ s.title }}</span></div>{% endfor %}
    </div>
  </section>
  {% endif %}
{% else %}
  {{ m.empty_inline(view.empty_title, view.empty_reason) }}
{% endif %}
