:host {
  /**
   * @prop --background: Background of the modal content
   *
   * @prop --border-color: Border color of the modal content
   * @prop --border-radius: Border radius of the modal content
   * @prop --border-width: Border width of the modal content
   * @prop --border-style: Border style of the modal content
   *
   * @prop --min-width: Minimum width of the modal
   * @prop --width: Width of the modal
   * @prop --max-width: Maximum width of the modal
   *
   * @prop --min-height: Minimum height of the modal
   * @prop --height: Height of the modal
   * @prop --max-height: Maximum height of the modal
   *
   * @prop --backdrop-opacity: Opacity of the backdrop
   */
  --width: 100%;
  --min-width: auto;
  --max-width: auto;
  --height: 100%;
  --min-height: auto;
  --max-height: auto;
  --overflow: hidden;
  --border-radius: 0;
  --border-width: 0;
  --border-style: none;
  --border-color: transparent;
  --background: var(--bkkr-overlay-background, var(--bkkr-background-color, #fff));
  --box-shadow: 0 15px 25px 0 rgba(var(--box-shadow-color, 0, 0, 0), 0.1), 0 6px 20px 0 rgba(var(--box-shadow-color, 0, 0, 0), 0.12), 0 13.2px 40px 0 rgba(var(--box-shadow-color, 0, 0, 0), 0.08);
  --backdrop-opacity: var(--bkkr-backdrop-opacity, 0.3);
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  position: absolute;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  outline: none;
  contain: strict;
}

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

.modal-wrapper {
  transform: translate3d(0, 100%, 0);
}

.modal-wrapper,
bkkr-backdrop {
  pointer-events: auto;
}

.modal-shadow,
.modal-wrapper {
  display: flex;
  position: relative;
  flex-direction: column;
  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);
  z-index: 10;
}

.modal-shadow {
  border-radius: var(--border-radius);
  position: absolute;
  pointer-events: none;
  background: transparent;
  box-shadow: var(--box-shadow);
}

.modal-wrapper-inner {
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
  display: flex;
  position: relative;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  border-width: var(--border-width);
  border-style: var(--border-style);
  border-color: var(--border-color);
  background: var(--background);
  overflow: var(--overflow);
  z-index: 10;
}
[dir=rtl] .modal-wrapper-inner, :host-context([dir=rtl]) .modal-wrapper-inner {
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.modal-handle {
  --handle-height: 5px;
  --handle-width: 32px;
  --handle-color: var(--color-step-350, #c0c0be);
  --handle-color-fill: var(--bkkr-text-color);
  --handle-transition: 0.2s transform cubic-bezier(0.25, 1.11, 0.78, 1.59), 0.2s box-shadow cubic-bezier(0.25, 1.11, 0.78, 1.59);
  --handle-transform: translate3d(0, -50%, 0);
  left: 0px;
  right: 0px;
  top: 10px;
  border-radius: 8px;
  margin-left: auto;
  margin-right: auto;
  position: absolute;
  width: var(--handle-width);
  height: var(--handle-height);
  transform: var(--handle-transform);
  transition: var(--handle-transition);
  border: 0;
  background-color: var(--handle-color);
  cursor: pointer;
  overflow: hidden;
  z-index: 11;
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
  .modal-handle {
    margin-left: unset;
    margin-right: unset;
    -webkit-margin-start: auto;
    margin-inline-start: auto;
    -webkit-margin-end: auto;
    margin-inline-end: auto;
  }
}
.modal-handle::before {
  /**
   * Adds a 4px tap area to the perimeter
   * of the handle.
   */
  padding-left: 4px;
  padding-right: 4px;
  padding-top: 4px;
  padding-bottom: 4px;
  position: absolute;
  width: 36px;
  height: 5px;
  transform: translate(-50%, -50%);
  content: "";
}
@supports (margin-inline-start: 0) or (-webkit-margin-start: 0) {
  .modal-handle::before {
    padding-left: unset;
    padding-right: unset;
    -webkit-padding-start: 4px;
    padding-inline-start: 4px;
    -webkit-padding-end: 4px;
    padding-inline-end: 4px;
  }
}
.modal-handle .modal-handle-duration {
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: var(--handle-color-fill);
  z-index: 11;
}

.modal-handle-animated .modal-handle-duration {
  transform: scale(0, 1);
  transform-origin: left center;
  animation-name: countdown;
  animation-timing-function: linear;
  animation-iteration-count: 1;
  animation-delay: 400ms;
  animation-fill-mode: forwards;
}

@keyframes countdown {
  100% {
    transform: scale(1, 1);
  }
}
.modal-close-button {
  --close-button-backround: var(--background);
  --close-button-backround-hover: var(--background);
  --close-button-backround-active: var(--background);
  --close-button-color: var(--bkkr-text-color, #000);
  --close-button-radius: 50%;
  --close-button-transform: scale(1.1);
  --close-button-transition: 0.2s transform cubic-bezier(0.32, 0.72, 0, 1), 0.2s background cubic-bezier(0.32, 0.72, 0, 1);
  right: var(--bkkr-spacer);
  top: -48px;
  border-radius: var(--close-button-radius);
  display: none;
  position: absolute;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: var(--close-button-transition);
  background: var(--close-button-backround);
  color: var(--close-button-color);
  box-shadow: var(--box-shadow);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  z-index: 8;
}
[dir=rtl] .modal-close-button, :host-context([dir=rtl]) .modal-close-button {
  left: unset;
  right: unset;
  left: var(--bkkr-spacer);
}

.close-icon {
  font-size: 1.25rem;
}

/**
 * Ensure that the sheet modal does not
 * completely cover the content.
 */
:host(.modal-sheet) {
  --height: calc(100% - (var(--safe-area-top) + 10px));
}

:host(.modal-sheet) .modal-wrapper,
:host(.modal-sheet) .modal-shadow {
  position: absolute;
  bottom: 0;
}

:host(.modal-card),
:host(.modal-sheet) {
  --border-radius: 24px;
}

:host(.modal-sheet) .modal-wrapper-inner {
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
:host-context([dir=rtl]):host(.modal-sheet) .modal-wrapper-inner, :host-context([dir=rtl]).modal-sheet .modal-wrapper-inner {
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

@media only screen and (min-width: 768px) and (min-height: 600px) {
  :host(.modal-sheet) {
    --margin-bottom: 10px;
    --height: calc(100% - (var(--safe-area-top) + 10px + var(--margin-bottom)));
  }

  :host(.modal-sheet) .modal-wrapper,
:host(.modal-sheet) .modal-shadow {
    bottom: var(--margin-bottom);
  }

  :host(.modal-sheet) .modal-wrapper-inner {
    border-radius: var(--border-radius);
  }
}
@media only screen and (min-width: 768px) and (min-height: 600px) {
  :host {
    --width: 600px;
    --height: 500px;
    --safe-area-top: 0px;
    --safe-area-bottom: 0px;
    --safe-area-right: 0px;
    --safe-area-left: 0px;
  }
}
@media only screen and (min-width: 768px) and (min-height: 768px) {
  :host {
    --width: 600px;
    --height: 600px;
  }
}
@media screen and (max-width: 767px) {
  @supports (width: 1px) {
    :host(.modal-card) {
      --height: calc(100% - max(30px, var(--safe-area-top)) - 10px);
    }
  }
  @supports not (width: 1px) {
    :host(.modal-card) {
      --height: calc(100% - 40px);
    }
  }
  :host(.modal-card) {
    --backdrop-opacity: 0;
    --width: 100%;
    align-items: flex-end;
  }

  :host(.modal-card) bkkr-backdrop {
    pointer-events: none;
  }
}
@media screen and (min-width: 768px) {
  :host(.modal-card) {
    --width: calc(100% - 120px);
    --max-width: 720px;
    --min-height: 300px;
    --max-height: 1000px;
    --border-radius: 24px;
    --box-shadow: 0 0 30px 10px rgba(0, 0, 0, 10%);
  }
  :host(.modal-card) .modal-wrapper-inner {
    border-radius: var(--border-radius);
  }
  :host(.modal-card) .modal-close-button {
    display: flex;
  }
}
@media (any-hover: hover) {
  .modal-handle:hover {
    --handle-transform: translate3d(0, -100%, 0);
    --handle-transition: 0.2s transform ease-out, 0.2s box-shadow ease-out;
  }

  .modal-close-button:hover {
    transform: var(--close-button-transform);
    background: var(--close-button-backround-hover);
  }
}
.modal-handle-button.state-activated {
  transform: var(--close-button-transform);
  background: var(--close-button-backround-active);
}

@media (prefers-reduced-motion: reduce) {
  .modal-handle-bar,
.modal-close-button {
    transition: none;
  }
}