@php
/**
* `testimonial-v04` layout.
*
* Base render mirrors html/home-furniture.html §10 (`section-testimonial-v2`):
* 2-per-view swiper, no avatar, col-right nav arrows. Each card: stars +
* author/verified inline + capitalized quote (h5) + br-line + product mini-card.
*
* html/home-fashion-2.html §8 "Testimonial" (lines 4425-4520) is the same card
* with cosmetic modifiers — opt in via knobs:
* card_modifier — extra classes on `.testimonial-v04` (fashion-2 `style-2`);
* `style-2` also tightens card spacing + h6 quote per demo
* container_class — wrapper container (default `container`; fashion-2 `container-full`)
* preview — desktop slides per view (default 2; fashion-2 3)
* view_all_url — when set, the col-right shows a "Read All Reviews" link
* view_all_text — link label (default "Read All Reviews")
* bg_main — 'yes' wraps heading+swiper in `
`
*
* Per-slide product attrs come from shortcode tabs:
* product_image, product_name, product_price (sale), product_old_price (regular), product_url
*/
$autoplay = ($shortcode->autoplay ?? 'yes') === 'yes';
$cardModifier = trim((string) ($shortcode->card_modifier ?? ''));
$isStyle2 = $cardModifier === 'style-2';
$containerClass = trim((string) ($shortcode->container_class ?? '')) ?: 'container';
$preview = max(1, min(4, (int) ($shortcode->preview ?? 2)));
$tablet = $preview >= 3 ? 2 : 2;
$viewAllUrl = trim((string) ($shortcode->view_all_url ?? ''));
$viewAllText = trim((string) ($shortcode->view_all_text ?? '')) ?: __('Read All Reviews');
$hasViewAll = $viewAllUrl !== '';
$useBgMain = ($shortcode->bg_main ?? 'no') === 'yes';
// style-2 uses the demo's tighter spacing scale + h6 quote; base keeps legacy values.
$mbStar = $isStyle2 ? 'mb-12' : 'mb-16';
$mbAuthor = $isStyle2 ? 'mb-20' : 'mb-24';
$mbQuote = $isStyle2 ? 'mb-20' : 'mb-24';
$mbLine = $isStyle2 ? 'mb-20' : 'mb-24';
$quoteClass = $isStyle2 ? 'h6' : 'h5';
@endphp
@if ($useBgMain)
@endif
@if ($shortcode->title)
{!! BaseHelper::clean($shortcode->title) !!}
@endif
@if ($shortcode->subtitle)
{!! BaseHelper::clean($shortcode->subtitle) !!}
@endif
@foreach ($items as $item)
@php
$name = $item['name'] ?? '';
$role = $item['role'] ?? __('Verified Buyer');
$quote = $item['content'] ?? '';
$rating = max(0, min(5, (int) ($item['rating'] ?? 5)));
$prdImg = $item['product_image'] ?? null;
$prdName = $item['product_name'] ?? '';
$prdPrice = $item['product_price'] ?? '';
$prdOld = $item['product_old_price'] ?? '';
$prdUrl = $item['product_url'] ?? '#';
@endphp
@for ($s = 0; $s < $rating; $s++)
@endfor
@if ($name)
{!! BaseHelper::clean($name) !!}
{!! BaseHelper::clean($role) !!}
@endif
@if ($quote)
{!! BaseHelper::clean($quote) !!}
@endif
@if ($prdImg || $prdName)
@if ($prdImg)
{!! RvMedia::image($prdImg, $prdName ?: $name, 'thumb', false, ['width' => 80, 'height' => 80, 'loading' => 'lazy']) !!}
@endif
@endif
@endforeach
@if ($useBgMain)
@endif