//
// Copyright 2022 Google LLC
// SPDX-License-Identifier: Apache-2.0
//
// [Modified by Sandlada & Kai Orion]
//
// Copyright 2025 Sandlada & Kai Orion
// SPDX-License-Identifier: MIT
//

@use 'sass:map';
@use '../../../themes';

@mixin styles() {
    & {
        @include _elevation(
            (
                'default': var(--_container-elevation),
                'focus': var(--_focus-container-elevation),
                'hover': var(--_hover-container-elevation),
                'pressed': var(--_pressed-container-elevation),
            ),
            var(--_container-shadow-color)
        );
    }

    &.lowered {
        @include _elevation(
            (
                'default': var(--_lowered-container-elevation),
                'focus': var(--_lowered-focus-container-elevation),
                'hover': var(--_lowered-hover-container-elevation),
                'pressed': var(--_lowered-pressed-container-elevation),
            )
        );
    }
}

@mixin _elevation($states, $shadow-color: null) {
    @include themes.md-comp-elevation-theme(
        (
            'level': map.get($states, 'default'),
        )
    );

    @if $shadow-color {
        @include themes.md-comp-elevation-theme(
            (
                'shadow-color': $shadow-color,
            )
        );
    }

    // apply elevation in order of focused, hovered, pressed, disabled
    // this ensures a button will have hover elevation after being focused
    &:focus {
        @include themes.md-comp-elevation-theme(
            (
                'level': map.get($states, 'focus'),
            )
        );
    }

    &:hover {
        @include themes.md-comp-elevation-theme(
            (
                'level': map.get($states, 'hover'),
            )
        );
    }

    &:active {
        @include themes.md-comp-elevation-theme(
            (
                'level': map.get($states, 'pressed'),
            )
        );
    }
}
