{#
/**
 * @file
 * Vartheme BS5 Starter Kit implementation for the Overlay Card component.
 *
 * Available properties:
 * - style_size: Card style size. (xsmall|small|medium|large|xlarge).
 * - card_border: Add a default border to the card. (true|false)
 * - padded: Add a default padding to the card. (true|false)
 * - equal_height: Equal height. (true|false)
 * - anchor_all: Anchor All. (true|false)
 * - horizontal_alignment: Horizontal alignment of the content. (start|center|end).
 * - vertical_alignment: Vertical alignment of the content. (start|center|end).
 *
 * Available attributes:
 * - card_attributes: Drupal attributes for featured card wrapper.
 * - media_attributes: Drupal attributes for card media slot region.
 * - content_attributes: Drupal attributes for card content slot region.
 * - card_overlay_utility_classes: Use to add extra Bootstrap utility classes for the main Card wrapper.
 *                    E.g. `mb-3 shadow-lg` ( Do not add `card`).
 * - card_overlay_media_utility_classes: Use to add extra Bootstrap utility classes for the Card Media region wrapper.
 *                          E.g. `bg-secondary mb-3` ( Do not add `card-img`).
 * - card_overlay_content_utility_classes: Use to add extra Bootstrap utility classes for the Card Content region wrapper.
 *                            E.g. `w-75 mb-3 overflow-y-hidden`  ( Do not add `card-body`)
 *
 * Available slots:
 * - media: Card Media slot region.
 * - content: Card Content slot region.
 */
#}

{% set style_size = style_size ? [style_size]: [] %}
{% set card_border = card_border ? ['bordered'] : ['border-0'] %}
{% set padded = padded ? ['p-4'] : [''] %}
{% set equal_height = equal_height ? ['h-100'] : [] %}
{% set anchor_all = anchor_all ? ['anchor-all'] : [] %}
{% set vertical_alignment = vertical_alignment == '' ? [] : ['justify-content-' ~ vertical_alignment] %}
{% set content_horizontal_alignment = horizontal_alignment == '' ? [] : ['align-items-' ~ horizontal_alignment] %}
{% set text_horizontal_alignment = horizontal_alignment == '' ? [] : ['align-items-' ~ horizontal_alignment] %}
{% set card_overlay_utility_classes = card_overlay_utility_classes ? card_overlay_utility_classes : [] %}
{% set card_overlay_media_utility_classes = card_overlay_media_utility_classes ? card_overlay_media_utility_classes : [] %}
{% set card_overlay_content_utility_classes = card_overlay_content_utility_classes ? card_overlay_content_utility_classes : [] %}

{%
  set card_classes = [
    'card',
    'varbase-overlay-card'
  ]|merge(style_size)|merge(card_border)|merge(padded)|merge(equal_height)|merge(anchor_all)|merge(card_overlay_utility_classes)
%}

{%
  set media_classes = []|merge(card_overlay_media_utility_classes)
%}

{%
  set content_classes = [
    'overlay-card-content',
    'card-img-overlay',
    'd-flex',
    'flex-column',
  ]|merge(vertical_alignment)|merge(content_horizontal_alignment)|merge(text_horizontal_alignment)|merge(card_overlay_content_utility_classes)
%}

{% if not card_attributes %}
  {% set card_attributes = create_attribute() %}
{% endif %}

{% if not content_attributes %}
  {% set content_attributes = create_attribute() %}
{% endif %}

<div{{ card_attributes.addClass(card_classes) }}>
  {% if media_classes is not empty %}
    {% if not media_attributes %}
      {% set media_attributes = create_attribute() %}
    {% endif %}
    <div{{ media_attributes.addClass(media_classes) }}>
  {% endif %}
    {{ media }}
  {% if media_classes is not empty %}
    </div>
  {% endif %}
  <div{{ content_attributes.addClass(content_classes) }}>
    {{ content }}
  </div>
</div>
