@if (request()->is('/'))
    @php
        $premiumCtaMediaRel = collect([
            'assets/default/img/montessori-premium/premium-home-cta.webp',
            'assets/default/img/montessori-premium/premium-home-cta.png',
            'assets/default/img/montessori-premium/premium-home-cta.jpg',
            'assets/default/img/montessori-premium/premium-home-cta-art.svg',
            'assets/default/img/montessori-premium/newsletter-illustration.png',
            'assets/default/img/montessori-premium/newsletter-illustration.jpg',
            'assets/default/img/home/newsletter-illustration.png',
        ])->first(static fn ($rel) => file_exists(public_path($rel)))
            ?? 'assets/default/img/montessori-premium/premium-home-cta-art.svg';

        $premiumCtaPhonesHtml = (string) (getContactPageSettings('phones') ?? '');
        $premiumCtaPhonesPlain = trim(html_entity_decode(strip_tags(str_replace(['<br/>', '<br>', '<br />'], "\n", $premiumCtaPhonesHtml))));
        $premiumCtaFirstPhone = '';
        foreach (preg_split('/[\r\n,]+/', $premiumCtaPhonesPlain) as $line) {
            $line = trim($line);
            if ($line !== '') {
                $premiumCtaFirstPhone = $line;
                break;
            }
        }
        $premiumCtaWaDigits = preg_replace('/\D+/', '', $premiumCtaFirstPhone) ?? '';
        if ($premiumCtaWaDigits !== '' && strlen($premiumCtaWaDigits) >= 10 && strlen($premiumCtaWaDigits) <= 11 && str_starts_with($premiumCtaWaDigits, '01')) {
            $premiumCtaWaDigits = '20' . substr($premiumCtaWaDigits, 1);
        }
        $premiumCtaWhatsappUrl = $premiumCtaWaDigits !== '' ? 'https://wa.me/' . $premiumCtaWaDigits : null;
    @endphp
    <section class="home-sections premium-home-conversion-banner reveal-up premium-home-strip premium-home-strip--cta" aria-labelledby="premium-home-cta-banner-heading" dir="rtl">
        <div class="premium-home-conversion-banner__particles" aria-hidden="true"></div>
        <div class="premium-home-conversion-banner__rays" aria-hidden="true"></div>
        <div class="premium-home-conversion-banner__glow" aria-hidden="true"></div>
        <div class="container py-35 py-lg-40 position-relative">
            {{-- من md: عمودان جنب بعض؛ موبايل: صورة ثم نص (مرتّبة بـ CSS order) --}}
            <div class="row align-items-center premium-home-conversion-banner__row">
                <div class="col-12 col-md-7 text-right mb-0 mb-md-0 premium-home-conversion-banner__copy">
                    <h2 id="premium-home-cta-banner-heading" class="premium-home-conversion-banner__title mb-15">{{ trans('home.premium_home_cta_banner_title') }}</h2>
                    <p class="premium-home-conversion-banner__hint mb-20 mb-lg-25">{{ trans('home.premium_home_cta_banner_hint') }}</p>
                    <form action="{{ url('/newsletters') }}" method="post" class="premium-home-conversion-banner__form m-0">
                        {{ csrf_field() }}
                        <div class="premium-home-conversion-banner__fields-row">
                            <div class="premium-home-conversion-banner__field">
                                <label class="premium-home-conversion-banner__label sr-only" for="premium-cta-banner-email">{{ trans('home.premium_home_cta_banner_email_label') }}</label>
                                <input id="premium-cta-banner-email" type="email" name="newsletter_email" required autocomplete="email"
                                    class="premium-home-conversion-banner__input w-100"
                                    placeholder="{{ trans('home.premium_home_cta_banner_email_placeholder') }}"
                                    value="{{ old('newsletter_email') }}">
                            </div>
                            <div class="premium-home-conversion-banner__field premium-home-conversion-banner__field--wa">
                                <a href="{{ $premiumCtaWhatsappUrl ?? url('/contact') }}" class="premium-home-conversion-banner__wa-btn w-100 d-inline-flex align-items-center justify-content-center"
                                    target="{{ $premiumCtaWhatsappUrl ? '_blank' : '_self' }}"
                                    @if ($premiumCtaWhatsappUrl) rel="noopener noreferrer" @endif
                                    aria-label="{{ $premiumCtaWhatsappUrl ? trans('home.premium_home_cta_banner_whatsapp_aria') : trans('home.premium_home_cta_banner_whatsapp_fallback_aria') }}">
                                    <span class="premium-home-conversion-banner__wa-icon" aria-hidden="true">
                                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" fill="currentColor" width="20" height="20" focusable="false">
                                            <path d="M380.9 97.1C339 55.1 283.2 32 223.9 32c-122.4 0-222 99.6-222 222 0 39.1 10.2 77.3 29.6 111L0 480l117.7-30.9c32.4 17.7 68.9 27 106.1 27h.1c122.3 0 224.1-99.6 224.1-222 0-59.3-25.2-115-67.1-157zm-157 341.6c-33.2 0-65.7-8.9-94-25.7l-6.7-4-69.8 18.3L72 359.2l-4.4-7c-18.5-29.4-28.2-63.3-28.2-98.2 0-101.7 82.8-184.5 184.6-184.5 49.3 0 95.6 19.2 130.4 54.1 34.8 34.9 56.2 81.2 56.1 130.5 0 101.8-84.9 184.6-186.6 184.6zm101.2-138.2c-5.5-2.8-32.8-16.2-37.9-18-5.1-1.9-8.8-2.8-12.5 2.8-3.7 5.6-14.3 18-17.6 21.8-3.2 3.7-6.5 4.2-12 1.4-32.6-16.3-54-29.1-75.5-66-5.7-9.8 5.7-9.1 16.3-30.3 1.8-3.7.9-6.9-.5-9.7-1.4-2.8-12.5-30.1-17.1-41.2-4.5-10.8-9.1-9.3-12.5-9.5-3.2-.2-6.9-.2-10.6-.2-3.7 0-9.7 1.4-14.8 6.9-5.1 5.6-19.4 19-19.4 46.3 0 27.3 19.9 53.7 22.6 57.4 2.8 3.7 39.1 59.7 94.8 83.8 35.2 15.2 49 16.5 66.6 13.9 10.7-1.6 32.8-13.4 37.4-26.4 4.6-13 4.6-24.1 3.2-26.4-1.3-2.5-5-3.9-10.5-6.6z"/>
                                        </svg>
                                    </span>
                                    <span>{{ $premiumCtaWhatsappUrl ? trans('home.premium_home_cta_banner_whatsapp_btn') : trans('home.premium_home_cta_banner_whatsapp_fallback_btn') }}</span>
                                </a>
                            </div>
                        </div>
                        <div class="premium-home-conversion-banner__actions d-flex flex-wrap align-items-center mt-18">
                            <button type="submit" class="btn premium-home-conversion-banner__btn border-0">{{ trans('home.premium_home_cta_banner_form_submit') }}</button>
                            <a href="{{ url('/classes') }}" class="premium-home-conversion-banner__link-muted font-14">{{ trans('home.premium_home_cta_banner_btn') }}</a>
                        </div>
                        @error('newsletter_email')
                            <div class="text-warning small mt-10">{{ $message }}</div>
                        @enderror
                    </form>
                </div>
                <div class="col-12 col-md-5 text-center mb-20 mb-md-0 premium-home-conversion-banner__art-col">
                    <div class="premium-home-conversion-banner__art">
                        {!! premium_picture_tag([
                            'src' => asset($premiumCtaMediaRel),
                            'alt' => trans('home.premium_home_cta_banner_img_alt'),
                            'class' => 'premium-home-conversion-banner__img img-fluid',
                            'width' => 460,
                            'height' => 420,
                            'loading' => 'lazy',
                            'responsive' => true,
                        ]) !!}
                    </div>
                </div>
            </div>
        </div>
    </section>
@endif
