/* 
 * Scroll lock body when dialog is open
 */
body:has(dialog[open]) {
  overflow: hidden;
  margin-right: var(--scrollbar-width, 15px);
}

/*
 * Dialog Frame
 */
.dialog {
  border: none;
  border-radius: 5px;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.5);
  max-width: 50ch;
  width: 100%;
  max-height: 80vh;
  padding: 0;
  opacity: 0;
}
.dialog[open] {
}
.dialog::backdrop {
  background-color: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(3px);
}


/* Animation for open and close */
.dialog,
.dialog::backdrop {
  transition: display 500ms allow-discrete,
              overlay 500ms allow-discrete;

  animation: dialog-close 500ms forwards;
}
.dialog[open],
.dialog[open]::backdrop {
  animation: dialog-open 500ms forwards;
}

@keyframes dialog-open {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes dialog-close {
  from {
    opacity: 1;
    right: calc( var(--scrollbar-width, 0) * -1);
  }
  to {
    opacity: 0;
    right: calc( var(--scrollbar-width, 0) * -1);
  }
}


/*
 * Dialog: Inner structure and styles
 */
.dialog-wrapper {
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  width: 100%;
}

.dialog-inner {
  padding: 0 2rem 1rem;
}
.dialog-inner p,
.dialog-inner ol,
.dialog-inner ul {
  margin-bottom: 1em;
  hyphens: auto;
  font-size: 0.875em;
  line-height: 1.25;
}
.dialog p:empty {
  display: none;
}

.dialog h3 {
  background: white;
  padding: 1rem 0rem;
  margin: 0;
  position: sticky;
  top: 0;
}

.dialog-close {
  background: transparent;
  border: 0;
  border-radius: 9999px;
  color: currentColor;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  text-align: center;
  opacity: 0.5;
  
  display: block;
  height: 1em;
  width: 1em;
  padding: 0;
  margin: 0;
  
  position: absolute;
  top: 0.5rem; /* Should match the Heading margin-top */
  right: 1rem;
}
.dialog-close:hover {
  opacity: 1;
}
.dialog-close:focus {
  opacity: 1;
  outline: 2px solid currentColor;
}

/* Trigger item in content */
.ps-popup-trigger {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: from-font;
/*  border-bottom: 1px dotted currentColor;*/
/*  padding-bottom: 0.125em;*/ 
}
.ps-popup-trigger-icon {
  height: 1.25em; 
  width: 1.25em; 
/*  transform: translateY(0.25em);*/
  vertical-align: text-bottom;
}
.ps-popup-trigger * {
  pointer-events: none;
}


/*
 * Hides dialog source content
 */
.ps-popup-source {
  display: none;
}