<?php
/**
 * Template Name: Software Launch Page
 * 
 * Full landing page template for software product launches.
 * All content is editable via ACF fields.
 * 
 * @package SoftwareLaunchTheme
 */

get_header();

// Get all field values
$countdown_bar_text = get_field('countdown_bar_text') ?: '🔥 LAUNCH SPECIAL: $37 price expires in';
$countdown_bar_cta = get_field('countdown_bar_cta') ?: 'GET INSTANT ACCESS →';
$countdown_bar_cta_url = get_field('countdown_bar_cta_url') ?: '#pricing';

// Hero
$eyebrow_text = get_field('eyebrow_text') ?: 'NEW FOR 2026';
$headline_white = get_field('headline_white');
$headline_accent = get_field('headline_accent');
$subheadline = get_field('subheadline');
$video_url = get_field('video_url');
$video_poster = get_field('video_poster');
$hero_cta_text = get_field('hero_cta_text') ?: 'YES! GIVE ME INSTANT ACCESS →';
$hero_cta_url = get_field('hero_cta_url') ?: '#pricing';
$trust_badges = get_field('trust_badges');

// Problem
$problem_intro = get_field('problem_intro') ?: "You're working harder than ever, but...";
$pain_points = get_field('pain_points');
$problem_transition = get_field('problem_transition') ?: "Sound familiar? There's a better way.";

// Solution
$product_name = get_field('product_name') ?: 'Product Name';
$product_image = get_field('product_image');
$solution_tagline = get_field('solution_tagline');
$solution_benefits = get_field('solution_benefits');

// Social Proof
$stats = get_field('stats');
$authority_quote = get_field('authority_quote');
$authority_name = get_field('authority_name');
$authority_title = get_field('authority_title');

// Features
$features_headline = get_field('features_headline') ?: 'EVERYTHING YOU GET INSIDE';
$features = get_field('features');

// How It Works
$steps_headline = get_field('steps_headline') ?: 'GET STARTED IN 3 SIMPLE STEPS';
$steps = get_field('steps');
$steps_tagline = get_field('steps_tagline');

// Comparison
$comparison_headline = get_field('comparison_headline') ?: 'THE OLD WAY vs. THE NEW WAY';
$comparison_without_label = get_field('comparison_without_label') ?: 'WITHOUT PRODUCT';
$comparison_with_label = get_field('comparison_with_label') ?: 'WITH PRODUCT';
$comparison_items = get_field('comparison_items');

// Bonuses
$bonuses_headline = get_field('bonuses_headline') ?: 'FAST ACTION BONUSES';
$bonuses_badge = get_field('bonuses_badge') ?: '🎁 First 50 Only';
$bonuses = get_field('bonuses');

// Pricing
$pricing_headline = get_field('pricing_headline') ?: 'CHOOSE YOUR PACKAGE';
$fe_title = get_field('fe_title') ?: 'FRONT END';
$fe_original_price = get_field('fe_original_price');
$fe_sale_price = get_field('fe_sale_price');
$fe_price_type = get_field('fe_price_type') ?: 'one-time';
$fe_features = get_field('fe_features');
$fe_cta_text = get_field('fe_cta_text') ?: 'GET ACCESS';
$fe_cta_url = get_field('fe_cta_url') ?: '#';

$bundle_enabled = get_field('bundle_enabled');
$bundle_badge = get_field('bundle_badge') ?: '★ BEST VALUE ★';
$bundle_title = get_field('bundle_title') ?: 'FULL BUNDLE';
$bundle_original_price = get_field('bundle_original_price');
$bundle_sale_price = get_field('bundle_sale_price');
$bundle_price_type = get_field('bundle_price_type') ?: 'one-time';
$bundle_features = get_field('bundle_features');
$bundle_cta_text = get_field('bundle_cta_text') ?: 'GET BUNDLE';
$bundle_cta_url = get_field('bundle_cta_url') ?: '#';

// Testimonials
$testimonials_headline = get_field('testimonials_headline') ?: 'WHAT OTHERS ARE SAYING';
$testimonials = get_field('testimonials');

// FAQ
$faq_headline = get_field('faq_headline') ?: 'FREQUENTLY ASKED QUESTIONS';
$faqs = get_field('faqs');

