@use '../../styles/abstract/base' as base;
@use '../../styles/abstract/variables' as v;
@use '../../styles/abstract/functions' as f;
@use '../../styles/abstract/mixins' as m;
@use '../../styles/abstract/direction' as d;
@use '../../styles/abstract/theme' as t;

$component: '#{base.$prefix}-snackbar';
$button: '#{base.$prefix}-button';
$icon-button: '#{base.$prefix}-icon-button';

$margin: 16px;

.#{$component} {
--#{base.$prefix}-density: 0;
@include m.typography('body-medium');
box-sizing: border-box;
position: fixed;
bottom: $margin;
z-index: f.get-z-index('snackbar');
display: flex;
align-items: center;
min-width: 320px;
max-width: 600px;
min-height: 48px;
padding: 0 16px;
background-color: t.color('inverse-surface');
color: t.color('inverse-on-surface');
border-radius: f.get-shape('extra-small');
@include m.elevation(3);

opacity: 0;
scale: 0.8;
transition:
opacity v.motion('spring-fast-effects-duration') v.motion('spring-fast-effects-easing'),
scale v.motion('spring-fast-spatial-duration') v.motion('spring-fast-spatial-easing');
pointer-events: none;

&--visible {
opacity: 1;
scale: 1;
pointer-events: auto;
}

&:where([popover]) {
inset: auto;
bottom: $margin;
margin: 0;
border: 0;
overflow: visible;
}

&--center {
left: 50%;
translate: -50% 0;
}

&--start {
@include d.start($margin, $self: true);
}

&--end {
@include d.end($margin, $self: true);
}

&__text {
@include m.truncate(2);
flex: 1 1 auto;
min-width: 0;
margin: 14px 0;
overflow-wrap: anywhere;
}

&--with-action &__text,
&--dismissible &__text {
padding-inline-end: 8px;
}

&--with-action {
padding-inline-end: 8px;
}

&--dismissible {
padding-inline-end: 0;
}

.#{$button}.#{$component}__action {
flex: 0 0 auto;
color: t.color('inverse-primary');

&:hover {
@include m.state-layer(t.color('inverse-primary'), 'hover');
}

&:focus-visible {
@include m.state-layer(t.color('inverse-primary'), 'focus');
outline-color: t.color('inverse-primary');
}

&:active,
&.#{$button}--active {
@include m.state-layer(t.color('inverse-primary'), 'pressed');
}
}

.#{$icon-button}.#{$component}__close {
flex: 0 0 auto;
color: t.color('inverse-on-surface');

&:hover {
color: t.color('inverse-on-surface');
}

&:focus-visible {
outline-color: t.color('inverse-on-surface');
}
}

&--action-below {
flex-wrap: wrap;
padding-bottom: 4px;

.#{$component}__text {
flex-basis: 100%;
padding-inline-end: 16px;
}

.#{$component}__action {
margin-inline-start: auto;
}
}

@include m.breakpoint-down('sm') {
min-width: 0;
max-width: none;
width: calc(100% - #{2 * $margin});

&--center {
left: $margin;
translate: none;
}

&--start,
&--end {
inset-inline: $margin;
}
}

@include m.reduced-motion {
scale: none;
transition: opacity v.motion('spring-fast-effects-duration') v.motion('spring-fast-effects-easing');

&--visible {
scale: none;
}
}

@include m.high-contrast {
border: 1px solid CanvasText;
}

@include m.print {
display: none;
}
}
