//
// 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.
//

//-----------------------------
// Notifications
//-----------------------------

@import '../../globals/scss/vars';
@import '../../globals/scss/layer';
@import '../../globals/scss/layout';
@import '../../globals/scss/vendor/@carbon/elements/scss/import-once/import-once';
@import '../../globals/scss/helper-mixins';
@import '../../globals/scss/css--reset';
@import '../../globals/scss/css--typography';
@import 'mixins';

@mixin toast-notifications {
  .#{$prefix}--toast-notification {
    @include reset;
    @include font-family;
    @include font-smoothing;
    @include layer('overlay');
    display: flex;
    justify-content: space-between;
    width: 16.875rem;
    padding: $spacing-md $spacing-md $spacing-xs $spacing-md;
    background-color: $ui-01;
    color: $text-01;
    margin-top: $spacing-xs;
    margin-bottom: $spacing-xs;
    margin-right: $spacing-md;

    &:first-child {
      margin-top: $spacing-md;
    }
  }

  .#{$prefix}--toast-notification--error {
    @include notification--color($support-01);
  }

  .#{$prefix}--toast-notification--success {
    @include notification--color($support-02);
  }

  .#{$prefix}--toast-notification--info {
    @include notification--color($support-04);
  }

  .#{$prefix}--toast-notification--warning {
    @include notification--color($support-03);
  }

  .#{$prefix}--toast-notification__close-button {
    background-color: $ui-01;
    border: none;
    cursor: pointer;
    margin: 0;
    width: 12px;
    height: 12px;
    position: relative;

    &:focus {
      @include focus-outline('border');
    }
  }

  .#{$prefix}--toast-notification__close-icon,
  .#{$prefix}--toast-notification__icon {
    height: 1rem;
    width: 1rem;
    height: 10px;
    width: 10px;
    fill: $ui-05;
    position: absolute;
    top: 1px;
    right: 1px;
  }

  .#{$prefix}--toast-notification__title {
    @include typescale('zeta');
    @include letter-spacing;
    font-weight: 600;
    line-height: 1;
    padding-bottom: $spacing-3xs;
  }

  .#{$prefix}--toast-notification__subtitle {
    @include typescale('omega');
    color: $text-02;
    margin-top: 0;
    margin-bottom: $spacing-md;
    line-height: 1.2;
  }

  .#{$prefix}--toast-notification__caption {
    @include typescale('omega');
    color: $text-02;
    line-height: 1;
  }
}

@mixin toast-notifications--x {
  .#{$prefix}--toast-notification {
    @include reset;

    display: flex;
    width: rem(288px);
    height: auto;
    padding-left: $carbon--spacing-05;
    color: $text-01;
    margin-top: $carbon--spacing-03;
    margin-bottom: $carbon--spacing-03;
    margin-right: $carbon--spacing-05;

    &:first-child {
      margin-top: $carbon--spacing-05;
    }

    @include carbon--breakpoint(max) {
      width: rem(352px);
    }
  }

  .#{$prefix}--toast-notification--error {
    @include notification--experimental($support-01, $notification-error-background-color);
  }

  .#{$prefix}--toast-notification--success {
    @include notification--experimental($support-02, $notification-success-background-color);
  }

  .#{$prefix}--toast-notification--info {
    @include notification--experimental($support-04, $notification-info-background-color);
  }

  .#{$prefix}--toast-notification--warning {
    @include notification--experimental($support-03, $notification-warning-background-color);
  }

  .#{$prefix}--toast-notification--warning .#{$prefix}--toast-notification__icon path[opacity='0'] {
    fill: $text-01;
    opacity: 1;
  }

  .#{$prefix}--toast-notification__icon {
    flex-shrink: 0;
    margin-right: $carbon--spacing-05;
    margin-top: $carbon--spacing-05;
  }

  .#{$prefix}--toast-notification__details {
    margin-right: $carbon--spacing-05;
  }

  .#{$prefix}--toast-notification__close-button {
    @include focus-outline('reset');
    background-color: transparent;
    border: none;
    cursor: pointer;
    margin-left: auto;
    padding: 0;
    height: rem(48px);
    width: rem(48px);
    min-height: rem(48px);
    min-width: rem(48px);
    transition: outline $transition--base, background-color $transition--base;

    &:focus {
      @include focus-outline('outline');
    }

    .#{$prefix}--toast-notification__close-icon {
      height: 1rem;
      width: 1rem;
      fill: $ui-05;
    }
  }

  .#{$prefix}--toast-notification__title {
    @include type-style('heading-01');

    font-weight: 600;
    margin-top: 1rem;
  }

  .#{$prefix}--toast-notification__subtitle {
    @include type-style('body-short-01');

    color: $text-01;
    margin-top: 0;
    margin-bottom: $carbon--spacing-06;
  }

  .#{$prefix}--toast-notification__caption {
    @include type-style('body-short-01');

    color: $text-01;
    margin-bottom: $carbon--spacing-05;
  }
}

@include exports('toast-notifications') {
  @if feature-flag-enabled('components-x') {
    @include toast-notifications--x;
  } @else {
    @include toast-notifications;
  }
}
