@extends('layouts.front.app')

@section('content')
    <div class="container py-3">
        <div class="row justify-content-center text-center">
            <div class="col-12 col-lg-8 py-5">
                <h2 class="h3 fw-bold">ProductAlert is the place to be for top rated product reviews with recommendation such
                    as the right price, latest trend, from the best brands from
                    {{ $country_locale->country_iso == '*' ? 'the whole world' : get_country_name_by_iso($country_locale->country_iso) }}.
                </h2>
            </div>
        </div>
    </div>
    <div class="container-fluid py-4 bg-dark text-light">
        <div class="container">
            <h3 class="h4 fw-bold text-center mb-3">Featured Articles</h3>
            <div class="row g-3 justify-content-center">
                @foreach ($featured_posts as $post)
                    <div class="col-12 col-xl-3">

                        <div class="card shadow-sm" style="height:100%;">
                            <a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
                                class="text-decoration-none">
                                <div class="card-img-top ratio ratio-16x9">
                                    <div class="lqip-loader">
                                        <!-- Use the LQIP image with the appropriate URL -->
                                        <img src="{{ $post->featured_image }}" alt="Photo of {{ $post->name }}">

                                        <!-- Use the final JPEG image with the appropriate URL -->
                                        <img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
                                            alt="Placeholder image of {{ $post->name }}">
                                    </div>

                                </div>
                            </a>

                            <div class="card-body d-flex justify-content-between flex-column">

                                <div class="mb-2">

                                    <p class="card-text fw-bold">
                                        <a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
                                            class="text-decoration-none">{{ $post->title }}</a>
                                    </p>
                                </div>
                                <div>
                                    <p class="card-text mb-0">
                                        <small>in </small>
                                        @foreach ($post->post_categories as $post_category)
                                            <small><a class="text-decoration-none"
                                                    href="{{ route('home.country.category', ['country' => $country_locale->country_iso, 'category' => $post_category->category->slug]) }}">{{ $post_category->category->name }}</a>
                                            </small>
                                            @if (!$loop->last)
                                                ,
                                            @endif
                                        @endforeach
                                        {{-- <small class="text-body-secondary ms-2">3 min read</small> --}}
                                    </p>
                                    <div class="d-flex justify-content-between align-items-center">
                                        <small
                                            class="text-body-secondary">{{ $post->publish_date->format('j F Y') }}</small>
                                        {{-- <small class="text-body-secondary">9 min read</small> --}}
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                @endforeach

            </div>
        </div>
    </div>
    <div class="container-fluid py-4">
        <div class="container">
            <div class="row justify-content-center">
                <div class="col col-md-12 col-lg-12 col-xl-11 col-xxl-9">
                    <h3 class="h4 fw-bold text-center mb-3">What's New in
                        {{ get_country_name_by_iso($country_locale->country_iso) }}</h3>
                    <div class="row g-3">
                        @foreach ($latest_posts as $post)
                            <div class="col-lg-6">

                                <div class="card" style="height:100%;">
                                    <div class="row g-0">
                                        <div class="col-md-5">
                                            <a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
                                                class="text-decoration-none">
                                                <div class="img-fluid rounded-start ratio ratio-16x9">
                                                    <div class="lqip-loader">
                                                        <!-- Use the LQIP image with the appropriate URL -->
                                                        <img src="{{ $post->featured_image }}"
                                                            alt="Photo of {{ $post->name }}">

                                                        <!-- Use the final JPEG image with the appropriate URL -->
                                                        <img class="lqip-frozen" src="{{ $post->featured_image_lqip }}"
                                                            alt="Placeholder image of {{ $post->name }}">
                                                    </div>
                                                </div>
                                            </a>
                                        </div>
                                        <div class="col-md-7">
                                            <div class="card-body d-flex justify-content-between flex-column"
                                                style="height:100%;">
                                                <div>
                                                    <a href="{{ route('home.country.post', ['country' => $country_locale->country_iso, 'post_slug' => $post->slug]) }}"
                                                        class="text-decoration-none">
                                                        <p class="card-title fw-bold">{{ $post->title }}</p>
                                                    </a>
                                                </div>
                                                <div class="d-flex justify-content-between align-items-center">
                                                    <p class="card-text mb-0">
                                                        <small>in </small>
                                                        @foreach ($post->post_categories as $post_category)
                                                            <small><a class="text-decoration-none"
                                                                    href="{{ route('home.country.category', ['country' => $country_locale->country_iso, 'category' => $post_category->category->slug]) }}">{{ $post_category->category->name }}</a>
                                                            </small>
                                                            @if (!$loop->last)
                                                                ,
                                                            @endif
                                                        @endforeach
                                                        {{-- <small class="text-body-secondary ms-2">3 min read</small> --}}
                                                    </p>
                                                    <small
                                                        class="text-body-secondary">{{ $post->publish_date->format('j F Y') }}</small>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach

                    </div>
                    <div class="text-center py-3">
                        <a href="{{ route('home.country.posts', ['country' => $country_locale->country_iso]) }}"
                            class="btn btn-primary">All News & Updates</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
