/* Prevent page scroll when modal open */
html.cbrm-modal-open,
body.cbrm-modal-open {
  overflow: hidden;
}

/* Overlay */

.cbrm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;

  background: rgba(58, 36, 22, 0.55);

  display: none;
  align-items: center;
  justify-content: center;

  padding: 24px;
}

.cbrm-modal-overlay.is-open {
  display: flex;
}


/* Modal */

.cbrm-modal {
  background: #fdfaf4;
  border-radius: 28px;

  width: 100%;
  max-width: 780px;

  max-height: 90vh;

  overflow: hidden;

  display: flex;
  flex-direction: column;

  position: relative;

  color: #5c3d2e;

  box-shadow:
    0 32px 80px rgba(58,36,22,.35),
    0 0 0 1px #ead9bb;

  animation: cbrmModalIn .25s ease;
}

@keyframes cbrmModalIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* Close button */

.cbrm-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;

  width: 36px;
  height: 36px;

  border-radius: 50%;
  border: 1.5px solid #e8896a;

  background: #fae8e0;
  color: #c4623a;

  font-size: 16px;

  cursor: pointer;

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

  transition: all .2s ease;

  z-index: 10;
}

.cbrm-modal-close:hover {
  background: #c4623a;
  color: #fdfaf4;
  border-color: #c4623a;
}


/* Modal body */

.cbrm-modal-body {
  overflow-y: auto;
  overflow-x: hidden;

  flex: 1;

  -webkit-overflow-scrolling: touch;
}


/* Elementor content adjustments */

.cbrm-modal-template .elementor {
  max-width: 100%;
}

.cbrm-modal-template img {
  max-width: 100%;
  height: auto;
}

.cbrm-modal-template .elementor-section,
.cbrm-modal-template .elementor-container,
.cbrm-modal-template .e-con,
.cbrm-modal-template .e-flex {
  max-width: 100%;
}


/* Post content spacing */

.cbrm-post-content p,
.cbrm-post-content ul,
.cbrm-post-content ol {
  margin-bottom: 1em;
}


/* Loading state */

.cbrm-loading {
  opacity: .6;
  pointer-events: none;
}



/* =======================================
   Mobile modal (Elementor-style sheet)
   ======================================= */

@media (max-width: 767px) {

  .cbrm-modal-overlay {
    align-items: flex-end;
    justify-content: stretch;
    padding: 0;
  }

  .cbrm-modal {
    width: 100%;
    max-width: none;

    max-height: 92vh;
    max-height: 92dvh;

    border-radius: 20px 20px 0 0;

    margin: 0;
  }

  .cbrm-modal-body {
    max-height: 92vh;
    max-height: 92dvh;

    overflow-y: auto;
  }

  /* iOS safe area padding */

  .cbrm-modal-template {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  /* Sheet drag handle */

  .cbrm-modal-handle {
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: #d8c7ab;
    margin: 10px auto 6px;
    flex-shrink: 0;
  }

}