// Final CTA
$final_headline = get_field('final_headline') ?: '⏰ THIS OFFER EXPIRES WHEN THE TIMER HITS ZERO';
$final_urgency_text = get_field('final_urgency_text') ?: 'After that, the price goes to $97/month.';
$final_cta_text = get_field('final_cta_text') ?: 'YES! GIVE ME INSTANT ACCESS FOR $37 →';
$final_cta_url = get_field('final_cta_url') ?: '#pricing';
$final_benefits = get_field('final_benefits');

// Footer
$footer_logo = get_field('footer_logo');
$company_name = get_field('company_name') ?: 'Company';
$privacy_url = get_field('privacy_url') ?: '#';
$terms_url = get_field('terms_url') ?: '#';
$contact_url = get_field('contact_url') ?: '#';
$earnings_disclaimer = get_field('earnings_disclaimer');
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>

<!-- ============================================
     1. STICKY COUNTDOWN BAR
     ============================================ -->
<div class="countdown-bar" id="countdown-bar">
    <div class="countdown-bar__content">
        <span class="countdown-bar__text"><?php echo esc_html($countdown_bar_text); ?></span>
        <div class="countdown-bar__timer" id="countdown-bar-timer">
            <span id="countdown-bar-hours">00</span>:
            <span id="countdown-bar-minutes">00</span>:
            <span id="countdown-bar-seconds">00</span>
        </div>
        <a href="<?php echo esc_url($countdown_bar_cta_url); ?>" class="btn btn--dark">
            <?php echo esc_html($countdown_bar_cta); ?>
        </a>
    </div>
</div>

<!-- ============================================
     2. HERO SECTION
     ============================================ -->
<section class="hero section" id="hero">
    <div class="container">
        <div class="hero__content">
            <?php if ($eyebrow_text) : ?>
                <span class="eyebrow"><?php echo esc_html($eyebrow_text); ?></span>
            <?php endif; ?>
            
            <h1 class="hero__headline">
                <?php if ($headline_white) : ?>
                    <span><?php echo esc_html($headline_white); ?></span>
                <?php endif; ?>
                <?php if ($headline_accent) : ?>
                    <br><span class="text-accent"><?php echo esc_html($headline_accent); ?></span>
                <?php endif; ?>
            </h1>
            
            <?php if ($subheadline) : ?>
                <p class="hero__subheadline"><?php echo esc_html($subheadline); ?></p>
            <?php endif; ?>
            
            <?php if ($video_url) : ?>
                <div class="hero__video" id="hero-video">
                    <?php if ($video_poster && !isset($_GET['autoplay'])) : ?>
                        <div class="hero__video-placeholder" id="video-placeholder">
                            <img src="<?php echo esc_url($video_poster['sizes']['large'] ?? $video_poster['url']); ?>" alt="Video" style="position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover;">
                            <div class="hero__play-btn">
                                <svg viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg>
                            </div>
                        </div>
                    <?php else : ?>
                        <?php echo slt_get_video_embed($video_url); ?>
                    <?php endif; ?>
                </div>
            <?php endif; ?>
            
            <a href="<?php echo esc_url($hero_cta_url); ?>" class="btn btn--primary btn--large">
                <?php echo esc_html($hero_cta_text); ?>
            </a>
            
            <?php if ($trust_badges && is_array($trust_badges)) : ?>
                <div class="hero__trust">
                    <?php foreach ($trust_badges as $badge) : ?>
                        <span><?php echo esc_html($badge['icon']); ?> <?php echo esc_html($badge['text']); ?></span>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>
        </div>
    </div>
</section>

<!-- ============================================
     3. PROBLEM AGITATION
     ============================================ -->
<section class="problem section section--surface" id="problem" data-animate>
    <div class="container container--narrow">
        <?php if ($problem_intro) : ?>
            <p class="problem__intro"><?php echo esc_html($problem_intro); ?></p>
        <?php endif; ?>
        
        <?php if ($pain_points && is_array($pain_points)) : ?>
            <ul class="problem__list">
                <?php foreach ($pain_points as $point) : ?>
                    <li class="problem__item">
                        <span class="problem__icon">✗</span>
                        <span class="problem__text"><?php echo esc_html($point['text']); ?></span>
                    </li>
                <?php endforeach; ?>
            </ul>
        <?php endif; ?>
        
        <?php if ($problem_transition) : ?>
            <p class="problem__transition"><?php echo esc_html($problem_transition); ?></p>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     4. SOLUTION INTRODUCTION
     ============================================ -->
