// Copyright 2015 Palantir Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.

@use "sass:math";
@import "@blueprintjs/colors/lib/scss/colors";
@import "flex";

$pt-intent-colors: (
  "primary": $pt-intent-primary,
  "success": $pt-intent-success,
  "warning": $pt-intent-warning,
  "danger" : $pt-intent-danger,
) !default;

$pt-intent-text-colors: (
  "primary": $blue2,
  "success": $green2,
  "warning": $orange2,
  "danger" : $red2,
) !default;

$pt-intent-active-text-colors: (
  "primary": $blue1,
  "success": $green1,
  "warning": $orange1,
  "danger": $red1
) !default;

$pt-dark-intent-text-colors: (
  "primary": $blue5,
  "success": $green5,
  "warning": $orange5,
  "danger" : $red5,
) !default;

@mixin intent-color($intentName) {
  color: map-get($pt-intent-colors, $intentName);
}

@mixin position-all($position, $value) {
  bottom: $value;
  left: $value;
  position: $position;
  right: $value;
  top: $value;
}

@mixin base-typography() {
  font-size: $pt-font-size;
  font-weight: 400;
  letter-spacing: 0;
  line-height: $pt-line-height;
  text-transform: none;
}

@mixin running-typography() {
  font-size: $pt-font-size;
  line-height: 1.5;
}

@mixin heading-typography() {
  color: $pt-heading-color;
  font-weight: 600;

  .#{$ns}-dark & {
    color: $pt-dark-heading-color;
  }
}

@mixin monospace-typography() {
  font-family: $pt-font-family-monospace;
  text-transform: none;
}

@mixin overflow-ellipsis() {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}

@mixin focus-outline($offset: 2px) {
  outline: $pt-outline-color solid 2px;
  outline-offset: $offset;
  -moz-outline-radius: 6px;
}

@function border-shadow($alpha, $color: $black, $size: 1px) {
  @return 0 0 0 $size rgba($color, $alpha);
}

// returns the padding necessary to center text in a container of the given height.
// default line-height is that of base typography, 18px assuming 14px font-size.

@function centered-text($height, $line-height: floor($pt-font-size * $pt-line-height)) {
  @return floor(($height - $line-height) * 0.5);
}

// Removes the unit from a Sass numeric value (if present): `strip-unit(12px) => 12`
// @see https://css-tricks.com/snippets/sass/strip-unit-function/

@function strip-unit($number) {
  @if type-of($number) == "number" and not unitless($number) {
    @return math.div($number, $number * 0 + 1);
  }

  @return $number;
}

// Isolates z-indices

@mixin new-render-layer() {
  transform: translateZ(0);
}
