{{-- Premium mock-style course tile (homepage). Uses $webinar->getImage() — do not change image source. --}}
@php
    $rateNum = round((float) $webinar->getRate(), 1);
    $reviewCount = $webinar->relationLoaded('reviews') ? $webinar->reviews->count() : 0;

    $createdTs = $webinar->created_at ?? null;
    $isNew = is_numeric($createdTs) ? ((int) $createdTs > (time() - 1209600)) : false;

    $badgeType = '';
    $badgeLabel = '';

    if ($webinar->bestTicket() < $webinar->price && !empty($webinar->price) && $webinar->price > 0) {
        $badgeType = 'bestseller';
        $badgeLabel = trans('home.premium_course_badge_bestseller');
    } elseif (!empty($webinar->feature)) {
        $badgeType = 'bestseller';
        $badgeLabel = trans('home.premium_course_badge_bestseller');
    } elseif ($isNew) {
        $badgeType = 'new';
        $badgeLabel = trans('home.premium_course_badge_new');
    }

    $levelLabel = !empty(trim((string) $webinar->age_level))
        ? clean($webinar->age_level, 'age_level')
        : trans('home.premium_course_level_default');

    $descRaw = isset($webinar->description) ? strip_tags((string) $webinar->description) : '';
    $descShort = truncate($descRaw, 110);
@endphp

<article class="premium-mock-course-card h-100">
    <a href="{{ $webinar->getUrl() }}" class="premium-mock-course-card__link d-flex flex-column h-100 text-decoration-none">
        <div class="premium-mock-course-card__image-wrap">
            @if ($badgeType !== '')
                <span class="premium-mock-course-card__badge premium-mock-course-card__badge--{{ $badgeType }}">{{ $badgeLabel }}</span>
            @endif
            <img src="{{ $webinar->getImage() }}" alt="{{ clean($webinar->title, 'title') }}" class="premium-mock-course-card__img img-cover w-100" loading="lazy" decoding="async" height="220">
        </div>
        <div class="premium-mock-course-card__body flex-grow-1 d-flex flex-column text-start">
            <h3 class="premium-mock-course-card__title">{{ clean($webinar->title, 'title') }}</h3>
            @if ($descShort !== '')
                <p class="premium-mock-course-card__desc text-gray">{{ $descShort }}</p>
            @endif
            <div class="premium-mock-course-card__footer mt-auto d-flex align-items-center justify-content-between flex-wrap pt-15">
                <div class="d-flex align-items-center flex-wrap gap-10">
                    <span class="premium-mock-course-card__stars" aria-hidden="true">
                        @for ($i = 1; $i <= 5; $i++)
                            <i class="fa fa-star{{ $i <= round($rateNum) ? '' : '-o' }}"></i>
                        @endfor
                    </span>
                    <span class="premium-mock-course-card__rate-num">{{ number_format(max(0.1, min(5.0, $rateNum ?: 5)), 1) }}</span>
                    @if ($reviewCount > 0)
                        <span class="premium-mock-course-card__reviews-count text-gray font-13">({{ $reviewCount }})</span>
                    @endif
                </div>
                <span class="premium-mock-course-card__level-badge">{{ $levelLabel }}</span>
            </div>
        </div>
    </a>
</article>
