// ============================================================================
// :: Account
// ============================================================================
/**
 * Account component which can contain a title, an icon, the amount of money
 * you have and the type of the account.
 */

// ============================================================================
// :: Root
// ============================================================================
.m-summary {
  width: 100%;
}

// ============================================================================
// :: Elements
// ============================================================================
.m-summary__label {
  margin-bottom: 1.2rem;
}

.m-summary__container {
  position: relative;

  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.m-summary__link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: $z-index-floor;

  word-break: break-word;

  width: 100%;
  height: 100%;

  font-weight: $font-weight-regular;
  text-decoration: none;
}

button.m-summary__link {
  padding: 0;

  border: none;
  background: transparent;
}

.m-summary__visual {
  display: block;

  width: 3.2rem;
  height: 3.2rem;
  min-width: 3.2rem;

  margin-right: 1rem;
}

.m-summary__image-container {
  display: flex;
  justify-content: center;
  align-items: center;

  width: 100%;
  height: 100%;
}

.m-summary__icon {
  display: block;

  // Style the icon
  &::before {
    font-size: $icon-size-3x-large;

    color: $primary-color-base;
  }
}

.m-summary__image {
  width: 100%;
}

.m-summary__block {
  width: 100%;
}

.m-summary__wrapper {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}

// When text zoom is large, stack summary content on mobile
html[data-text-zoom="large"],
html[data-text-zoom="xlarge"] {
  .m-summary__wrapper {
    flex-direction: column;

    // Restore row layout on tablet and up
    @include respond-at($breakpoint-tablet-default) {
      flex-direction: row;
    }
  }
}

.m-summary__title {
  margin-bottom: 0.5rem;

  font-family: $font-family-sora;
  font-weight: $font-weight-regular;
  font-size: $font-size-1x-small;
  line-height: $line-height-1x-small;

  color: $text-color-base;

  word-break: break-word;

  @include respond-at($breakpoint-tablet-default) {
    font-size: $font-size-base;
    line-height: $line-height-base;
  }
}

.m-summary__info {
  padding-left: 0;

  list-style-type: none;
}

.m-summary__info-item {
  font-family: $font-family-sora;
  font-weight: $font-weight-regular;
  font-size: $font-size-1x-small;
  line-height: $line-height-1x-small;
  hyphens: auto;
  word-break: break-word;

  color: $text-color-medium;

  @include respond-at($breakpoint-tablet-default) {
    font-size: $font-size-base;
    line-height: $line-height-base;
  }
}