<section class="solution section" id="solution" data-animate>
    <div class="container">
        <span class="eyebrow text-center" style="display:block;">INTRODUCING</span>
        <h2 class="text-center"><?php echo esc_html($product_name); ?></h2>
        
        <div class="solution__grid">
            <?php if ($product_image) : ?>
                <div>
                    <img src="<?php echo esc_url($product_image['sizes']['large'] ?? $product_image['url']); ?>" 
                         alt="<?php echo esc_attr($product_name); ?>" 
                         class="solution__image">
                </div>
            <?php endif; ?>
            
            <div>
                <?php if ($solution_tagline) : ?>
                    <p class="solution__tagline"><?php echo esc_html($solution_tagline); ?></p>
                <?php endif; ?>
                
                <?php if ($solution_benefits && is_array($solution_benefits)) : ?>
                    <ul class="solution__benefits">
                        <?php foreach ($solution_benefits as $benefit) : ?>
                            <li class="solution__benefit">
                                <span class="solution__check">✓</span>
                                <span><?php echo esc_html($benefit['text']); ?></span>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
            </div>
        </div>
    </div>
</section>

<!-- ============================================
     5. SOCIAL PROOF BLOCK
     ============================================ -->
<section class="social-proof section section--surface" id="social-proof" data-animate>
    <div class="container">
        <?php if ($stats && is_array($stats)) : ?>
            <div class="social-proof__stats">
                <?php foreach ($stats as $stat) : ?>
                    <div class="stat">
                        <div class="stat__value"><?php echo esc_html($stat['value']); ?></div>
                        <div class="stat__label"><?php echo esc_html($stat['label']); ?></div>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
        
        <?php if ($authority_quote) : ?>
            <div class="social-proof__quote">
                <blockquote><?php echo esc_html($authority_quote); ?></blockquote>
                <?php if ($authority_name) : ?>
                    <cite>— <?php echo esc_html($authority_name); ?><?php echo $authority_title ? ', ' . esc_html($authority_title) : ''; ?></cite>
                <?php endif; ?>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     6. FEATURE GRID
     ============================================ -->
<section class="features section" id="features" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($features_headline); ?></h2>
        
        <?php if ($features && is_array($features)) : ?>
            <div class="features__grid">
                <?php foreach ($features as $feature) : ?>
                    <div class="feature-card">
                        <?php if (!empty($feature['icon'])) : ?>
                            <div class="feature-card__icon"><?php echo esc_html($feature['icon']); ?></div>
                        <?php endif; ?>
                        <h3 class="feature-card__title"><?php echo esc_html($feature['title']); ?></h3>
                        <p class="feature-card__description"><?php echo esc_html($feature['description']); ?></p>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     7. HOW IT WORKS
     ============================================ -->
<section class="how-it-works section section--surface" id="how-it-works" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($steps_headline); ?></h2>
        
        <?php if ($steps && is_array($steps)) : ?>
            <div class="steps">
                <?php $step_number = 1; ?>
                <?php foreach ($steps as $step) : ?>
                    <div class="step">
                        <div class="step__number"><?php echo $step_number++; ?></div>
                        <?php if (!empty($step['image'])) : ?>
                            <img src="<?php echo esc_url($step['image']['sizes']['medium'] ?? $step['image']['url']); ?>" 
                                 alt="<?php echo esc_attr($step['title']); ?>" 
                                 class="step__image">
                        <?php endif; ?>
                        <h3 class="step__title"><?php echo esc_html($step['title']); ?></h3>
                        <?php if (!empty($step['description'])) : ?>
                            <p class="step__description"><?php echo esc_html($step['description']); ?></p>
                        <?php endif; ?>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
        
        <?php if ($steps_tagline) : ?>
            <p class="how-it-works__tagline"><?php echo esc_html($steps_tagline); ?></p>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     8. COMPARISON TABLE
     ============================================ -->
<section class="comparison section" id="comparison" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($comparison_headline); ?></h2>
        
        <?php if ($comparison_items && is_array($comparison_items)) : ?>
            <div class="comparison__table">
                <div class="comparison__column comparison__column--without">
                    <div class="comparison__header"><?php echo esc_html($comparison_without_label); ?></div>
                    <ul class="comparison__list">
                        <?php foreach ($comparison_items as $item) : ?>
                            <li class="comparison__item">
                                <span class="comparison__icon">✗</span>
                                <span><?php echo esc_html($item['without']); ?></span>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                </div>
                
                <div class="comparison__column comparison__column--with">
                    <div class="comparison__header"><?php echo esc_html($comparison_with_label); ?></div>
                    <ul class="comparison__list">
                        <?php foreach ($comparison_items as $item) : ?>
                            <li class="comparison__item">
                                <span class="comparison__icon">✓</span>
                                <span><?php echo esc_html($item['with']); ?></span>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                </div>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     9. BONUS STACK
     ============================================ -->
