<?php
declare(strict_types=1);

/**
 * @var \App\View\AppView $this
 * @var \Cake\Collection\CollectionInterface<\App\Model\Entity\Teacher> $teachers
 */
$teacherList = $teachers->toList();
?>
<?php $this->assign('title', 'Book a class · CandleCraft Academy'); ?>

<section class="cc-booking-wrap">
    <div class="cc-booking-head cc-reveal">
        <div class="cc-eyebrow">Book a class</div>
        <h1 style="margin-top: 14px;">Pick a teacher to see open times.</h1>
        <p>Every class is 90 minutes, 1-on-1, in our Melbourne studio. Pick someone whose work you like — or just pick the next open slot.</p>
    </div>

    <div class="cc-steps-bar">
        <div class="cc-step-pill is-on"><span class="cc-step-pill__num">1</span> Pick a teacher</div>
        <div class="cc-step-pill"><span class="cc-step-pill__num">2</span> Pick a time</div>
        <div class="cc-step-pill"><span class="cc-step-pill__num">3</span> Pay & confirm</div>
    </div>

    <div class="cc-teacher-picker">
        <?php foreach ($teacherList as $i => $t):
            $href = $this->Url->build(['_name' => 'booking_teacher', 'slug' => $t->slug]);
        ?>
            <a class="cc-teacher cc-reveal" href="<?= h($href) ?>" style="--cc-reveal-delay: <?= $i * 80 ?>ms; cursor: pointer;">
                <div class="cc-teacher__photo">
                    <?php if (!empty($t->photo_path)): ?>
                        <?= $this->Html->image($t->photo_path, ['alt' => $t->full_name, 'loading' => 'lazy']) ?>
                    <?php else: ?>
                        <div class="cc-teacher__photo-fallback"><?= h($t->getInitials()) ?></div>
                    <?php endif; ?>
                </div>
                <div class="cc-teacher__body">
                    <div class="cc-teacher__name"><?= h($t->full_name) ?></div>
                    <div class="cc-teacher__role"><?= h($t->role) ?></div>
                    <p class="cc-teacher__bio"><?= h($t->bio) ?></p>
                    <div class="cc-teacher__tags">
                        <?php foreach (array_slice($t->getSpecialtyList(), 0, 3) as $tag): ?>
                            <span class="cc-chip"><?= h($tag) ?></span>
                        <?php endforeach; ?>
                    </div>
                    <div style="margin-top: 14px; font-weight: 700; font-size: 15px;">
                        From A$<?= h($t->getHourlyDollars()) ?>
                        <span class="cc-muted" style="font-weight: 500; font-size: 13px;">/ class</span>
                    </div>
                </div>
            </a>
        <?php endforeach; ?>
    </div>
</section>
