<?php
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/includes/db.php';
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/functions_tags.php';
require_once __DIR__ . '/includes/layout.php';

$tags = getPopularTags(100);
renderHeader('태그 탐색', 'tags');
?>
<div class="tags-page">
    <div class="page-title-section">
        <h1 class="page-main-title">태그 탐색</h1>
        <p class="page-subtitle">드라이브, 운동, 밤에 듣기처럼 내 음악을 상황과 분위기로 찾아보세요.</p>
    </div>
    <?php if (empty($tags)): ?>
        <section class="empty-list-state">
            <i class="fa-solid fa-tags"></i>
            <h2>아직 등록된 태그가 없습니다</h2>
            <p>곡 상세 화면에서 태그를 추가하면 이곳에서 모아볼 수 있습니다.</p>
        </section>
    <?php else: ?>
        <div class="tag-cloud-grid">
            <?php foreach ($tags as $tag): ?>
                <a class="tag-cloud-card" href="tag.php?id=<?php echo h($tag['id']); ?>">
                    <strong>#<?php echo h($tag['name']); ?></strong>
                    <span><?php echo number_format((int)$tag['song_count']); ?>곡</span>
                </a>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
</div>
<?php renderFooter(); ?>
