Oooooh, excellent question!
So Gimli’s love is hidden away quite well – but it bursts out of him at times, usually due to frustrated worry. The whole of Chapter 24 is basically an illustration of this tendency, ngl.
He figured out his deepening attraction upon Anduin, as they shared a boat. Since Lothlorien he didn’t feel obligated to hate Legolas for his race or his part in the Company’s past, and so Gimli was spending time with him without those old perceptions colouring their every interaction. And it was pleasant.
More than pleasant.
He spends all of Chapter 18 basically flirting. It’s banter, to be sure, but that’s how he flirts. Gimli is good with words, and he enjoys them. That Legolas can more than hold his own is a delight to him.
And then, Chapter 19, and THIS.
Then the Elf turned back to allow his eyes to settle again on Gimli. Thorin’s star was pale, his face drawn into lines of pain once more. His dark eyes were screwed shut.
“My friend,” Legolas said, and he dropped to a crouch before the Dwarf, his expression open and full of sorrow and sympathy. “Here.”
Gimli opened his eyes, and saw Legolas’ slim white knife offered to him. He stared at it, unmoving, for a long moment, and then he took it in his great thick-fingered hands, his palm sliding over the hilt.
Legolas watched, utterly silent, as Gimli undid the plaits of his bright beard. His hand rose, the white knife glinting, and a swathe of red hair fell into the foaming white water as Boromir was carried away towards Rauros-falls, and Gondor.
This is such a huge thing to Gimli. It’s important to the extent that he actually mentions it later in ch20, thanking Legolas for the use of his knife, even while running over Rohan with a head full of frantic worry for the Hobbits.
It’s the moment that turns a ‘liking’ into something a little more. Legolas shows a perfect understanding of Gimli by offering him the use of his knife – it displays respect both for his customs AND for his emotions. It shows Gimli that Legolas sees him, truly – as both a Dwarf and as an individual.
Legolas, now – Legolas doesn’t even realise. Not for a while longer, as you say. After Aragorn is lost over the cliff, Legolas turns to Gimli for comfort. He already knows that Gimli’s death would be the thing to break him, and says so, but he doesn’t follow that thought to its end because of his grief for Aragorn. Events move at an incredible pace after that. They barely have any time for introspection at all – only that brief pause upon the walls of Helm’s Deep. So Legolas never has the leisure to think, really.
But check out this moment at the end of Chapter 25:
“Things go ill,” he panted, wiping the sweat from his brow.
“Ill enough,” Legolas said, and glanced back at the heavy door with its steel bars, “but not yet hopeless. Where is Gimli?”
Aragorn blinked the sweat from his eyes, and then looked alarmed as he turned back to stare at the closed door as well. “I do not know. I last saw him fighting on the ground behind the wall, but the enemy swept us apart.”
Legolas paled so swiftly and dramatically that Thorin half-feared he would faint. “In the Deep?” he faltered weakly. “That is evil news.”
“He is stout and strong,” said Aragorn, stepping forward quickly and grasping Legolas’ shoulders tightly. “Let us hope he will escape back to the caves. There he would be safe for a while. Such a refuge would be to the liking of a Dwarf.”
Legolas’ breath was coming fast as he said in a whisper, “that must be my hope.”
“Legolas,” Aragorn said helplessly, but the Elf shook his head sharply and his face was so twisted and ravaged that Thorin could barely believe it belonged to one of the Firstborn.
Aragorn shook the slender shoulders firmly. “Legolas, he will be well,” he swore.
“I desired…” Legolas said, and he raised his head to meet the eyes of the Man, something fierce and defiant and desperate in his gaze. “I desired to tell him that my tale is now thirty-one.”
“If he wins back to the caves, he will pass your count again,” Aragorn said encouragingly. “Never did I see an axe so wielded.”
Legolas nodded silently, and then he said, “I must seek more arrows.”
Aragorn gave him a dubious look, but let go of his shoulders and began to make his way through the tunnels of the Hornburg.
Legolas stood where he was for a moment, and then he drew himself up tall. His face was still white as milk, but two bright spots of colour glowed in his cheeks and he looked nearly maddened with grief. “Hear me, Thorin Oakenshield, if you be near,” he said in a voice that cracked and shook, “find him. Leave this place and find him! I will do you any service, perform for you any penance, if you can only tell me that he is alive and well! If that cannot sway you, then for the love we both bear him, find him. Protect him. I cannot lose him!”
This moment. YUP. Legolas Found His Clue.
And of course, at this stage Gimli is still concealing his own (hopeless, or so he thinks) love for Legolas, half-certain that it will not be accepted, half-afraid he would ruin their friendship (so new and strange in itself) by speaking.
STRAIGHT AFTER THIS LIL MOMENT, WE GET THE BOMBSHELL THAT IS CHAPTER 26:
“I never thought to find wisdom in a Dwarf,” Legolas said softly, wiping down Gimli’s cheek. His long, pale fingers hovered over Gimli’s thick wild hair. “No, nor beauty either.”
Aragorn looked up, startled. “Legolas?”
The Elf paused, and when he spoke again his voice was barely audible. “De melin, Aragorn.”
There was silence, and then Aragorn shook his head roughly. “Man ebennig?” he demanded.
“Westron!” Thorin growled.
“De melin,” Legolas said, and closed his eyes. “Melin Gimli.”
“Ci vêr?” Aragorn said, leaning forward and reaching out to touch Legolas’ forehead. The Elf batted his hand away irritably.
“I tell you, it is true!” he said insistently, before turning back to look down at the sleeping Dwarf. “I never knew, not until I thought him lost. Then it was clear to me. He is the one I have waited for, and nothing shall part my heart from his, not war or death or my people or his.”
Thorin froze. His blood began to crystallise in his veins, except where it pounded in his temples.
Legolas looked up, defiance in his eyes. “You disapprove?”
Aragorn blew out a long breath, and then he chuckled softly. “Mellon nin, I am absolutely amazed you have not actually realised this before now.”
And whoops then they all get drunk, and Gimli is happy and a bit handsy but still well able to keep his emotions hidden. LEGOLAS? HELL NO. He comes so close to saying it, to confessing, and he even gets a bit weepy. He calls Gimli ‘meleth nin’ and babbles in Sindarin. Helpful, if the person you are babbling to speaks Sindarin. As it is, Gimli is just ??? SPEAK WESTRON, ALSO YOU’RE A BIT BONKERS AND YOU’RE WORRYING ME NOW ARE YOU OKAY
(And guess what: if Legolas had confessed his love in Westron, then Gimli most likely would not have spoken to Aragorn the next day. Aragorn would not have told him about the pecularities of Elves in love, and the risk of death they face when loving a mortal.
Gimli would not have continued to hide his love for the NEXT TEN CHAPTERS, weeks and weeks and weeks and weeks. He wouldn’t have summarily decided that he knew what was best for both Legolas and himself without ever consulting the Elf at all, making them both so thoroughly miserable. THERE IS A GIANT WHAT-IF HERE, is what I’m saying heheheh)
So yeah – there’s a tremendously thorough answer, I spose! lmao, I should title this as “Analysis and Implied Development of the Gimli/Legolas Relationship in the Fic ‘Sansukh’ By Some Twit Somewhere” :DDDDD