/* ── palette ──
 * Command palette, the /settings and /help floating windows, and the drag bars.
 * Linked from index.html in cascade order — the order is load-bearing. */

/* ── Command palette ───────────────────────────────── */
#palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg-page) 40%, transparent);
  backdrop-filter: blur(1.5px);
}
#palette-overlay.hidden { display: none; }
#palette-overlay.preview { background: transparent; backdrop-filter: none; }

#palette {
  position: absolute;
  bottom: calc(var(--status-height) + 10px);
  left: 16px;
  width: 340px;
  background: color-mix(in srgb, var(--bg-raised) 97%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), 0 0 0 1px var(--accent-soft);
}
#palette.anchored { bottom: auto; }

/* ── Floating-window modes (/settings, /help) ───────────────────────────────
   lazy.nvim's shape: a centred bordered frame with its name sitting on the top
   border. Same palette element and same keyboard model — only the frame moves,
   so every existing mode keeps working untouched. */
#palette.float {
  bottom: auto; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 48px));
  max-height: min(620px, calc(100vh - 120px));
  display: flex; flex-direction: column;
  overflow: visible;                 /* the title sits on the border, don't clip it */
  border-radius: 10px;
}
#palette.float::before {
  content: attr(data-title);
  position: absolute; top: -9px; left: 22px; padding: 0 9px;
  background: var(--bg-raised); color: var(--accent);
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
}
#palette.float #palette-search-row { border-radius: 10px 10px 0 0; }
#palette.float #palette-list {
  flex: 1; max-height: none; overflow-y: auto;
  padding-bottom: 6px;
}
#palette.float #palette-title { padding-top: 14px; }

/* Drag bars — the real sliders, only rendered in the settings float. */
#palette-bars { padding: 6px 16px 12px; border-top: 1px solid var(--border-soft); flex: 0 0 auto; }
#palette-bars.hidden { display: none; }
.pal-bar { display: flex; align-items: center; gap: 12px; height: 28px; }
.pal-bar label { width: 92px; flex: 0 0 auto; color: var(--fg-dim); font-size: 12px; }
.pal-bar input[type="range"] {
  flex: 1; appearance: none; -webkit-appearance: none;
  height: 4px; border-radius: 3px; background: var(--border); outline: 0; cursor: ew-resize;
}
/* ── Where the arrow keys are ────────────────────────────────────────────────
   The settings panel is fully arrow-navigable, so every stop needs to say so.
   The sliders said nothing at all: `outline: 0` above kills the UA ring (it has
   to — the default ring around a 4px track is ugly), and nothing replaced it, so
   nine identical sliders gave no clue which one ↑/↓ would move.

   The row highlights rather than the track, matching the command rows above —
   which are the stops the eye already reads correctly. A ring around a 4px-tall
   line is a hairline; a lit row is unmissable, and it lights the label too, which
   is the part naming what you are about to change. */
.pal-bar:focus-within {
  background: var(--accent-soft);
  border-radius: 6px;
  box-shadow: 0 0 0 6px var(--accent-soft);   /* pads the row without moving it */
}
.pal-bar:focus-within label,
.pal-bar:focus-within output { color: var(--fg); }
.pal-bar input[type="range"]:focus-visible { background: color-mix(in srgb, var(--accent) 35%, var(--border)); }
/* The thumb grows on focus: the row says which slider, the thumb says where in it. */
.pal-bar input[type="range"]:focus-visible::-webkit-slider-thumb { width: 14px; height: 20px; }
.pal-bar input[type="range"]:focus-visible::-moz-range-thumb { width: 14px; height: 20px; }
.pal-bar input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 10px; height: 16px; border: 0; border-radius: 2px;
  background: var(--accent); cursor: ew-resize;
}
.pal-bar input[type="range"]::-moz-range-thumb {
  width: 10px; height: 16px; border: 0; border-radius: 2px;
  background: var(--accent); cursor: ew-resize;
}
.pal-bar output {
  width: 54px; flex: 0 0 auto; text-align: right;
  color: var(--fg-dim); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.pal-bars-hint { padding: 2px 16px 10px; color: var(--fg-faint); font-size: 11px; }

@media (max-width: 620px) {
  #palette.float { width: calc(100vw - 24px); max-height: calc(100vh - 90px); }
  .pal-bar label { width: 70px; }
}

#palette-search-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 13px;
  border-bottom: 1px solid var(--border-soft);
}
#palette-search-row .slash { color: var(--accent); font-size: 13px; }
#palette-search {
  flex: 1;
  display: block;
  background: transparent;
  border: none;
  padding: 7px 0;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  caret-color: var(--cursor-color);
}
#palette-search::placeholder { color: var(--fg-faint); }

#palette-title {
  padding: 8px 13px 2px;
  font-size: 9.5px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
#palette-title:empty { display: none; }

#palette-list {
  list-style: none;
  padding: 3px 6px 6px;
  max-height: 320px;
  overflow-y: auto;
}

#palette-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--fg-dim);
}
#palette-list li .cmd-ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: color-mix(in srgb, var(--fg) 4%, transparent);
  color: var(--fg-dim);
  font-size: 11px;
  flex-shrink: 0;
}
#palette-list li .cmd-ico svg { width: 14px; height: 14px; }
#palette-list li .cmd-name { color: var(--fg); }
#palette-list li .cmd-desc { font-size: 10.5px; color: var(--fg-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#palette-list li .right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#palette-list li kbd {
  font-family: inherit;
  font-size: 10px;
  color: var(--fg-faint);
  border: 1px solid var(--border-soft);
  border-radius: 3px;
  padding: 1px 6px;
}
#palette-list li .tag-current {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  padding: 1px 6px;
}
#palette-list li.active {
  background: var(--accent-soft);
}
#palette-list li.active .cmd-ico { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
#palette-list li.active .cmd-name { color: color-mix(in srgb, var(--fg) 92%, white); }
#palette-list li:hover:not(.active) { background: color-mix(in srgb, var(--fg) 4%, transparent); }

/* /help section divider — read-only label, not a selectable row */
#palette-list li.cmd-section {
  display: block;
  padding: 11px 8px 3px;
  font-size: 9px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--fg-faint);
  cursor: default;
  pointer-events: none;
}

#palette-foot {
  display: flex;
  gap: 14px;
  padding: 7px 13px;
  border-top: 1px solid var(--border-soft);
  font-size: 10px;
  color: var(--fg-faint);
}
#palette-foot b { color: var(--fg-dim); font-weight: 500; }
