<?php ob_start(); ?>

<section class="gallery-section">
    <div class="container">
        <?php if ($system_page['show_title'] ?? 1): ?>
        <h1 class="section-title"><?= e($system_page['title'] ?? $page_title ?? 'Gallery') ?></h1>
        <?php endif; ?>

        <?php if (!empty($system_page['content'])): ?>
        <div class="page-content module-intro"><?= $system_page['content'] ?></div>
        <?php endif; ?>

        <?php if (empty($albums)): ?>
        <p class="text-muted">No albums found.</p>
        <?php else: ?>
        <div class="gallery-grid">
            <?php foreach ($albums as $album): ?>
            <a href="/gallery/<?= e($album['slug']) ?>" class="gallery-card">
                <?php if (!empty($album['cover_image'])): ?>
                <?= picture_tag($album['cover_image'], $album['title'], 'gallery-card-image', true) ?>
                <?php else: ?>
                <div class="gallery-card-placeholder"></div>
                <?php endif; ?>
                <div class="gallery-card-info">
                    <h3><?= e($album['title']) ?></h3>
                    <?php if (!empty($album['description'])): ?>
                    <p><?= e(str_truncate($album['description'], 100)) ?></p>
                    <?php endif; ?>
                </div>
            </a>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
    </div>
</section>

<?php $content = ob_get_clean(); include __DIR__ . '/layout.php'; ?>
