<?php
/**
 * Snippet: chapter/nav-footer
 * Params: $page (current chapter page)
 */
$prev = $page->prevListed();
$next = $page->nextListed();
?>
<footer class="chapter-footer">

  <?php if ($prev && $prev->template()->name() === 'chapter'): ?>
  <a href="<?= $prev->url() ?>" class="nav-card prev">
    <span class="label">— Previous</span>
    <span class="num-big">CHAPTER <?= str_pad($prev->chapter_number()->value(), 2, '0', STR_PAD_LEFT) ?></span>
    <span class="title"><?= $prev->title()->html() ?></span>
    <span class="arrow">← Back</span>
  </a>
  <?php else: ?>
  <a class="nav-card prev disabled" aria-disabled="true">
    <span class="label">— Previous</span>
    <span class="num-big">— —</span>
    <span class="title">Beginning</span>
    <span class="arrow">↑ Cover</span>
  </a>
  <?php endif ?>

  <?php if ($next && $next->template()->name() === 'chapter'): ?>
  <a href="<?= $next->url() ?>" class="nav-card next">
    <span class="label">Next chapter —</span>
    <span class="num-big">CHAPTER <?= str_pad($next->chapter_number()->value(), 2, '0', STR_PAD_LEFT) ?></span>
    <span class="title"><?= $next->title()->html() ?></span>
    <span class="arrow">Continue →</span>
  </a>
  <?php else: ?>
  <a href="<?= $site->url() ?>" class="nav-card next">
    <span class="label">End of volume —</span>
    <span class="num-big">— —</span>
    <span class="title">Return to Cover</span>
    <span class="arrow">↑ Home</span>
  </a>
  <?php endif ?>

</footer>
