@import "./toast.vars";

// Toast
// --------------------------------------------------

:host {
  /**
   * @prop --background: Background of the toast
   * @prop --color: Color of the toast text
   *
   * @prop --border-color: Border color of the toast
   * @prop --border-radius: Border radius of the toast
   * @prop --border-width: Border width of the toast
   * @prop --border-style: Border style of the toast
   *
   * @prop --white-space: White space of the toast message
   *
   * @prop --box-shadow: Box shadow of the toast
   *
   * @prop --min-width: Minimum width of the toast
   * @prop --width: Width of the toast
   * @prop --max-width: Maximum width of the toast
   *
   * @prop --min-height: Minimum height of the toast
   * @prop --height: Height of the toast
   * @prop --max-height: Maximum height of the toast
   *
   * @prop --button-color: Color of the button text
   *
   * @prop --start: Position from the left if direction is left-to-right, and from the right if direction is right-to-left
   * @prop --end: Position from the right if direction is left-to-right, and from the left if direction is right-to-left
   */
  --border-width: 0;
  --border-style: none;
  --border-color: initial;
  --box-shadow: none;
  --min-width: auto;
  --width: auto;
  --min-height: auto;
  --height: auto;
  --max-height: auto;
  --white-space: normal;

  @include position(0, null, null, 0);

  display: block;
  position: absolute;

  width: 100%;
  height: 100%;

  outline: none;

  color: var(--color);

  font-family: $font-family-base;

  contain: strict;
  z-index: $z-index-overlay;
  pointer-events: none;
}

:host(.overlay-hidden) {
  display: none;
}

:host(.ion-color) {
  --button-color: inherit;

  color: #{current-color(contrast)};
}

:host(.ion-color) .toast-button-cancel {
  color: inherit;
}

:host(.ion-color) .toast-wrapper {
  background: #{current-color(base)};
}

.toast-wrapper {
  @include border-radius(var(--border-radius));
  @include position-horizontal(var(--start), var(--end));

  width: var(--width);
  min-width: var(--min-width);
  max-width: var(--max-width);

  height: var(--height);
  min-height: var(--min-height);
  max-height: var(--max-height);

  border-width: var(--border-width);
  border-style: var(--border-style);
  border-color: var(--border-color);

  background: var(--background);

  box-shadow: var(--box-shadow);

  pointer-events: auto;
}

.toast-wrapper.toast-top {
  @include transform(translate3d(0, -100%, 0));

  top: 0;
}

.toast-wrapper.toast-bottom {
  @include transform(translate3d(0, 100%, 0));

  bottom: 0;
}

.toast-container {
  display: flex;

  align-items: center;

  height: inherit;
  min-height: inherit;
  max-height: inherit;

  contain: content;
}

.toast-layout-stacked .toast-container {
  flex-wrap: wrap;
}

.toast-layout-baseline .toast-content {
  display: flex;

  flex-direction: column;
  justify-content: center;
}

.toast-icon {
  @include margin(null, null, null, 16px);
}

.toast-content {
  flex: 1;

  min-width: 0;
}

.toast-message {
  flex: 1;

  white-space: var(--white-space);
}

.toast-button-group {
  display: flex;
}

.toast-layout-stacked .toast-button-group {
  justify-content: end;

  width: 100%;
}

.toast-button {
  border: 0;

  outline: none;

  color: var(--button-color);

  z-index: 0;
}

.toast-icon,
.toast-button-icon {
  font-size: 1.4em;
}

.toast-button-inner {
  display: flex;

  align-items: center;
}

// Toast Button: Hover
// --------------------------------------------------

@media (any-hover: hover) {
  .toast-button:hover {
    cursor: pointer;
  }
}
