<?php snippet('header') ?>

<main class="game">
  <article class="game__content">
    <!-- Info -->
    <div class="game__info">
      <h1 class="game__title"><?= $page->title() ?></h1>

      <?php if ($page->description()->isNotEmpty()): ?>
        <p class="game__description"><?= $page->description() ?></p>
      <?php endif ?>

      <!-- Rules -->
      <?php if ($page->rules()->isNotEmpty()): ?>
        <div class="game__rules">
          <?= $page->rules()->toBlocks() ?>
        </div>
      <?php endif ?>

      <!-- Status Button -->
      <?php if ($page->game_status()->value() !== 'available'): ?>
        <div class="game__status">
          <span class="btn btn--disabled">
            <?= $page->game_status()->value() === 'coming_soon' ? 'Bientôt disponible' : 'En maintenance' ?>
          </span>
        </div>
      <?php endif ?>
    </div>

    <!-- Game Area -->
    <div class="game__area">
      <?php if ($page->game_status()->value() === 'available'): ?>
        <?php if ($page->is_embedded()->toBool() && $page->play_link()->isNotEmpty()): ?>
          <iframe src="<?= $page->play_link() ?>" class="game__iframe" frameborder="0"></iframe>
        <?php elseif ($page->play_link()->isNotEmpty()): ?>
          <a href="<?= $page->play_link() ?>" class="game__external-link btn btn--large" target="_blank">
            Jouer maintenant
          </a>
        <?php endif ?>

        <?php if ($cover = $page->cover()->toFile()): ?>
          <div class="game__cover">
            <img src="<?= $cover->url() ?>" alt="<?= $page->title() ?>">
          </div>
        <?php endif ?>
      <?php endif ?>
    </div>
  </article>

  <!-- Back Navigation -->
  <nav class="game__nav">
    <a href="<?= $page->parent()->url() ?>" class="game__nav-back">
      &larr; Retour aux jeux
    </a>
  </nav>
</main>

<?php snippet('footer') ?>
