/* =========================================================================
   Command palette (Ctrl K) and the shortcut sheet (?).

   Both are MudDialogs wearing the task dialogs' look (.hf-task-dialog in
   timeline.css): the same border, radius, shadow and banded title and
   footer. This sheet only adds what is theirs: the palette's field over a
   list, the key caps, and the sheet's two-column lines.

   Colours are tokens only (the stone ramp, the inks and the surfaces that
   timeline.css declares on :root, plus .hf-task-dialog's --hf-dialog-lit).
   There is not one literal colour in this file, so a theme that redefines
   the tokens restyles all of it without touching a rule here.

   Nothing in here moves. The dialogs' own open and close come from
   MudBlazor, which already honours prefers-reduced-motion.
   ========================================================================= */

/* ---- key caps: shared by the palette, the sheet and the sidebar row ---- */

.hf-kbd {
  display: inline-block;
  min-width: 1.35rem;
  padding: 0.05rem 0.32rem;
  border: 1px solid var(--stone-300);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-base);
  color: var(--ink-muted);
  font-family: 'DM Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

/* ---- the palette ------------------------------------------------------- */

/* Near the top of the window, where a search box is expected, and never so
   tall that the footer leaves the screen. */
.mud-dialog.hf-cmd-dialog {
  margin-top: min(12vh, 6rem);
  max-height: min(34rem, calc(100dvh - 7rem));
}

/* The title names the dialog for a screen reader. On screen the field says
   the same thing, so the band is clipped away rather than removed: MudDialog
   points aria-labelledby at it. */
.hf-cmd-dialog .mud-dialog-title.hf-cmd-title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The field stays put and the list scrolls under it. */
.hf-cmd-dialog .mud-dialog-content {
  padding: 0;
  gap: 0;
  overflow: hidden;
}

.hf-cmd-search {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--stone-200);
  background: var(--hf-dialog-lit, var(--surface-elev));
  cursor: text;
}

.hf-cmd-search .hf-cmd-search-icon {
  color: var(--ink-muted);
  flex-shrink: 0;
}

.hf-cmd-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0.15rem 0;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-primary);
}

.hf-cmd-input::placeholder {
  color: var(--ink-muted);
  opacity: 1;
}

/* The field has no ring of its own, so the band it sits in shows the focus. */
.hf-cmd-search:focus-within {
  box-shadow: inset 0 -2px 0 var(--stone-500);
}

/* .hf-task-dialog stops its content children shrinking so they scroll as one
   column. Here the list is the part that scrolls, so it alone may shrink. */
.hf-cmd-dialog .mud-dialog-content > .hf-cmd-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0.3rem 0 0.55rem;
}

/* With nothing to list, the list steps aside for the "nothing matches" line beside it. */
.hf-cmd-dialog .mud-dialog-content > .hf-cmd-list[hidden] {
  display: none;
}

.hf-cmd-group {
  margin: 0;
  padding: 0.7rem 1.15rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hf-cmd-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 1.15rem 0.5rem calc(1.15rem - 3px);
  border-left: 3px solid transparent;
  color: var(--ink-primary);
  font-size: 0.92rem;
  line-height: 1.35;
  cursor: pointer;
}

.hf-cmd-row:hover {
  background: var(--stone-50);
}

/* The current row: a fill and a bar, so it does not rest on colour alone. */
.hf-cmd-row.is-active {
  background: var(--stone-100);
  border-left-color: var(--stone-600);
}

.hf-cmd-row .hf-cmd-icon {
  color: var(--ink-muted);
  flex-shrink: 0;
}

