{# Chrome badge content: envelope, well, separator, diamond status indicator.
   Specimen: badge-final.svg
   Layer order: envelope -> inner stroke -> well -> chrome bleed -> specular #}
{# Chrome envelope #}
<g clip-path="url(#{{ uid }}-clip)">
  <rect width="{{ width }}" height="{{ h }}" fill="url(#{{ uid }}-env)" filter="url(#{{ uid }}-sh)"/>
  <rect x="{{ chrome_inner_inset }}" y="{{ chrome_inner_inset }}" width="{{ cellular_inner_stroke_w }}" height="{{ cellular_inner_stroke_h }}" rx="{{ chrome_inner_rx }}" fill="none" stroke="var(--dna-surface-deep)" stroke-width="0.6"/>
  <rect class="hw-well" x="{{ chrome_well_inset }}" y="{{ chrome_well_inset }}" width="{{ chrome_well_w }}" height="{{ chrome_well_h }}" rx="{{ chrome_well_rx }}" fill="url(#{{ uid }}-well)"/>
  <rect x="{{ chrome_well_inset }}" y="{{ chrome_well_inset }}" width="{{ chrome_rail_w }}" height="{{ chrome_well_h }}" fill="url(#{{ uid }}-env)" opacity="0.7"/>
</g>

{# Top highlight #}
<rect x="{{ chrome_highlight_x }}" y="{{ chrome_highlight_y }}" width="{{ chrome_highlight_w }}" height="{{ chrome_highlight_h }}" rx="{{ chrome_highlight_rx }}" fill="{{ specular_light }}" opacity="{{ highlight_opacity | default('0.1') }}"/>

{# Separator line #}
<line x1="{{ left_panel_width }}" y1="{{ chrome_separator_y1 }}" x2="{{ left_panel_width }}" y2="{{ chrome_separator_y2 }}" stroke="url(#{{ uid }}-sep)" stroke-width="0.75"/>

{# Glyph — glyph_y supplied by compose/layout.py (Invariant 6). #}
{% if has_glyph and glyph_svg %}
<g data-hw-zone="glyph" transform="translate({{ glyph_x }},{{ glyph_y }})">
  {{ glyph_svg | safe }}
</g>
{% endif %}

{# Label — class-styled for chrome paradigm (matches stats/chart typography) #}
{# Chrome uses text-anchor=start with first-character x positions from
   compute_badge_zones. Etched seam (two hairlines: dark cut at seam_left_x,
   specular catch +0.6px right) renders between label and value. #}
{% if seam_left_x and seam_left_x > 0 %}
<line x1="{{ seam_left_x }}" y1="{{ chrome_seam_y1 }}" x2="{{ seam_left_x }}" y2="{{ chrome_seam_y2 }}"
      stroke="var(--dna-seam-gap)" stroke-width="0.6" opacity="0.8"/>
<line x1="{{ seam_specular_x }}" y1="{{ chrome_seam_y1 }}" x2="{{ seam_specular_x }}" y2="{{ chrome_seam_y2 }}"
      stroke="var(--dna-specular, var(--dna-signal))" stroke-width="0.4" opacity="0.09"/>
{% endif %}

<text data-hw-zone="label"
      x="{{ label_x }}" y="{{ text_y }}"
      text-anchor="{{ text_anchor | default('middle') }}" dominant-baseline="central"
      class="{{ uid }}-label"
      fill="var(--dna-signal)"{% if label_text_length and label_text_length > 0 %} textLength="{{ label_text_length }}" lengthAdjust="spacingAndGlyphs"{% endif %}>{{ label_display | default(label | upper) }}</text>

{# Value — Orbitron 10/800. Label and value share y = h/2 + 0.5
   (= 10.5 at h=20), preventing the 1px vertical drift where the label
   sat lower than the value. #}
<text data-hw-zone="value"
      x="{{ value_x }}" y="{{ text_y }}"
      text-anchor="{{ text_anchor | default('middle') }}" dominant-baseline="central"
      class="{{ uid }}-value"
      fill="{{ glyph_fill | default('var(--dna-ink-primary)') }}"{% if value_text_length and value_text_length > 0 %} textLength="{{ value_text_length }}" lengthAdjust="spacingAndGlyphs"{% endif %}>{{ value }}</text>

{# Diamond status indicator — gated on resolver-supplied show_indicator (mode-driven).
   Housing fill + ring stroke route through dedicated --dna-diamond-* vars
   sourced from per-variant diamond_housing / diamond_stroke fields in
   chrome.json. Single-responsibility vars eliminate the --dna-signal-dim
   aliasing that caused warm-tan strokes on horizon (accent_complement was
   warm tan, --dna-signal-dim resolved to it, the var() fallback never fired). #}
{% if show_indicator %}
{% set indicator_ring_class = "" %}
{% set indicator_ring_stroke = "var(--dna-diamond-stroke)" %}
{% set indicator_stroke_width_value = chrome_diamond_stroke_width %}
{% set indicator_bit_class = "hw-logic-bit" %}
{% set indicator_bit_fill = "var(--dna-status-color, var(--dna-status-passing-core))" %}
{% include "frames/badge/indicators/" ~ indicator_shape ~ "-indicator.j2" %}
{% endif %}
