/*****************************************************************************************************
* bub Modal: CSS
******************************************************************************************************/

/*
Common Modal Styles
---------------------------------------------------------------------------------------------------- */

/* Common: Mixed
--------------------------------------------- */

/* Default trigger styles (class must be added to trigger) */

*[class*="bub-modal-trigger"] {
  cursor: pointer;
}


/* Common: Backdrop
--------------------------------------------- */

body:has(.bub-modal--backdrop) .bub-modal-backdrop {
  background-color: rgba(0,0,0,0);
  content: '';
  inset: 0;
  pointer-events: none;
  position: fixed;
  transition: background-color 300ms;
  /* Same as modal base z-index (JS) */
  z-index: 100000;
}

body:has(.bub-modal--backdrop.bub-modal--open):not(:has(.bub-modal--full.bub-modal--open)) 
  .bub-modal-backdrop {
  background-color: rgba(0,0,0,0.5);
  cursor: pointer;
  pointer-events: all;
}


/* Common: Modal
--------------------------------------------- */

/* Container */

.bub-modal {
  background: rgb(0,0,0,0.85);
  color: #ddd;
  hyphens: auto;
  outline: none;
  overflow: overlay;
  position: fixed;
  visibility: hidden;
}

:where(.bub-modal-js-loaded) .bub-modal {
  visibility: visible;
}

:where(.bub-modal-resize) .bub-modal:not(.bub-modal--open) {
  /* Prevent potential flashing of closed modals with transition styles. */
  display: none;
}

.bub-modal a {
  color: inherit;
}

/* Content */

.bub-modal__title {
  margin: 0 0 1em;
  text-align: center;
}

.bub-modal__title h1,
.bub-modal__title h2 {
  font-size: 1.35rem;
  font-weight: bold;
  line-height: 1.3;
  margin: 0;
}

.bub-modal__content h3 {
  font-size: 1.15rem;
  font-weight: bold;
  line-height: 1.3;
  margin: 0.5em 0 0.3em;
}

.bub-modal__before p {
  margin: 0 0 .5em;
}

/* Close */

.bub-modal__close {
  background: transparent;
  border: none;
  color: transparent;
  cursor: pointer;
  /* Adjust only font size to scale the button and "X". */
  font-size: 16px;
    /* Same height and width for square */
    height: 5em;
    width: 5em;
  overflow: hidden;
  padding: 0;
  position: absolute;
    right: 0;
    top: 0;
  text-indent: 200%;
  /* Make sure text-indent works. */
  white-space: nowrap;
  z-index: 1;
}

.bub-modal__close::before,
.bub-modal__close::after {
  background-color: #e5e5e5;
  content: '';
  /* Adjust height to change thickness of the "X". */
  height: 0.15em;
  position: absolute;
    top: 50%;
    left: 50%;
  transform-origin: center;
  /* Adjust width to change "X" size relative to button. */
  width: 70%;
}

.bub-modal__close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.bub-modal__close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}


/*
Modal Variants
---------------------------------------------------------------------------------------------------- */

/* Fullscreen Modals
--------------------------------------------- */

body:has(.bub-modal--full.bub-modal--open) {
  /* Disable default page scroll. */
  overflow: hidden;
}

/* Container */

.bub-modal--full {
  align-items: center;
  display: flex;
  flex-flow: column nowrap;
  height: 100%;
  justify-content: center;
  left: 0;
  opacity: 0;
  overflow: auto;
  padding: 80px 3vw;
  top: 0;
  transform: scale(0.5);
  transition: transform 0.2s, opacity 0.2s, visibility 0s 0.2s;
  visibility: hidden;
  width: 100%;
}

.bub-modal--full:where(.bub-modal--open) {
  opacity: 1;
  transform: scale(1);
  transition: transform 0.2s, opacity 0.2s;
  visibility: visible;
}

/* Content */

.bub-modal__content--full {
  position: relative;
}

/* Close */

@media screen and (max-width: 1000px) {

  .bub-modal__close--full {
    font-size: 13px;
  }
}


/* Boxed Fullscreen Modal
--------------------------------------------- */

.bub-modal__content--boxed {
  background: #252525;
  color: #fff;
  box-shadow: 1px 1px 20px #00000077;
  max-width: 40em;
  padding: 2.1em min(2.7em, 5%);
}

