Spin-orbit coupling can be described in two approaches. The first method, known as the "MacDonald torque", is often combined with a convenient assumption that the quality factor Q is frequency-independent. This makes the method inconsistent, because derivation of the expression for the MacDonald torque tacitly fixes the rheology of the mantle by making Q scale as the inverse tidal frequency. Spin-orbit coupling can be treated also in an approach called "the Darwin torque". While this theory is general enough to accommodate an arbitrary frequency-dependence of Q, this advantage has not yet been fully exploited in the literature, where Q is often assumed constant or is set to scale as inverse tidal frequency, the latter assertion making the Darwin torque equivalent to a corrected version of the MacDonald torque. However neither a constant nor an inverse-frequency Q reflect the properties of realistic mantles and crusts, because the actual frequency-dependence is more complex. Hence it is necessary to enrich the theory of spin-orbit interaction with the right frequency-dependence. We accomplish this programme for the Darwin-torque-based model near resonances. We derive the frequency-dependence of the tidal torque from the first principles of solid-state mechanics, i.e., from the expression for the mantle's compliance in the time domain. We also explain that the tidal torque includes not only the customary, secular part, but also an oscillating part. We demonstrate that the lmpq term of the Darwin-Kaula expansion for the tidal torque smoothly passes zero, when the secondary traverses the lmpq resonance (e. g., the principal tidal torque smoothly goes through nil as the secondary crosses the synchronous orbit). Thus, we prepare a foundation for modeling entrapment of a despinning primary into a resonance with its secondary. The roles of the primary and secondary may be played, e. g., by Mercury and the Sun, correspondingly, or by an icy moon and a Jovian planet. We also offer a possible explanation for the "improper" frequency-dependence of the tidal dissipation rate in the Moon, discovered by LLR.