// https://m3.material.io/components/sliders/specs

.sd-slider {
    --percentage: 0%;
    --min-length: 5rem;
    box-sizing: border-box;
    display: inline-block;
    vertical-align: middle;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent; // remove webkit blue tap effect

    &-inactive_track,
    &-active_track {
        display: inline-block;
        position: absolute;
    }

    &-inactive_track {
        background: var(--md-sys-color-surface-container-highest);
        width: 100%;
        border-radius: 8px;
    }
    &-active_track {
        background: var(--md-sys-color-primary);
    }

    &:focus {
        outline: none;
    }

    &[data-sd-disabled='true'] {
        pointer-events: none;
        filter: grayscale(98%) opacity(40%);
    }

    //? horizontal
    &[data-sd-direction='horizontal'] {
        min-width: var(--min-length);
        height: 40px;
        margin: 0 20px;
        .sd-slider-inactive_track,
        .sd-slider-active_track {
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            height: 4px;
        }
        .sd-slider-inactive_track {
            width: 100%;
        }
        .sd-slider-active_track {
            width: var(--percentage);
            border-top-left-radius: 8px;
            border-bottom-left-radius: 8px;
        }

        .sd-slider-handle,
        .sd-slider-state_layer {
            top: 50%;
            transform: translateY(-50%);
        }
        .sd-slider-handle {
            left: calc(var(--percentage) - 10px);
        }
        .sd-slider-state_layer {
            left: calc(var(--percentage) - 20px);
        }
    }

    //? vertical
    &[data-sd-direction='vertical'] {
        min-height: var(--min-length);
        width: 40px;
        margin: 20px 0;
        .sd-slider-inactive_track,
        .sd-slider-active_track {
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 4px;
        }
        .sd-slider-inactive_track {
            height: 100%;
        }
        .sd-slider-active_track {
            height: var(--percentage);
            border-bottom-left-radius: 8px;
            border-bottom-right-radius: 8px;
        }

        .sd-slider-handle,
        .sd-slider-state_layer {
            left: 50%;
            transform: translateX(-50%);
        }
        .sd-slider-handle {
            bottom: calc(var(--percentage) - 10px);
        }
        .sd-slider-state_layer {
            bottom: calc(var(--percentage) - 20px);
        }
    }

    &-handle,
    &-state_layer {
        display: inline-block;
        box-sizing: border-box;
        border-radius: 50%;
        position: absolute;
        border-radius: 50%;
    }

    &-handle {
        cursor: grab;
        height: 20px;
        width: 20px;
        background: var(--md-sys-color-primary);
        touch-action: none;
    }
    &-state_layer {
        height: 40px;
        width: 40px;
        pointer-events: none;
        transition: opacity 200ms;
        background-color: rgb(0 0 0 / 0.1);
    }
    &-label {
        font-size: 10px;
        font-weight: 500;
        background: var(--md-sys-color-primary);
        color: var(--md-sys-color-on-primary);
        display: inline-block;
        box-sizing: border-box;
        width: 28px;
        height: 28px;
        border-radius: 100%;
        line-height: 28px;
        text-align: center;
        pointer-events: none;
        transition: opacity 200ms;
        text-wrap: nowrap;
        white-space: nowrap;
        overflow: visible;
        padding: 0 4px;
        text-overflow: ellipsis;
    }
}
