/* Shared form helpers (packages/core/src/confirm.tsx, public/submit-once.js, public/dirty-guard.js): the confirm
   disclosure and page, the busy button, the unsaved-changes dialog and sortable headers. Loaded on every page by
   Document right after tokens.css, so a surface's own sheet can restyle any of it. Tokens only, no colour literals. */

/* ---------- Confirm disclosure and page ---------- */
details.confirm > summary {
  cursor: pointer;
  color: var(--err);
  font-weight: 700;
  min-height: 24px;
}
details.confirm[open] > summary {
  margin-bottom: var(--space-3);
}
/* A confirm's heading names the person or thing, so a long email or name wraps instead of widening the page. */
.confirm-page h2 {
  overflow-wrap: anywhere;
}
.confirm-body {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
}
details.confirm .confirm-body {
  border-left: 3px solid var(--err);
  padding-left: var(--space-4);
}
/* A confirmed step that adds something (tone="action"): the page's own colours, not the destructive red. */
details.confirm.action > summary {
  color: var(--text);
  text-decoration: underline;
}
details.confirm.action .confirm-body {
  border-left-color: var(--gold);
}
details.confirm.action .confirm-ack input {
  accent-color: var(--charcoal);
}
.confirm-effect {
  margin: 0;
}
/* The address an email is about to go to, on its own line and large, so a typo is seen before it's sent. */
.confirm-to {
  margin: var(--space-1) 0;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.confirm-to strong {
  display: block;
  font-size: var(--text-lg);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.confirm-to span {
  display: block;
  margin-top: var(--space-1);
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  color: var(--muted);
}
.confirm-ack {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  font-weight: 600;
}
.confirm-ack input {
  width: 24px;
  height: 24px;
  margin: 0;
  flex: none;
  accent-color: var(--err);
}

/* ---------- Select arrow ---------- */
/* A one-line select draws its own chevron with room to its right: Chrome and Safari put their native arrow against the
   border, and Safari ignores our corners and fill. The :not()s keep a list box (multiple or size) native and outrank a
   surface sheet's plain `select` rule, whose padding and background shorthands would otherwise undo this. A sheet that
   colours a select under an equal or stronger selector sets background-color, not the shorthand. */
select:not([multiple]):not([size]) {
  appearance: none;
  padding-right: var(--space-10);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 12px 8px;
}
select:not([multiple]):not([size]):disabled {
  background-image: var(--select-arrow-disabled);
}
/* High-contrast modes repaint controls in system colours, which a fixed-colour image can't follow: the native arrow
   comes back, with the ordinary padding so text isn't cut short beside it. */
@media (forced-colors: active) {
  select:not([multiple]):not([size]),
  select:not([multiple]):not([size]):disabled {
    appearance: auto;
    padding-right: var(--space-3);
    background-image: none;
  }
}

/* ---------- Busy button (submit-once) ---------- */
/* The disabled look already greys it; no extra fade, so the busy label keeps its contrast. */
.btn.is-busy,
button.is-busy {
  cursor: progress;
}

/* ---------- Notices ---------- */
/* A notice takes focus on load only so a screen reader reads it (focus-alert.js); it isn't a control, so no ring. */
.notice[data-focus-on-load]:focus {
  outline: none;
}
/* Neutral notice for plain news that isn't a success. D09 restyles notices as a set. */
.notice.info {
  background: var(--card-bg);
  border-color: var(--line);
  color: var(--charcoal);
}

/* ---------- Unsaved-changes dialog (dirty-guard) ---------- */
dialog.dirty-guard {
  max-width: min(28rem, calc(100vw - 2 * var(--space-4)));
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--charcoal);
}
dialog.dirty-guard::backdrop {
  /* Dims the page behind the dialog: a shade, not a brand colour, so there's no token for it. */
  background: rgb(0 0 0 / 40%);
}
dialog.dirty-guard p {
  margin: 0 0 var(--space-4);
}

/* ---------- Sortable table headers ---------- */
th .sort-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
th .sort-arrow {
  margin-left: var(--space-1);
  font-size: 0.75em;
}

/* ---------- Action tiles (#905, src/action-tiles.tsx) ---------- */
/* The things you can do on a page, each a tile with a title (verb + object) and one line on what happens. Same box as
   the Printables tiles (fundraise kit-index.css .kit-tile), so organizers already know them. A confirm tile opens its
   step inside itself and doesn't span the row; choosing it again closes it. */
.action-group {
  display: grid;
  gap: var(--space-3);
}
.action-group > h2,
.action-group > h3 {
  margin: 0;
}
.action-tiles {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  align-items: start;
}
/* A lone tile keeps one tile's width rather than stretching across the card (the daily email switch, #923). */
.action-tiles:has(> :only-child) {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
}
/* Rows with no confirm tile line up like the Printables tiles; a row with one keeps start, so opening it moves nothing. */
.action-tiles:not(:has(> details)) {
  align-items: stretch;
}
.action-tile {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--charcoal);
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 120ms ease-out,
    border-color 120ms ease-out;
}
.action-tile[hidden] {
  display: none;
}
/* A form tile's form steps aside so its button is the grid item. */
.action-tile-form {
  display: contents;
}
a.action-tile:hover,
button.action-tile:hover,
details.action-tile:not([open]):hover {
  background: var(--cream);
  border-color: var(--caramel);
}
.action-tile:focus-visible,
details.action-tile > summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.action-tile-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}
.action-tile-mark {
  color: var(--gold-ink);
}
.action-tile small {
  display: block;
  margin-top: 2px;
  font-weight: 500;
  color: var(--text-muted);
}
.action-tile.is-featured {
  background: var(--cream);
  border-color: var(--gold);
}
.action-tile.is-featured:hover {
  background: var(--cream-2);
}
/* Confirm first: the summary is the tile's face; opened, the tile shows the effect and the button, in place. */
details.action-tile > summary {
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius-md);
}
details.action-tile > summary::-webkit-details-marker {
  display: none;
}
details.action-tile[open] {
  background: var(--surface);
}
/* Open, the effect says it in full, so the one-line note steps aside. */
details.action-tile[open] > summary small {
  display: none;
}
/* Charcoal at rest (a choice, not an error); red once a destructive tile is open. */
details.action-tile.is-danger[open] {
  border-color: var(--err);
}
details.action-tile.is-danger[open] .action-tile-title {
  color: var(--err);
}
details.action-tile.is-action[open] {
  border-color: var(--gold);
}
details.action-tile .confirm-body {
  display: grid;
  gap: var(--space-3);
  justify-items: start;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--rule);
  font-weight: 500;
}
/* A group's copy result: plain text (the words say whether it worked, so never green), its line reserved so the
   tiles below don't move when it fills. */
.action-status {
  margin: 0;
  min-height: 1.5em;
  color: var(--text);
  font-weight: 600;
}
