<?php snippet('html-head', [
    'pageTitle' => $site->title()->value() . ' — Cover',
    'extraCss'  => ['assets/css/home.css'],
]) ?>

<body data-screen-label="00 Cover">

<?php snippet('effects') ?>
<?php snippet('header') ?>

<!-- ===== Hero ===== -->
<section class="cover-hero">
  <div class="cover-bg">
    <svg class="brush" viewBox="0 0 1200 220" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg">
      <defs>
        <filter id="rough">
          <feTurbulence type="fractalNoise" baseFrequency="0.02" numOctaves="3" seed="2"/>
          <feDisplacementMap in="SourceGraphic" scale="14"/>
        </filter>
      </defs>
      <path d="M-20 110 Q 200 60, 420 100 T 820 90 Q 1000 80, 1240 130" stroke="#b91c1c" stroke-width="3" fill="none" opacity="0.6" filter="url(#rough)"/>
      <path d="M-20 130 Q 280 180, 580 120 T 1240 150" stroke="#b91c1c" stroke-width="1.5" fill="none" opacity="0.4" filter="url(#rough)"/>
    </svg>
  </div>

  <div class="cover-numerals">
    <span>I</span>
    <span>IV</span>
  </div>

  <div class="cover-content">
    <div class="cover-titleblock">
      <div class="cover-eyebrow"><?= $page->eyebrow()->html() ?></div>
      <h1 class="cover-title">
        <?= $page->title()->html() ?>
        <em><?= $page->title_em()->html() ?></em>
      </h1>
      <div class="cover-tagline"><?= $page->tagline() ?></div>
      <div class="cover-meta">
        <span><span class="pip">●</span> <?= $page->chapters_count()->value() ?> Chapters</span>
        <span><?= $page->read_time()->html() ?></span>
        <span><?= $page->genre()->html() ?></span>
      </div>
    </div>

    <?php $firstChapter = $site->children()->listed()->filterBy('template', 'chapter')->first() ?>
    <div class="cover-bottom">
      <?php if ($firstChapter): ?>
      <a href="<?= $firstChapter->url() ?>" class="cover-cta">
        <span><?= $page->cta_label()->or('Begin descent')->html() ?></span>
        <span class="arr">→</span>
      </a>
      <?php endif ?>
      <div class="cover-stamp"><?= $page->stamp_text()->html() ?></div>
      <?php if ($page->content_notice()->isNotEmpty()): ?>
      <div class="cover-warning">
        <span class="label">Content notice</span>
        <?= nl2br($page->content_notice()->html()) ?>
      </div>
      <?php endif ?>
    </div>
  </div>
</section>

<!-- ===== Chapter index ===== -->
<section class="index-section">
  <div class="index-header">
    <h2 class="reveal"><?= $page->index_heading()->html() ?></h2>
    <div class="reveal text"><?= $page->index_description() ?></div>
  </div>

  <ol class="index-list">
    <?php
    $chapters = $site->index()->filterBy('template', 'chapter')->sortBy('chapter_number', 'asc');
    foreach ($chapters as $chapter):
    ?>
    <li class="reveal">
      <a href="<?= $chapter->url() ?>">
        <span class="index-num">CH <?= str_pad($chapter->chapter_number()->value(), 2, '0', STR_PAD_LEFT) ?></span>
        <span class="index-title"><?= $chapter->title()->html() ?></span>
        <span class="index-meta"><?= $chapter->read_time()->html() ?> · Pinned scroll</span>
        <span class="index-arrow">READ →</span>
      </a>
    </li>
    <?php endforeach ?>
  </ol>
</section>

<!-- ===== Footer ===== -->
<footer class="cover-footer">
  <span><?= $page->footer_left()->html() ?></span>
  <span class="center">●</span>
  <span class="right"><?= $page->footer_right()->html() ?></span>
</footer>

<?php snippet('menu', ['currentPage' => $page]) ?>
<?php snippet('scripts') ?>

</body>
</html>
