/* Wave 8, polish: shortcuts shown where the click happens, the first day
   without coach marks, the error standard, bulk outcomes, the in-app error
   pages, and WCAG 2.2 as polish (24px targets, focus never under a bar,
   contrast). Loads after every earlier wave file (alphabetical), so equal
   specificity here wins. Tokens from hub.css and wave5-tokens.css. */

/* ---- 1. Keyboard hints ------------------------------------------------- */

/* One hint: the keys as small caps-height blocks, in the numeric face so a
   row of them lines up. Inside a row button it is invisible until the row
   is hovered or selected; in a sheet row, a palette entry or the first-day
   line it is always there. */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  vertical-align: middle;
}

.kbd-hint .kbd,
kbd.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-raised);
  color: var(--ink-soft);
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  text-transform: none;
}

/* A hint on a dark pill takes the pill's ink. */
.btn-forest .kbd-hint .kbd,
.btn-primary .kbd-hint .kbd,
.sheet-row-quiet .kbd-hint .kbd {
  border-color: rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .14);
  color: inherit;
}

.btn-primary .kbd-hint .kbd {
  border-color: rgba(12, 65, 41, .3);
  background: rgba(12, 65, 41, .1);
}

/* In a row the hint waits for the hover or the selection. Transitions are
   opacity only, under 200ms; the row is a high-frequency surface. */
.needs-row .kbd-hint,
.person-row .kbd-hint,
.more-menu-item .kbd-hint {
  opacity: 0;
  transition: opacity 120ms var(--ease-out);
}

.needs-row:hover .kbd-hint,
.needs-row[data-selected] .kbd-hint,
.needs-row:focus-within .kbd-hint,
.person-row:hover .kbd-hint,
.person-row[data-selected] .kbd-hint,
.person-row:focus-within .kbd-hint,
.more-menu[open] .more-menu-item .kbd-hint {
  opacity: 1;
}

.more-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Sheet rows: the key sits at the end of the line. */
.sheet-row .kbd-hint {
  margin-left: auto;
}

.sheet-row:has(.kbd-hint) {
  display: flex;
  align-items: center;
}

/* Palette entries: label, hint, then the keys at the far end. */
.palette-item-keys {
  margin-left: 0;
}

.palette-item .palette-item-hint + .palette-item-keys {
  margin-left: 4px;
}

/* The first-day line reads inline. */
.kbd-hint.is-inline {
  margin: 0 2px;
}

/* No keyboard, no hints. (hover: none) is the phone and the tablet. */
@media (hover: none) {
  .kbd-hint {
    display: none;
  }
}

/* ---- 2. The shortcuts sheet ------------------------------------------- */

.shortcuts-group {
  margin: 16px 0 2px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-faint);
}

.shortcuts-group:first-of-type {
  margin-top: 6px;
}

.shortcuts-list > div {
  grid-template-columns: 112px 1fr;
}

.shortcuts-list dt {
  align-items: center;
  flex-wrap: wrap;
}

.shortcuts-then {
  margin: 0 2px;
  font-size: 11px;
  color: var(--ink-faint);
}

.shortcuts-footer {
  margin-top: 14px;
}

.shortcuts-footer kbd {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-num);
  font-size: 11px;
}

/* ---- 3. The selected row ----------------------------------------------- */

/* Selection is an attribute, not a focus trap: the row shows the ring, the
   tab order stays the document's own. The same look as .is-keyed, which the
   inbox controller still reads. */
.needs-row[data-selected],
.person-row[data-selected],
[data-keyable][data-selected] {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm);
}

/* Two controls that cancelled the ring without replacing it: the shelf's
   drag handle (wave 4) and the palette's field, whose box is the focus. */
.shelf-handle:focus-visible {
  box-shadow: var(--focus-ring);
}

.palette-input:focus-visible {
  box-shadow: inset 0 0 0 2px var(--line-strong);
}

/* ---- 4. The first day --------------------------------------------------- */

.first-day-task .needs-list {
  margin: 0;
}

.first-day-task .needs-row {
  padding-left: 0;
  padding-right: 0;
}

.first-day-note {
  margin: 10px 0 0;
}

.first-day-hint .first-day-line {
  margin: 0 0 10px;
  font-size: var(--fs-body);
}

/* The first-run panel: one card, centred, no sheet handle, no Cancel. */
.first-run {
  max-width: 440px;
}