/* Wraps, never ellipsis: a task found by name has to be readable in full. */
.hf-cmd-main {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.hf-cmd-label {
  font-weight: 600;
}

.hf-cmd-detail {
  margin-left: 0.4rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

/* Neutral on purpose, as in Pick from today: amber means "live, time passing". */
.hf-cmd-main mark {
  padding: 0 1px;
  border-radius: 3px;
  background: var(--stone-200);
  box-shadow: inset 0 -2px 0 var(--stone-400);
  color: inherit;
}

.hf-cmd-keys {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.hf-cmd-empty {
  margin: 0;
  padding: 1rem 1.15rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.hf-cmd-dialog .mud-dialog-actions {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* The hints wrap when the window is narrow; the button beside them does not. */
.hf-cmd-dialog .mud-dialog-actions .mud-button-root {
  flex-shrink: 0;
  white-space: nowrap;
}

.hf-cmd-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 auto 0 0;
  font-size: 0.74rem;
  color: var(--ink-muted);
}

/* ---- the shortcut sheet ------------------------------------------------ */

.hf-keys-dialog .mud-dialog-content {
  gap: 1.1rem;
}

.hf-keys-title {
  margin: 0 0 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.hf-keys-list {
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
  gap: 0.5rem 1rem;
  align-items: baseline;
  margin: 0;
}

.hf-keys-list dt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.hf-keys-list dd {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--ink-primary);
}

.hf-keys-then {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.hf-keys-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* The sheet's one setting, "Single-key shortcuts": its words on the left, the switch on the
   right. The switch is the notification settings' own (.nfy-switch in notifications.css, which
   every host links), so it looks and behaves like every other switch in the app. */
.hf-keys-setting {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--stone-200);
}

.hf-keys-setting-copy {
  flex: 1;
  min-width: 0;
}

.hf-keys-setting-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-primary);
  cursor: pointer;
}

.hf-keys-setting-desc {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* ---- the sidebar's way in ---------------------------------------------- */

/* "Search and commands" sits at the foot of the web sidebar, apart from the
   three places and Quick Add above it: an auto margin takes up whatever
   height the nav has left over.

   For that the nav has to end where the drawer ends, and until now it did
   not: plan.css makes it 100% tall, which under the sidebar's header pushed
   its last 55px below the drawer, where the drawer's own overflow hid it.
   The rule in MainLayout.razor.css that was written to stop that never
   matches (it leads with ::deep, which needs a scoped ancestor, and inside
   MudDrawer there is none). Nothing sat that low before, so nobody saw it.
   These four declarations are that rule's layout half, as a global rule. */
.hf-web-sidebar-inner > .hf-drawer-nav {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow-y: auto;
}

.hf-sidebar-nav.hf-sidebar-commands {
  margin-top: auto;
  padding-top: 1rem;
}

/* A longer label than its neighbours, with a key cap after it, in a 280px
   drawer: one step down in size and a little less air keep it on one line. */
.hf-sidebar-commands .hf-sidebar-link {
  gap: 0.4rem;
  padding-right: 0.3rem;
  font-size: 0.875rem;
}

/* The row is disabled until the app is listening for it, a second or two after the page
   arrives. It keeps its look through that: plan.css dims a disabled sidebar button to say "you
   cannot do this", and here it would flash dim and back on every page load for something that
   is only not ready yet. It still does not light up under the cursor (plan.css again), and a
   screen reader is told it is unavailable. */
.hf-sidebar-commands .hf-sidebar-link:disabled {
  opacity: 1;
  cursor: default;
}

/* The key hint sits at the end of the row. */
.hf-sidebar-link .hf-sidebar-keys {
  display: inline-flex;
  margin-left: auto;
  flex-shrink: 0;
}

.hf-sidebar-keys .hf-kbd {
  min-width: 0;
  padding: 0.05rem 0.25rem;
  font-size: 0.66rem;
}

/* ---- narrow windows ----------------------------------------------------- */

/* The palette is a keyboard feature, but the sidebar row can open it in a
   narrow browser window too. There it takes the width and the hints that
   only describe keys step aside. */
@media (max-width: 640px) {
  .mud-dialog.hf-cmd-dialog {
    width: calc(100% - 1.25rem);
    max-width: none;
    margin: 0.625rem;
    max-height: calc(100dvh - 1.25rem);
  }
}

@media (hover: none), (pointer: coarse) {
  .hf-cmd-hints,
  .hf-cmd-keys,
  .hf-sidebar-link .hf-sidebar-keys {
    display: none;
  }

  .hf-cmd-row {
    min-height: 2.75rem;
  }
}

/* Windows high contrast drops fills, which is all the current row had. */
@media (forced-colors: active) {
  .hf-cmd-row.is-active {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}
