/* Confirmation page and dialog (brandbook "Dialogs", "Confirmation page and
   confirmation dialog"). Every confirmation ends with the action row
   (action-row.css): the action first, the way back second.

   The page: templates/form/confirm-form.html.twig. The page title is the
   question; one card holds the description and the form's action row. */
.mm-confirm {
  max-width: 560px;
}

.mm-confirm > .mm-body {
  margin-top: 0;
  font-size: 16px;
  line-height: 1.5;
}

.mm-confirm > .mm-body p {
  margin: 0;
}

.mm-confirm > .mm-body p + p {
  margin-top: var(--mm-space-3);
}

@media (min-width: 768px) {
  .mm-confirm {
    padding: 28px 28px 22px;
  }
}

/* The dialog: core's jQuery UI dialog, which js/dialog.js gives .mm-dialog,
   the close icon and an .mm-action-row button set. A card that floats over
   the scrim: 6 px corners, the overlay shadow, at most 480 px wide and on a
   phone the width less the 16 px gutters (the module's own width option is
   overridden; the help modal, the document preview and the note edit are the
   wider variants, below). Core's dialog CSS can load
   after the theme's (an AJAX
   response adds it to the page), so every rule here is one class more
   specific than its jQuery UI dialog.css or theme.css counterpart, never
   !important. */
.ui-widget-overlay.ui-front {
  background: var(--mm-scrim);
  opacity: 1;
}

.ui-dialog.mm-dialog {
  min-width: min(480px, calc(100vw - 2 * var(--mm-space-4)));
  max-width: min(480px, calc(100vw - 2 * var(--mm-space-4)));
  padding: 22px var(--mm-space-5) 18px;
  border: 0;
  border-radius: var(--mm-radius-card);
  background: var(--mm-surface);
  box-shadow: var(--mm-shadow-overlay);
  color: var(--mm-text);
  font: 400 16px/1.5 var(--mm-sans);
}

.ui-dialog.mm-dialog :is(input, select, textarea, button) {
  font-family: var(--mm-sans);
}

.ui-dialog.mm-dialog a:not(.mm-btn) {
  color: var(--mm-primary);
}

/* Title bar: the serif title only, clear of the close button. Copy is never
   cut, so the title wraps. */
.ui-dialog.mm-dialog .ui-dialog-titlebar {
  position: static;
  padding: 0 40px 0 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--mm-text);
  font-weight: 400;
}

.ui-dialog.mm-dialog .ui-dialog-title {
  float: none;
  width: auto;
  margin: 0;
  overflow: visible;
  white-space: normal;
  font-family: var(--mm-serif);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.2;
  text-wrap: balance;
}

/* The close button: 44 x 44 in the corner, the 22 px close icon. */
.ui-dialog.mm-dialog .ui-dialog-titlebar-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--mm-radius-field);
  background: none;
  color: var(--mm-muted);
  text-indent: 0;
  cursor: pointer;
}

.ui-dialog.mm-dialog .ui-dialog-titlebar-close:is(:hover, :focus, :active) {
  border: 0;
  background: none;
  color: var(--mm-text);
}

.ui-dialog.mm-dialog .ui-dialog-titlebar-close:focus-visible {
  outline: none;
  box-shadow: var(--mm-focus);
}

.ui-dialog.mm-dialog .ui-dialog-titlebar-close svg {
  width: 22px;
  height: 22px;
}

/* The help modal (HelpController: .mamaney-help-dialog, which js/dialog.js
   keeps beside .mm-dialog): a reading width, at most 640 px, so a help
   item's lists keep a readable measure; on a phone the same width less the
   gutters. Its body is css/areas/help-modal.css. A forced item (--forced)
   closes only with its acknowledgement, so it has no close button. */
.ui-dialog.mm-dialog.mamaney-help-dialog {
  min-width: min(640px, calc(100vw - 2 * var(--mm-space-4)));
  max-width: min(640px, calc(100vw - 2 * var(--mm-space-4)));
}

.ui-dialog.mm-dialog.mamaney-help-dialog--forced .ui-dialog-titlebar-close {
  display: none;
}

/* The module's other wide dialogs. The document preview
   (AbstractWizardStepController: .document-preview-modal) shows a page of
   the document: up to 800 px, the 720 px paper on its desk (wizard.css). The
   note edit (.promissory-note-edit-modal, the module's 560) is 560 px. Every
   other operation dialog is the 480 px card, whatever width its controller
   asks for (30 %, 40 %). */
.ui-dialog.mm-dialog.document-preview-modal {
  min-width: min(800px, calc(100vw - 2 * var(--mm-space-4)));
  max-width: min(800px, calc(100vw - 2 * var(--mm-space-4)));
}

.ui-dialog.mm-dialog.promissory-note-edit-modal {
  min-width: min(560px, calc(100vw - 2 * var(--mm-space-4)));
  max-width: min(560px, calc(100vw - 2 * var(--mm-space-4)));
}

