{# Chrome stats defs: envelope + well + text gradients + rim + filters.
   Ported from tier2/genomes/chrome/horizon/github-profile-stats-card-v6.svg,
   then refactored (v0.2.6) so every color comes from the genome via the
   shared _profile_visual_context. chrome's 11-stop envelope is
   preserved as the fallback when a genome doesn't declare envelope_stops —
   but any chrome genome that does will override it cleanly. #}

{# Envelope — genome-declared. Required field for chrome paradigm;
   enforced at load time by validate_genome_against_paradigms so this
   template never needs a specimen-color fallback. #}
<linearGradient id="{{ uid }}-env" x1="0" x2="0" y1="{{ gradient_y_neg_010 }}" y2="{{ gradient_y_090 }}">
{% for stop in envelope_stops %}
  <stop offset="{{ stop.offset }}" stop-color="{{ stop.color }}"/>
{% endfor %}
  <animateTransform attributeName="gradientTransform" type="translate"
    values="0 -0.2; 0 0.2; 0 -0.2" dur="{{ chrome_rhythm | default('6s') }}"
    repeatCount="indefinite" calcMode="spline"
    keySplines="0.4 0 0.2 1;0.4 0 0.2 1"/>
</linearGradient>

{# Well — genome-declared (required field for chrome paradigm). #}
<linearGradient id="{{ uid }}-well" x1="0" x2="0" y1="0" y2="1">
  <stop offset="0%"   stop-color="{{ well_top }}"/>
  <stop offset="100%" stop-color="{{ well_bottom }}"/>
</linearGradient>

{# Hero value gradient — genome hero_text_gradient (required field
   for chrome paradigm). chrome_text_gradient is an optional cascade
   step retained for genomes that only declare the title gradient and
   want it reused for the hero zone. #}
<linearGradient id="{{ uid }}-ct-hero" x1="0" y1="0" x2="1" y2="0">
{% for stop in (hero_text_gradient if hero_text_gradient else chrome_text_gradient) %}
  <stop offset="{{ stop.offset }}" stop-color="{{ stop.color }}"/>
{% endfor %}
</linearGradient>

{# Separator — genome-derived accent, opacity-ramped. specular_light
   sourced from genome.highlight_color (required for chrome paradigm). #}
<linearGradient id="{{ uid }}-sep" x1="0" y1="0" x2="1" y2="0">
  <stop offset="0%"   stop-color="var(--dna-signal)" stop-opacity="0"/>
  <stop offset="30%"  stop-color="var(--dna-signal)" stop-opacity="0.35"/>
  <stop offset="50%"  stop-color="{{ specular_light }}" stop-opacity="0.5"/>
  <stop offset="70%"  stop-color="var(--dna-signal)" stop-opacity="0.35"/>
  <stop offset="100%" stop-color="var(--dna-signal)" stop-opacity="0"/>
</linearGradient>

{# Rim sweep — genome highlight_color drives the shimmer band. #}
<linearGradient id="{{ uid }}-rim" x1="0" y1="0" x2="1" y2="0">
  <stop offset="0%"   stop-color="{{ specular_light }}" stop-opacity="0"/>
  <stop offset="35%"  stop-color="{{ specular_light }}" stop-opacity="0"/>
  <stop offset="46%"  stop-color="{{ specular_light }}" stop-opacity="0.3"/>
  <stop offset="50%"  stop-color="var(--dna-specular-core, var(--dna-ink-primary))" stop-opacity="0.6"/>
  <stop offset="54%"  stop-color="{{ specular_light }}" stop-opacity="0.3"/>
  <stop offset="65%"  stop-color="{{ specular_light }}" stop-opacity="0"/>
  <stop offset="100%" stop-color="{{ specular_light }}" stop-opacity="0"/>
  <animate attributeName="x1" values="-0.4;1.0;-0.4" dur="14s" repeatCount="indefinite" calcMode="spline" keySplines="0.4 0 0.6 1;0.4 0 0.6 1"/>
  <animate attributeName="x2" values="0.4;1.8;0.4"  dur="14s" repeatCount="indefinite" calcMode="spline" keySplines="0.4 0 0.6 1;0.4 0 0.6 1"/>
</linearGradient>

<filter id="{{ uid }}-bevel" x="-3%" y="-4%" width="106%" height="112%">
  <feDropShadow dx="0" dy="2.5" stdDeviation="4" flood-color="var(--dna-shadow-color, black)" flood-opacity="{{ bevel_shadow_opacity | default('0.5') }}"/>
</filter>

<filter id="{{ uid }}-horizon-glow" x="-5%" y="-400%" width="110%" height="900%">
  <feGaussianBlur in="SourceGraphic" stdDeviation="3" result="blur"/>
  <feMerge>
    <feMergeNode in="blur"/>
    <feMergeNode in="SourceGraphic"/>
  </feMerge>
</filter>

<clipPath id="{{ uid }}-clip">
  <rect width="{{ stats_layout.rects.chrome_clip.w }}" height="{{ stats_layout.rects.chrome_clip.h }}"
        rx="{{ stats_layout.rects.chrome_clip.rx }}"/>
</clipPath>

<style>
  {{ font_faces | safe }}
  text { font-family: var(--dna-font-mono, 'JetBrains Mono', monospace); shape-rendering: geometricPrecision; }
  .{{ uid }}-identity   { font-family: '{{ identity_font_family | default("Orbitron") }}', sans-serif; font-size: {{ identity_font_size | default(8.5) }}px; font-weight: {{ identity_font_weight | default(700) }}; letter-spacing: {{ identity_letter_spacing_em | default(0.1) }}em; fill: var(--dna-signal); }
  .{{ uid }}-hero       { font-family: var(--dna-font-display, 'Orbitron', sans-serif); font-size: 44px; font-weight: 900; letter-spacing: -0.01em; fill: url(#{{ uid }}-ct-hero); }
  .{{ uid }}-hero-label { font-family: var(--dna-font-mono, 'JetBrains Mono', monospace); font-size: 7.5px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; fill: var(--dna-ink-muted); opacity: 0.9; }
  .{{ uid }}-mval       { font-family: var(--dna-font-display, 'Orbitron', sans-serif); font-size: 20px; font-weight: 900; letter-spacing: 0.01em; fill: var(--dna-ink-primary); }
  .{{ uid }}-mlabel     { font-family: var(--dna-font-mono, 'JetBrains Mono', monospace); font-size: 7px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; fill: var(--dna-ink-muted); }
  .{{ uid }}-act-label  { font-family: var(--dna-font-mono, 'JetBrains Mono', monospace); font-size: 7.5px; font-weight: 700; letter-spacing: 0.20em; text-transform: uppercase; fill: var(--dna-ink-muted); opacity: 0.95; }
  .{{ uid }}-foot       { font-family: var(--dna-font-mono, 'JetBrains Mono', monospace); font-size: 7px; font-weight: 600; letter-spacing: 0.14em; fill: var(--dna-ink-muted); opacity: 0.8; }
  .{{ uid }}-brand      { font-family: var(--dna-font-mono, 'JetBrains Mono', monospace); font-size: 7px; font-weight: 700; letter-spacing: 0.28em; fill: var(--dna-ink-muted); opacity: 0.65; }
  [data-hw-status="active"], [data-hw-status="passing"] { --hw-core: var(--dna-signal); }
  [data-hw-status="warning"] { --hw-core: var(--dna-status-warning-core, var(--dna-signal)); }
  [data-hw-status="critical"], [data-hw-status="failing"] { --hw-core: var(--dna-status-failing-core, var(--dna-signal)); }
  @keyframes {{ uid }}-breathe       { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }
  @keyframes {{ uid }}-horizon-pulse { 0%,100% { opacity: 0.75; } 50% { opacity: 1; } }
  .{{ uid }}-dia, .{{ uid }}-present { animation: {{ uid }}-breathe 2.618s ease-in-out infinite; will-change: opacity; }
  .{{ uid }}-horizon                 { animation: {{ uid }}-horizon-pulse 4.236s ease-in-out infinite; will-change: opacity; }
  @media (prefers-reduced-motion: reduce) {
    .{{ uid }}-dia, .{{ uid }}-present, .{{ uid }}-horizon { animation: none !important; opacity: 0.85; }
    animate, animateTransform { display: none !important; }
  }
</style>
