For more than three decades Kevin Costner has personified the all-American everyman. We root for him to save the day – and it’s an archetype he’s happy to embody.

“I think when people are watching a movie, they often just want to feel like the right thing is going to be said and done. They want to know that somebody is willing to die for an idea, and I’ve been fortunate to play that kind of hero,” says the screen legend and Oscar-winning director. It’s an astute observation given the indelible characters he’s portrayed in blockbusters ranging from classic baseball flicks, Bull Durham (1988) and Field Of Dreams (1989), to epic western, Dances With Wolves (1990) and romantic thriller The Bodyguard (1992).

In the tradition of Spencer Tracy (one of his own role models), and his contemporary, Tom Hanks, Costner possesses a basic decency – together with blue-collar cred – that translates authentically onto the screen. “You know, movies are a chance for us to sit in the dark and wonder who we are and who we wish we could be,” reflects Costner, discussing his formidable film career over coffee in Beverly Hills. “People go, ‘I wish I was him,’ or ‘I wish somebody would fight for me the way he fought for them.’ We all want somebody to stand up for us,” says the actor, who at 62, remains a charismatic presence. There are lines around his vivid green eyes, but that doesn’t detract from his intrinsic good looks. He’s in great shape. Rather than rigorous sessions logged at the gym, it’s the result of intensive physical labour at his 160-acre Aspen, Colorado ranch and keeping up with his three young children – Cayden (nine), Hayes (seven), and Grace (six) – from his second marriage to Christine Baumgartner.

There have been deviations from Costner’s stock in good-guy roles: he played against type as a terrifying psychopath in last year’s sci-fi thriller, Criminal. But it’s the heroes that have defined him, which is obviously why Theodore Melfi (writer/director of St Vincent) cast him as the head of NASA’s Space Task Group, standing up to racial prejudice, in the soaring drama Hidden Figures. Set in the early 1960s at the height of the Cold War, when segregation divided the United States, it’s based on the book of the same name by Margot Lee Shetterly. The film relates the true, little-known story of three brilliant black female mathematicians. Known at the time as ‘coloured computers,’ they were instrumental in helping America to win the Space Race.

“These young black women were so smart that their talent was recognised – and they had success in between the raindrops of racism,” says Costner, who nails the role of their boss, the gum-chewing, straight-talking (fictional) Al Harrison, with his crew cut, grey Brooks Brothers suits and narrow ties. A pragmatist, Harrison observes the potential of one of the ‘computers’, Katherine Johnson (played in the film by Taraji P Henson). A mathematical prodigy, Johnson, now 98, calculated the trajectory for astronaut John Glenn’s historic 1962 orbit of the Earth. (Glenn died in December last year).

“Maths is almost like sports: you can either do it or you can’t,” says Costner, explaining how Johnson and the other women, Dorothy Vaughan (Octavia Spencer) and Mary Jackson, NASA’s first black, female engineer (Janelle Monáe) were hired and made an impact, despite the racial discrimination and sexism they faced. “Maths has nothing to do with the power of your personality or good looks or anything else that people are often measured by,” says Costner, “so when they were looking for the very best at NASA, they had the tendency to go colour blind.”

There is a dramatic, pivotal moment in the film that sums up Costner’s character – and the man himself – when Al Harrison takes a hammer to the ‘whites only’ bathroom sign and smashes it down, pronouncing: “At NASA we all pee the same colour.” Costner says his character isn’t a civil rights pioneer; he is simply intent on getting the job done. “He doesn’t want America to lose the Space Race, but he also has empathy and fairness, so when injustice is put in front of his face, he says ‘of course, that should be fixed.’”

I said the N-word a thousand times as a child. That’s how you talked. But there comes a moment when you choose how you are going to be yourself.

