{#
/**
 * @file
 * CivicTheme Navigation Card component.
 *
 * Props:
 * - theme: [string] Theme variation (light or dark).
 * - image_as_icon: [boolean] Whether to show the image as an icon.
 * - attributes: [string] Additional HTML attributes.
 * - modifier_class: [string] Additional CSS classes.
 * - image: [object] Card image.
 *   Each property contains:
 *   - url: [string] Link URL.
 *   - alt: [string] Image alt text.
 * - link: [object] Link object.
 *   Each property contains:
 *   - text: [string] Link text.
 *   - url: [string] Link URL.
 *   - is_new_window: [boolean] Whether to open link in a new window.
 *   - is_external: [boolean] Whether the link is external.
 * - is_title_click: [boolean] Whether to make only the title clickable instead of the whole card.
 *
 * Slots:
 * - icon: Icon name.
 * - title: Card title text.
 * - summary: Card summary.
 * - content_top: Card top content.
 * - image_over: Image overlay content.
 * - content_middle: Card middle content.
 * - content_bottom: Card bottom content.
 *
 * Blocks:
 * - image_block
 * - image_over_block
 * - content_top_block
 * - icon_block
 * - title_block
 * - content_middle_block
 * - summary_block
 * - content_bottom_block
 */
#}

{% set with_image = image.url is not empty %}
{% set with_image_class = with_image ? 'ct-navigation-card--with-image' : '' %}
{% set with_link = link is not empty and link.url is defined and link.url is not empty %}
{% set with_link_class = with_link ? 'ct-navigation-card--with-link' : '' %}
{% set is_card_clickable = with_link and is_title_click is empty %}
{% set card_clickable_class = is_card_clickable ? 'ct-navigation-card--card-clickable' : '' %}
{% set image_as_icon_class = image_as_icon ? 'ct-navigation-card--image-as-icon' : '' %}
{% set theme_class = 'ct-theme-%s'|format(theme|default('light')) %}
{% set modifier_class = '%s %s %s %s %s %s'|format(theme_class, with_image_class, with_link_class, image_as_icon_class, card_clickable_class, modifier_class|default('')) %}

{% if title is not empty %}
  <div class="ct-navigation-card {{ modifier_class -}}" {% if attributes is not empty %}{{- attributes|raw -}}{% endif %}>
    {% block image_block %}
      {% if not image_as_icon %}
        {% if image.url is not empty %}
          <div class="ct-navigation-card__image">
            {% include 'civictheme:image' with {
              theme: theme,
              url: image.url,
              alt: image.alt,
            } only %}

            {% block image_over_block %}
              {% if image_over %}
                <div class="ct-navigation-card__image__over">
                  {{ image_over }}
                </div>
              {% endif %}
            {% endblock %}
          </div>
        {% endif %}
      {% endif %}
    {% endblock %}

    <div class="ct-navigation-card__content">
      {% block content_top_block %}
        {% if content_top is not empty %}
          <div class="ct-navigation-card__content-top">
            {{- content_top|raw -}}
          </div>
        {% endif %}
      {% endblock %}

      {% block icon_block %}
        {% if icon is not empty or (with_image and image_as_icon) %}
          <div class="ct-navigation-card__icon">
            {% if icon is not empty %}
              {% include 'civictheme:icon' with {
                symbol: icon,
                size: 'extra-large',
              } only %}
            {% endif %}
            {% if image_as_icon and with_image %}
              <div class="ct-icon ct-icon--size-extra-large ct-navigation-card__icon__image">
                {% include 'civictheme:image' with {
                  theme: theme,
                  url: image.url,
                  alt: image.alt,
                } only %}
              </div>
            {% endif %}
          </div>
        {% endif %}
      {% endblock %}

      {% block title_block %}
        {% if title is not empty %}
          {% set title_content %}
            {% if with_link %}
              <a
                class="ct-navigation-card__title-link"
                href="{{ link.url }}"
                {% if link.is_new_window %}target="_blank"{% endif %}
              >{{ title }}</a>
            {% else %}
              {{ title }}
            {% endif %}
          {% endset %}
          <div class='ct-navigation-card__title'>{{ title_content }}</div>
        {% endif %}
      {% endblock %}

      {% block content_middle_block %}
        {% if content_middle is not empty %}
          <div class="ct-navigation-card__content-middle">
            {{- content_middle|raw -}}
          </div>
        {% endif %}
      {% endblock %}

      {% block summary_block %}
        {% if summary is not empty %}
          {% include 'civictheme:paragraph' with {
            theme: theme,
            content: summary,
            allow_html: true,
            no_margin: true,
            modifier_class: 'ct-navigation-card__summary',
          } only %}
        {% endif %}
      {% endblock %}

      {% block content_bottom_block %}
        {% if content_bottom is not empty %}
          <div class="ct-navigation-card__content-bottom">
            {{- content_bottom|raw -}}
          </div>
        {% endif %}
      {% endblock %}

      {% if is_card_clickable %}
        <div class="ct-navigation-card__tags">
          <div class="ct-navigation-card__link-graphic">
            {% include 'civictheme:icon' with {
              symbol: 'right-arrow-2',
              size: 'regular',
            } only %}
          </div>
        </div>
      {% endif %}
    </div>
  </div>
{% endif %}