/* jQuery UI's own icon and label spacer, in case the icon was not swapped. */
.ui-dialog.mm-dialog .ui-dialog-titlebar-close .ui-icon,
.ui-dialog.mm-dialog .ui-dialog-titlebar-close .ui-button-icon-space {
  display: none;
}

/* Body: 12 px under the title. jQuery UI scrolls it (overflow: auto), which
   would clip a focus ring on its first or last child (the inline help
   panel's summary, the last field): a 4 px padding, given back by the
   margin on all four sides, keeps the ring inside and adds no height. */
.ui-dialog.mm-dialog .ui-dialog-content {
  margin: calc(var(--mm-space-3) - 4px) -4px -4px;
  padding: 4px;
  border: 0;
  background: none;
  color: inherit;
  overscroll-behavior: contain;
}

/* A dialog taller than the screen: core caps the body (an inline max-height
   from its 95 % maxHeight, less the title and the pane), so the body scrolls
   and the title and the action row stay in view, on a phone too. A hairline
   shows at the top or the bottom edge while text is hidden past it: two
   surface-coloured covers scroll with the text and hide the lines while the
   body is at that end. The help modal draws its own (help-modal.css), the
   document preview is its grey desk (wizard.css). */
.ui-dialog.mm-dialog:not(.mamaney-help-dialog) .ui-dialog-content:not(:has(.mamaney-document)) {
  background:
    linear-gradient(var(--mm-surface), var(--mm-surface)) top / 100% var(--mm-space-2) no-repeat local,
    linear-gradient(var(--mm-surface), var(--mm-surface)) bottom / 100% var(--mm-space-2) no-repeat local,
    linear-gradient(var(--mm-line), var(--mm-line)) top / 100% 1px no-repeat scroll,
    linear-gradient(var(--mm-line), var(--mm-line)) bottom / 100% 1px no-repeat scroll;
}

/* The document preview's desk spans the body's own width (its padding is
   wizard.css's), level with the title. */
.ui-dialog.mm-dialog .ui-dialog-content:has(.mamaney-document) {
  margin-inline: 0;
  margin-bottom: 0;
}

/* A confirmation page's card opened as a dialog: the dialog is the card. */
.ui-dialog.mm-dialog .mm-confirm {
  max-width: none;
  padding: 0;
  border: 0;
  background: none;
}

/* Core hides the form's buttons once it copies them into the pane; the
   emptied row (with its frame) and the messages container (filled only by
   an AJAX error) take no room in the form's 16 px stack. */
.ui-dialog.mm-dialog .ui-dialog-content .mm-action-frame:not(:has(> .mm-action-row > :not([style*="display: none"], [type="hidden"]))),
.ui-dialog.mm-dialog .ui-dialog-content .mm-action-row:not(:has(> :not([style*="display: none"], [type="hidden"]))),
.ui-dialog.mm-dialog .ui-dialog-content .mm-form > div:empty {
  display: none;
}

/* Button pane: no bar, no line; its set is the action row, and the pane is
   that row's query container (action-row.css). Not the dialog itself:
   containment there would make it the containing block of a fixed term
   explanation in the dialog's text (tooltip.css). */
.ui-dialog.mm-dialog .ui-dialog-buttonpane {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  container-type: inline-size;
}

.ui-dialog.mm-dialog .ui-dialog-buttonpane .mm-action-row {
  float: none;
}

/* The pane's buttons. Core copies each original button's classes, so the
   kind is the form's (.mm-btn--primary, --danger, --secondary, --text);
   jQuery UI's button look (ui-button, its :hover, :focus and :active) is
   undone here. */
.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn {
  display: inline-flex;
  margin: 0;
  padding: 11px var(--mm-space-5);
  border: 1px solid transparent;
  border-radius: var(--mm-radius-control);
  font: 600 16px/1.25 var(--mm-sans);
  text-decoration: none;
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--primary {
  background: var(--mm-primary);
  color: var(--mm-surface);
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--primary:is(:hover, :active) {
  background: var(--mm-primary-pressed);
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--danger {
  background: var(--mm-danger);
  color: var(--mm-surface);
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--danger:is(:hover, :active) {
  background: var(--mm-danger-pressed);
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--secondary {
  border-color: var(--mm-primary);
  background: var(--mm-surface);
  color: var(--mm-primary);
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--secondary:is(:hover, :active) {
  background: var(--mm-primary-surface);
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--text {
  min-height: 44px;
  padding: 0 var(--mm-space-2);
  background: none;
  color: var(--mm-primary);
  text-decoration: underline;
  text-decoration-color: var(--mm-underline);
  text-underline-offset: 4px;
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn--text:is(:hover, :active) {
  background: none;
  color: var(--mm-primary-pressed);
  text-decoration-color: currentColor;
}

.ui-dialog.mm-dialog .ui-dialog-buttonset .mm-btn:focus-visible {
  outline: none;
  box-shadow: var(--mm-focus);
}
