@php
    $ytcode = null;
    if (!empty($course->video_demo)) {
        $ytarray = explode('/', $course->video_demo);
        $ytendstring = end($ytarray);
        $ytendarray = explode('?v=', $ytendstring);
        $ytendstring = end($ytendarray);
        $ytendarray = explode('&', $ytendstring);
        $ytcode = $ytendarray[0];
    }

    $brochureUrl = null;
    if (!empty($course->description) && preg_match('/href=["\']([^"\']+\.(pdf|docx?|xlsx?))[^"\']*/i', $course->description, $m)) {
        $brochureUrl = $m[1];
    }

    $hasCertificateQuiz = $course->quizzes->where('certificate', 1)->count() > 0;
    $tagline = $heroTagline ?? '';
    $excerpt = $heroExcerpt ?? '';
@endphp

<section class="cp-hero cp-animate" id="premium-course-top">
    <div class="container cp-hero__inner">
        <div class="cp-hero__grid">
            <div class="cp-hero__copy cp-hero__surface">
                <p class="cp-hero__eyebrow">{{ trans('webinars.'.$course->type) }}</p>
                <h1 class="cp-hero__title">{{ $course->title }}</h1>
                @if(!empty($course->age_level))
                    <p class="cp-hero__age">{{ clean($course->age_level, 'age_level') }}</p>
                @endif
                @if($tagline !== '')
                    <p class="cp-hero__tagline">{{ $tagline }}</p>
                @endif
                @if($excerpt !== '')
                    <p class="cp-hero__lead">{{ $excerpt }}</p>
                @endif

                <div class="cp-hero__stats">
                    @if($hasCertificateQuiz)
                        <div class="cp-stat-card">
                            <span class="cp-stat-card__icon cp-stat-card__icon--1"><i data-feather="award" width="22" height="22"></i></span>
                            <span class="cp-stat-card__label">{{ trans('webinars.landing_badge_certified') }}</span>
                        </div>
                    @endif
                    <div class="cp-stat-card">
                        <span class="cp-stat-card__icon cp-stat-card__icon--2"><i data-feather="globe" width="22" height="22"></i></span>
                        <span class="cp-stat-card__label">{{ trans('webinars.landing_badge_online') }}</span>
                    </div>
                    <div class="cp-stat-card">
                        <span class="cp-stat-card__icon cp-stat-card__icon--3"><i data-feather="clock" width="22" height="22"></i></span>
                        <span class="cp-stat-card__label">{{ convertMinutesToHourAndMinute(!empty($course->duration) ? $course->duration : 0) }} {{ trans('home.hours') }}</span>
                    </div>
                </div>

                <div class="cp-hero__actions">
                    <a href="#enroll" class="btn cp-btn cp-btn--primary">{{ trans('webinars.landing_cta_enroll') }}</a>
                    @if($brochureUrl)
                        <a href="{{ $brochureUrl }}" class="btn cp-btn cp-btn--outline" target="_blank" rel="noopener">
                            <i data-feather="download" width="18" height="18" aria-hidden="true"></i>
                            {{ trans('webinars.landing_cta_brochure') }}
                        </a>
                    @endif
                </div>
            </div>

            <div class="cp-hero__media cp-hero__media-surface">
                @if($ytcode)
                    @include('web.default.includes.premium.video_facade', [
                        'embedUrl' => 'https://www.youtube.com/embed/'.$ytcode,
                        'youtubeId' => $ytcode,
                        'title' => $course->title ?? '',
                        'wrapperClass' => 'cp-hero__video video-facade-wrap',
                    ])
                    <span class="cp-hero__badge">
                        <i data-feather="check-circle" width="16" height="16" aria-hidden="true"></i>
                        {{ trans('webinars.landing_video_badge') }}
                    </span>
                @else
                    <div class="cp-hero__thumb">
                        @include('web.default.includes.premium.responsive_image', [
                            'src' => $course->getImage(),
                            'alt' => $course->title,
                            'class' => 'img-cover w-100',
                            'width' => 640,
                            'height' => 400,
                            'loading' => 'eager',
                            'fetchpriority' => 'high',
                        ])
                    </div>
                @endif
            </div>
        </div>
    </div>
</section>