“I’ve been humiliated before in my life by a teacher,” he goes on. “I was in the fourth grade (aged nine), I remember I was scared, so can you imagine being humiliated everyday of your life? Racism is alive and well in America,” Costner comments, noting that Hidden Figures is still relevant in the new era of Trump’s America. “It’s unfortunate, but it’s there, and all I can try to do is make my choices and educate my children.” (As well as his young family, Costner has three older children, Annie (32), Lily (30), and Joe (29), from his first marriage to Cindy Silva – they divorced in 1994. He also has a son Liam (20), from a relationship he had with Bridget Rooney.

Costner admits that growing up in Compton, close to LA, racism was entrenched and his own family and friends were oblivious to the language they used habitually. “I said the N-word a thousand times as a child. That’s how you talked. But there comes a moment when you choose how you are going to be yourself. All of a sudden, telepathically you knew that word wasn’t funny; it fell flat like a coke that had no more bubbles in it, and it was gone, eliminated.” He points out, though, that even in the early 1990s, “Some people weren’t happy that I picked Whitney Houston to be my love interest in The Bodyguard – and that I kissed her; who wouldn’t want to kiss her? I don’t think those people were happy that I would do Hidden Figures.”

While Costner is motivated by a deep, altruistic impulse, he has consistently refused to play it safe. There’s been no shortage of accolades in his career, Dance With Wolves won seven Oscars, two for Costner. Oliver Stone’s JFK led to strong reviews, so did the golfing comedy Tin Cup (1996), Clint Eastwood’s drama, A Perfect World (1993), and the 2012 mini-series Hatfields & McCoys, which resulted in an Emmy. There have been disappointments, too: the 1995 post-apocalyptic Waterworld was panned by the critics and tanked at the box office, although the film eventually broke even internationally. Yet Costner has always enjoyed taking risks and is prepared to put his own money on the line for passion projects.

“I have done it a lot in my life. My wife and I paid for Black and White with our money [a recent film dealing with race relations]. Relativity Media [the company behind the film] went bankrupt, but I am proud of the movie. I’m drawn to stories of all different sizes – Field of Dreams and Bull Durham cost less than $10m – it’s simply how I conduct my life. I love the ‘what if it works,’ better than the ‘well I guess it didn’t…’ I love the ‘everything’s possible’ mentality.”

He has the same approach to business. “I’ve lost my own money on projects, but I’ve never lost other people’s money. I’ve invested enormous amounts of money in technologies that I thought would help the world,” says Costner whose company, Ocean Therapy Solutions (OTS), developed a system designed to clean up oil spills. The actor tells me he lost more than $40m with his eco endeavours. Characteristically, he has no regrets. “I did it at the time because I thought it was the right thing to do. I made that money back 20 years later, believe it or not, and I didn’t know that I ever would,” he says. “But I am not the greatest businessman because most businessmen say: ‘use other people’s money.’ I’m more of a dreamer. I’ve always felt that failure is a completely underrated experience. I take chances, it’s part of my DNA.”

I mentioned to Costner that I would have to take three flights back to LA, and he immediately arranged for me to travel home in his own Gulfstream III

It’s one of the actor’s most appealing qualities. And I’ve discovered over the course of many interviews with Costner, that he is also instinctively warm and generous. Several years ago, at a remote film set in Louisiana, where he was shooting The Guardian (another of those Costner staples in which he played a rescue swimmer) we talked over lunch in his trailer – steak and potatoes – and the actor invited me to a private concert at a nearby US air force base, where he was performing with his rock band, Kevin Costner & Modern West. (They still tour regularly.)

The next day, I mentioned to Costner that I would have to take three flights back to LA, where I live, and he immediately arranged for me to travel home in his own Gulfstream III, flown by his personal pilot. Another interview took place at the actor’s sprawling ranch in Colorado, which he describes as ‘God’s country’. He drove me around the estate, which has breathtaking views over the mountains, and gave me a tour of the house; before we joined his wife and children for lunch. The family also owns an ocean-front house near Santa Barbara. It’s evident that Costner doesn’t take any of it for granted and is still firmly in touch with his working-class roots. He was raised with his older brother Dan; (a middle brother died at birth); his father Bill, a ditch digger, then an electrician; and his mother Sharon. “My family had very modest amounts of money – we had a small house, but my backyard was my kingdom,” he says. “And I loved being out in the wild.”

Costner attended college in California, studying business, where he met his first wife. With the goal of becoming an actor, he paid the rent working a variety of jobs: as a carpenter, a fisherman and a truck driver. Given Costner’s all-American persona, it’s interesting that the man who inspired him to pursue his dreams seriously was fiery Welsh rebel rouser Richard Burton, who he met on a plane in 1978, returning to California from his honeymoon in Mexico.

“I saw that he (Burton) boarded the plane before anyone else. He’d bought four seats around him so nobody would talk to him. I didn’t fucking know that,” laughs Costner. “I just saw him and took the opportunity to try talk to him.” With the cavalier bravado of youth, Costner walked up to Burton. “I was like a mouse playing with a mongoose. I said, ‘Hey, can I talk to you?’ And he said ‘OK, after I finish this book.’ I saw him put the book down and then he went to sleep.”

When Burton woke up, Costner sat down beside him. “I’d grown up hearing about his reputation as a brawler and having a kind of unhappy life, and I told him: ‘Gee, I don’t really want it [success] that bad to go through all that.’” What exactly did the two men discuss? “He didn’t say ‘Well, you’re going to have to work really hard.’ He didn’t bother with all that bullshit because either you know that or you don’t… I’m not telling you what he said, because I haven’t told anybody, but he was kind.” The actor laughs. “When we got off the plane he didn’t have to go through customs and I thought: ‘Wow, that’s cool!’ Then me and my wife were sitting out on the curb at the airport in LA with our luggage, waiting for the bus, and I swear to God, all of a sudden this limousine came this close,” Costner reaches out across the sofa and touches my arm, “and it stopped, and the window came down, and it was Burton – he said ‘Good luck!’”

The serendipitous encounter changed his life. “I had taken a job in construction, but I was going to acting school at night, after that, I said to my wife: ‘We’re moving to Hollywood.’” Of course, he never looked back. After the disappointment of his first film role, as a corpse in Lawrence Kasdan’s classic, The Big Chill, which ended up on the cutting room floor, he landed the role of federal agent Eliot Ness in the gangster flick, The Untouchables, three decades ago. That same year, the psychological thriller No Way Out vaulted Costner to stardom, establishing him as a leading man – and a sex symbol.

His enthusiasm for filmmaking has never diminished. “It’s about being fearless. I’ve never been afraid of whether or not I’m number one at the box office.” He returns to his favourite theme, essentially his philosophy on life: work hard and take risks. “I’ve tried to live my life so my kids can take whatever example they want from it. They understand that when things don’t work for me, I just change my thinking and I figure it out.”

Given his own humble upbringing, he says he’s done his best to teach his children strong values, without spoiling them. “Their set of problems are different from mine,” he smiles. “They’re having to learn how to share the good luck that we’ve had,” says Costner, a devoted family man. “Fatherhood is a lifetime commitment,” he says. “It is the one thing I’m really proud of. I’ve heard a lot of people say ‘Oh the first time around I was so busy with my career, I didn’t get to be with them,’ but that’s not my story.”

Costner’s Hollywood story continues with a mammoth project planned for 2017, which sees him going behind the camera, returning to the genre that is closest to his heart. “I’m making a ten-hour western – maybe it will be three movies, I don’t care – I’m going to shoot it all. It’s going to be pretty beautiful and pretty violent, about people making their way across the country in a resourceful way, in a violent way, and the people who got trampled in the middle,” he says, carried away by his epic vision. The last film Costner directed was a western too, Open Range in 2003. “I’m always drawn to them; they look at how America was this giant experiment, full of hope and opportunity for some people and a death note for others.”

“There’s no formula for why I do what I do when I do it,” he says about his choice of roles. “It’s like when you’re in school and you hear the bell go off, I just run outside and see what I want to do.” But Costner says he is most content on the Aspen ranch. “I was just there for three weeks and I worked every day for seven hours. I got on my tractor; I built roads; I built a tree house; designed a barn,” he says. “I get the hammers and the saw out – I get the kids out there and we work. I’m not a terribly good craftsman, but I can work all day. I’m kind of a mule and I am happy when I’m on my tractor.” He pauses and smiles: “You know, I never had a perfect life, but I have had a perfect life in a way. My children are healthy, I’ve got a couple more cowboy movies I want to make, and I’m feeling alright.”

Hidden Figures is in cinemas on 17 February 2017.