@@ -156,7 +156,10 @@ dfn {
156156
157157/* Rules are generated via r[foo.bar] syntax, processed by mdbook-spec. */
158158.rule {
159- font-size : 0.8em ;
159+ --font-size-mult : 0.8 ;
160+ --font-size : calc (1em * var (--font-size-mult ));
161+
162+ font-size : var (--font-size );
160163}
161164
162165/* included in the grid below as 20px */
@@ -296,6 +299,60 @@ main > .rule {
296299 width : 20px ;
297300}
298301
302+ /* Align rules to various siblings */
303+ .rule : has (+ p ),
304+ .rule : has (+ ul ) {
305+ margin-top : calc ((1em - var (--font-size )) / var (--font-size-mult ) / 2 );
306+ }
307+
308+ .rule : has (+ h1 ) {
309+ align-self : center;
310+ }
311+
312+ .rule : has (+ h2 ) {
313+ /* multiplying by this turns h2's em into .rule's em*/
314+ --h2-em-mult : calc (
315+ (1 / var (--font-size-mult )) /* to main font size */
316+ * 1.5 /* to h2 font size */
317+ );
318+
319+ margin-top : calc (
320+ /* h2 margin top */
321+ 2.5em * var (--h2-em-mult ) - 16px
322+ /* half of the font size difference */
323+ + (1em * var (--h2-em-mult ) - 1em ) / 2
324+ )
325+ }
326+ .rule : has (+ h3 ) {
327+ /* multiplying by this turns h3's em into .rule's em*/
328+ --h3-em-mult : calc (
329+ (1 / var (--font-size-mult )) /* to main font size */
330+ * 1.17 /* to h3 font size */
331+ );
332+
333+ margin-top : calc (
334+ /* h3 margin top */
335+ 2.5em * var (--h3-em-mult ) - 16px
336+ /* half of the font size difference */
337+ + (1em * var (--h3-em-mult ) - 1em ) / 2
338+ )
339+ }
340+
341+ .rule : has (+ h4 ) {
342+ /* multiplying by this turns h4's em into .rule's em*/
343+ --h4-em-mult : calc (
344+ (1 / var (--font-size-mult )) /* to main font size */
345+ * 1 /* to h4 font size */
346+ );
347+
348+ margin-top : calc (
349+ /* h4 margin top */
350+ 2em * var (--h4-em-mult ) - 16px
351+ /* half of the font size difference */
352+ + (1em * var (--h4-em-mult ) - 1em ) / 2
353+ )
354+ }
355+
299356/* Sets the color for [!HISTORY] blockquote admonitions. */
300357.history > blockquote {
301358 background : # f7c0eb ;
0 commit comments