A well-organized comedy full of pleasant surprises.

Almost everyone in Crazy Stupid Love has strong romantic feelings for someone they shouldn’t. That’s one of the reasons love is crazy and stupid, you see. Another reason is that love has this habit of looking pathetic until you fall into it, and then you can’t see how you were ever opposed to it. See? Crazy. And stupid.

Those are the observations made by the film, a multi-threaded and well-organized comedy full of pleasant surprises and appealing characters. Perhaps most surprising is the movie’s provenance: It was written by Dan Fogelman, who has worked mostly on children’s films (Cars, Bolt, Fred Claus), and directed by Glenn Ficarra and John Requa, who wrote the naughty Bad Santa before making the darkly comic I Love You Phillip Morris. Crazy Stupid Love lies at the intersection of those paths, a PG-13 story for grown-ups with a hint of subversiveness and a lot of sweetness.

It begins with good-hearted family man Cal Weaver (Steve Carell) learning that his wife of nearly 25 years, Emily (Julianne Moore), wants a divorce. She has been unhappy for a while, and has recently slept with a co-worker, David Lindhagen, whose name comes to be the movie’s favorite swear word, like Seinfeld’s “Newman.” Wounded and sad, Cal dutifully moves out of the house and into a condo.

While moping and drinking in an upscale cocktail lounge one night, the pitiable Cal draws the attention of Jacob (Ryan Gosling), an impossibly smooth and sharply dressed ladies’ man who can take a different girl home with him every night if he chooses to (and he does choose to). Jacob finds Cal’s pathetic dishevelment and dorky fashion sense fascinating. “I don’t know if I should help you or if I should euthanize you,” he says. He opts for the former and gives Cal one of those dress-and-grooming makeovers that movies love so much, in addition to supplying him with guidelines on how to pick up women.

But this is not just a smooth-guy-helps-nerd-find-love comedy, thank goodness. Jacob’s tutorial is effective, in its way — Cal finds a woman (Marisa Tomei) who admires his desperate honesty — but that’s accomplished while the movie is still young. Meanwhile, Jacob himself is in pursuit of his Great White Whale, Hannah (Emma Stone), a law student who is so far the only woman to resist his charms. (She has a sappy boyfriend, amusingly played by Josh Groban, whom she’s considering settling for.) The last thing Jacob wants is to fall in love, but he’s intrigued by the idea of someone who won’t sleep with him.

Then there’s Cal and Emily’s 13-year-old son, Robbie (Jonah Bobo), who is madly in love with his babysitter, 17-year-old Jessica (Analeigh Tipton), and tells her so. She wants nothing to do with a 13-year-old, obviously — and besides, she’s secretly in love with Robbie’s dad. So there’s another coupling that isn’t ever gonna happen.

Maybe we’re so accustomed to formulas that any slight deviation seems remarkable, but the way Crazy Stupid Love veers from the beaten path is, well, remarkable. You could make a good movie out of the Jacob/Cal story, each man teaching the other something about love and romance, each eventually finding his way, and so forth. But Fogelman’s witty, astute screenplay gives us more than that. The characters you’d expect to be supporting ones, like Hannah and Emily and the teenagers, are fully developed, and their stories are given due attention. The movie expands from a two-man piece into an ensemble affair.

Carell, funny as usual, is the more restrained version of himself here — more Dan in Real Life than Date Night. We’ve seen that before, and we like it. Gosling, on the other hand, is breaking new ground. In perusing his IMDb page, I’m astonished to realize that he has never starred in a comedy before. And yet here he is, giving his suave, sensitive persona a hilarious tweak as an unflappably confident pickup artist who winds up having some depth, too.

Emma Stone, who ought to be a bigger star than she is, continues to charm my socks off; Julianne Moore helps us sympathize with Emily, who’s hurting over the break-up almost as much as Cal is; the kids, Jonah Bobo and Analeigh Tipton, are confident performers; and hey, there’s Kevin Bacon as the oily David Lindhagen.

After being quite smitten with the first 75 percent of the movie, I feared all was lost when suddenly the plot threads began to converge in a contrived and farcical manner into one of those “they’re on a collision course with wackiness!!” scenarios. And then, somehow, the ship righted itself — only to go off-course again with a gooey, disappointing, formulaic finale. But most of the film rings true, reflecting all the humor and tragedy to be found in that crazy, stupid emotion.