//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@use '../form' as *;
@use '../../config' as *;
@use '../../spacing' as *;
@use '../../motion' as *;
@use '../../type' as *;
@use '../../breakpoint' as *;
@use '../../theme' as *;
@use '../../utilities/component-reset';
@use '../../utilities/convert' as *;
@use '../../utilities/high-contrast-mode' as *;

/// Unit styles
/// @access public
/// @group unit
@mixin unit {
  .#{$prefix}--unit {
    white-space: nowrap;
    &:after,
    .unit__small {
      font-size: 0.7em;
      font-style: italic;
      margin-left: 0.3em;
      opacity: 0.7;
    }
  }

  .#{$prefix}--unit--hide,
  .#{$prefix}--unit--hide .unit {
    &:after,
    tspan:last-child {
      display: none;
    }
  }

  .#{$prefix}--unit--light {
    &:after {
      font-weight: 300;
      margin-left: 0.2em;
      opacity: 1;
    }
  }

  .#{$prefix}--unit--littleusd {
    &:after {
      content: 'USD';
    }
  }

  .#{$prefix}--unit--none {
    white-space: normal;
  }

  .#{$prefix}--unit--tusd {
    &:after {
      content: 'T USD';
    }
  }

  .#{$prefix}--unit--usd {
    &:after {
      content: 'M USD';
    }
  }

  .#{$prefix}--unit--busd {
    &:after {
      content: 'B USD';
    }
  }

  .#{$prefix}--unit--metrictons {
    &:after {
      content: 'MetricTons';
    }
  }
  .#{$prefix}--unit--mt {
    &:after {
      content: 'MT';
    }
  }

  .#{$prefix}--unit--people {
    &:after {
      content: 'People';
    }
    &.#{$prefix}--unit--million {
      &:after {
        content: 'M People';
      }
    }
  }

  /*.#{$prefix}--unit--million {
      &:after {
          content: "M";
      }
  }*/

  .#{$prefix}--unit--partners {
    &:after {
      content: 'Partners';
    }
  }

  .#{$prefix}--unit--countries {
    &:after {
      content: 'Countries';
    }
  }

  .#{$prefix}--unit--kg {
    &:after {
      content: 'Kg';
    }
  }

  .#{$prefix}--unit--percentage,
  .#{$prefix}--unit--simplepercentage {
    &:after {
      content: '%';
    }
  }

  .#{$prefix}--unit--mbeneficiaries {
    &:after {
      content: 'M Beneficiaries';
    }
  }

  .#{$prefix}--unit--beneficiaries,
  .#{$prefix}--unit--beneficiaries--text {
    &:after {
      content: 'Beneficiaries';
    }
  }

  .#{$prefix}--unit--months {
    &:after {
      content: 'Months';
    }
    &.#{$prefix}--unit--singular {
      &:after {
        content: 'Month';
      }
    }
  }

  .#{$prefix}--unit--households {
    &:after {
      content: 'Households';
    }
  }

  .#{$prefix}--unit--trips {
    &:after {
      content: 'Trips';
    }
  }

  .#{$prefix}--unit--level {
    &:before {
      content: 'Level ';
    }
  }

  .#{$prefix}--unit--usd {
    &:before {
      content: 'US$ ';
    }
    &:after {
      content: '';
    }
    &.#{$prefix}--unit--external {
      &:after {
        content: '';
      }
      &:before {
        content: 'US$ ';
      }
    }
    &.#{$prefix}--unit--thousand {
      &:after {
        content: 'T';
      }
      &.#{$prefix}--unit--external {
        &:after {
          content: ' thousand';
        }
        &:before {
          content: 'T US$ ';
        }
      }
    }
    &.#{$prefix}--unit--million {
      &:after {
        content: 'M';
      }
      &.#{$prefix}--unit--external {
        &:after {
          content: ' million';
        }
        &:before {
          content: 'US$ ';
        }
      }
    }
    &.#{$prefix}--unit--billion {
      &:after {
        content: 'B';
      }
      &.#{$prefix}--unit--external {
        &:after {
          content: ' billion';
        }
        &:before {
          content: 'US$ ';
        }
      }
    }
  }

  .#{$prefix}--unit--num {
    &:after {
      content: '';
    }
    &.#{$prefix}--unit--external {
      &:after {
        content: '';
      }
    }
    &.#{$prefix}--unit--thousand {
      &:after {
        content: 'T';
      }
      &.#{$prefix}--unit--external {
        &:after {
          content: ' thousand';
        }
      }
    }
    &.#{$prefix}--unit--million {
      &:after {
        content: 'M';
      }
      &.#{$prefix}--unit--external {
        &:after {
          content: ' million';
        }
      }
    }
    &.#{$prefix}--unit--billion {
      &:after {
        content: 'B';
      }
      &.#{$prefix}--unit--external {
        &:after {
          content: ' billion';
        }
      }
    }
  }

  .#{$prefix}--unit--svg {
    tspan:last-child {
      font-size: 6px !important;
      font-style: italic;
      opacity: 0.6;
    }
  }
}
