{# stats override — earthen: big terracotta numbers with a botanical fern flourish (impact-metrics DNA). Field reads, columns control flow, countUp data-stats/data-countup-value hooks and the entire count-up <script> preserved verbatim from the builtin; only classes/style/fonts reskinned. #}
<section data-block-override="earthen:stats" class="py-12 md:py-20 bg-paper-grain text-foreground{% if class %} {{ class }}{% endif %}"{% if countUp %} data-stats{% endif %}>
  <div class="mx-auto max-w-6xl px-4">
    {% if heading %}<h2 class="text-center text-3xl md:text-4xl font-semibold" style="font-family:var(--font-heading, 'Fraunces', 'Playfair Display', Georgia, serif);color:hsl(var(--primary))">{{ heading }}</h2>{% endif %}
    {% if intro %}<p class="mx-auto mt-4 max-w-2xl text-center text-lg text-muted-foreground" style="font-family:var(--font-body, 'Work Sans', ui-sans-serif, system-ui, sans-serif)">{{ intro }}</p>{% endif %}
    <div class="mt-8 flex justify-center" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48" class="earthen-glyph" style="color:hsl(var(--primary));" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M24 44V8"></path><path d="M24 12c-4-2-7-2-9 0M24 12c4-2 7-2 9 0"></path><path d="M24 18c-6-2-10-1-12 1M24 18c6-2 10-1 12 1"></path><path d="M24 25c-7-1-12 0-14 3M24 25c7-1 12 0 14 3"></path><path d="M24 33c-7 0-11 2-12 5M24 33c7 0 11 2 12 5"></path></svg></div>
    <dl class="mt-8 grid grid-cols-2 gap-8 {% if columns == 2 %}md:grid-cols-2{% elif columns == 3 %}md:grid-cols-3{% else %}md:grid-cols-4{% endif %}">
      {% for item in items %}
      <div class="px-2 text-center">
        <dd class="text-4xl md:text-5xl font-semibold tracking-tight" style="font-family:var(--font-heading, 'Fraunces', 'Playfair Display', Georgia, serif);color:hsl(var(--accent))">{% if item.prefix %}{{ item.prefix }}{% endif %}<span{% if countUp %} data-countup-value="{{ item.value }}"{% endif %}>{{ item.value }}</span>{% if item.suffix %}{{ item.suffix }}{% endif %}</dd>
        {% if item.label %}<dt class="mt-2 text-xs uppercase tracking-wider text-muted-foreground" style="font-family:var(--font-body, 'Work Sans', ui-sans-serif, system-ui, sans-serif)">{{ item.label }}</dt>{% endif %}
      </div>
      {% endfor %}
    </dl>
  </div>
</section>
{% if countUp %}<script>
(function(){
  var sections = document.querySelectorAll('[data-stats]');
  var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  function animate(section){
    var nodes = section.querySelectorAll('[data-countup-value]');
    nodes.forEach(function(node){
      var raw = node.getAttribute('data-countup-value') || '';
      var target = parseFloat(raw.replace(/[^0-9.\-]/g, ''));
      if (isNaN(target)) return;
      var decimals = (raw.split('.')[1] || '').length;
      var start = null, dur = 1200;
      function step(ts){
        if (start === null) start = ts;
        var p = Math.min((ts - start) / dur, 1);
        var eased = 1 - Math.pow(1 - p, 3);
        node.textContent = (target * eased).toFixed(decimals);
        if (p < 1) requestAnimationFrame(step);
        else node.textContent = target.toFixed(decimals);
      }
      requestAnimationFrame(step);
    });
  }
  sections.forEach(function(section){
    if (reduce || !('IntersectionObserver' in window)) return;
    var io = new IntersectionObserver(function(entries){
      entries.forEach(function(e){
        if (e.isIntersecting){ animate(section); io.disconnect(); }
      });
    }, { threshold: 0.3 });
    io.observe(section);
  });
})();
</script>{% endif %}
