@php($pageSections = $page->sections ?? collect()) @if($pageSections->isNotEmpty())
@foreach($pageSections as $section) @continue(!$section->is_enabled) @php($data = is_array($section->data) ? $section->data : []) @switch($section->type) @case('Hero') @php($heroTone = $data['tone'] ?? 'forest') @php($heroDark = $heroTone === 'forest')
@if(!empty($data['eyebrow']))

{{ $data['eyebrow'] }}

@endif @if(!empty($data['heading']))

{{ $data['heading'] }}

@endif @if(!empty($data['body']))

{{ $data['body'] }}

@endif @php($heroLinks = [['label'=>$data['primaryLabel']??'','url'=>$data['primaryUrl']??'','primary'=>true],['label'=>$data['secondaryLabel']??'','url'=>$data['secondaryUrl']??'','primary'=>false]]) @if(collect($heroLinks)->contains(fn($link)=>filled($link['label']) && filled($link['url'])))
@foreach($heroLinks as $link) @php($heroExternal = str_starts_with(strtolower((string)$link['url']), 'https://') && filter_var($link['url'], FILTER_VALIDATE_URL)) @php($heroInternal = str_starts_with((string)$link['url'], '/') && !str_starts_with((string)$link['url'], '//')) @if(filled($link['label']) && ($heroExternal || $heroInternal)) {{ $link['label'] }} @endif @endforeach
@endif
@break @case('Heading') @php($level = in_array($data['level'] ?? 'h2', ['h2','h3','h4'], true) ? $data['level'] : 'h2')
@if(!empty($data['eyebrow']))

{{ $data['eyebrow'] }}

@endif @if(!empty($data['heading'])) @if($level === 'h2')

{{ $data['heading'] }}

@elseif($level === 'h3')

{{ $data['heading'] }}

@else

{{ $data['heading'] }}

@endif @endif
@break @case('RichText') @php($safeBody = app(\App\Services\PageBuilderService::class)->sanitizeRichText($data['body'] ?? ''))
{!! $safeBody !!}
@break @case('Image') @php($imageSrc = trim((string)($data['src'] ?? ''))) @php($imageSafe = (str_starts_with($imageSrc, '/') && !str_starts_with($imageSrc, '//')) || (str_starts_with(strtolower($imageSrc), 'https://') && filter_var($imageSrc, FILTER_VALIDATE_URL))) @if($imageSafe && !empty($data['alt'])) @php($imageWidth = $data['width'] ?? 'full') @php($imageAspect = $data['aspect'] ?? 'landscape')
{{ $data['alt'] }} @if(!empty($data['caption']))
{{ $data['caption'] }}
@endif
@endif @break @case('ImageText') @php($itSrc = trim((string)($data['src'] ?? ''))) @php($itSafe = (str_starts_with($itSrc, '/') && !str_starts_with($itSrc, '//')) || (str_starts_with(strtolower($itSrc), 'https://') && filter_var($itSrc, FILTER_VALIDATE_URL))) @php($itBody = app(\App\Services\PageBuilderService::class)->sanitizeRichText($data['body'] ?? ''))
@if(($data['imageSide'] ?? 'left') === 'left' && $itSafe && !empty($data['alt'])){{ $data['alt'] }}@endif
@if(!empty($data['eyebrow']))

{{ $data['eyebrow'] }}

@endif @if(!empty($data['heading']))

{{ $data['heading'] }}

@endif @if($itBody !== '')
{!! $itBody !!}
@endif @php($itUrl = trim((string)($data['buttonUrl'] ?? ''))) @php($itExternal = str_starts_with(strtolower($itUrl), 'https://') && filter_var($itUrl, FILTER_VALIDATE_URL)) @php($itInternal = str_starts_with($itUrl, '/') && !str_starts_with($itUrl, '//')) @if(!empty($data['buttonLabel']) && ($itExternal || $itInternal)){{ $data['buttonLabel'] }}@endif
@if(($data['imageSide'] ?? 'left') === 'right' && $itSafe && !empty($data['alt'])){{ $data['alt'] }}@endif
@break @case('Columns') @php($leftBody = app(\App\Services\PageBuilderService::class)->sanitizeRichText($data['leftBody'] ?? '')) @php($rightBody = app(\App\Services\PageBuilderService::class)->sanitizeRichText($data['rightBody'] ?? ''))
@if(!empty($data['leftHeading']))

{{ $data['leftHeading'] }}

@endif
{!! $leftBody !!}
@if(!empty($data['rightHeading']))

{{ $data['rightHeading'] }}

@endif
{!! $rightBody !!}
@break @case('Cards') @php($cardColumns = in_array((string)($data['columns'] ?? '3'), ['2','3','4'], true) ? (string)$data['columns'] : '3')
@if(!empty($data['heading']))

{{ $data['heading'] }}

@endif @if(!empty($data['intro']))

{{ $data['intro'] }}

@endif
@foreach(($data['items'] ?? []) as $card)
@if(!empty($card['title']))

{{ $card['title'] }}

@endif @if(!empty($card['body']))

{{ $card['body'] }}

@endif @php($cardUrl = trim((string)($card['url'] ?? ''))) @php($cardExternal = str_starts_with(strtolower($cardUrl), 'https://') && filter_var($cardUrl, FILTER_VALIDATE_URL)) @php($cardInternal = str_starts_with($cardUrl, '/') && !str_starts_with($cardUrl, '//')) @if(!empty($card['linkLabel']) && ($cardExternal || $cardInternal)){{ $card['linkLabel'] }} →@endif
@endforeach
@break @case('Stats') @php($statTone = $data['tone'] ?? 'cream') @php($statItems = collect($data['items'] ?? [])->take(4)) @if($statItems->isNotEmpty())
@foreach($statItems as $stat)
{{ $stat['value'] ?? '' }}{{ $stat['label'] ?? '' }}
@endforeach
@endif @break @case('Quote') @if(!empty($data['quote']))
“{{ $data['quote'] }}” @if(!empty($data['attribution']) || !empty($data['source']))
— {{ $data['attribution'] ?? '' }}@if(!empty($data['attribution']) && !empty($data['source'])), @endif{{ $data['source'] ?? '' }}
@endif
@endif @break @case('FaqList')
@if(!empty($data['heading']))

{{ $data['heading'] }}

@endif
@foreach(($data['items'] ?? []) as $faq)
{{ $faq['question'] ?? '' }} @if(!empty($faq['answer']))

{{ $faq['answer'] }}

@endif
@endforeach
@break @case('Video') @php($embedUrl = trim((string)($data['embedUrl'] ?? ''))) @php($safeEmbed = str_starts_with($embedUrl, 'https://www.youtube-nocookie.com/embed/') || str_starts_with($embedUrl, 'https://player.vimeo.com/video/')) @if($safeEmbed)
@if(!empty($data['caption']))
{{ $data['caption'] }}
@endif
@endif @break @case('Callout') @php($safeBody = app(\App\Services\PageBuilderService::class)->sanitizeRichText($data['body'] ?? '')) @break @case('Action') @php($actionUrl = trim((string) ($data['url'] ?? ''))) @php($external = str_starts_with(strtolower($actionUrl), 'https://') && filter_var($actionUrl, FILTER_VALIDATE_URL)) @php($internal = str_starts_with($actionUrl, '/') && !str_starts_with($actionUrl, '//')) @if(!empty($data['label']) && ($internal || $external))
{{ $data['label'] }}@if($external) ↗@endif
@endif @break @case('Divider') @php($spacing = $data['spacing'] ?? 'normal')
@break @endswitch @endforeach
@endif