/*
 * Universal modal (qb-modal)
 * Shared overlay/dialog/close styles for any modal on the site
 * (product reviews, plugin popups, etc.). Content is server-rendered;
 * open/close is handled by assets/js/qb-modal.js via the `closed` class.
 */

.qb-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  overflow-y: auto;
  padding: 40px 20px; /* keeps top/bottom gaps when the modal is taller than the screen */
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7));
  z-index: 10000;

  display: flex;
  align-items: flex-start;
  justify-content: center;

  opacity: 1;
  visibility: visible;
  transition: opacity 0.28s ease, visibility 0s linear 0s;
}

/*
 * Closed state is kept in the DOM (not display:none) so BOTH open and close
 * animate. visibility flips to hidden only after the fade-out finishes.
 */
.qb-modal.closed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0s linear 0.28s;
}

/*
 * Scroll-safe centering: margin:auto centers the dialog when it fits, and when it
 * is taller than the viewport it keeps the TOP reachable (unlike align-items:center,
 * which clips the top and makes it impossible to scroll up to it).
 */
.qb-modal__dialog {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: 640px;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.3, 1), opacity 0.28s ease;
}

/* The dialog rises + fades in on open (and reverses on close). */
.qb-modal.closed .qb-modal__dialog {
  opacity: 0;
  transform: translateY(16px) scale(0.98);
}

.qb-modal__content {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 24px;
  background-color: #fff;
}

.qb-modal__close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  margin: 0;
  background: none;
  line-height: 0;
  cursor: pointer;
  z-index: 1000;
}

.qb-modal__close svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qb-modal__close svg path {
  fill: #000000;
}

/* Lock background scrolling while a modal is open (html is the scroll container). */
html.qb-modal-open {
  overflow: hidden;
}

@media (max-width: 568px) {
  .qb-modal {
    padding: 20px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .qb-modal,
  .qb-modal.closed,
  .qb-modal__dialog,
  .qb-modal.closed .qb-modal__dialog {
    transition: none;
  }
}