.first-run .role-cards {
  display: grid;
  gap: 8px;
}

/* The practice creator's page: one quiet line under the header. */
.sample-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
  font-size: var(--fs-body);
}

/* The brand shelf's empty state: the partial, then the three ghost rows. */
.empty-shelf .ghost-rows {
  margin-top: 4px;
}

/* ---- 5. Errors, outcomes, the error pages ----------------------------- */

/* The error standard (04 R12): title, body, verb. Red for what needs a
   hand now; amber (is-warn) for a workflow error that can wait. */
.error-message {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 12px 14px;
  border: 1px solid var(--danger-600);
  border-radius: var(--r-sm);
  background: var(--danger-tint);
  color: var(--ink);
}

.error-message.is-warn {
  border-color: var(--warning-600);
  background: var(--warning-tint);
}

.error-message-title {
  display: block;
  font-size: var(--fs-body);
}

.error-message-body {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.error-message-action {
  flex: none;
}

/* What the last bulk action did: the headline, then one row per failure
   with the verb that fixes it. */
.bulk-outcome {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-raised);
}

.bulk-outcome.is-partial {
  border-color: var(--warning-600);
  background: var(--warning-tint);
}

.bulk-outcome-headline {
  margin: 0;
  font-size: var(--fs-body);
}

.bulk-outcome-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.bulk-outcome-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 2fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: var(--fs-body);
}

.bulk-outcome-who {
  font-weight: 600;
}

.bulk-outcome-why {
  color: var(--ink-soft);
}

@media (max-width: 640px) {
  .bulk-outcome-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* The 404 and 500 inside the hub: one card, the way back in lime. */
.error-page {
  max-width: 560px;
  margin: 32px auto;
}

.error-page h1 {
  margin-bottom: 8px;
}

/* ---- 6. WCAG 2.2 as polish --------------------------------------------- */

/* Target size (minimum): 24 by 24 CSS px on the dense row icons, by
   padding rather than glyph size. The dots, the close crosses, the
   dismiss on a toast, the compact copy link, the PDF link. */
.more-menu summary.btn-quiet,
.sheet-close,
.flash-dismiss,
.person-copy .table-link,
.pdf-link,
.fold-chevron,
.chip-button,
.quick-action-icon {
  min-width: 24px;
  min-height: 24px;
  box-sizing: border-box;
}

.more-menu summary.btn-quiet,
.sheet-close,
.flash-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
}

.pdf-link,
.person-copy .table-link {
  display: inline-flex;
  align-items: center;
  padding: 2px 4px;
}

/* Focus not obscured: a focused row scrolls clear of the fixed top bar on
   a phone, the tab bar, the Next bar, the pay bar and a sticky form bar.
   The numbers are the bars' own (wave2-shell, wave2-creators, wave4-money). */
html {
  scroll-padding-top: 24px;
  scroll-padding-bottom: 96px;
}

@media (max-width: 840px) {
  html {
    scroll-padding-top: calc(52px + var(--safe-t, 0px) + 12px);
    scroll-padding-bottom: calc(50px + var(--safe-b, 0px) + 72px);
  }
}

.hub-dialog {
  scroll-padding-top: 16px;
  scroll-padding-bottom: 80px;
}

/* prefers-contrast: more. Wave 5 stepped the greys; this finishes the
   job on the rings, the chips, the selection and the card edges. */
@media (prefers-contrast: more) {
  :focus-visible {
    outline-width: 3px;
    outline-offset: 3px;
  }

  .needs-row[data-selected],
  .person-row[data-selected],
  .needs-row.is-keyed {
    box-shadow: 0 0 0 3px var(--ink);
  }

  .chip,
  .kbd-hint .kbd,
  kbd.kbd {
    border: 1px solid currentColor;
  }

  .btn-secondary,
  .card,
  .needs-row,
  .person-row,
  .error-message,
  .bulk-outcome,
  .sample-banner {
    border-color: var(--line-strong);
  }

  .btn-secondary {
    border-width: 2px;
  }

  .page-sub,
  .field-hint {
    color: var(--ink-soft);
  }
}

/* Reduced motion: the hint fades are already opacity only; drop them to
   nothing so the row answers at once. */
@media (prefers-reduced-motion: reduce) {
  .needs-row .kbd-hint,
  .person-row .kbd-hint,
  .more-menu-item .kbd-hint {
    transition: none;
  }
}
