/* 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: 0;
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-1);
  overflow: hidden;             /* the bar keeps the rounded corners */
}

.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;
}

/* The bar: anthracite with the calendar band's linen, 40px, the title in small capitals (like Availability's bar). */
.dialog__header {
  position: relative;
  isolation: isolate;           /* keeps the linen behind the title */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  min-height: var(--sp-10);
  padding: 0 var(--sp-2) 0 var(--sp-4);
  color: var(--c-page);
  background-color: var(--c-anthracite);
}

.dialog__header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, var(--c-linen) 0 var(--border-1), transparent var(--border-1) var(--sp-1)),
    repeating-linear-gradient(-45deg, var(--c-linen) 0 var(--border-1), transparent var(--border-1) var(--sp-1));
}

.dialog__title {
  padding-block: var(--sp-3);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: inherit;
}

.dialog__close {
  display: grid;
  flex: none;
  place-items: center;
  width: var(--sp-8);
  height: var(--sp-8);
  color: var(--c-on-dark-muted);
  border-radius: var(--radius-1);
}

.dialog__close:hover {
  color: var(--c-page);
  background-color: var(--c-on-dark-hover);
}

.dialog__body {
  padding: var(--sp-6) 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);
}

/* Cancel: light grey, so the main button (red when it removes something) is the only strong colour. */
.dialog__footer .button--secondary {
  color: var(--c-text);
  background-color: var(--c-surface);
  border-color: var(--c-line);
}

.dialog__footer .button--secondary:hover {
  background-color: 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;
  }
}
