@extends('layouts.app')
@section('title', 'Search: ' . $query . ' | ' . config('app.name'))
@section('robots', 'noindex, follow')
@section('content')
<div class="search-page">
  <div class="search-header">
    <h1 class="search-title">Search results for "<em>{{ $query }}</em>"</h1>
    <p class="search-count">{{ $results->total() }} {{ Str::plural('result', $results->total()) }} found</p>
  </div>
  <form action="{{ route('search') }}" method="GET" class="search-form" role="search">
    <input type="search" name="q" value="{{ $query }}" placeholder="Search The Hindu..." aria-label="Search" required>
    <button type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
  </form>
  @if($results->isEmpty())
  <div class="no-results">
    <p>No results found for "{{ $query }}". Try different keywords.</p>
  </div>
  @else
  <div class="cat-list">
    @foreach($results as $art)
    <article class="cat-item">
      <a href="{{ $art->canonical_url }}" class="cat-item-img">
        <img src="{{ $art->photo_url }}" alt="{{ $art->news_title }}" loading="lazy" width="200" height="130">
      </a>
      <div class="cat-item-body">
        <span class="cat-item-tag">{{ strtoupper($art->category->category_name ?? 'NEWS') }}</span>
        <h3 class="cat-item-title"><a href="{{ $art->canonical_url }}" title="{{ $art->news_title }}">{{ $art->news_title }}</a></h3>
        <p class="cat-item-summary">{{ Str::limit(strip_tags($art->news_content_short), 150) }}</p>
        <div class="cat-item-meta">
          <span>{{ strtoupper($art->author->name ?? 'THE HINDU BUREAU') }}</span>
          @if($art->published_at)<span> · {{ $art->published_at->format('M j, Y') }}</span>@endif
        </div>
      </div>
    </article>
    @endforeach
  </div>
  @if($results->hasPages())
  <div class="hindu-pagination">{{ $results->links('partials.pagination') }}</div>
  @endif
  @endif
</div>
@endsection
