@* Bounces an unauthenticated user to /login with the original URL preserved as
   ?returnUrl=. The /auth/login endpoint reads the parameter and forwards after a
   successful bind so deep-links survive the auth hop. *@

@inject NavigationManager Nav

@code {
    protected override void OnInitialized()
    {
        var current = Nav.ToBaseRelativePath(Nav.Uri);
        var returnUrl = string.IsNullOrEmpty(current) || current.StartsWith("login", StringComparison.OrdinalIgnoreCase)
            ? null
            : "/" + current;
        var target = returnUrl is null ? "/login" : $"/login?returnUrl={Uri.EscapeDataString(returnUrl)}";
        Nav.NavigateTo(target, forceLoad: true);
    }
}
