@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;

$component: '#{base.$prefix}-tooltip';
$arrow-size: 8px;

.#{$component} {
position: fixed;
top: 0;
left: 0;
z-index: 1000;
max-width: 200px;
padding: 4px 8px;
border-radius: v.shape('extra-small');
background-color: t.color('inverse-surface');
color: t.color('inverse-on-surface');
text-align: center;
pointer-events: none;
opacity: 0;
transform: scale(0.9);
transform-origin: center;
box-sizing: border-box;

@include m.typography('body-small');

transition:
opacity 150ms cubic-bezier(0, 0, 0.2, 1),
transform 150ms cubic-bezier(0, 0, 0.2, 1);

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

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


&--default,
&--plain {
min-width: 40px;
min-height: 24px;
}

&--rich {
max-width: 320px;
padding: 12px 16px 8px;
border-radius: v.shape('medium');
background-color: t.color('surface-container');
--#{base.$prefix}-tooltip-arrow-color: #{t.color('surface-container')};
color: t.color('on-surface-variant');
text-align: start;
@include m.typography('body-medium');
@include m.elevation(2);
}

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

&__arrow {
position: absolute;
width: 0;
height: 0;
border: $arrow-size solid transparent;
pointer-events: none;

&--top {
bottom: 100%;
left: 50%;
transform: translateX(-50%);
border-bottom-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-top-width: 0;
}

&--top-start {
bottom: 100%;
left: $arrow-size;
border-bottom-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-top-width: 0;
}

&--top-end {
bottom: 100%;
right: $arrow-size;
border-bottom-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-top-width: 0;
}

&--bottom {
top: 100%;
left: 50%;
transform: translateX(-50%);
border-top-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-bottom-width: 0;
}

&--bottom-start {
top: 100%;
left: $arrow-size;
border-top-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-bottom-width: 0;
}

&--bottom-end {
top: 100%;
right: $arrow-size;
border-top-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-bottom-width: 0;
}

&--left {
right: 100%;
top: 50%;
transform: translateY(-50%);
border-right-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-left-width: 0;
}

&--left-start {
right: 100%;
top: $arrow-size;
border-right-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-left-width: 0;
}

&--left-end {
right: 100%;
bottom: $arrow-size;
border-right-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-left-width: 0;
}

&--right {
left: 100%;
top: 50%;
transform: translateY(-50%);
border-left-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-right-width: 0;
}

&--right-start {
left: 100%;
top: $arrow-size;
border-left-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-right-width: 0;
}

&--right-end {
left: 100%;
bottom: $arrow-size;
border-left-color: var(--#{base.$prefix}-tooltip-arrow-color, #{t.color('inverse-surface')});
border-right-width: 0;
}
}

}
