.bw-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-index-popover, 20);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.bw-modal[hidden] {
  display: none;
}

/* A pruned trigger carries the hidden attribute, and the UA rule behind it loses to every author
   `display` a button or doclink already sets. */
a[href*="#bw-modal-"][hidden],
[data-bw-modal-auto][hidden] {
  display: none;
}

.bw-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 45%);
  opacity: 0;
  transition: opacity var(--bw-dur-base) var(--bw-ease-standard);
}

.bw-modal.is-open .bw-modal__backdrop {
  opacity: 1;
}

.bw-modal__card {
  position: relative;
  box-sizing: border-box;
  width: 1200px;
  max-width: 100%;
  max-height: calc(100dvh - 40px);
  overflow: auto;
  overscroll-behavior: contain;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition:
    opacity var(--bw-dur-base) var(--bw-ease-standard),
    transform var(--bw-dur-base) var(--bw-ease-standard);
}

.bw-modal.is-open .bw-modal__card {
  opacity: 1;
  transform: none;
}

.bw-modal__close {
  position: absolute;
  inset-block-start: 20px;
  inset-inline-end: 22px;
  z-index: 2;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--bw-ink);
  cursor: pointer;
  background: #fbfcf8;
  border: 1px solid #949494;
  border-radius: 999px;
}

.bw-modal__close svg {
  display: block;
  width: 10px;
  height: 10px;
}

.bw-modal-lock {
  overflow: hidden !important;
}

@media (max-width: 959px) {
  .bw-modal {
    align-items: flex-end;
    padding: 0;
  }

  .bw-modal__card {
    max-height: calc(100dvh - 40px);
  }

  .bw-modal__close {
    inset-block-start: 16px;
    inset-inline-end: 16px;
    width: 44px;
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bw-modal__backdrop,
  .bw-modal__card {
    transition: none;
  }

  .bw-modal__card {
    transform: none;
  }
}
