<?php
declare(strict_types=1);
/** Библиотека документов: шесть разделов, как на прежнем сайте. */
require_once __DIR__ . '/../includes/layout.php';
require_once __DIR__ . '/../includes/kb.php';

page_header(t('nav_kb'), 'kb');
?>
<section class="hero">
  <h1><?= e(t('kb_title')) ?></h1>
  <p class="lead"><?= e(t('kb_intro')) ?></p>
</section>

<div class="kb-grid">
<?php foreach (kb_sections() as $s):
    $intro = (string)($s['intro_' . current_lang()] ?? '');
    $pub   = (int)$s['published_count'];
    $pend  = (int)$s['pending_count'];
    ?>
  <a class="kb-card" href="/kb-section?s=<?= e($s['code']) ?>" style="--kb-color: <?= e($s['color']) ?>">
    <h2><?= e(ref_name($s)) ?></h2>
    <?php if ($intro !== ''): ?><p><?= e($intro) ?></p><?php endif; ?>
    <p class="kb-count">
      <?= e(t('kb_docs_n', $pub)) ?><?php if ($pend > 0): ?><span class="kb-pending"><?= e(t('kb_pending_n', $pend)) ?></span><?php endif; ?>
    </p>
  </a>
<?php endforeach; ?>
</div>

<p class="muted kb-note"><?= e(t('kb_note')) ?></p>
<?php
page_footer();
