/* Dialog sized to its content (operator, 2026-11-08: « agrandis la taille des modales en fonction de leur contenu »). The reference
   (kit.css `.dialog`) gives the chrome: xl radius, 20px padding, floating shadow, 16px title, 18px above the buttons; this sheet only
   lets the box follow what it holds. Auto starts at the reference's 420px and grows with content that is wide by nature (a table,
   two columns of fields, a long value) up to 960px, while text wraps to the box instead of widening it, so a confirmation stays
   at 420px. Small, Medium, Large and XLarge fix the width at 420, 600, 760 and 960px. The box is never wider than the scrim's
   16px margins, so a phone gets the full width as before. Its height follows the content up to the visible viewport; past that
   only the body scrolls, under the title and above the buttons. */

.dialog[data-size] {
  display: flex; flex-direction: column; max-width: min(960px, 92vw, 100%);
  max-height: calc(var(--app-h, 100dvh) - max(16px, var(--safe-t)) - max(16px, var(--view-b)));
}
.dialog[data-size="auto"] { width: max-content; min-width: min(420px, 100%); }
.dialog[data-size="small"] { width: min(420px, 100%); }
.dialog[data-size="medium"] { width: min(600px, 100%); }
.dialog[data-size="large"] { width: min(760px, 100%); }
.dialog[data-size="xlarge"] { width: min(960px, 92vw, 100%); }
/* Text never sets the width of an Auto box: it wraps at whatever the rest of the content asks for. */
.dialog[data-size="auto"] :is(h2, p, li, dd, .banner, .fgroup > label, .fgroup > .flabel) { contain: inline-size; }

.dialog[data-size] > h2, .dialog[data-size] > .buttons { flex: none; }
/* The body reaches the box's edges so its scroll bar sits at the border and focus rings are never cut. */
.dialog-body {
  flex: 0 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  margin: 0 -20px; padding: 0 20px 3px;
}
