{% if variant and variant|lower != 'default' %}
  {% set variants = variant|split('__')|map(v => v|lower|replace({(v): 'fr-card--' ~ v})|replace({_: '-'})) %}
  {% set attributes = attributes.addClass(variants) %}
  {% if 'fr-card--horizontal' in variants and horizontal_ratio %}
    {% set attributes = attributes.addClass('fr-card--horizontal-' ~ horizontal_ratio) %}
  {% endif %}
{% endif %}

{% if enlarge_link and not footer %}
  {% set attributes = attributes.addClass('fr-enlarge-link') %}
{% endif %}

{% if no_arrow %}
  {% set attributes = attributes.addClass('fr-card--no-arrow') %}
{% endif %}

{% if bg_boxes %}
  {% set attributes = attributes.addClass('fr-card--' ~ bg_boxes) %}
{% endif %}

{% set title_tag = title_tag|default('h3') %}

{% if title %}
  <div{{ attributes.addClass('fr-card') }}>
    <div class="fr-card__body">
      <div class="fr-card__content">
        <{{ title_tag }} class="fr-card__title">
          {{ title }}
        </{{ title_tag }}>
        {% if description %}<div class="fr-card__desc">{{ description }}</div>{% endif %}
        {% if detail or tags_badges %}
          <div class="fr-card__start">
            {{ tags_badges }}
            {% if detail %}
              <div class="fr-card__detail {{ detail_icon }}">{{ detail }}</div>
            {% endif %}
          </div>
        {% endif %}
        {% if detail_end %}
          <div class="fr-card__end">
            {% if detail_end %}
              <div class="fr-card__detail {{ detail_end_icon }}">{{ detail_end }}</div>
            {% endif %}
          </div>
        {% endif %}
      </div>
      {% if footer %}
        <div class="fr-card__footer">
          {{ footer }}
        </div>
      {% endif %}
    </div>
    {% if image %}
      <div class="fr-card__header">
        <div class="fr-card__img">
          {{ image|add_class('fr-responsive-img') }}
        </div>
        {{ image_badges }}
      </div>
    {% endif %}
  </div>
{% endif %}
