“Logan” made Oscar history by becoming the first ever superhero movie to earn an Academy Award nomination for Best Adapted Screenplay — and writer/director James Mangold says they key to its success was focusing on what Logan fears most.

It isn’t Sentinels, Sabretooth, or any of the legion of foes he’s dispatched over the decades.

“For us, ‘Logan’ was always going to be a dramatic character piece,” Mangold, who wrote the film with Scott Frank and Michael Green, told TheWrap. “The last chapter of Wolverine’s arc, to us, should be about what he fears most, and that’s not the end of the world or his life, but intimacy. So every step of the way, we wanted to put Logan in a situation where he’d be in the greatest jeopardy, which is being asked to be vulnerable and to trust.”

Mangold said he and his fellow writers are grateful not only to the Academy, but to the “X-Men” fans who were willing to join him as Hugh Jackman and Patrick Stewart’s delivered their final performances as Wolverine and Professor Xavier.

“When I first started writing the film with Scott Frank and Michael Green, I was really nervous over whether the take we were going to have on Logan was going to be something that people were going to be shocked by and reject or embrace. The way people have leaned into this story has been very moving, and it’s really gratifying that we put this picture out almost a year ago and that people are still talking about it so much,” Mangold said.

“Logan” was loosely inspired by Marc Millar’s 2009 comic “Old Man Logan,” which finds the former Wolverine crossing a harshly divided America. The film finds a weakened, older Logan trying to protect both a senile and unstable Xavier and a young mutant named Laura (a.k.a. X-23), in a world where mutants are either engineered for nefarious purposes or exterminated.

Superhero films of late have been divided by the darkness of DC efforts like “Batman v Superman” and the comic tone of Marvel hits like “Thor: Ragnarok” and “Guardians of the Galaxy.”

“Logan” is dark in places and even sad, but Mangold says he wanted his tone to suit the story.

“‘Dark’ can just be an art direction,” Mangold said.

The film had two major inspirations, he said. The first was X-23, an “X-Men” character who debuted in the animated series “X-Men: Evolution” and has since grown in the comics as a successor and foil to Wolverine. The second was the 1950s western “Shane,” a film that is referenced in “Logan” and which provides the words for Laura’s tearful tribute to Logan at the end of the film.

Also Read: How 'Justice League' Became a 'Frankenstein' (Exclusive)

Much like Logan, the titular gunslinger in “Shane” finds himself running from a dark past, finding new purpose in helping a group of people he comes to see as a family, only to sacrifice everything for them.

“The first time I saw ‘Shane’ was when my dad got a Betamax machine and I watched it in upstate New York with him,” he recalls. “In fact, in the scene where Laura watches the film with Charles, the story he brings up about how he first saw the film is actually how Patrick [Stewart] saw the film for the first time, and it was something we just added into the script.”