$query,
'language_filter' => $language,
]);
$pageCopy = [
'en' => [
'meta_title' => 'Cinematic Digital Library',
'meta_description' => 'Explore a bespoke digital library with an editorial catalog, immersive discovery panels, and bilingual browsing for public documents.',
'hero_eyebrow' => 'Cinematic editorial library',
'hero_title' => 'A digital archive staged like a premium reading room.',
'hero_copy' => 'Browse the public collection inside a more expressive library shell: dark graphite atmosphere, warm archival surfaces, and faster discovery across English and Arabic titles.',
'browse_catalog' => 'Enter the catalog',
'add_documents' => 'Open Admin Studio',
'hero_stat_public' => 'public works on display',
'hero_stat_private' => 'private works in reserve',
'hero_stat_summaries' => 'AI summaries prepared',
'curator_kicker' => 'Curator note',
'curator_title' => 'Designed for a modern archive, not a generic dashboard.',
'curator_copy' => 'This first theme pass turns the library into a more memorable public-facing experience while keeping the structure fast, readable, and ready for the document pages next.',
'curator_name' => 'Editorial Library Mode',
'curator_role' => 'Graphite base · ivory surfaces · cyan and amber glow',
'snapshot_kicker' => 'Shelf spotlight',
'snapshot_title' => 'What now feels different',
'snapshot_badge' => 'Bespoke theme',
'public_titles' => 'Public titles',
'private_titles' => 'Private titles',
'ai_summaries' => 'AI summaries',
'snapshot_item_1' => 'Shared public pages inherit the new cinematic shell automatically',
'snapshot_item_2' => 'Discovery controls now sit in a more premium editorial layout',
'snapshot_item_3' => 'The visual system is ready to extend into document and profile pages next',
'discovery_kicker' => 'Discovery desk',
'discovery_title' => 'Search the active collection',
'keyword' => 'Keyword',
'keyword_placeholder' => 'Title, author, tag, or excerpt',
'language_filter' => 'Content language',
'all_shelves' => 'All shelves',
'filter' => 'Refine',
'rules_kicker' => 'Reading room rules',
'rules_title' => 'Public and private shelves remain clearly separated.',
'rules_copy' => 'Only public works appear in this catalog. Private items stay reserved for the admin workspace, so the public stage remains intentional and curated.',
'rules_link' => 'Review publishing controls',
'palette_title' => 'Theme palette',
'palette_copy' => 'Graphite depth, archival ivory cards, luminous cyan highlights, and warm amber contrast create a premium “digital archive” mood.',
'catalog_kicker' => 'Public collection',
'catalog_title' => 'Available titles on stage',
'catalog_copy' => 'A cleaner one-language-per-view catalog with stronger visual hierarchy and a more collectible feel.',
'result_singular' => 'result',
'result_plural' => 'results',
'empty_title' => 'No public documents yet',
'empty_copy' => 'Upload your first Arabic or English document from the Admin Studio to turn this stage into a browsable library.',
'open_admin' => 'Open Admin Studio',
'no_cover' => 'No cover',
'untitled' => 'Untitled document',
'cover_alt' => 'Cover image for',
'author' => 'Author',
'views' => 'Views',
'tags' => 'Tags',
'author_fallback' => 'Not set',
'open_reader' => 'Open reader →',
'workflow_kicker' => 'Reader journey',
'workflow_title' => 'How the experience flows',
'workflow_item_1' => 'An admin uploads a document and decides whether it belongs on the public stage or in private reserve.',
'workflow_item_2' => 'Readers discover public titles from the catalog, then open the detail page and immersive reader.',
'workflow_item_3' => 'Language, summaries, and activity tracking stay aligned with the current browsing context.',
'recent_kicker' => 'Fresh arrivals',
'recent_title' => 'Latest public additions',
'manage_shelf' => 'Manage the shelf',
'unknown_author' => 'Unknown author',
],
'ar' => [
'meta_title' => 'مكتبة رقمية سينمائية',
'meta_description' => 'استكشف مكتبة رقمية بتصميم مخصص مع فهرس تحريري ولوحات اكتشاف غامرة وتصفح ثنائي اللغة للمستندات العامة.',
'hero_eyebrow' => 'مكتبة تحريرية سينمائية',
'hero_title' => 'أرشيف رقمي بواجهة تشبه قاعة قراءة فاخرة.',
'hero_copy' => 'تصفح المجموعة العامة داخل هوية بصرية أكثر تميزاً: أجواء جرافيت داكنة، وأسِطح أرشيفية دافئة، واكتشاف أسرع للعناوين العربية والإنجليزية.',
'browse_catalog' => 'ادخل إلى الفهرس',
'add_documents' => 'افتح مساحة الإدارة',
'hero_stat_public' => 'أعمال عامة معروضة',
'hero_stat_private' => 'أعمال خاصة محفوظة',
'hero_stat_summaries' => 'ملخصات ذكاء اصطناعي جاهزة',
'curator_kicker' => 'ملاحظة قيّمة',
'curator_title' => 'التصميم الآن أقرب إلى أرشيف حديث منه إلى لوحة تقليدية.',
'curator_copy' => 'هذا التحديث الأول يحول المكتبة إلى تجربة عامة أكثر تميزاً مع الحفاظ على السرعة والوضوح والاستعداد لتوسيع النمط إلى صفحات المستندات والملف الشخصي لاحقاً.',
'curator_name' => 'وضع المكتبة التحريرية',
'curator_role' => 'قاعدة جرافيتية · أسطح عاجية · توهج سماوي وعنّابي دافئ',
'snapshot_kicker' => 'واجهة الرف',
'snapshot_title' => 'ما الذي أصبح مختلفاً الآن',
'snapshot_badge' => 'هوية مخصصة',
'public_titles' => 'العناوين العامة',
'private_titles' => 'العناوين الخاصة',
'ai_summaries' => 'ملخصات الذكاء الاصطناعي',
'snapshot_item_1' => 'جميع الصفحات العامة ترث الآن الغلاف السينمائي الجديد تلقائياً',
'snapshot_item_2' => 'أدوات الاكتشاف أصبحت داخل تخطيط تحريري أكثر فخامة',
'snapshot_item_3' => 'النظام البصري أصبح جاهزاً لتمديده إلى صفحات المستند والملف الشخصي لاحقاً',
'discovery_kicker' => 'مكتب الاكتشاف',
'discovery_title' => 'ابحث في المجموعة النشطة',
'keyword' => 'الكلمة المفتاحية',
'keyword_placeholder' => 'العنوان أو المؤلف أو الوسوم أو المقتطف',
'language_filter' => 'لغة المحتوى',
'all_shelves' => 'كل الرفوف',
'filter' => 'تنقيح',
'rules_kicker' => 'قواعد قاعة القراءة',
'rules_title' => 'يبقى الفصل واضحاً بين الرف العام والرف الخاص.',
'rules_copy' => 'لا تظهر هنا إلا الأعمال العامة. أما العناصر الخاصة فتبقى محفوظة داخل مساحة الإدارة حتى يظل المشهد العام مقصوداً ومنسقاً.',
'rules_link' => 'راجع ضوابط النشر',
'palette_title' => 'لوحة الألوان',
'palette_copy' => 'عمق جرافيتي، وبطاقات عاجية أرشيفية، ولمسات سماوية مضيئة، وتباين كهرماني دافئ يمنح المكتبة مزاج أرشيف رقمي فاخر.',
'catalog_kicker' => 'المجموعة العامة',
'catalog_title' => 'العناوين المتاحة على الواجهة',
'catalog_copy' => 'فهرس أوضح بلغة واجهة واحدة في كل مرة مع هرمية بصرية أقوى وطابع أكثر قابلية للاقتناء.',
'result_singular' => 'نتيجة',
'result_plural' => 'نتائج',
'empty_title' => 'لا توجد مستندات عامة بعد',
'empty_copy' => 'ارفع أول مستند عربي أو إنجليزي من مساحة الإدارة لتحويل هذه الواجهة إلى مكتبة قابلة للتصفح.',
'open_admin' => 'افتح مساحة الإدارة',
'no_cover' => 'بدون غلاف',
'untitled' => 'مستند بدون عنوان',
'cover_alt' => 'صورة الغلاف لـ',
'author' => 'المؤلف',
'views' => 'المشاهدات',
'tags' => 'الوسوم',
'author_fallback' => 'غير محدد',
'open_reader' => 'فتح القارئ ←',
'workflow_kicker' => 'رحلة القارئ',
'workflow_title' => 'كيف تتدفق التجربة',
'workflow_item_1' => 'يرفع المشرف مستنداً ويقرر ما إذا كان سيظهر على الواجهة العامة أو يبقى محفوظاً بشكل خاص.',
'workflow_item_2' => 'يكتشف القراء العناوين العامة من الفهرس ثم يفتحون صفحة التفاصيل والقارئ الغامر.',
'workflow_item_3' => 'تظل اللغة والملخصات وتتبع النشاط متوافقة مع سياق التصفح الحالي.',
'recent_kicker' => 'وصل حديثاً',
'recent_title' => 'أحدث الإضافات العامة',
'manage_shelf' => 'إدارة الرف',
'unknown_author' => 'مؤلف غير معروف',
],
][$lang];
$page = isset($_GET['page']) ? max(1, (int) $_GET['page']) : 1;
$limit = 12;
$offset = ($page - 1) * $limit;
$result = library_fetch_documents_paginated(true, ['q' => $query, 'language' => $language], $limit, $offset);
$documents = $result['data'];
$totalDocuments = $result['total'];
$totalPages = (int) ceil($totalDocuments / $limit);
$metrics = library_catalog_metrics();
$recentDocuments = library_recent_documents(3, true);
library_render_header(
$pageCopy['meta_title'],
$pageCopy['meta_description'],
'catalog'
);
?>