@function rem($pixels, $text-size: 9pt) {
    @if (unitless($pixels)) {
        $pixels: $pixels * 1px;
    }

    @if (unitless($text-size)) {
        $text-size: $text-size * 1px;
    }

    @if ($pixels > 0) {
        // Workaround GTK clamping instead of rounding up
        @return ($pixels / $text-size * 1rem) + 0.000000001rem;
    } @else {
        // Workaround GTK clamping instead of rounding up
        @return ($pixels / $text-size * 1rem) - 0.000000001rem;
    }
}

@function shadow($level) {
    @if $color-scheme == "light" {
        @if $level == 1 {
            @return
                0 1px 3px rgba(black, 0.12),
                0 1px 2px rgba(black, 0.24);
        } @else if $level == 2 {
            @return
                0 3px 4px rgba(black, 0.15),
                0 3px 3px -3px rgba(black, 0.35);
        } @else if $level == 3 {
            @return
                0 3px 8px 2px rgba(black, 0.1),
                0 5px 5px -3px rgba(black, 0.4),
                0 8px 5px 1px rgba(black, 0.1);
        } @else if $level == 4 {
            @return
                0 2px 4px 2px rgba(black, 0.1),
                0 15px 12px -10px rgba(black, 0.4),
                0 8px 14px 4px rgba(black, 0.15);
        }
    } @else if $color-scheme == "dark" {
        @if $level == 1 {
            @return
                0 1px 3px rgba(black, 0.42),
                0 1px 2px rgba(black, 0.44);
        } @else if $level == 2 {
            @return
                0 3px 4px rgba(black, 0.25),
                0 3px 3px -3px rgba(black, 0.45);
        } @else if $level == 3 {
            @return
                0 3px 8px 2px rgba(black, 0.2),
                0 5px 5px -3px rgba(black, 0.5),
                0 8px 5px 1px rgba(black, 0.2);
        } @else if $level == 4 {
            @return
                0 2px 4px 2px rgba(black, 0.2),
                0 15px 12px -10px rgba(black, 0.5),
                0 8px 14px 4px rgba(black, 0.25);
        }
    }
}

@function highlight($sides: "full") {
    $highlight:
        inset 1px 0 0 0 scale-color($highlight_color, $alpha: -93%),
        inset -1px 0 0 0 scale-color($highlight_color, $alpha: -93%);

    @if $sides == "top" or $sides == "full" {
        $highlight:
            inset 0 1px 0 0 scale-color($highlight_color, $alpha: -70%),
            $highlight;
    }

    @if $sides == "bottom" or $sides == "full" {
        $highlight:
            inset 0 -1px 0 0 scale-color($highlight_color, $alpha: -80%),
            $highlight;
    }

    @return $highlight;
}

$disabled-opacity: 0.5;
$window_radius: 9px;
