@php
    $defCfg = (isset($premiumHomeDefinitions) && is_array($premiumHomeDefinitions)) ? $premiumHomeDefinitions : [];
    $definitionsResolveMedia = static function (?string $path): string {
        $path = trim(str_replace('\\', '/', (string) ($path ?? '')));
        if ($path === '') {
            return '';
        }
        if (preg_match('#^https?://#i', $path)) {
            return $path;
        }
        if ($path[0] === '/') {
            return url($path);
        }

        return asset(ltrim($path, '/'));
    };

    $accent = trim((string) ($defCfg['accent_color'] ?? ''));
    $premiumDefSectionClass = 'home-sections premium-features-section position-relative reveal-up';
    if ($accent !== '') {
        $premiumDefSectionClass .= ' premium-features-section--admin-accent';
    }
    $premiumDefSectionStyle = $accent !== '' ? '--definitions-accent: '.e($accent).';' : '';

    $premiumDefEyebrow = trim((string) ($defCfg['spotlight_eyebrow'] ?? '')) !== '' ? $defCfg['spotlight_eyebrow'] : trans('home.premium_features_eyebrow');
    $premiumDefSpotTitle = trim((string) ($defCfg['spotlight_title'] ?? '')) !== '' ? $defCfg['spotlight_title'] : trans('home.premium_spotlight_title');
    $premiumDefCtaLabel = trim((string) ($defCfg['spotlight_cta_label'] ?? '')) !== '' ? $defCfg['spotlight_cta_label'] : trans('home.premium_spotlight_cta');
    $premiumDefCtaUrlRaw = trim((string) ($defCfg['spotlight_cta_url'] ?? ''));
    if ($premiumDefCtaUrlRaw === '') {
        $premiumDefCtaHref = url('/classes');
    } elseif (preg_match('#^https?://#i', $premiumDefCtaUrlRaw)) {
        $premiumDefCtaHref = $premiumDefCtaUrlRaw;
    } elseif ($premiumDefCtaUrlRaw[0] === '/') {
        $premiumDefCtaHref = url($premiumDefCtaUrlRaw);
    } else {
        $premiumDefCtaHref = url('/'.ltrim($premiumDefCtaUrlRaw, '/'));
    }

    $premiumDefSpotImgCustom = trim((string) ($defCfg['spotlight_image'] ?? ''));
    $premiumDefSpotImgSrc = $premiumDefSpotImgCustom !== '' ? $definitionsResolveMedia($premiumDefSpotImgCustom) : '';
    $premiumDefSpotFallback = public_path('assets/default/img/montessori-premium/seminar-hero-classroom.jpg');
    if ($premiumDefSpotImgSrc === '' && file_exists($premiumDefSpotFallback)) {
        $premiumDefSpotImgSrc = asset('assets/default/img/montessori-premium/seminar-hero-classroom.jpg');
    }

    $premiumDefVeil = trim((string) ($defCfg['spotlight_veil'] ?? ''));

    $premiumDefCardsRaw = $defCfg['feature_cards'] ?? [];
    if (!is_array($premiumDefCardsRaw)) {
        $premiumDefCardsRaw = [];
    }
    $premiumDefCardsResolved = [];
    foreach ($premiumDefCardsRaw as $c) {
        if (!is_array($c)) {
            continue;
        }
        $ct = trim((string) ($c['title'] ?? ''));
        $cd = trim((string) ($c['description'] ?? ''));
        if ($ct === '' && $cd === '') {
            continue;
        }
        $ctone = mb_strtolower((string) ($c['icon_tone'] ?? 'blue'));
        if (!in_array($ctone, ['blue', 'amber', 'mint', 'rose'], true)) {
            $ctone = 'blue';
        }
        $cicon = trim((string) ($c['icon'] ?? ''));
        if ($cicon === '') {
            $cicon = 'fas fa-star';
        }
        $premiumDefCardsResolved[] = [
            'icon' => $cicon,
            'icon_tone' => $ctone,
            'title' => $ct !== '' ? $ct : '—',
            'description' => $cd,
        ];
    }
    if (count($premiumDefCardsResolved) === 0) {
        $premiumDefCardsResolved = [
            ['icon' => 'fas fa-book', 'icon_tone' => 'blue', 'title' => trans('home.premium_feature_course'), 'description' => trans('home.premium_feature_course_hint')],
            ['icon' => 'fas fa-star', 'icon_tone' => 'amber', 'title' => trans('home.premium_feature_materials'), 'description' => trans('home.premium_feature_materials_hint')],
            ['icon' => 'fas fa-chalkboard-teacher', 'icon_tone' => 'mint', 'title' => trans('home.premium_feature_schools'), 'description' => trans('home.premium_feature_schools_hint')],
            ['icon' => 'fas fa-users', 'icon_tone' => 'rose', 'title' => trans('home.premium_feature_parents'), 'description' => trans('home.premium_feature_parents_hint')],
        ];
    }
@endphp
<section class="{{ $premiumDefSectionClass }}" dir="rtl" aria-labelledby="premium-spotlight-title" @if($premiumDefSectionStyle !== '') style="{{ $premiumDefSectionStyle }}" @endif>
    <svg class="premium-section-curve premium-section-curve--top" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 56" preserveAspectRatio="none" aria-hidden="true">
        <path fill="var(--premium-ivory-soft, #faf8f5)" d="M0 56 V20 Q360 0 720 28 T1440 36 V56 Z"/>
    </svg>
    <div class="container premium-features-section__contain py-35 py-lg-35 mb-0">
        <div class="row align-items-stretch">
            <article class="col-12 col-xl-4 mb-35 mb-xl-0">
                <div class="premium-feature-spotlight h-100">
                    <div class="premium-feature-spotlight__media">
                        @if ($premiumDefSpotImgSrc !== '')
                            <img src="{{ $premiumDefSpotImgSrc }}" alt="" loading="lazy" class="premium-feature-spotlight__bg">
                        @endif
                        <div class="premium-feature-spotlight__veil" @if($premiumDefVeil !== '') style="{{ $premiumDefVeil }}" @endif></div>
                    </div>
                    <div class="premium-feature-spotlight__copy">
                        <p class="premium-features-section__eyebrow">{{ $premiumDefEyebrow }}</p>
                        <h3 id="premium-spotlight-title" class="premium-feature-spotlight__title">{{ $premiumDefSpotTitle }}</h3>
                        <a href="{{ $premiumDefCtaHref }}" class="btn btn-premium-spotlight">{{ $premiumDefCtaLabel }}</a>
                    </div>
                </div>
            </article>
            <div class="col-12 col-xl-8">
                <div class="row justify-content-xl-start">
                    @foreach ($premiumDefCardsResolved as $fc)
                        <div class="col-12 col-md-6 mb-20">
                            <div class="premium-feature-glass h-100">
                                <div class="premium-feature-icon premium-feature-icon--{{ $fc['icon_tone'] }}" aria-hidden="true">
                                    <i class="{{ $fc['icon'] }}"></i>
                                </div>
                                <span class="premium-feature-title">{{ $fc['title'] }}</span>
                                @if ($fc['description'] !== '')
                                    <p class="premium-feature-hint mb-0 mt-10">{{ $fc['description'] }}</p>
                                @endif
                            </div>
                        </div>
                    @endforeach
                </div>
            </div>
        </div>
    </div>
</section>
