/* `showModal()` reveals this by setting `display: grid`, so the shown state must be a
 * grid. Sits under the toasts (z-index 1000): an error raised while the modal is open
 * has to stay readable. */
.modal-component {
  display: none;
  place-items: center;
  position: fixed;
  inset: 0;
  z-index: 900;
  padding: clamp(12px, 4vh, 48px) clamp(12px, 4vw, 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(3px);
}

.modal-component .modal-content-wrapper {
  width: 100%;
  max-width: 34rem;
  margin: auto;
}

.modal-component .modal-component-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* vh first as the fallback; svh tracks the mobile browser chrome. */
  max-height: calc(100vh - 2 * clamp(12px, 4vh, 48px));
  max-height: calc(100svh - 2 * clamp(12px, 4vh, 48px));
  padding: clamp(20px, 3vw, 32px);
  border-radius: var(--radius-lg);
  background-color: var(--color-neutral-0);
  box-shadow: var(--shadow-3);
  animation: modal-component-rise 0.18s ease-out;
}

@keyframes modal-component-rise {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal-component .modal-component-content {
    animation: none;
  }
}

/* Only the body scrolls, so the heading and the actions stay put. */
.modal-component .modal-component-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Content that scrolls itself gets a roomier panel and scrolls as one piece: capping it
 * would put a second scrollbar beside the one the content already has. */
.modal-component.wide .modal-content-wrapper {
  max-width: 52rem;
}

.modal-component.wide .modal-component-content {
  max-height: none;
}

.modal-component.wide .modal-component-body {
  overflow: visible;
}

.modal-component .modal-component-body > :first-child {
  margin-top: 0;
}

.modal-component .modal-component-body > :last-child {
  margin-bottom: 0;
}

.modal-component .modal-component-body h1 {
  padding-right: 2rem; /* clears the close button */
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--color-neutral-800);
}

.modal-component .modal-component-body p {
  color: var(--color-neutral-600);
  line-height: 1.5;
}

.modal-component .modal-component-body hr {
  border: 0;
  border-top: 1px solid var(--color-neutral-200);
  margin: 16px 0;
}

/* The Close Button */
.modal-component .modal-component-close {
  position: absolute;
  top: 10px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px; /* a tap target, though the glyph is small */
  height: 36px;
  border-radius: var(--radius-full);
  font-size: 26px;
  line-height: 1;
  color: var(--color-neutral-400);
  cursor: pointer;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}

.modal-component .modal-component-close:hover,
.modal-component .modal-component-close:focus-visible {
  color: var(--color-neutral-800);
  background-color: var(--color-neutral-100);
  text-decoration: none;
  outline: none;
}

.modal-component .modal-component-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-component .modal-component-footer:empty {
  display: none;
}

/* Narrow screens: stack the actions full-width rather than crowd them onto one line. */
@media (max-width: 400px) {
  .modal-component .modal-component-footer {
    flex-direction: column-reverse;
  }

  .modal-component .modal-component-footer > * {
    width: 100%;
  }

  .modal-component .modal-component-footer .button {
    justify-content: center;
    width: 100%;
  }
}

.modal-component iframe.embedded-html-email {
  width: 100%;
  height: 100%;
  border: none;
}
