{% macro anime_card(anime, in_watchlist=False, lang='vostfr') %}
<div class="hc" id="anime-{{ anime.url | hash }}"
     @click="activeTab = 'anime'; window.dispatchEvent(new CustomEvent('set-tab', { detail: { tab: 'anime' } })); $nextTick(() => { const input = document.getElementById('animeSearchInput'); if (input) { input.value = '{{ anime.title | e }}'; htmx.trigger(input, 'keyup'); } });">
    <div class="hc-poster">
        {% set poster = anime.cover_image or (anime.metadata.poster_image if anime.metadata else None) or 'https://placehold.co/400x600/161625/00d9ff?text=No+Image' %}
        <img src="{{ poster }}" alt="{{ anime.title }}" loading="lazy" referrerpolicy="no-referrer"
             onerror="this.src='https://placehold.co/400x600/161625/00d9ff?text=Error'; this.onerror=null;">
        {% if anime.metadata and anime.metadata.rating %}
        <span class="hc-rating"><i class="fas fa-star"></i> {{ anime.metadata.rating }}</span>
        {% endif %}
        <span class="hc-play"><i class="fas fa-search"></i></span>
    </div>
    <div class="hc-info">
        <span class="hc-src">{{ anime.provider_id or 'Anime' }}</span>
        <span class="hc-title">{{ anime.title }}</span>
    </div>
</div>
{% endmacro %}