<section class="bonuses section section--surface" id="bonuses" data-animate>
    <div class="container container--narrow">
        <div class="bonuses__header">
            <?php if ($bonuses_badge) : ?>
                <span class="bonuses__badge"><?php echo esc_html($bonuses_badge); ?></span>
            <?php endif; ?>
            <h2><?php echo esc_html($bonuses_headline); ?></h2>
        </div>
        
        <?php 
        $total_value = 0;
        if ($bonuses && is_array($bonuses)) : 
        ?>
            <?php $bonus_number = 1; ?>
            <?php foreach ($bonuses as $bonus) : 
                $total_value += floatval($bonus['value']);
            ?>
                <div class="bonus-card">
                    <?php if (!empty($bonus['image'])) : ?>
                        <img src="<?php echo esc_url($bonus['image']['sizes']['thumbnail'] ?? $bonus['image']['url']); ?>" 
                             alt="<?php echo esc_attr($bonus['title']); ?>" 
                             class="bonus-card__image">
                    <?php endif; ?>
                    
                    <div class="bonus-card__content">
                        <span class="bonus-card__number">BONUS #<?php echo $bonus_number++; ?></span>
                        <h3 class="bonus-card__title"><?php echo esc_html($bonus['title']); ?></h3>
                        <p class="bonus-card__description"><?php echo esc_html($bonus['description']); ?></p>
                    </div>
                    
                    <div class="bonus-card__value">
                        <span class="bonus-card__value-label">VALUE</span>
                        <span class="bonus-card__value-amount"><?php echo slt_format_price($bonus['value']); ?></span>
                    </div>
                </div>
            <?php endforeach; ?>
            
            <div class="bonuses__total">
                <div class="bonuses__total-label">TOTAL BONUS VALUE:</div>
                <div class="bonuses__total-value"><?php echo slt_format_price($total_value); ?></div>
                <div class="bonuses__total-subtext">Yours FREE with your order today</div>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     10. PRICING SECTION
     ============================================ -->
<section class="pricing section" id="pricing" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($pricing_headline); ?></h2>
        
        <div class="pricing__grid">
            <!-- Front-End Offer -->
            <div class="pricing-card">
                <h3 class="pricing-card__title"><?php echo esc_html($fe_title); ?></h3>
                
                <div class="pricing-card__price">
                    <?php if ($fe_original_price) : ?>
                        <div class="pricing-card__original"><?php echo slt_format_price($fe_original_price); ?>/mo</div>
                    <?php endif; ?>
                    <div class="pricing-card__sale">
                        <sup>$</sup><?php echo number_format(floatval($fe_sale_price), 0); ?>
                    </div>
                    <div class="pricing-card__type"><?php echo strtoupper(str_replace('-', ' ', $fe_price_type)); ?></div>
                </div>
                
                <?php if ($fe_features && is_array($fe_features)) : ?>
                    <ul class="pricing-card__features">
                        <?php foreach ($fe_features as $feature) : ?>
                            <li class="pricing-card__feature">
                                <svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/></svg>
                                <span><?php echo esc_html($feature['text']); ?></span>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
                
                <a href="<?php echo esc_url($fe_cta_url); ?>" class="btn btn--primary btn--full">
                    <?php echo esc_html($fe_cta_text); ?> <?php echo slt_format_price($fe_sale_price); ?>
                </a>
            </div>
            
            <?php if ($bundle_enabled) : ?>
            <!-- Bundle Offer -->
            <div class="pricing-card pricing-card--featured">
                <?php if ($bundle_badge) : ?>
                    <span class="pricing-card__badge"><?php echo esc_html($bundle_badge); ?></span>
                <?php endif; ?>
                
                <h3 class="pricing-card__title"><?php echo esc_html($bundle_title); ?></h3>
                
                <div class="pricing-card__price">
                    <?php if ($bundle_original_price) : ?>
                        <div class="pricing-card__original"><?php echo slt_format_price($bundle_original_price); ?></div>
                    <?php endif; ?>
                    <div class="pricing-card__sale">
                        <sup>$</sup><?php echo number_format(floatval($bundle_sale_price), 0); ?>
                    </div>
                    <div class="pricing-card__type"><?php echo strtoupper(str_replace('-', ' ', $bundle_price_type)); ?></div>
                </div>
                
                <?php if ($bundle_features && is_array($bundle_features)) : ?>
                    <ul class="pricing-card__features">
                        <?php foreach ($bundle_features as $feature) : ?>
                            <li class="pricing-card__feature">
                                <svg viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/></svg>
                                <span><?php echo esc_html($feature['text']); ?></span>
                            </li>
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
                
                <a href="<?php echo esc_url($bundle_cta_url); ?>" class="btn btn--primary btn--full">
                    <?php echo esc_html($bundle_cta_text); ?> <?php echo slt_format_price($bundle_sale_price); ?>
                </a>
            </div>
            <?php endif; ?>
        </div>
        
        <div class="pricing__trust">
            <span>🔒 Secure 256-bit SSL checkout</span>
            <span>💳 All major cards accepted</span>
            <span>✓ 30-day money-back guarantee</span>
        </div>
    </div>
