//Claro buttons as mixins

@mixin button(
  $background: var(--button-bg-color),
  $color: var(--button-fg-color),
  $hover: var(--button--hover-bg-color),
  $active: var(--button--active-bg-color)
) {
  -webkit-appearance: none;
  appearance: none;
  background-color: $background;
  border: 1px solid transparent !important; /* 2 */
  border-radius: var(--button-border-radius-size);
  color: $color;
  cursor: pointer;
  display: inline-block;
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased; /* 3 */
  font-weight: 700;
  line-height: 1rem;
  margin: var(--space-m) var(--space-s) var(--space-m) 0; /* LTR */
  padding: calc(var(--space-m) - 1px) calc(var(--space-l) - 1px); /* 1 */
  text-align: center;
  text-decoration: none;

  &:not(:focus) {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  }

  &:focus {
    text-decoration: none;
  }

  &:hover {
    background-color: $hover;
    color: $color;
    text-decoration: none;
  }

  &:active {
    background-color: $active;
    color: $color;
  }
}

@mixin va-buttons(
  $background: var(--va-blue-dark),
  $hover: var(--va-blue-darkest),
  $ghost: false
) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: $background;
  border: 0;
  border-radius: 5px;
  color: var(--va-white);
  display: inline-block;
  font-family: var(--font-family-sans);
  font-size: 1em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 0.5em;
  margin-right: 0.5em;
  margin-top: 0.5em;
  padding: 10px 20px;
  text-align: center;
  text-decoration: none;
  width: auto;

  &:hover {
    background-color: $hover;
    color: var(--va-white);
    text-decoration: none;
  }

  @if $ghost {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--va-blue-dark);
    color: var(--va-blue-dark);

    &:hover {
      background: transparent;
      box-shadow: inset 0 0 0 2px var(--va-blue-darkest);
      color: var(--va-blue-darkest) 3;
    }
  }
}

@mixin button-outline {
  background-color: var(--va-white);
  border: 2px solid var(--va-blue-dark) !important;
  box-shadow: none;
  color: var(--va-blue-dark);
  padding: calc(var(--space-m) - 2px) calc(var(--space-l) - 2px); //2px offset for border

  &:hover {
    background-color: var(--va-blue-lightest);
    border: 2px solid var(--va-blue-darkest);
    color: var(--va-blue-darkest);
  }
}

@mixin wysiwyg-va-action-links($color: var(--va-green-dark)) {
  &::before {
    //    content: '\F138'; hide until FA support added
    color: $color;
    display: inline-block;
    font-family: "Font Awesome 5 Free";
    font-size: 175%;
    font-weight: 900;
    height: 0;
    padding-right: 1rem;
    transform: translateY(5px);
    vertical-align: -4px; //needed until FA support added
    width: 30px; //needed until FA support added
  }

  font-weight: 700;
  padding: 8px 0;
}

@mixin wysiwyg-va-body-font {
  font-family: "Source Sans Pro", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 1em;
}

@mixin va-body-font {
  font-family: var(--font-family-sans);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 1em;
}

@mixin input-reset {
  //reset input styles incase we need to style a parent div as a button
  background: none;
  border: 0;
  box-shadow: none !important;
  margin: 0;
  padding: 0;

  &:hover {
    background: none;
  }

  &:focus {
    outline: none;
  }
}

/*
 A small subset of Formation for html tags enabled in rich text editor used in
 wysiwyg editor and node views.
 */

@mixin va-basic-styling {
  .field__item {
    @include va-body-font;

    /* Reset field labels for nested fields */
    .field__label {
      font-size: 81.3%;
      text-transform: uppercase;
    }
  }

  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var(--font-family-serif);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5em;
  }

  h2 {
    font-size: 1.6rem;
  }

  h3 {
    font-size: 1.2rem;
  }

  h4 {
    font-size: 1rem;
  }

  /* Lists */

  ol {
    list-style-position: outside;
    margin: 0 0 0 1.25em;
    padding: 0;
  }

  ul {
    list-style: square outside;
    margin: 0 0 0 1.25em;
    padding: 0;
  }

  li {
    line-height: 1.5;
    margin-bottom: 0.5em;
  }

  /* Abbreviations */
  /* stylelint-disable */
  abbr[title] {
    text-decoration: underline dotted;
  }
  /* stylelint-enable */

  /* Links */

  a {
    color: var(--va-blue-dark);
    text-decoration: underline;
    transition-duration: 0.3s;
    transition-property: color, background-color, border-color;
    transition-timing-function: ease-in-out;
  }

  a:hover {
    background-color: var(--va-blue-lightest);
    color: var(--va-blue-darkest);
    text-decoration: none;
  }

  .field--type-text-long,
  .field--type-string-long {
    max-width: 700px;
  }

  /* Block styles */

  .va-address-block {
    border-left: 3px solid var(--va-blue-dark);
    margin-left: 5rem;
    padding-left: 1rem;
  }

  /* Default button (blue) */
  .usa-button {
    @include va-buttons(var(--va-blue-dark), var(--va-blue-darkest));
  }

  /* Primary button (green) */
  .usa-button-primary,
  .va-button-primary {
    @include va-buttons(var(--va-green-lightest), var(--va-green-dark));
  }

  /* Secondary button (blue 'ghost') */
  a.usa-button-secondary {
    @include va-buttons($ghost: true);
  }

  a.vads-c-action-link--green {
    @include wysiwyg-va-action-links(var(--va-green-dark));

    &::before {
      content: url("/themes/custom/vagovclaro/images/icons/2e8540/chevron-circle-right-solid.svg"); //needed until FA support added
    }
  }

  a.vads-c-action-link--blue {
    @include wysiwyg-va-action-links(var(--va-blue-dark));

    &::before {
      content: url("/themes/custom/vagovclaro/images/icons/004795/chevron-circle-right-solid.svg"); //needed until FA support added
    }
  }

  a.vads-c-action-link--white {
    @include wysiwyg-va-action-links(var(--va-white));

    color: var(--va-white);

    &::before {
      transition-duration: 0.3s;
      transition-property: color, background-color, border-color;
      transition-timing-function: ease-in-out;
    }

    &:hover {
      background-color: transparent;
      color: #f9c642;

      &::before {
        color: #f9c642;
      }
    }
  }
}

@mixin intro-text {
  font-family: var(--font-family-serif);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 2rem;
  margin: 0;
}

// consistent styles for icons in alerts
@mixin alert-icon($url) {
  position: relative;

  &::before {
    background-image: url($url);
    background-size: contain;
    content: "";
    display: inline-block;
    height: var(--space-m);
    left: var(--space-l);
    margin-top: calc(var(--space-m) / -2);
    position: absolute;
    text-align: center;
    top: 50%;
    width: var(--space-m);
  }
}

// placeholder map until design tokens are defined... breakpoint values likely to change
$breakpoints: (
  "sm": 767px,
  "md": 992px,
  "lg": 1200px,
  "xl": 1440px,
  "tabs": 48em
    // see: docroot/core/themes/claro/css/components/tabs.css line 203.,,,,,,
);

@mixin breakpoint($breakpoint) {
  @if map-has-key($breakpoints, $breakpoint) {
    @media screen and (min-width: map-get($breakpoints, $breakpoint)) {
      @content;
    }
  } @else {
    @warn 'No breakpoint with name `#{$breakpoint}`. '
      + 'Available breakpoints are: #{map-keys($breakpoints)}.';
  }
}
