/* ADR-036 UI-5 · D-142 — the feedback components (/ui/feedback.js): toasts, dialogs, the three states of a region.
   Tokens only (tokens.css); each kind has its icon and its words as well as its colour. */

/* ── toasts: the page's live region (#status), a stack at the reading end of the screen; it never takes a click
      outside its own messages */
.toasts {
  position: fixed; z-index: 50; inset-block-end: var(--sp-4); inset-inline-start: var(--sp-4);
  width: min(440px, calc(100vw - 2 * var(--sp-4)));
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: var(--sp-3); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-inline-start: 4px solid var(--neutral);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-body); line-height: var(--lh);
}
.toast .toast-icon { flex: none; width: 20px; height: 20px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast .toast-label { font-weight: 600; flex: none; }
.toast .toast-label::after { content: ':'; }
.toast .toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .toast-close {
  flex: none; min-width: var(--control-h); min-height: var(--control-h); margin: calc(-1 * var(--sp-2));
  display: inline-grid; place-items: center;
  background: transparent; border: 0; border-radius: var(--r-sm); color: var(--text-2); cursor: pointer;
}
.toast .toast-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.toast .toast-close:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.toast.ok { border-inline-start-color: var(--ok); }
.toast.ok .toast-icon, .toast.ok .toast-label { color: var(--ok); }
.toast.info { border-inline-start-color: var(--info); }
.toast.info .toast-icon, .toast.info .toast-label { color: var(--info); }
.toast.warn { border-inline-start-color: var(--warn); }
.toast.warn .toast-icon, .toast.warn .toast-label { color: var(--warn); }
.toast.danger { border-inline-start-color: var(--danger); background: var(--danger-bg); }
.toast.danger .toast-icon, .toast.danger .toast-label { color: var(--danger); }
.toast.busy .toast-icon { color: var(--text-2); animation: erp-spin 1s linear infinite; }

/* ── dialogs: message · confirmation · the panel's text prompts */
dialog.dialog {
  width: min(520px, calc(100vw - 2 * var(--sp-4))); max-height: calc(100vh - 2 * var(--sp-4)); overflow: auto;
  border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-5);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-2);
}
dialog.dialog::backdrop { background: var(--overlay); }
dialog.dialog h2 { margin-top: 0; font-size: var(--fs-title); }
dialog.dialog .actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-4); flex-wrap: wrap; }
dialog.dialog .actions button { margin-top: 0; min-height: var(--control-h); }
dialog.dialog .dialog-details { margin-top: var(--sp-3); color: var(--text-2); font-size: var(--fs-small); }
dialog.dialog .dialog-details summary { cursor: pointer; min-height: var(--control-h); display: flex; align-items: center; }

/* ── the three states of a region */
.state-block { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-6) var(--sp-4); color: var(--text-2); text-align: center; }
.state-block .state-icon { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.state-block p { margin: 0; }
.state-block.is-failure { color: var(--danger); }
.state-block.is-failure p { color: var(--text); }
.spin { animation: erp-spin 1s linear infinite; }
@keyframes erp-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spin, .toast.busy .toast-icon { animation: none; }
}
