@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/theme' as t;
@use '../../styles/abstract/direction' as d;

$component: '#{base.$prefix}-fab';

.#{$component} {
padding: 0;
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
border: none;
background-color: t.color('primary-container');
color: t.color('on-primary-container');
font: inherit;
text-decoration: none;
cursor: pointer;
user-select: none;
vertical-align: middle;
appearance: none;
overflow: hidden;

@include m.elevation(3);

@include m.motion-transition(
transform,
box-shadow,
background-color,
color
);

&:focus {
outline: none;
}

&:focus-visible {
outline: 2px solid t.color('outline');
outline-offset: 2px;
}

width: 56px;
height: 56px;
border-radius: f.get-shape('large');

&__icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;

svg {
width: 24px;
height: 24px;
}
}


&--default {
}

&--medium {
width: 80px;
height: 80px;
border-radius: f.get-shape('large-increased');

.#{$component}__icon {
width: 28px;
height: 28px;

svg {
width: 28px;
height: 28px;
}
}
}

&--large {
width: 96px;
height: 96px;
border-radius: f.get-shape('extra-large');

.#{$component}__icon {
width: 32px;
height: 32px;

svg {
width: 32px;
height: 32px;
}
}
}

@each $role in primary-container, secondary-container, tertiary-container,
primary, secondary, tertiary {
&--#{$role} {
background-color: t.color('#{$role}');
color: t.color('on-#{$role}');
}
}

&:hover {
@include m.state-layer(currentColor, 'hover');
@include m.elevation(4);
}

&:focus-visible {
@include m.state-layer(currentColor, 'focus');
@include m.elevation(3);
}

&:active {
@include m.state-layer(currentColor, 'pressed');
@include m.elevation(3);
}

&.#{$component}--lowered {
@include m.elevation(1);

&:hover {
@include m.elevation(2);
}

&:focus-visible,
&:active {
@include m.elevation(1);
}
}

&:disabled,
&.#{$component}--disabled {
pointer-events: none;

&,
&:hover,
&:focus-visible,
&:active {
@include m.elevation(0);
color: t.alpha('on-surface', 0.38);
background-color: t.alpha('on-surface', 0.12);
}

&::before {
display: none;
}
}

&--top-right,
&--top-end {
position: fixed;
top: 16px;
right: 16px;
z-index: v.z-index('dropdown');
}

&--top-left,
&--top-start {
position: fixed;
top: 16px;
left: 16px;
z-index: v.z-index('dropdown');
}

&--bottom-right,
&--bottom-end {
position: fixed;
bottom: 16px;
right: 16px;
z-index: v.z-index('dropdown');
}

&--bottom-left,
&--bottom-start {
position: fixed;
bottom: 16px;
left: 16px;
z-index: v.z-index('dropdown');
}

&--top-start,
&--bottom-start {
@include d.flip-start(16px);
}

&--top-end,
&--bottom-end {
@include d.flip-end(16px);
}

@keyframes fab-enter {
from {
transform: scale(0);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}

&--animate-enter {
animation: fab-enter 0.3s f.get-motion-easing('emphasized-decelerate') forwards;
}
}
