/*
 * The outcome of an action (fix 1a) — the message area, the dialog for a step
 * that did not happen, and the mark on a box that needs attention. Markup from
 * src/infra/ui/feedback.js; behaviour in public/ui/feedback.js.
 *
 * Only the tokens every theme defines (public/brand/tokens.css, and each theme's
 * complete copy): no colour is chosen here, so it reads in every theme, light
 * and dark, on the dashboard and the console alike. Meaning is in attributes,
 * so a page that changes its own markup keeps these.
 */

/* ── The message area: under the sticky header, in view wherever the page is ── */
/* `--msgs-top` is the page's own sticky header, measured by feedback.js (the dashboard's and the console's differ,
   and the console's wraps onto two lines on a phone); `--header-h` until it is measured, or without script. */
.ui-msgs {
  position: sticky; top: var(--msgs-top, var(--header-h)); z-index: 9;
  display: grid; gap: var(--sp-2);
  margin: 0 0 var(--sp-4); padding-top: var(--sp-2);
}
.ui-msg {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius);
  box-shadow: var(--shadow); background: var(--paper); color: var(--ink);
}
.ui-msg--success { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--paper)); }
.ui-msg--error { border-left-color: var(--urgent); background: color-mix(in srgb, var(--urgent) 7%, var(--paper)); }
.ui-msg--notice { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, var(--paper)); }
.ui-msg__icon {
  flex: none; width: 20px; height: 20px; margin-top: 2px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--paper);
}
.ui-msg--success .ui-msg__icon { background: var(--ok); }
.ui-msg--error .ui-msg__icon { background: var(--urgent); }
.ui-msg--notice .ui-msg__icon { background: var(--warn); }
.ui-msg__text { flex: 1; margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* The ×: a whole tap target, at the end of the line. */
.ui-msg__close, .ui-dialog__close {
  flex: none; min-width: var(--tap-min); min-height: var(--tap-min);
  margin: calc(-1 * var(--sp-2)) calc(-1 * var(--sp-1)) calc(-1 * var(--sp-2)) 0;
  display: grid; place-items: center; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--ink-muted); font: inherit; font-size: 1.4rem; line-height: 1; cursor: pointer;
}
.ui-msg__close:hover, .ui-dialog__close:hover { color: var(--ink); background: var(--paper-tint); }
.ui-msg__close[hidden] { display: none; }
.ui-msg__close:focus-visible, .ui-dialog__close:focus-visible, .ui-dialog__go:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}

/* ── The dialog: a step that did not happen ───────────────────────────────── */
.ui-dialog {
  width: min(32rem, calc(100vw - 2 * var(--sp-4))); padding: var(--sp-5);
  border: 1px solid var(--line); border-top: 4px solid var(--urgent); border-radius: var(--radius-lg);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lg);
}
.ui-dialog::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.ui-dialog__head { display: flex; align-items: flex-start; gap: var(--sp-3); }
/* A sentence, not a section label: a page's own heading rules (capitals, spacing, a muted colour) stop here. */
.ui-dialog__title {
  flex: 1; margin: 0; display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--text-lg); line-height: var(--leading-tight); font-weight: 600;
  text-transform: none; letter-spacing: 0; color: var(--ink);
}
.ui-dialog__icon {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: var(--paper); background: var(--urgent);
}
.ui-dialog__text { margin: var(--sp-4) 0 var(--sp-5); }
.ui-dialog__actions { display: flex; justify-content: flex-end; }
.ui-dialog__go {
  min-height: var(--tap-min); padding: var(--sp-3) var(--sp-5); font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--action-bg); border-radius: var(--radius-sm);
  background: var(--action-bg); color: var(--action-fg);
}
.ui-dialog__go:hover { filter: brightness(1.05); }

/* ── A box that needs attention: a bar and words, never the colour alone ──── */
/* `:root` lifts the mark above a page's own box rules (`.box { border: … }`), whichever stylesheet comes last. */
:root [data-attention] { border-left: 4px solid var(--warn); }
.ui-attention-label {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  margin-left: var(--sp-3); padding: 2px var(--sp-2); vertical-align: middle;
  border: 1px solid var(--warn-line); border-radius: var(--radius-pill);
  background: var(--warn-wash); color: var(--warn);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0;
}
.ui-box-warning {
  margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--warn-line); border-left: 4px solid var(--warn); border-radius: var(--radius);
  background: var(--warn-wash); color: var(--ink);
}
.ui-box-warning > p { margin: 0; }
.ui-box-warning > p + p { margin-top: var(--sp-2); }

/* ── Where a jump lands: below the header and the messages, and shown ─────── */
[data-landing] { scroll-margin-top: calc(var(--msgs-top, var(--header-h)) + var(--msgs-h, 0px) + var(--sp-4)); }
[data-landing]:target, [data-landing]:focus { outline: 2px solid var(--gold-soft); outline-offset: 2px; }
[data-landing]:focus:not(:focus-visible):not(:target) { outline: none; }
