<?php
declare(strict_types=1);
@ini_set('display_errors', '1');
@error_reporting(E_ALL);
@date_default_timezone_set('UTC');

$vocabularyData = [
    'title' => 'Quranic Vocabulary Master (85% Coverage)',
    'decks' => [
        [
            'name' => 'Deck 1: Core Prepositions & Conjunctions',
            'words' => [
                ['arabic' => "'Alā", 'english' => 'On'],
                ['arabic' => "'An", 'english' => 'About'],
                ['arabic' => 'Bi', 'english' => 'In, with, by'],
                ['arabic' => 'Fī', 'english' => 'In'],
                ['arabic' => 'Ilā', 'english' => 'To'],
                ['arabic' => 'Ka', 'english' => 'Like'],
                ['arabic' => 'Li', 'english' => 'To, for'],
                ['arabic' => 'Maa`', 'english' => 'With'],
                ['arabic' => 'Min', 'english' => 'From'],
                ['arabic' => 'Wa', 'english' => 'And'],
                ['arabic' => 'Fa', 'english' => 'Then, therefore, so'],
                ['arabic' => 'Thumma', 'english' => 'Then'],
                ['arabic' => 'Am', 'english' => 'Or'],
                ['arabic' => 'In', 'english' => 'If, indeed'],
                ['arabic' => 'An', 'english' => 'That'],
                ['arabic' => 'Law', 'english' => 'If']
            ]
        ],
        [
            'name' => 'Deck 2: Pronouns (Detached)',
            'words' => [
                ['arabic' => 'Ana', 'english' => 'I'],
                ['arabic' => 'Nahnu', 'english' => 'We'],
                ['arabic' => 'Anta', 'english' => 'You (m. sing.)'],
                ['arabic' => 'Anti', 'english' => 'You (f. sing.)'],
                ['arabic' => 'Antum', 'english' => 'You all (m. pl.)'],
                ['arabic' => 'Huwa', 'english' => 'He'],
                ['arabic' => 'Hiya', 'english' => 'She'],
                ['arabic' => 'Hum', 'english' => 'They (m. pl.)']
            ]
        ],
    ]
];
$totalWords = array_reduce($vocabularyData['decks'], function ($sum, $deck) {
    return $sum + count($deck['words']);
}, 0);

?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title><?= htmlspecialchars($vocabularyData['title']) ?></title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&family=Lato:wght@400;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
</head>
<body class="bg-light">

<div class="container my-5">
    <div class="card shadow-lg mb-4">
        <div class="card-body text-center p-5">
            <h1 class="card-title display-4 text-warning">
                <i class="bi bi-book-half me-2"></i>
                <?= htmlspecialchars($vocabularyData['title']) ?>
            </h1>
            <p class="card-text text-white-50">
                Total words: <?= $totalWords ?>
            </p>
            <button id="toggle-all" class="btn btn-warning">Collapse All</button>
        </div>
    </div>

    <div class="main-content">
        <?php foreach ($vocabularyData['decks'] as $deck): ?>
            <div class="deck">
                <div class="deck-header">
                    <div class="chevron">
                        <i class="bi bi-chevron-right text-warning"></i>
                    </div>
                    <div class="deck-name">
                        <span class="text-yellow-300 fw-bold"><?= htmlspecialchars($deck['name']) ?></span>
                        <span class="text-yellow-100 small ms-2">(<?= count($deck['words']) ?> words)</span>
                    </div>
                </div>
                <div class="words">
                    <?php foreach ($deck['words'] as $word): ?>
                        <div class="word">
                            <div class="word-connector"></div>
                            <div class="word-content">
                                <span class="text-yellow-400 fw-medium"><?= htmlspecialchars($word['arabic']) ?></span>
                                <span class="text-yellow-100-80 small ms-2">- <?= htmlspecialchars($word['english']) ?></span>
                            </div>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
</div>

<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
</body>
</html>
