@use "sass:color";

// own vars
$eccgui-size-typo-tooltip: $eccgui-size-typo-caption !default;
$eccgui-size-typo-tooltip-lineheight: $eccgui-size-typo-caption-lineheight !default;
$eccgui-size-tooltip-width: 20em !default;

// library vars
$tooltip-background-color: #{eccgui-color-var("layout", "grey", "900")};
$tooltip-text-color: #{eccgui-color-var("identity", "text", "300")};

// $dark-tooltip-background-color: $light-gray3 !default;
// $dark-tooltip-text-color: $dark-gray5 !default;
$tooltip-padding-vertical: $eccgui-size-block-whitespace * 0.25; // !default;
$tooltip-padding-horizontal: $eccgui-size-block-whitespace * 0.5; // !default;

@import "~@blueprintjs/core/src/components/tooltip/tooltip";

.#{$ns}-tooltip {
    font-size: $eccgui-size-typo-tooltip;
    line-height: $eccgui-size-typo-tooltip-lineheight;
    overflow-wrap: break-word;
    white-space: normal;
}

.#{$eccgui}-tooltip--small {
    max-width: $eccgui-size-tooltip-width * 0.5;
}
.#{$eccgui}-tooltip--medium {
    max-width: $eccgui-size-tooltip-width;
}
.#{$eccgui}-tooltip--large {
    max-width: $eccgui-size-tooltip-width * 2;
}

.#{$eccgui}-tooltip__wrapper:not(.#{$ns}-tooltip-indicator) {
    cursor: inherit;
}

.#{$eccgui}-tooltip__content {
    a {
        color: inherit;
        text-decoration: none;
    }

    pre,
    .#{$eccgui}-typography__contentblock pre,
    pre.#{$eccgui}-typography__text,
    code,
    .#{$eccgui}-typography__contentblock code,
    code.#{$eccgui}-typography__text {
        background-color: eccgui-color-mix(
            eccgui-color-var("identity", "background", "900") 100% * $eccgui-opacity-ghostly,
            transparent
        );

        code {
            background-color: transparent;
        }
    }
}

.#{$prefix}--tooltip-content {
    max-width: $eccgui-size-tooltip-width;
    padding: 0.25 * $eccgui-size-block-whitespace 0.5 * $eccgui-size-block-whitespace;

    // align Carbon tooltips, they are used automatically by a few carbon based elements, e.g. pagination buttons
    font-size: $eccgui-size-typo-tooltip;
    line-height: $eccgui-size-typo-tooltip-lineheight;
    overflow-wrap: break-word;
    white-space: normal;

    --cds-popover-background-color: #{$tooltip-background-color};
    --cds-popover-text-color: #{$tooltip-text-color};
}

.#{$ns}-popover-content {
    .#{$ns}-tooltip.#{$ns}-intent-primary & {
        color: $eccgui-color-primary-contrast;
        background-color: $eccgui-color-primary;
    }
    .#{$ns}-tooltip.#{$eccgui}-intent--accent & {
        color: $eccgui-color-accent-contrast;
        background-color: $eccgui-color-accent;
    }
}

.#{$ns}-popover-arrow-fill {
    .#{$ns}-tooltip.#{$ns}-intent-primary & {
        fill: $eccgui-color-primary;
    }
    .#{$ns}-tooltip.#{$eccgui}-intent--accent & {
        fill: $eccgui-color-accent;
    }
}