</section>

<!-- ============================================
     11. TESTIMONIALS GRID
     ============================================ -->
<section class="testimonials section section--surface" id="testimonials" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($testimonials_headline); ?></h2>
        
        <?php if ($testimonials && is_array($testimonials)) : ?>
            <div class="testimonials__grid">
                <?php foreach ($testimonials as $testimonial) : ?>
                    <div class="testimonial-card">
                        <div class="testimonial-card__header">
                            <?php if (!empty($testimonial['photo'])) : ?>
                                <img src="<?php echo esc_url($testimonial['photo']['sizes']['thumbnail'] ?? $testimonial['photo']['url']); ?>" 
                                     alt="<?php echo esc_attr($testimonial['name']); ?>" 
                                     class="testimonial-card__avatar">
                            <?php endif; ?>
                            <div class="testimonial-card__info">
                                <div class="testimonial-card__name"><?php echo esc_html($testimonial['name']); ?></div>
                                <?php if (!empty($testimonial['title'])) : ?>
                                    <div class="testimonial-card__title"><?php echo esc_html($testimonial['title']); ?></div>
                                <?php endif; ?>
                            </div>
                            <div class="testimonial-card__stars"><?php echo slt_get_stars($testimonial['rating'] ?? 5); ?></div>
                        </div>
                        <p class="testimonial-card__quote"><?php echo esc_html($testimonial['quote']); ?></p>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     12. FAQ ACCORDION
     ============================================ -->
<section class="faq section" id="faq" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($faq_headline); ?></h2>
        
        <?php if ($faqs && is_array($faqs)) : ?>
            <div class="faq__list">
                <?php foreach ($faqs as $index => $faq) : ?>
                    <div class="faq-item" id="faq-<?php echo $index; ?>">
                        <button class="faq-item__question" aria-expanded="false" aria-controls="faq-answer-<?php echo $index; ?>">
                            <span><?php echo esc_html($faq['question']); ?></span>
                            <span class="faq-item__icon">
                                <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <polyline points="6 9 12 15 18 9"></polyline>
                                </svg>
                            </span>
                        </button>
                        <div class="faq-item__answer" id="faq-answer-<?php echo $index; ?>">
                            <div class="faq-item__answer-content">
                                <?php echo wp_kses_post($faq['answer']); ?>
                            </div>
                        </div>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     13. FINAL CTA
     ============================================ -->
<section class="final-cta section" id="final-cta" data-animate>
    <div class="container">
        <h2 class="text-center"><?php echo esc_html($final_headline); ?></h2>
        
        <div class="final-cta__timer">
            <div class="final-cta__countdown" id="final-countdown">
                <div class="final-cta__time-unit">
                    <span class="final-cta__time-value" id="final-hours">00</span>
                    <span class="final-cta__time-label">Hours</span>
                </div>
                <div class="final-cta__time-unit">
                    <span class="final-cta__time-value" id="final-minutes">00</span>
                    <span class="final-cta__time-label">Minutes</span>
                </div>
                <div class="final-cta__time-unit">
                    <span class="final-cta__time-value" id="final-seconds">00</span>
                    <span class="final-cta__time-label">Seconds</span>
                </div>
            </div>
        </div>
        
        <?php if ($final_urgency_text) : ?>
            <p class="final-cta__urgency"><?php echo esc_html($final_urgency_text); ?></p>
        <?php endif; ?>
        
        <div class="text-center">
            <a href="<?php echo esc_url($final_cta_url); ?>" class="btn btn--primary btn--large animate-pulse">
                <?php echo esc_html($final_cta_text); ?>
            </a>
        </div>
        
        <?php if ($final_benefits && is_array($final_benefits)) : ?>
            <div class="final-cta__benefits">
                <?php foreach ($final_benefits as $benefit) : ?>
                    <div class="final-cta__benefit">
                        <svg viewBox="0 0 20 20" fill="currentColor" width="20" height="20"><path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/></svg>
                        <span><?php echo esc_html($benefit['text']); ?></span>
                    </div>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>
    </div>
