@use "sass:math" $fs: 21px $mplr: 1.667 $lcct: 32 $lgth: $lcct * 1rem $lmch: $mplr * 1rem $lsid: calc(($mplr - 1) / 2) * 1rem $lacs: (2 * $mplr - 1) * 1rem html, body writing-mode: vertical-rl font-size: $fs article height: $lgth text: align: justify margin: $lacs // Style text frame @mixin text_frame($_lcct, $should_set_fs: false) @if $should_set_fs html, body font-size: $fs article height: $_lcct * 1rem @function corresponding_screen_height($text_frame_height) // Should return `px` @debug $text_frame_height, $fs, $text_frame_height + (2 * $mplr - 1) * 2 * $fs @return $text_frame_height + (2 * $mplr - 1) * 2 * $fs // Create `max-height` breakpoints $_last_breakpoint: null @mixin screen_breakpoints($start_lcct, $decrease, $fs) $fs: $fs !global @for $i from 0 through $decrease @if $i == 0 @if $_last_breakpoint != null @media screen and (max-height: corresponding_screen_height($_last_breakpoint)) @include text_frame($start_lcct - $i, true) @else @media screen and (max-height: corresponding_screen_height(($start_lcct - $i + 1) * $fs)) @include text_frame($start_lcct - $i) @if $i == $decrease $_last_breakpoint: ($start_lcct - $i) * $fs !global @mixin lgth_step_down($ideal_lcct, $min_lcct, $sizes...) $sizes: append($sizes, 0px) @for $i from 1 to length($sizes) $greedy_step: math.floor(math.div((nth($sizes, $i) - nth($sizes, $i + 1)) * $ideal_lcct, nth($sizes, $i))) $step: min($greedy_step, $ideal_lcct - $min_lcct) @include screen_breakpoints($ideal_lcct, $step, nth($sizes, $i)) @include lgth_step_down($lcct, 18, 21px, 18px, 16px)