<?php
/**
 * After login: set client marker then continue into the app (PWA session gate).
 * Expects $pwaEstablishRedirect (string URL under this site) set by app.php.
 */
declare(strict_types=1);

if (!isset($pwaEstablishRedirect) || $pwaEstablishRedirect === '') {
    $pwaEstablishRedirect = BASE_PATH . '/mobile';
}
$targetJs = json_encode($pwaEstablishRedirect, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_UNESCAPED_SLASHES);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
    <meta name="theme-color" content="#0b1b89">
    <title>Loading…</title>
</head>
<body style="margin:0;background:#0b1b89;color:rgba(255,255,255,0.85);font-family:system-ui,sans-serif;display:flex;align-items:center;justify-content:center;min-height:100dvh;">
<p style="font-size:0.9rem;">Loading…</p>
<script>
try { sessionStorage.setItem('naz_m_pwa', '1'); } catch (e) {}
window.location.replace(<?= $targetJs ?>);
</script>
</body>
</html>