</section>

<!-- ============================================
     14. FOOTER
     ============================================ -->
<footer class="footer" id="footer">
    <div class="container">
        <?php if ($footer_logo) : ?>
            <img src="<?php echo esc_url($footer_logo['url']); ?>" alt="<?php echo esc_attr($company_name); ?>" class="footer__logo">
        <?php endif; ?>
        
        <nav class="footer__links">
            <a href="<?php echo esc_url($privacy_url); ?>" class="footer__link">Privacy Policy</a>
            <a href="<?php echo esc_url($terms_url); ?>" class="footer__link">Terms</a>
            <a href="#earnings-disclaimer" class="footer__link">Earnings Disclaimer</a>
            <a href="<?php echo esc_url($contact_url); ?>" class="footer__link">Contact</a>
        </nav>
        
        <p class="footer__copyright">
            © <?php echo date('Y'); ?> <?php echo esc_html($company_name); ?>. All rights reserved.
            <br>This site is not part of Facebook, Google, or any third-party platform.
        </p>
        
        <?php if ($earnings_disclaimer) : ?>
            <p class="footer__disclaimer" id="earnings-disclaimer">
                <strong>EARNINGS DISCLAIMER:</strong> <?php echo esc_html($earnings_disclaimer); ?>
            </p>
        <?php endif; ?>
    </div>
</footer>

<script>
// FAQ Accordion
document.querySelectorAll('.faq-item__question').forEach(button => {
    button.addEventListener('click', () => {
        const faqItem = button.parentElement;
        const isActive = faqItem.classList.contains('active');
        
        // Close all
        document.querySelectorAll('.faq-item').forEach(item => {
            item.classList.remove('active');
            item.querySelector('button').setAttribute('aria-expanded', 'false');
        });
        
        // Open clicked if wasn't active
        if (!isActive) {
            faqItem.classList.add('active');
            button.setAttribute('aria-expanded', 'true');
        }
    });
});

// Video placeholder click
const videoPlaceholder = document.getElementById('video-placeholder');
if (videoPlaceholder) {
    videoPlaceholder.addEventListener('click', () => {
        const videoContainer = document.getElementById('hero-video');
        const videoUrl = '<?php echo esc_js($video_url); ?>';
        
        // Determine embed
        let embedHtml = '';
        if (videoUrl.includes('youtube.com') || videoUrl.includes('youtu.be')) {
            const videoId = videoUrl.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^\&\?\/]+)/)?.[1];
            if (videoId) {
                embedHtml = `<iframe src="https://www.youtube.com/embed/${videoId}?autoplay=1&rel=0" frameborder="0" allowfullscreen allow="autoplay; encrypted-media"></iframe>`;
            }
        } else if (videoUrl.includes('vimeo.com')) {
            const videoId = videoUrl.match(/vimeo\.com\/(\d+)/)?.[1];
            if (videoId) {
                embedHtml = `<iframe src="https://player.vimeo.com/video/${videoId}?autoplay=1" frameborder="0" allowfullscreen></iframe>`;
            }
        }
        
        if (embedHtml) {
            videoContainer.innerHTML = embedHtml;
        }
    });
}

// Scroll animations
const animateOnScroll = () => {
    const elements = document.querySelectorAll('[data-animate]');
    elements.forEach(el => {
        const rect = el.getBoundingClientRect();
        const isVisible = rect.top < window.innerHeight * 0.85;
        if (isVisible) {
            el.classList.add('animated');
        }
    });
};

window.addEventListener('scroll', animateOnScroll);
window.addEventListener('load', animateOnScroll);
</script>

<?php wp_footer(); ?>
</body>
</html>