.m-summary__info-item--with-copy {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.m-summary__budget {
  font-size: $font-size-base;
  line-height: $line-height-base;
}

.m-summary__content {
  margin-top: 1.8rem;
  padding-top: 1.8rem;

  border-top: $border-width-base solid $border-color-1x-light;
}

.m-summary__action {
  display: flex;

  align-self: center;
}

.m-summary__copy-inline {
  position: relative;
  z-index: $z-index-roof + 1;
  display: inline-flex;
}

.m-summary__copy {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;

  border: none;
  background: transparent;

  color: $text-color-base;

  cursor: pointer;

  .icon-id::before {
    font-size: $icon-size-base;
  }

  &:focus {
    outline: 0.2rem solid $primary-color-base;
    outline-offset: 0.2rem;
  }
}

.m-summary__edit {
  @extend %__icon-edit;

  align-self: center;

  display: flex;

  min-width: 24px;
  min-height: 24px;
  justify-content: center;
  align-items: center;

  text-decoration: none;

  color: $text-color-base;

  // Style the icon
  &::before {
    font-size: $icon-size-1x-large;
  }
}

button.m-summary__edit {
  padding: 0;

  border: none;
  background: transparent;

  cursor: pointer;
}

.m-summary__remove {
  @extend %__icon-trash;

  align-self: center;

  text-decoration: none;

  color: $ui-error;

  // Style the icon
  &::before {
    font-size: $icon-size-1x-large;
  }
}

button.m-summary__remove {
  padding: 0;

  border: none;
  background: transparent;

  cursor: pointer;
}

// ============================================================================
// :: Modifiers
// ============================================================================
.m-summary__budget--large {
  font-size: $font-size-3x-large;

  @include respond-at($breakpoint-tablet-default) {
    font-size: $font-size-2x-large;
  }
}

.m-summary__info-item--uppercase {
  text-transform: uppercase;
}

.m-summary--expand {

  .m-summary__link,
  .m-summary__container {
    &::after {
      content: "";

      position: absolute;
      bottom: -1.3rem;
      z-index: $z-index-floor;

      height: 1.5rem;
    }
  }

  .m-summary__link {
    z-index: $z-index-roof;

    &::after {
      left: 50%;

      width: 6.5rem;

      transform: translateX(-50%);
    }
  }

  .m-summary__container {
    &::before {
      position: absolute;
      bottom: -1.3rem;
    }

    &::before {
      @extend %__icon-chevron-down;

      left: 50%;
      z-index: $z-index-floor + 1;

      transform: translateX(-50%);
    }

    &::after {
      left: 0;
      width: 100%;

      background-image: url("/assets/general/img/account/shape.svg");
      background-repeat: no-repeat;
      background-position: center bottom;
      background-size: contain;
    }
  }
}

.m-summary--contained,
.m-summary--expand,
.m-summary--button {
  font-weight: $font-weight-regular;
  text-decoration: none;

  .m-summary__container {
    padding: 1.5rem;

    border: $border-width-base solid $border-color-1x-light;
    border-radius: $border-radius-base;
  }
}

.m-summary--contained-desktop {
  .m-summary__container {
    @include respond-at($breakpoint-tablet-default) {
      padding: 1.5rem;

      border: $border-width-base solid $border-color-1x-light;
      border-radius: $border-radius-base;
    }
  }
}

.m-summary--small {

  .m-summary__title,
  .m-summary__info-item,
  .m-summary__budget {
    font-size: $font-size-1x-small;
    line-height: $line-height-1x-small;
  }
}

.m-summary--button {

  .m-summary__icon,
  .m-summary__action {

    // Style the icon
    &::before {
      color: $text-color-medium;

      transition: color 0.2s ease-in-out;
    }
  }

  .m-summary__icon {
    display: none;
    margin-bottom: 2rem;

    @include respond-at($breakpoint-tablet-default) {
      display: block;
    }
  }

  .m-summary__action {
    align-self: flex-end;
    margin-bottom: 0.5rem;
  }

  .m-summary__container {
    flex-direction: column;
    padding: 0.5rem 0 2rem 0;
    border-width: 0 0 $border-width-base 0;
    border-radius: 0;
    height: 100%;

    transition: border 0.2s ease-in-out;

    @include respond-at($breakpoint-tablet-default) {
      padding: 2.5rem;
      border: $border-width-base solid $border-color-base;
      border-radius: $border-radius-base;
    }
  }

  .m-summary__block {
    display: flex;

    justify-content: space-between;
  }

  .m-summary__title {
    font-weight: $font-weight-bold;
    color: $text-color-base;

    transition: color 0.2s ease-in-out;
  }
}

// ============================================================================
// :: States
// ============================================================================
.m-summary {
  &.is-disabled {
    pointer-events: none;

    cursor: not-allowed;

    .m-summary__container {
      padding: 1.5rem;

      background-color: $background-color-base;
      border: $border-width-base solid $border-color-1x-light;
      border-radius: $border-radius-base;
    }

    .m-summary__title,
    .m-summary__budget,
    .m-summary__info-item {
      color: $text-color-medium;
    }

    .m-summary__icon {

      // Style the icon
      &::before {
        color: $text-color-medium;
      }
    }

    .m-summary__image {
      opacity: 0.2;
    }
  }
}

.m-summary--button {
  &:hover {
    @include respond-at($breakpoint-tablet-default) {
      .m-summary__container {
        border: $border-width-base solid $border-color-blue;
      }

      .m-summary__title {
        color: $text-color-base;
      }

      .m-summary__action {
        &::before {
          color: $text-color-black;
        }
      }

      .m-summary__icon {
        &::before {
          color: $primary-color-dark;
        }
      }
    }
  }
}