@media screen and (max-width: 500px) {

  .bub-modal--boxed {
    padding-inline: 0;
  }
  
  .bub-modal__content--boxed {
    box-shadow: none;
  }
}


/* Panels
--------------------------------------------- */

/* Container */

.bub-modal--panel {
  --scrollbar-foreground: #3a3a3a;
  background: #252525;
  color: #fff;
  height: 100%;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: var(--scrollbar-foreground) transparent;
  scrollbar-width: thin;  
  transition: transform 0.3s ease;
  width: 100%;
}

/* Scrollbar Fallback */
.bub-modal--panel::-webkit-scrollbar {
  width: 8px;
}
.bub-modal--panel::-webkit-scrollbar-track {
  background: transparent;
}
.bub-modal--panel::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-foreground);
}

/* Close */

.bub-modal__close--panel {
  background: var(--scrollbar-foreground);
  font-size: 40%;
}

.bub-modal__close--panel::before,
.bub-modal__close--panel::after {
  background-color: #8b8b8b;
  height: 0.25em;
  width: 65%;
}

@media screen and (max-width: 800px) {

  .bub-modal:is(.bub-modal--left, .bub-modal--right) {
    left: auto;
    max-width: 100%;
    opacity: 0;
    overflow: auto;
    right: auto;
    transform: scale(0.5);
    transition: transform 0.2s, opacity 0.2s, visibility 0s 0.2s;
    visibility: hidden;
  }

  .bub-modal--open:is(.bub-modal--left, .bub-modal--right) {
    opacity: 1;
    transform: scale(1);
    transition: transform 0.2s, opacity 0.2s;
    visibility: visible;
  }
}


/* Left Panel
--------------------------------------------- */

/* Container */

.bub-modal--left {
  box-shadow: 2px 0 20px rgba(0,0,0,0.25);
  max-width: 400px;
  left: -400px;
  top: 0;
}

.bub-modal--left:where(.bub-modal--open) {
  transform: translateX(100%);
}

/* Content */

.bub-modal__content--left {
  padding: 50px 25px 35px 20px;
}


/* Right Panel
--------------------------------------------- */

/* Container */

.bub-modal--right {
  box-shadow: -2px 0 20px rgba(0,0,0,0.25);
  max-width: 400px;
  right: -400px;
  top: 0;
}

.bub-modal--right:where(.bub-modal--open) {
  transform: translateX(-100%);
}

/* Content */

.bub-modal__content--right {
  padding: 50px 20px 35px 25px;
}

/* Close */

.bub-modal__close--right {
  left: 0;
}


/* Bottom Panel
--------------------------------------------- */

/* Container */

.bub-modal--bottom {
  bottom: 0;
  box-shadow: 0 -2px 20px rgba(0,0,0,0.25);
  height: auto;
  max-height: 100%;
  min-height: min(80vh, 200px);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.bub-modal--bottom:where(.bub-modal--open) {
  transform: translateY(0%);
}

/* Content */

.bub-modal__content--bottom {
  padding: min(5vh, 40px) min(5vw, 40px);
}

/* Close */

.bub-modal__close--bottom {
  right: 0;
}


/* Free Modals
--------------------------------------------- */

/* Container */

.bub-modal--free {
  --scrollbar-foreground: #3a3a3a;
  inset: auto auto 0 0;
  max-width: min(100%, 650px);
  min-height: min(80vh, 280px);
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s, visibility 0s 0.2s;
  transform: scale(0.5);
  visibility: hidden;
  width: 100%;
}

.bub-modal--free:where(.bub-modal--open) {
  opacity: 1;
  transform: scale(1);
  transition: transform 0.2s, opacity 0.2s;
  visibility: visible;
}

/* Content */

.bub-modal__content--free {
  padding: min(5vh, 40px) min(5vw, 40px);
}

/* Close */

.bub-modal__close--free {
  background: var(--scrollbar-foreground);
  font-size: 40%;
}

.bub-modal__close--free::before,
.bub-modal__close--free::after {
  background-color: #8b8b8b;
  height: 0.25em;
  width: 65%;
}


/* Center Modal
--------------------------------------------- */

/* Container */

.bub-modal--center {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%) scale(0.5);
}

.bub-modal--center:where(.bub-modal--open) {
  transform: translate(-50%, -50%) scale(1);
}


