<!-- ================================================================= -->
            <!-- COUNTDOWN TO OUR SPECIAL DAY                                       -->
            <!-- ================================================================= -->
            <?php 
                $countdownTargetStr = null;
                $targetEventName = 'Special Day';

                // Priority 1: Primary Ceremony (marked is_primary = 1)
                foreach ($events as $evt) {
                    if (!empty($evt['is_primary'])) {
                        $countdownTargetStr = $evt['event_date'] ?? null;
                        $targetEventName = $evt['event_name'] ?? 'Primary Ceremony';
                        break;
                    }
                }

                // Priority 2: Holy Matrimony / Pemberkatan / Akad
                if (!$countdownTargetStr) {
                    foreach ($events as $evt) {
                        $evtNameLower = strtolower($evt['event_name'] ?? '');
                        if (strpos($evtNameLower, 'holy matrimony') !== false || strpos($evtNameLower, 'pemberkatan') !== false || strpos($evtNameLower, 'akad') !== false) {
                            $countdownTargetStr = $evt['event_date'] ?? null;
                            $targetEventName = $evt['event_name'];
                            break;
                        }
                    }
                }

                // Priority 3: Reception / Resepsi
                if (!$countdownTargetStr) {
                    foreach ($events as $evt) {
                        $evtNameLower = strtolower($evt['event_name'] ?? '');
                        if (strpos($evtNameLower, 'reception') !== false || strpos($evtNameLower, 'resepsi') !== false) {
                            $countdownTargetStr = $evt['event_date'] ?? null;
                            $targetEventName = $evt['event_name'];
                            break;
                        }
                    }
                }

                // Priority 4: Earliest ceremony date
                if (!$countdownTargetStr && !empty($events)) {
                    $countdownTargetStr = $events[0]['event_date'] ?? null;
                    $targetEventName = $events[0]['event_name'] ?? 'Special Day';
                }

                // Priority 5: Fallback to workspace wedding date
                if (!$countdownTargetStr) {
                    $countdownTargetStr = $weddingDateStr;
                }

                $countdownTargetISO = (new \DateTime($countdownTargetStr))->format('c');
            ?>
            <section class="py-16 md:py-20 lg:py-24 px-6 md:px-12 text-center space-y-6 border-b <?= $style['borderColor'] ?>">
                <?php
    $headerClass = 'space-y-2';
    $headerEmoji = '❤️';
    $headerTitle = 'Counting Down to Our Special Day';
    require __DIR__ . '/../partials/section_header.php';
    unset($headerClass, $headerEmoji, $headerEmojiClass, $headerTitle);
?>

                <!-- Active Countdown Timer Container -->
                <div id="countdown-active-box" class="grid grid-cols-2 sm:grid-cols-4 gap-4 max-w-lg mx-auto text-center pt-2">
                    <div class="<?= $style['cardBg'] ?> border <?= $style['borderColor'] ?> shadow-sm p-4 rounded-3xl space-y-1">
                        <span id="cd-days" class="block text-3xl sm:text-4xl font-bold <?= $style['accent'] ?> font-mono">00</span>
                        <span class="text-xs font-semibold uppercase tracking-wider text-slate-400">Days</span>
                    </div>
                    <div class="<?= $style['cardBg'] ?> border <?= $style['borderColor'] ?> shadow-sm p-4 rounded-3xl space-y-1">
                        <span id="cd-hours" class="block text-3xl sm:text-4xl font-bold <?= $style['accent'] ?> font-mono">00</span>
                        <span class="text-xs font-semibold uppercase tracking-wider text-slate-400">Hours</span>
                    </div>
                    <div class="<?= $style['cardBg'] ?> border <?= $style['borderColor'] ?> shadow-sm p-4 rounded-3xl space-y-1">
                        <span id="cd-mins" class="block text-3xl sm:text-4xl font-bold <?= $style['accent'] ?> font-mono">00</span>
                        <span class="text-xs font-semibold uppercase tracking-wider text-slate-400">Minutes</span>
                    </div>
                    <div class="<?= $style['cardBg'] ?> border <?= $style['borderColor'] ?> shadow-sm p-4 rounded-3xl space-y-1">
                        <span id="cd-secs" class="block text-3xl sm:text-4xl font-bold <?= $style['accent'] ?> font-mono">00</span>
                        <span class="text-xs font-semibold uppercase tracking-wider text-slate-400">Seconds</span>
                    </div>
                </div>

                <!-- Arrival Message Box (Hidden until timer reaches 0) -->
                <div id="countdown-arrived-box" class="hidden <?= $style['accentBg'] ?> border border-amber-200 text-amber-800 rounded-3xl p-6 max-w-lg mx-auto text-center space-y-2">
                    <span class="text-3xl">💍</span>
                    <h3 class="text-xl font-bold font-serif-fancy">Today is Our Wedding Day ❤️</h3>
                    <p class="text-xs text-amber-700">Our special day has arrived. We cannot wait to celebrate with you!</p>
                </div>
            </section>
