{# HyperWeave Tier 3 Metadata Block (Resonant).
   Injected by document.svg.j2 when metadata_tier >= 1.

   v0.3.2 Phase 8c: hardcoded Jinja2 `default('...')` fallbacks removed.
   Every metadata field now sources from context.py — see _base_context()
   in compose/context.py. New fields: hw:variant, hw:stratum, accurate
   theme_category/palette/contrast_ratio/font_stack/etc. #}
  <metadata>
  <hw:artifact id="{{ artifact_id }}" type="{{ frame_type }}" series="{{ series }}" version="{{ version }}"
               xmlns:hw="https://hyperweave.app/hw/v1.0">
    <hw:provenance>
      <hw:generator>HyperWeave Compositor v{{ version }} (InnerAura Labs)</hw:generator>
      <hw:created>{{ created_at }}</hw:created>
      <hw:human-directed>true</hw:human-directed>
    </hw:provenance>
    <hw:spec size="{{ width }}x{{ height }}" performance="composite-only"
             theme="{{ theme_category }}" a11y="WCAG-AA" platform="{{ platform }}"/>
  </hw:artifact>
  <hw:composition xmlns:hw="https://hyperweave.app/hw/v1.0">
    <hw:frame>{{ frame_type }}</hw:frame>
    <hw:genome>{{ genome_id }}@{{ version }}</hw:genome>
{% if variant %}    <hw:variant>{{ variant }}</hw:variant>
{% endif %}{% if profile_id %}    <hw:profile>{{ profile_id }}</hw:profile>
{% endif %}{% if stratum %}    <hw:stratum>{{ stratum }}</hw:stratum>
{% endif %}    <hw:slots>
{% for slot in slots | default([]) %}
      <hw:slot zone="{{ slot.zone }}" {% if slot.value %}value="{{ slot.value }}"{% endif %}{% if slot.data %} data="{{ slot.data | e }}"{% endif %}/>
{% endfor %}
    </hw:slots>
    <hw:environment platform="{{ platform }}" motion="{{ motion_id }}" status="{{ status }}"/>
  </hw:composition>
{% if metadata_tier >= 2 %}
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
           xmlns:dc="http://purl.org/dc/elements/1.1/">
    <rdf:Description>
      <dc:title>{{ title_text }}</dc:title>
      <dc:creator>HyperWeave Compositor v{{ version }} (InnerAura Labs)</dc:creator>
      <dc:date>{{ created_at }}</dc:date>
      <dc:rights>CC BY 4.0</dc:rights>
    </rdf:Description>
  </rdf:RDF>
{% endif %}
{% if metadata_tier >= 3 %}
  <hw:aesthetic xmlns:hw="https://hyperweave.app/hw/v1.0">
    <hw:chromatic system="{{ genome_id }}" space="oklch"
                  palette="{{ palette }}" contrast-ratio="{{ contrast_ratio | default('') }}"/>
    <hw:motion vocabulary="{{ motion_id }}" physics="none"
               timing="phi" duration-base="{{ rhythm_base }}"
               stagger-regime="contemplative" cim-compliant="{{ cim_compliant }}"/>
    <hw:geometry form-language="{{ form_language }}" corner-radius="{{ corner | default('5px') }}"
                 grid="auto" proportional-system="phi"
                 mathematical-basis="golden-ratio" symmetry="bilateral"/>
    <hw:typography stack="{{ font_stack }}" hierarchy="11/18/8"
                   weight-range="500-900" metrics-method="lut"/>
    <hw:material surface="genome-native" depth="{{ material_depth }}" texture="none"/>
  </hw:aesthetic>
  <hw:reasoning xmlns:hw="https://hyperweave.app/hw/v1.0">
    <hw:intent>{{ reasoning_intent | default('') }}</hw:intent>
    <hw:approach>{{ reasoning_approach | default('') }}</hw:approach>
    <hw:tradeoffs>{{ reasoning_tradeoffs | default('') }}</hw:tradeoffs>
    <hw:constraints-applied>self-contained, cim-compliant, wcag-aa</hw:constraints-applied>
    <hw:spatial-notes>{{ width }}x{{ height }} ({{ spatial_aspect_ratio }}), left-to-right</hw:spatial-notes>
  </hw:reasoning>
{% endif %}
{# hw:payload + hw:envelope — emitted at EVERY metadata tier when present:
   the payload IS the artifact's data (data-carrying frames are lossy
   without it), not tier-3 garnish. CDATA bodies are canonical and
   CDATA-safe by construction (core/envelope.py:cdata_safe_json); the
   envelope id is recomputable as sha256 of the payload bytes below. #}
{% if payload_json %}  <hw:payload xmlns:hw="https://hyperweave.app/hw/v1.0" schema="{{ payload_schema }}" media-type="application/json"><![CDATA[{{ payload_json }}]]></hw:payload>
{% endif %}{% if envelope_json %}  <hw:envelope xmlns:hw="https://hyperweave.app/hw/v1.0" format="{{ envelope_format }}" media-type="application/json"><![CDATA[{{ envelope_json }}]]></hw:envelope>
{% endif %}</metadata>
