/* Dialog: the site's own replacement for the browser's confirm(), styled like Bootstrap's modal.
   Built by site.js on the native <dialog> element, so focus stays inside it and Escape closes it.
   Clicking outside it (on the dimmed backdrop) or the × also closes it.

   <dialog class="dialog">
     <form class="dialog__form" method="dialog">
       <header class="dialog__header"><h2 class="dialog__title">…</h2><button class="dialog__close" value="cancel">×</button></header>
       <div class="dialog__body">…</div>
       <footer class="dialog__footer">buttons</footer>
     </form>
   </dialog> */

.dialog {
  width: calc(100% - 2 * var(--sp-2));
  max-width: var(--dialog-w);
  margin: auto;                 /* centred on the page, top to bottom and side to side */
  padding: 0;                   /* so a click on the dialog itself can only be the backdrop */
  color: var(--c-text);
  background-color: var(--c-page);
  border: var(--border-1) solid var(--c-line);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-1);
}

.dialog[open] {
  animation: dialog-in var(--duration-slow) var(--ease-out);
}

.dialog::backdrop {
  background-color: var(--c-backdrop);
  animation: backdrop-in var(--duration-fast) linear;
}

.dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-bottom: var(--border-1) solid var(--c-line);
}

.dialog__title {
  font-size: var(--fs-lead);
  line-height: var(--lh-body);
}

.dialog__close {
  display: grid;
  place-items: center;
  width: var(--sp-8);
  height: var(--sp-8);
  margin: calc(-1 * var(--sp-2)) calc(-1 * var(--sp-2)) calc(-1 * var(--sp-2)) auto;
  color: var(--c-text-muted);
  border-radius: var(--radius-1);
}

.dialog__close:hover {
  color: var(--c-text);
}

.dialog__body {
  padding: var(--sp-4);
}

.dialog__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: var(--border-1) solid var(--c-line);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(calc(-1 * var(--sp-12))); /* Bootstrap slides down from 50px; 48 on our grid */
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
}
