{{--
    Artwork Not Found (contextual) — HTTP 404 or 403
    Shown when:
    - Artwork ID not found at all → HTTP 404
    - Artwork exists but is private/unapproved → HTTP 403 ($isForbidden=true)
    Separate view for permanently deleted → errors/410.blade.php

    Variables:
    $isForbidden      bool              true when private/403
    $trendingArtworks Collection        (max 6)
    $creatorArtworks  Collection        (max 6, optional)
    $creatorUsername  string|null
--}}
@php
    $isForbidden    = $isForbidden ?? false;
    $errorCode      = $isForbidden ? 403 : 404;
    $errorTitle     = $isForbidden ? 'Access Denied' : 'Artwork Not Found';
    $errorMessage   = $isForbidden
        ? 'This artwork is private and not publicly available.'
        : 'This artwork is no longer available, or the link may be broken.';
    $badgeLabel     = $isForbidden ? 'Private Artwork' : 'Artwork Not Found';
@endphp
@extends('errors._layout', [
    'error_code'    => $errorCode,
    'error_title'   => $errorTitle,
    'error_message' => $errorMessage,
])

@section('badge', $badgeLabel)

@section('primary-cta')
@if($isForbidden)
@guest
<a href="/login"
   class="inline-flex items-center gap-2 rounded-xl bg-sky-500 hover:bg-sky-400 text-white font-semibold px-6 py-3 text-sm shadow-lg shadow-sky-900/30 transition-colors">
    <i class="fas fa-sign-in-alt" aria-hidden="true"></i>
    Sign In to View
</a>
@else
<a href="/discover/trending"
   class="inline-flex items-center gap-2 rounded-xl bg-sky-500 hover:bg-sky-400 text-white font-semibold px-6 py-3 text-sm shadow-lg shadow-sky-900/30 transition-colors">
    <i class="fas fa-compass" aria-hidden="true"></i>
    Explore Discover
</a>
@endguest
@else
<a href="/discover/trending"
   class="inline-flex items-center gap-2 rounded-xl bg-sky-500 hover:bg-sky-400 text-white font-semibold px-6 py-3 text-sm shadow-lg shadow-sky-900/30 transition-colors">
    <i class="fas fa-compass" aria-hidden="true"></i>
    Explore Discover
</a>
@endif
@endsection

@section('secondary-ctas')
<a href="/explore/wallpapers" class="rounded-xl border border-white/10 hover:border-white/25 text-white/70 hover:text-white px-4 py-2 text-sm transition-colors">
    Browser Wallpapers
</a>
<a href="/search" class="rounded-xl border border-white/10 hover:border-white/25 text-white/70 hover:text-white px-4 py-2 text-sm transition-colors">
    <i class="fas fa-search mr-1.5" aria-hidden="true"></i> Search
</a>
@endsection

@section('recovery')

{{-- Creator's other artworks (if we have a hint about the creator) --}}
@if(isset($creatorArtworks) && $creatorArtworks->count())
<div class="mb-12">
    <h2 class="text-sm font-semibold text-white/40 uppercase tracking-widest mb-4">
        More from this Creator
    </h2>
    <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">
        @foreach($creatorArtworks->take(6) as $artwork)
            @include('errors._artwork-card', ['artwork' => $artwork])
        @endforeach
    </div>
    @if(isset($creatorUsername))
    <div class="mt-3">
        <a href="/@{{ $creatorUsername }}" class="text-xs text-sky-400 hover:text-sky-300 transition-colors">
            View full gallery →
        </a>
    </div>
    @endif
</div>
@endif

{{-- Trending artworks --}}
@if(isset($trendingArtworks) && $trendingArtworks->count())
<div>
    <h2 class="text-sm font-semibold text-white/40 uppercase tracking-widest mb-4">Trending Wallpapers</h2>
    <div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3">
        @foreach($trendingArtworks->take(6) as $artwork)
            @include('errors._artwork-card', ['artwork' => $artwork])
        @endforeach
    </div>
</div>
@endif

@endsection
