{# Shared render macros. The state/absence vocabulary comes from the kit's
   template pack (mgf/macros.html — M1 P4.2, the copy-paste that lived here
   pre-0.4); these thin wrappers keep fed-web's historical call sites
   (m.sync_chip / m.derived / m.tstate / m.absence / m.empty_inline) and bind
   the fed-web-specific defaults. task_card stays: it is app domain. #}
{% import "mgf/macros.html" as kit %}

{# Sync-state chip — the brand state-chip; CHECKING/SYNCING swap the dot for a spinner. #}
{%- macro sync_chip(state) -%}{{ kit.sync_chip(state) }}{%- endmacro -%}

{# The violet "derived" tag — web-inferred, never a project-reported fact (spec §5.2). #}
{%- macro derived() -%}{{ kit.derived_tag('mgf-fed-web') }}{%- endmacro -%}

{# Task / stage workflow-state chip (done, in_progress, next, blocked, …). #}
{%- macro tstate(state) -%}{{ kit.tstate(state) }}{%- endmacro -%}

{# A work-unit card (In progress / Decisions). `age` is derived (now − started_at). #}
{%- macro task_card(t, age=None) -%}
<article class="card fw-task">
  <header class="fw-task__h">
    <span class="pill">{{ t.id }}</span>
    <span class="fw-task__t">{{ t.title }}</span>
    {% if t.owner %}<span class="pill">{{ t.owner }}</span>{% endif %}
  </header>
  <div class="fw-task__meta">
    {{ tstate(t.state) }}
    {% if t.impact %}<span class="level-badge level-badge--{{ t.impact }}">impact {{ t.impact }}</span>{% endif %}
    {% if t.effort %}<span class="level-badge level-badge--effort">effort {{ t.effort }}</span>{% endif %}
    {% if t.eta %}<span class="pill">eta {{ t.eta }}</span>{% endif %}
    {% if t.stage %}<span class="pill">{{ t.stage }}</span>{% endif %}
    {% if age %}<span class="pill pill--age">started {{ age }} ago</span>{{ derived() }}
    {% elif t.state == 'in_progress' %}<span class="pill">age not reported</span>{% endif %}
  </div>
  {% if t.reason %}<div class="detail-block detail-block--warning"><div class="detail-block__head">⚠ why</div>{{ t.reason }}</div>{% endif %}
  {% if t.evidence %}<p class="evidence">evidence · {{ t.evidence }}</p>{% endif %}
</article>
{%- endmacro -%}

{# Honest-absence block — every absence is an explicit state + reason (spec §1.6). #}
{%- macro absence(view) -%}
{{- kit.absence(view.state, view.title, view.reason, action=view.action, errors=view.errors) -}}
{%- endmacro -%}

{# An inline "nothing here" empty card (data present but the slice is empty). #}
{%- macro empty_inline(title, reason) -%}{{ kit.empty_state(title, reason) }}{%- endmacro -%}
