@import '../override-function';

//=======================================
// Media query helper. Use to set max-width queries.
// Use this sparingly. Please use @include media instead.
//=======================================

@mixin media-maxwidth($bp) {
  @media screen and (max-width: #{$bp}) {
    @content;
  }
}

//=======================================
// Heading style mixins
//=======================================

// These styles Were orginally pulled from the corresponding,
// legacy h* elements, which is why there is no `h1` style
// and why `h3` is currently larger than `h2`.
// See discussion in:
//    https://github.com/department-of-veterans-affairs/vets-website/pull/5267#issuecomment-293024728
// TODO(team, eventually):
//  - Decide on heading style hierarchy and consistency (design).
//  - Update markup accordingly
//  - Update these mixins
//  - Delete these comments.

@mixin heading-2 {
  font-size: 1.2em;
  line-height: 1.2;
  font-weight: bold;
}

@mixin heading-3 {
  font-size: 1.8em;
  line-height: 1.5;
  font-weight: bold;
}

@mixin heading-4 {
  font-size: 1.35em;
  line-height: 1.5;
  font-weight: bold;
}

@mixin heading-5 {
  font-size: 1.15em;
  line-height: 1.5;
  font-weight: bold;
}

@mixin heading-6 {
  font-size: 0.9em;
  line-height: 1.5;
  font-weight: bold;
}

@mixin exit-icon {
  // Using longhand properties instead of the shorthand to limit
  // risk and impact of side effects
  background-position: 100% 50%;
  background-repeat: no-repeat;
  background-size: 1em auto;
  padding-right: 1.2em;
  position: relative;

  &:after {
    // adds non-visible alt content for screen readers
    position: absolute;
    height: 1px;
    width: 1px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    padding: 0;
    border: 0;
    margin: -1px;
    content: "this will open a new website";
  }
}

// There are a few places where the exit-icon is explicitly hidden using prop / values
// like 'background-image: none;'. In these cases, we want to hide the corresponding
// content placed in the ::after pseudo-element
@mixin no-sr-content {
  &:after {
    content: none;
  }
}

@mixin focus-gold-light-outline($offset: 2) {
  outline: $focus-outline;
  outline-offset: #{$offset}px;
}

@mixin focus-gold-lighter-highlight {
  background: $color-gold-lighter;
  outline: 2px solid $color-gold-lighter;
  outline-offset: 0;
}

@mixin focus {
  @include focus-gold-light-outline;
}

@mixin color-transition {
  -webkit-transition-duration: 0.3s;
    transition-duration: 0.3s;

  -webkit-transition-timing-function: ease-in-out;
  transition-timing-function: ease-in-out;

  // Transition only these properties.
  -webkit-transition-property: color, background-color, border-color;
  transition-property: color, background-color, border-color;
}

@mixin linear-gradient-background($from, $to) {
  background: $from; /* Old browsers */
  background: -moz-linear-gradient(top, $from 0%, $to 63%); /* FF3.6-15 */
  background: -webkit-linear-gradient(top, $from 0%,$to 63%); /* Chrome10-25,Safari5.1-6 */
  background: linear-gradient(to bottom, $from 0%,$to 63%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=$from, endColorstr=$to,GradientType=0 ); /* IE6-9 */
}

@mixin button-link {
  background: none;
  background-color: transparent !important;
  border: 0;
  border-radius: 0;
  outline: 0;
  padding: 0 !important;
  margin: 0;
  text-align: left;
  -webkit-font-smoothing: auto;
  color: $color-link-default !important;
  font-weight: normal;
  text-decoration: underline;
  display: inline;
  width: auto !important;
  line-height: inherit;
  &:hover {
    background: none;
    border: 0;
    border-radius: 0;
    outline: 0;
    padding: 0 !important;
    color: $color-link-default;
    text-decoration: underline;
    background-color: $color-link-default-hover !important;
    @include color-transition;
  }
  &:active {
    background: $color-link-default-hover;
  }
  &:focus {
    @include focus-gold-light-outline;
    outline-offset: 0;
  }
  &:disabled {
    text-decoration: none;
    color: $color-gray-light !important;
  }
}

@mixin modal-close-button {
  background-color: transparent;
  color: $color-primary;
  font-size: scale-rem(2.25rem);
  padding: 0;
  position: absolute;
  margin: units(2);
  right: 0;
  top: 0;
  width: auto;
  z-index: 9;

  &:hover {
    background-color: transparent;
    color: $color-primary-darker;
  }

  &:active {
    background-color: transparent;
    color: $color-primary-darkest;
  }
}

// Flexbox columns
@mixin flexbox-col($size) {
  flex: 0 0 percentage($size / $grid-columns);
  max-width: percentage($size / $grid-columns); // IE10+ and Firefox
}

@mixin equal-width-flexbox-col() {
  flex-basis: 0;
  flex-grow: 1;
  max-width: 100%;
}
