/* The keys: one small keycap, the shortcut list that is rows of them, and the
   one that stands beside a control while Shift is held
   (hotkey_mode_controller). */
@layer components {
  .keycap,
  [data-hotkey-mode] [data-hotkey]::after {
    display: inline-grid;
    place-items: center;
    min-inline-size: 1.125rem;
    block-size: 1.125rem;
    padding-inline: 0.25rem;
    font-family: var(--font-mono);
    font-size: var(--text-x-small);
    font-weight: 400;
    line-height: 1;
    color: var(--color-ink-subtle);
    background-color: var(--color-canvas);
    border: var(--border);
    border-block-end-width: 2px;
    border-radius: var(--border-radius);
  }

  :where([data-hotkey-mode] [data-hotkey]) {
    position: relative;
  }

  /* Above the control, so nothing moves and no neighbour is covered. A control
     that always says its key needs no second one. */
  [data-hotkey-mode] [data-hotkey]:not(:has(kbd))::after {
    content: attr(data-hotkey);
    position: absolute;
    inset-block-end: calc(100% + 0.125rem);
    inset-inline-end: 0;
    z-index: var(--z-raised);
  }

  /* In the chrome there is no room above: it stands beside. */
  [data-hotkey-mode] :is(#header, #footer) [data-hotkey]::after {
    inset-block: 50% auto;
    inset-inline: calc(100% + 0.25rem) auto;
    translate: 0 -50%;
  }

  [data-hotkey-mode] #header .header__end [data-hotkey]::after {
    inset-inline: auto calc(100% + 0.25rem);
  }

  /* A palette tile has a neighbour on each side and the band's edge just
     above: its key sits on its corner. */
  [data-hotkey-mode] .palette-section[data-hotkey]::after {
    inset-block: -0.5rem auto;
    inset-inline: auto -0.25rem;
  }

  /* A menu's row has room at its own end. */
  [data-hotkey-mode] #my-menu [data-hotkey]::after {
    inset-inline: auto var(--inline-space);
  }

  /* A tab has none, and the popup's edge is just above it: it stands under
     its word. */
  [data-hotkey-mode] #my-menu nav [data-hotkey]::after {
    inset-block: calc(100% - 0.25rem) auto;
    inset-inline: 50% auto;
    translate: -50% 0;
  }

  /* Nothing behind an open modal or menu answers (behindOverlay), so nothing
     behind it says its key: the page's S would stand beside the popup's. */
  [data-hotkey-mode]:has(dialog:modal, [popover]:popover-open) [data-hotkey]:not(dialog:modal *, [popover]:popover-open *)::after {
    content: none;
  }

  .shortcuts {
    columns: 2 16rem;
    column-gap: var(--inline-space-double);
  }

  .shortcuts__group {
    break-inside: avoid;
    padding-block-end: var(--block-space);

    li {
      padding-block: 0.1875rem;
    }
  }
}
