<?php
/**
 * TamRank Onboarding Wizard Template
 *
 * Renders a full-screen wizard without WP admin chrome.
 * Variables available: $detection (from controller)
 *
 * Layout: variant 2 "Verhuisplan" (wizard-redesign, 21 Aug 2026). Every step is
 * one wide document sheet with a fixed anatomy (head, body, foot) that fits on a
 * single screen without scrolling. Steps 2 and 3 of the old five-step flow are
 * merged into one: the site scan is no longer a screen of its own but the side
 * track of the choice it informs.
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

$tamrank_site_host = wp_parse_url( home_url(), PHP_URL_HOST );
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title><?php echo esc_html( tamrank__( 'onboarding_wizard_title', 'TamRank Setup Wizard' ) ); ?></title>
    <?php wp_print_styles( 'tamrank-onboarding' ); ?>
    <?php wp_print_scripts( 'tamrank-onboarding' ); ?>
</head>
<body class="tamrank-wizard-body">

<div class="tamrank-wizard" role="main">

    <!-- Header -->
    <header class="tamrank-wizard__header">
        <div class="tamrank-wizard__logo">
            <svg width="30" height="30" viewBox="0 0 40 40" fill="none" aria-hidden="true">
                <rect x="4" y="4" width="32" height="32" rx="8" fill="#1e293b"/>
                <rect x="10" y="10" width="20" height="5" rx="2" fill="#10b981"/>
                <rect x="15" y="10" width="5" height="20" rx="2" fill="#10b981"/>
                <rect x="22" y="18" width="5" height="12" rx="2" fill="#10b981" opacity="0.5"/>
            </svg>
            <?php /* Wordmark per Branding.md: "Tam" slate-800, "Rank" emerald. */ ?>
            <span class="tamrank-wizard__logo-text">Tam<b>Rank</b></span>
        </div>
        <div class="tamrank-wizard__header-actions">
            <?php
            $tamrank_current_lang = tamrank_get_language();
            $tamrank_languages = array(
                'nl' => array( 'label' => 'Nederlands', 'flag' => '🇳🇱' ),
                'en' => array( 'label' => 'English',    'flag' => '🇬🇧' ),
                'de' => array( 'label' => 'Deutsch',    'flag' => '🇩🇪' ),
                'fr' => array( 'label' => 'Français',   'flag' => '🇫🇷' ),
            );
            ?>
            <div class="tamrank-wizard__lang-switcher" id="tamrank-lang-switcher" role="group" aria-label="<?php echo esc_attr( tamrank__( 'wizard_language_aria', 'Choose language' ) ); ?>">
                <?php foreach ( $tamrank_languages as $tamrank_code => $tamrank_lang ) : ?>
                <button type="button"
                        class="tamrank-wizard__lang-btn <?php echo $tamrank_code === $tamrank_current_lang ? 'is-selected' : ''; ?>"
                        data-lang="<?php echo esc_attr( $tamrank_code ); ?>"
                        title="<?php echo esc_attr( $tamrank_lang['label'] ); ?>"
                        aria-label="<?php echo esc_attr( $tamrank_lang['label'] ); ?>"
                        aria-pressed="<?php echo $tamrank_code === $tamrank_current_lang ? 'true' : 'false'; ?>">
                    <span aria-hidden="true"><?php echo esc_html($tamrank_lang['flag']); ?></span>
                </button>
                <?php endforeach; ?>
            </div>
            <a href="#" class="tamrank-wizard__skip" id="tamrank-skip">
                <?php tamrank_e( 'onboarding_skip', 'Skip' ); ?>
                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
                    <path d="M5 12h14M12 5l7 7-7 7"/>
                </svg>
            </a>
        </div>
    </header>

    <!-- Stepper — four steps: Selection has merged into the Moving plan -->
    <nav class="tamrank-wizard__stepper" aria-label="<?php echo esc_attr( tamrank__( 'wizard_steps_label', 'Wizard steps' ) ); ?>">
        <?php
        $tamrank_steps = array(
            tamrank__( 'wizard_step_detection', 'Detection' ),
            tamrank__( 'wizard_step_plan', 'Moving plan' ),
            tamrank__( 'wizard_step_migration', 'Migration' ),
            tamrank__( 'wizard_step_done', 'Done' ),
        );
        foreach ( $tamrank_steps as $tamrank_i => $tamrank_label ) :
        ?>
        <div class="tamrank-wizard__step <?php echo $tamrank_i === 0 ? 'is-active' : ''; ?>"
             data-step="<?php echo esc_attr($tamrank_i); ?>"
             aria-current="<?php echo $tamrank_i === 0 ? 'step' : 'false'; ?>"
             aria-label="<?php echo esc_attr( $tamrank_label ); ?>">
            <span class="tamrank-wizard__step-bar"></span>
            <span class="tamrank-wizard__step-label"><?php echo esc_html( $tamrank_label ); ?></span>
        </div>
        <?php endforeach; ?>
    </nav>

    <!-- Panels container (the stage the document sheets live on) -->
    <div class="tamrank-wizard__panels">

        <!-- Step 0: Detection (welcome) -->
        <section class="tamrank-wizard__panel tamrank-sheet is-active" data-panel="0" role="tabpanel" aria-label="<?php echo esc_attr( tamrank__( 'wizard_step_detection', 'Detection' ) ); ?>">
            <div class="tamrank-sheet__head">
                <div>
                    <h1 class="tamrank-sheet__title" tabindex="-1"><?php tamrank_e( 'wizard_detection_title', 'Welcome to TamRank' ); ?></h1>
                    <p class="tamrank-sheet__sub"><?php tamrank_e( 'wizard_detection_subtitle', "We'll prep your site in a few quick steps. First, is an SEO plugin already active?" ); ?></p>
                </div>
                <span class="tamrank-sheet__site"><?php echo esc_html( $tamrank_site_host ); ?></span>
            </div>
            <div class="tamrank-sheet__body">
                <div id="tamrank-detect-result">
                    <div class="tamrank-wizard__detect-loading">
                        <div class="tamrank-wizard__spinner" aria-hidden="true"></div>
                        <span><?php tamrank_e( 'wizard_detecting', 'Detecting...' ); ?></span>
                    </div>
                </div>

                <!-- Anchor 1: the promise, UNDER the plugin items (Sam's point 1).
                     Two facts, both filled by JS with the name of the selected
                     source: we only read, and the old plugin does not have to go.
                     Hidden on the clean-start flow, where there is no other
                     plugin to read at all. -->
                <div class="tamrank-trustbar" id="tamrank-detect-trust" hidden>
                    <span class="tamrank-trustbar__icon" aria-hidden="true">
                        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="m9 12 2 2 4-4"/></svg>
                    </span>
                    <span>
                        <span class="tamrank-trustbar__title" id="tamrank-detect-trust-read"></span>
                        <span class="tamrank-trustbar__body" id="tamrank-detect-trust-keep"></span>
                    </span>
                </div>
            </div>
            <div class="tamrank-sheet__foot">
                <p class="tamrank-sheet__foot-note" id="tamrank-detect-desc"></p>
                <button type="button" class="tamrank-btn tamrank-btn--primary" id="tamrank-detect-next" disabled>
                    <?php tamrank_e( 'next_step', 'Next' ); ?>
                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
                </button>
            </div>
        </section>

        <!-- Step 1: Moving plan (the old Site Scan + Selection in one sheet) -->
        <section class="tamrank-wizard__panel tamrank-sheet" data-panel="1" role="tabpanel" aria-label="<?php echo esc_attr( tamrank__( 'wizard_step_plan', 'Moving plan' ) ); ?>">
            <div class="tamrank-sheet__head">
                <div>
                    <h1 class="tamrank-sheet__title" id="tamrank-plan-title" tabindex="-1"><?php tamrank_e( 'wizard_plan_title_generic', 'What do we take along?' ); ?></h1>
                    <p class="tamrank-sheet__sub" id="tamrank-plan-subtitle"><?php tamrank_e( 'wizard_plan_subtitle_generic', 'Tick what TamRank moves over. Your existing SEO data stays where it is.' ); ?></p>
                </div>
                <span class="tamrank-sheet__site"><?php echo esc_html( $tamrank_site_host ); ?></span>
            </div>
            <div class="tamrank-sheet__body">
                <div class="tamrank-plan">
                    <div class="tamrank-plan__main">
                        <div class="tamrank-plan__list">
                            <div class="tamrank-plan__listhead">
                                <span class="tamrank-plan__listhead-l" id="tamrank-plan-found"><?php tamrank_e( 'wizard_plan_found_generic', 'Found in your old SEO plugin' ); ?></span>
                                <button type="button" class="tamrank-plan__toggle" id="tamrank-plan-toggle"><?php tamrank_e( 'wizard_plan_select_none', 'Select nothing' ); ?></button>
                            </div>
                            <div id="tamrank-categories">
                                <!-- Populated by JS after the scan -->
                            </div>
                            <div class="tamrank-plan__total" id="tamrank-plan-total-row">
                                <span class="tamrank-plan__total-l"><?php tamrank_e( 'wizard_plan_total_label', 'Will be moved over' ); ?></span>
                                <span class="tamrank-plan__total-n" id="tamrank-plan-total">&nbsp;</span>
                            </div>
                        </div>
                    </div>

                    <div class="tamrank-plan__aside">
                        <!-- Side track: the scan facts. Subordinate to the choice,
                             never blocking. Replaced by the robots.txt conflict
                             question when there is one: a decision beats context. -->
                        <div id="tamrank-facts-default">
                            <p class="tamrank-aside__kicker"><?php tamrank_e( 'wizard_aside_title', 'What else we saw on your site' ); ?></p>

                            <div id="tamrank-facts-loading">
                                <p class="tamrank-aside__scanline" role="status"><?php tamrank_e( 'wizard_scan_running', 'Scanning…' ); ?></p>
                                <div aria-hidden="true">
                                    <div class="tamrank-fact"><span class="tamrank-skel" style="width:62%"></span><span class="tamrank-skel tamrank-skel--num"></span></div>
                                    <div class="tamrank-fact"><span class="tamrank-skel" style="width:74%"></span><span class="tamrank-skel tamrank-skel--num"></span></div>
                                    <div class="tamrank-fact"><span class="tamrank-skel" style="width:55%"></span><span class="tamrank-skel tamrank-skel--num"></span></div>
                                    <div class="tamrank-fact"><span class="tamrank-skel" style="width:68%"></span><span class="tamrank-skel tamrank-skel--num"></span></div>
                                </div>
                            </div>

                            <!-- Scan failed: an honest line plus a way out. The choice
                                 on the left keeps working; only the context is missing. -->
                            <div id="tamrank-facts-failed" hidden>
                                <div class="tamrank-note tamrank-note--warn" role="alert">
                                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><path d="M12 9v4M12 17h.01"/></svg>
                                    <span><?php tamrank_e( 'wizard_scan_failed_text', 'We could not scan your site just now. That may be a temporary glitch; try again, or simply continue.' ); ?></span>
                                </div>
                                <p class="tamrank-aside__retry">
                                    <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--outline" id="tamrank-scan-retry"><?php tamrank_e( 'wizard_retry', 'Retry' ); ?></button>
                                </p>
                            </div>

                            <!-- Empty site: one row, not four zeroes -->
                            <div id="tamrank-facts-empty" hidden>
                                <div class="tamrank-fact">
                                    <span class="tamrank-fact__label"><?php tamrank_e( 'wizard_scan_empty_label', 'Published pages and posts' ); ?>
                                        <span class="tamrank-fact__src"><?php tamrank_e( 'wizard_scan_empty_src', 'Nothing published yet. As soon as content is there, TamRank scores every page.' ); ?></span>
                                    </span>
                                    <span class="tamrank-fact__num tamrank-fact__num--muted"><?php tamrank_e( 'wizard_scan_value_none', 'none' ); ?></span>
                                </div>
                            </div>

                            <div id="tamrank-facts-list" hidden>
                                <div class="tamrank-fact" data-stat="total_posts">
                                    <span class="tamrank-fact__label"><?php tamrank_e( 'wizard_stat_pages_posts', 'Pages and posts' ); ?>
                                        <span class="tamrank-fact__src"><?php tamrank_e( 'wizard_scan_src_posts', 'Published. Other post types (products, for example) are not counted.' ); ?></span>
                                    </span>
                                    <span class="tamrank-fact__num" id="tamrank-scan-total"><span class="tamrank-fact__val">0</span></span>
                                </div>
                                <div class="tamrank-fact" data-stat="missing_desc">
                                    <span class="tamrank-fact__label"><?php tamrank_e( 'wizard_stat_missing_desc', 'Without meta description' ); ?>
                                        <span class="tamrank-fact__src"><?php tamrank_e( 'wizard_scan_src_desc', 'Counted across TamRank, Yoast and Rank Math together.' ); ?></span>
                                    </span>
                                    <span class="tamrank-fact__num" id="tamrank-scan-desc"><span class="tamrank-fact__val">0</span></span>
                                </div>
                                <div class="tamrank-fact" data-stat="duplicate_titles">
                                    <span class="tamrank-fact__label"><?php tamrank_e( 'wizard_stat_duplicate_titles', 'Duplicate page titles' ); ?>
                                        <span class="tamrank-fact__src"><?php tamrank_e( 'wizard_scan_src_dup', 'Identical WordPress titles; the SEO title is not counted.' ); ?></span>
                                    </span>
                                    <span class="tamrank-fact__num" id="tamrank-scan-dup"><span class="tamrank-fact__val">0</span></span>
                                </div>
                                <div class="tamrank-fact" data-stat="schema_pct">
                                    <span class="tamrank-fact__label"><?php tamrank_e( 'wizard_stat_schema', 'Schema markup switched on' ); ?>
                                        <span class="tamrank-fact__src"><?php tamrank_e( 'wizard_scan_src_schema', 'On pages where you have not switched schema off.' ); ?></span>
                                    </span>
                                    <?php /* The unit is a separate span on its own size: "%" is not a third digit. */ ?>
                                    <span class="tamrank-fact__num"><span class="tamrank-fact__val" id="tamrank-scan-schema">0</span><span class="tamrank-fact__unit">%</span></span>
                                </div>
                            </div>

                            <span class="tamrank-aside__open" id="tamrank-scan-open" hidden><?php tamrank_e( 'wizard_scan_open_text', 'Work for after the migration. You will find it back in the SEO audit; the migration itself does not touch it.' ); ?></span>

                            <div class="tamrank-note" id="tamrank-scan-warning" hidden>
                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 8v4l3 2"/></svg>
                                <span><b><?php tamrank_e( 'wizard_scan_big_title', 'Large site.' ); ?></b> <span id="tamrank-scan-warning-text"></span></span>
                            </div>

                            <!-- Redirects the source has but this migration leaves
                                 behind (AIOSEO Pro keeps them in an add-on table).
                                 Not importing them is the design; leaving without a
                                 word is not, so the count is said out loud here,
                                 before the user presses start. -->
                            <div class="tamrank-note tamrank-note--warn" id="tamrank-redirects-note" hidden>
                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 17H7A5 5 0 0 1 7 7h2M15 7h2a5 5 0 0 1 0 10h-2M8 12h8"/></svg>
                                <span id="tamrank-redirects-note-text"></span>
                            </div>

                            <!-- Redirects the migration DOES bring along, but that
                                 hand the visitor to another domain. Imported and
                                 performed exactly as configured; the plan just
                                 stops being silent about where that traffic goes.
                                 Sits under the left-behind note on purpose: same
                                 subject, and it is the smaller of the two facts. -->
                            <div class="tamrank-note tamrank-note--warn" id="tamrank-external-redirects-note" hidden>
                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
                                <span id="tamrank-external-redirects-note-text"></span>
                            </div>

                            <!-- robots.txt provenance: where the version we import came from -->
                            <div class="tamrank-note" id="tamrank-robots-panel" hidden>
                                <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/></svg>
                                <span id="tamrank-robots-origin"></span>
                            </div>
                        </div>

                        <!-- robots.txt conflict: the user edited it, so this is a
                             choice, not a notice. Takes the place of the side track.
                             The previews scroll internally: a robots.txt is long by
                             nature and that has nothing to do with the page fitting. -->
                        <div id="tamrank-robots-conflict" hidden>
                            <p class="tamrank-aside__kicker"><?php tamrank_e( 'wizard_robots_choice_kicker', 'Robots.txt needs a decision' ); ?></p>
                            <p class="tamrank-rob__title">
                                <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
                                <?php tamrank_e( 'wizard_robots_conflict_title', 'You have edited your robots.txt yourself' ); ?>
                            </p>
                            <p class="tamrank-rob__desc"><?php tamrank_e( 'wizard_robots_conflict_desc', 'Choose what TamRank should do. Keeping your own version is the safe choice; you can always copy lines over afterwards.' ); ?></p>
                            <!-- Reference material: this is what shrinks when the
                                 column runs short. The question and the two answers
                                 below it always stay in view. -->
                            <div class="tamrank-rob__previews">
                                <p class="tamrank-rob__col-title"><?php tamrank_e( 'wizard_robots_current', 'Your current robots.txt' ); ?></p>
                                <pre class="tamrank-rob__pre" id="tamrank-robots-current"></pre>
                                <p class="tamrank-rob__col-title"><?php tamrank_e( 'wizard_robots_new', 'From your old SEO plugin' ); ?></p>
                                <pre class="tamrank-rob__pre" id="tamrank-robots-new"></pre>
                            </div>
                            <p class="tamrank-rob__cap" id="tamrank-robots-conflict-cap"></p>
                            <div class="tamrank-rob__choice">
                                <label><input type="radio" name="tamrank_robots_conflict" value="keep" checked> <?php tamrank_e( 'wizard_robots_keep', 'Keep my own version' ); ?></label>
                                <label><input type="radio" name="tamrank_robots_conflict" value="replace"> <?php tamrank_e( 'wizard_robots_replace', 'Replace with the imported version' ); ?></label>
                            </div>
                        </div>

                        <!-- A physical robots.txt beats everything TamRank sets, so
                             this warning leads the column in both aside states: the
                             CSS lifts it above the reference material, so it is in
                             view the moment the step opens and never ends up behind
                             something that has given way. -->
                        <div class="tamrank-note tamrank-note--warn" id="tamrank-robots-physical" hidden></div>
                    </div>
                </div>

                <!-- Anchor 2: the mechanism, as the signature strip of the plan,
                     directly above the button that starts it. Three checkable
                     facts: we copy, we back up first, the old plugin may stay on. -->
                <div class="tamrank-mechstrip" id="tamrank-safety-message">
                    <span class="tamrank-mechstrip__title">
                        <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
                        <span id="tamrank-safety-text"></span>
                    </span>
                    <span class="tamrank-mechstrip__item">
                        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6.5L9 17.5l-5-5"/></svg>
                        <span id="tamrank-trust-copy"></span>
                    </span>
                    <span class="tamrank-mechstrip__item">
                        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6.5L9 17.5l-5-5"/></svg>
                        <span id="tamrank-trust-backup"></span>
                    </span>
                    <span class="tamrank-mechstrip__item">
                        <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6.5L9 17.5l-5-5"/></svg>
                        <span id="tamrank-trust-keep"></span>
                    </span>
                </div>
            </div>
            <div class="tamrank-sheet__foot">
                <p class="tamrank-sheet__foot-note"><?php tamrank_e( 'wizard_plan_foot_note', 'Existing TamRank data is not overwritten. The roll-back button is on the Done step, once the migration has finished.' ); ?></p>
                <button type="button" class="tamrank-btn tamrank-btn--ghost" data-prev>
                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>
                    <?php tamrank_e( 'previous_step', 'Back' ); ?>
                </button>
                <button type="button" class="tamrank-btn tamrank-btn--primary" id="tamrank-migrate-start">
                    <span id="tamrank-migrate-start-label"><?php tamrank_e( 'wizard_start_migration', 'Start migration' ); ?></span>
                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
                </button>
            </div>
        </section>

        <!-- Step 2: Migration (progress) -->
        <section class="tamrank-wizard__panel tamrank-sheet" data-panel="2" role="tabpanel" aria-label="<?php echo esc_attr( tamrank__( 'wizard_step_migration', 'Migration' ) ); ?>">
            <div class="tamrank-sheet__head">
                <div>
                    <h1 class="tamrank-sheet__title" tabindex="-1"><?php tamrank_e( 'wizard_migration_title', 'Migration in progress...' ); ?></h1>
                    <p class="tamrank-sheet__sub" id="tamrank-migrate-subtitle"><?php tamrank_e( 'wizard_migration_subtitle', 'Please wait, we are moving your SEO data to TamRank.' ); ?></p>
                </div>
                <span class="tamrank-mig__pct" id="tamrank-progress-pct">0%</span>
            </div>
            <div class="tamrank-sheet__body">
                <div class="tamrank-mig__bar" id="tamrank-progress-bar" aria-hidden="true"><div class="tamrank-mig__fill" id="tamrank-progress-fill"></div></div>
                <div class="tamrank-mig__meta">
                    <span id="tamrank-progress-items">&nbsp;</span>
                </div>

                <div class="tamrank-mig">
                    <div>
                        <p class="tamrank-aside__kicker"><?php tamrank_e( 'wizard_mig_list_title', 'Moving list' ); ?></p>
                        <ul class="tamrank-mig__list" id="tamrank-migrate-list" aria-live="polite"></ul>
                    </div>
                    <div>
                        <p class="tamrank-aside__kicker"><?php tamrank_e( 'wizard_mig_log_title', 'Log' ); ?></p>
                        <ul class="tamrank-mig__log" id="tamrank-mig-log" aria-live="polite"></ul>

                        <div class="tamrank-mig__error" id="tamrank-error-box" hidden>
                            <p class="tamrank-mig__error-title">
                                <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
                                <span id="tamrank-error-msg"></span>
                            </p>
                            <div class="tamrank-mig__error-actions">
                                <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--outline" id="tamrank-error-retry">
                                    <?php tamrank_e( 'wizard_retry', 'Retry' ); ?>
                                </button>
                                <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--outline" id="tamrank-error-skip">
                                    <?php tamrank_e( 'wizard_mig_error_skip', 'Skip this group' ); ?>
                                </button>
                                <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--ghost" id="tamrank-error-stop">
                                    <?php tamrank_e( 'wizard_mig_error_stop', 'Stop and show the report' ); ?>
                                </button>
                            </div>
                            <p class="tamrank-mig__error-keep"><?php tamrank_e( 'wizard_mig_error_keep', 'What was already moved over stays put. So does the backup.' ); ?></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tamrank-sheet__foot">
                <p class="tamrank-sheet__foot-note"><?php tamrank_e( 'wizard_mig_foot', 'Leave this screen open until the move is finished. A backup was made first; it is kept until you use it.' ); ?></p>
            </div>
        </section>

        <!-- Step 3: Done (the plan becomes the report) -->
        <section class="tamrank-wizard__panel tamrank-sheet" data-panel="3" role="tabpanel" aria-label="<?php echo esc_attr( tamrank__( 'wizard_step_done', 'Done' ) ); ?>">
            <div class="tamrank-confetti" id="tamrank-confetti" aria-hidden="true"></div>
            <div class="tamrank-sheet__head">
                <div>
                    <h1 class="tamrank-sheet__title" id="tamrank-success-title" tabindex="-1"><?php tamrank_e( 'wizard_done_title', "You're all set!" ); ?></h1>
                    <p class="tamrank-sheet__sub" id="tamrank-success-subtitle"><?php tamrank_e( 'wizard_done_subtitle', 'Your SEO data has been successfully migrated to TamRank.' ); ?></p>
                </div>
                <span class="tamrank-done__badge" id="tamrank-zero-errors" hidden>
                    <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6.5L9 17.5l-5-5"/></svg>
                    <span><?php tamrank_e( 'wizard_zero_errors', '0 errors' ); ?></span>
                </span>
            </div>
            <div class="tamrank-sheet__body">
                <div class="tamrank-done">
                    <div>
                        <div class="tamrank-res" id="tamrank-success-block">
                            <div class="tamrank-res__head" id="tamrank-success-head"><?php tamrank_e( 'wizard_done_results_head', 'Moved over to TamRank' ); ?></div>
                            <div id="tamrank-success-stats">
                                <!-- Populated by JS -->
                            </div>
                        </div>

                        <div class="tamrank-qwin" id="tamrank-quick-win" hidden>
                            <span>
                                <span class="tamrank-qwin__label"><?php tamrank_e( 'wizard_quick_win', 'Quick Win' ); ?></span>
                                <span class="tamrank-qwin__text" id="tamrank-quick-win-text"></span>
                            </span>
                        </div>
                    </div>

                    <div>
                        <!-- Anchor 3: the way back, on the step where doubt lands.
                             Hidden when nothing was migrated (clean start). -->
                        <div class="tamrank-rb" id="tamrank-rollback-block" hidden>
                            <p class="tamrank-rb__title"><?php tamrank_e( 'wizard_rollback_title', 'Not happy with the result?' ); ?></p>
                            <p class="tamrank-rb__body" id="tamrank-rollback-body"></p>
                            <p class="tamrank-rb__keep" id="tamrank-rollback-keep"></p>

                            <div class="tamrank-rb__actions" id="tamrank-rollback-actions">
                                <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--outline" id="tamrank-rollback-start">
                                    <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>
                                    <?php tamrank_e( 'onboarding_rollback_migration', 'Roll back migration' ); ?>
                                </button>
                            </div>

                            <!-- Two-step confirm, inline: this wizard runs outside the admin
                                 chrome, so the shared TamRank.confirm() dialog is not loaded. -->
                            <div class="tamrank-rb__confirm" id="tamrank-rollback-confirm" role="group" aria-labelledby="tamrank-rollback-question" hidden>
                                <p class="tamrank-rb__question" id="tamrank-rollback-question"><?php tamrank_e( 'wizard_rollback_confirm_question', 'Roll back the migration now?' ); ?></p>
                                <div class="tamrank-rb__actions">
                                    <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--outline" id="tamrank-rollback-yes">
                                        <?php tamrank_e( 'wizard_rollback_confirm_yes', 'Yes, roll back' ); ?>
                                    </button>
                                    <button type="button" class="tamrank-btn tamrank-btn--sm tamrank-btn--ghost" id="tamrank-rollback-cancel">
                                        <?php tamrank_e( 'wizard_rollback_cancel', 'Keep the result' ); ?>
                                    </button>
                                </div>
                            </div>

                            <p class="tamrank-rb__status" id="tamrank-rollback-status" role="status" tabindex="-1" hidden></p>
                        </div>

                        <!-- Migration report: what was taken over, skipped, replaced or
                             not mappable. Filled by JS from the notes the server returns. -->
                        <ul class="tamrank-report" id="tamrank-migration-report" hidden></ul>
                    </div>
                </div>

                <!-- Email tips opt-in card (post-success, optional) -->
                <?php $tamrank_admin_email = get_bloginfo( 'admin_email' ); ?>
                <div class="tamrank-optin" id="tamrank-email-optin-card">
                    <span>
                        <span class="tamrank-optin__title"><?php tamrank_e( 'onboarding_tips_title', 'Setup tips by email' ); ?></span>
                        <span class="tamrank-optin__chip"><?php tamrank_e( 'onboarding_optional', 'Optional' ); ?></span>
                    </span>
                    <span class="tamrank-optin__body"><?php tamrank_e( 'onboarding_tips_body', 'Short practical emails about SEO, schema, redirects and site health.' ); ?></span>

                    <label class="tamrank-optin__row" id="tamrank-email-optin-row" for="tamrank-email-optin-checkbox">
                        <input type="checkbox" id="tamrank-email-optin-checkbox" class="tamrank-optin__checkbox">
                        <span class="tamrank-optin__box" aria-hidden="true"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6.5L9 17.5l-5-5"/></svg></span>
                        <span class="tamrank-optin__checkbox-label"><?php
                            /* translators: %s: admin email address */
                            echo wp_kses(
                                sprintf( tamrank__( 'onboarding_tips_consent', 'Yes, send the tips to <strong>%s</strong>' ), esc_html( $tamrank_admin_email ) ),
                                array( 'strong' => array() )
                            );
                        ?></span>
                    </label>

                    <!-- Persona reveal — only shown when checkbox is checked -->
                    <div class="tamrank-optin__persona" id="tamrank-persona-block" hidden>
                        <span class="tamrank-optin__persona-label"><?php tamrank_e( 'onboarding_persona_title', 'What best describes you?' ); ?></span>
                        <div class="tamrank-optin__persona-grid" role="radiogroup" aria-label="<?php echo esc_attr( tamrank__( 'onboarding_persona_title', 'What best describes you?' ) ); ?>">
                            <?php
                            // Two-way split mirrors the FREE welcome-flow paths
                            // (Path A owner / Path B dev). The in-house/freelance
                            // PRO personas are detected post-purchase, not here.
                            $tamrank_personas = array(
                                'A' => tamrank__( 'onboarding_persona_a', 'I manage my own site or webshop' ),
                                'B' => tamrank__( 'onboarding_persona_b', 'I build WordPress sites for clients' ),
                            );
                            foreach ( $tamrank_personas as $tamrank_code => $tamrank_label ) :
                            ?>
                            <label class="tamrank-optin__persona-card" data-persona="<?php echo esc_attr( $tamrank_code ); ?>">
                                <input type="radio" name="tamrank_persona_track" value="<?php echo esc_attr( $tamrank_code ); ?>" class="tamrank-optin__persona-radio">
                                <span class="tamrank-optin__persona-bullet" aria-hidden="true"></span>
                                <span class="tamrank-optin__persona-text"><?php echo esc_html( $tamrank_label ); ?></span>
                            </label>
                            <?php endforeach; ?>
                        </div>
                    </div>

                    <span class="tamrank-optin__disclaimer"><?php tamrank_e( 'onboarding_tips_disclaimer', '5 emails over 14 days, then silence. No newsletter. One-click unsubscribe in every email.' ); ?></span>
                </div>
            </div>
            <div class="tamrank-sheet__foot">
                <p class="tamrank-sheet__foot-note"><?php tamrank_e( 'wizard_done_foot', 'Know exactly what to improve: your first fix is waiting above.' ); ?></p>
                <a href="<?php echo esc_url( admin_url( 'admin.php?page=tam-rank-dashboard' ) ); ?>" class="tamrank-btn tamrank-btn--primary" id="tamrank-go-dashboard">
                    <?php tamrank_e( 'wizard_go_dashboard', 'Go to Dashboard' ); ?>
                    <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
                </a>
            </div>
        </section>

    </div><!-- /.tamrank-wizard__panels -->

</div><!-- /.tamrank-wizard -->

</body>
</html>
