/* The palette that plays: the command palette of a podcast editor, on a black page. Every command is drawn over
   its own waveform; the one picked plays in amber. The colours of the sound are read by the script from here. */
:root {
  --page: #000000;          /* the page */
  --panel: #131316;         /* the palette and its button */
  --edge: #2a2a31;          /* their edge */
  --edge-hi: #3d3d46;       /* the edge under the pointer */
  --ink: #f4f4f6;           /* what is typed, the command picked */
  --label: #c9c9d1;         /* the other commands */
  --muted: #8f8f99;         /* group names, hints */
  --key: #1d1d22;           /* a key */
  --key-edge: #383840;      /* its edge */
  --key-ink: #b8b8c1;       /* its letter */
  --found: #ffcf85;         /* the letters found */
  --wave: rgba(255, 255, 255, 0.2);       /* the sound of a command */
  --wave-picked: rgba(255, 176, 64, 0.9); /* the sound of the command picked */
  --wave-done: rgba(255, 244, 224, 0.55); /* the sound once the command has run */
  --band: rgba(255, 255, 255, 0.045);     /* the row picked */
  --playhead: #fff4e0;      /* the playhead that runs a command */
  --tick: #ffb547;          /* the tick of a command done */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Radio Canada Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* the button above, the palette under it: the room is kept for the longest list, so nothing below moves */
.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 24px 16px;
}

.desk {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: start;
  gap: 12px;
  width: min(560px, 100%);
}

/* ---------------------------------------------------------------- the keys drawn on the button and the rows */
.keys {
  display: inline-flex;
  flex: none;
  gap: 4px;
}

.key {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--key-edge);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--key);
  color: var(--key-ink);
  font: 560 12px / 1 'Radio Canada Variable', system-ui, sans-serif;
  font-stretch: 90%;
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1), border-color 0.2s ease;
}

.key svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key--icon {
  padding: 0 4px;
}

.key--word {
  padding: 0 7px;
  font-stretch: 85%;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- the button */
.open {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(320px, 100%);
  height: 56px;
  padding: 0 16px 0 18px;
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--panel);
  color: var(--muted);
  font: 450 16px / 1 'Radio Canada Variable', system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1), border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.open__lens,
.pal__lens {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.open__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (hover: hover) and (pointer: fine) {
  .open:hover {
    border-color: var(--edge-hi);
    color: var(--label);
  }

  .open:hover .key {
    transform: translateY(-1px);
    border-color: #45454e;
  }
}

.open:active {
  transform: scale(0.97);
}

.open:active .key {
  transform: translateY(1px);
}

.open[aria-expanded='true'] {
  border-color: var(--edge-hi);
  background: #19191d;
  color: var(--label);
}

.open:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* the focus comes back to the button when the palette closes: its ring shows only to who uses the keys */
html[data-using='pointer'] .open:focus-visible {
  outline: none;
}

.open:disabled {
  border-color: #1f1f24;
  color: #55555d;
  cursor: not-allowed;
}

.open:disabled .key {
  color: #55555d;
  border-color: #2a2a30;
}

/* ---------------------------------------------------------------- the palette */
.pal {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transform-origin: 50% 0;
}

.pal[hidden] {
  display: none;
}

.pal__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--edge);
  color: var(--muted);
}

.pal__input {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--tick);
  font: 430 17px / normal 'Radio Canada Variable', system-ui, sans-serif;
  -webkit-appearance: none;
  appearance: none;
}

.pal__input::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* the caret of the library's preview, which types without taking the focus */
.pal__caret {
  position: absolute;
  left: 0;
  top: 50%;
  width: 2px;
  height: 22px;
  margin-top: -11px;
  border-radius: 1px;
  background: var(--tick);
  opacity: 0;
  pointer-events: none;
}

.pal__caret.is-on {
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }

  50.01%,
  100% {
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- the list: rows placed by the script */
.pal__list {
  position: relative;
  height: 0;
  overflow: hidden;
}

/* the sound of every row, drawn under the words */
.pal__wave {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.grp {
  margin: 0;
}

.grp[hidden] {
  display: none;
}

.grp__name,
.cmd {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  opacity: 0;
}

.grp__name {
  display: flex;
  align-items: flex-end;
  height: 28px;
  margin: 0;
  padding: 0 12px 6px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: 0.01em;
}

.cmd {
  height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.cmd[hidden],
.grp__name[hidden] {
  display: none;
}

/* the row's content: the row is moved by the script, its content is pressed by the CSS */
.cmd__in {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  padding: 0 12px;
  border-radius: 10px;
  transition: transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

.cmd:active .cmd__in {
  transform: scale(0.985);
}

.cmd__icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease;
}

.cmd__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--label);
  font-size: 15px;
  font-weight: 440;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}

.cmd__label mark {
  background: none;
  color: var(--found);
  font-weight: 640;
}

.cmd[aria-selected='true'] .cmd__label {
  color: var(--ink);
}

.cmd[aria-selected='true'] .cmd__icon {
  stroke: var(--ink);
}

/* the shortcut, and the tick that takes its place when the command has run */
.cmd__end {
  position: relative;
  display: grid;
  flex: none;
  justify-items: end;
}

.cmd__end > * {
  grid-area: 1 / 1;
}

.cmd__tick {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--tick);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

/* a command not available yet */
.cmd[aria-disabled='true'] .cmd__label {
  color: #7b7b85;
}

.cmd[aria-disabled='true'][aria-selected='true'] .cmd__label {
  color: #a3a3ad;
}

.cmd[aria-disabled='true'] .cmd__icon {
  stroke: #5f5f69;
}

.cmd__note {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

/* where the canvas cannot show which row is picked */
@media (forced-colors: active) {
  .cmd[aria-selected='true'] .cmd__in {
    outline: 2px solid Highlight;
  }
}

/* nothing matches */
.pal__none {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: 18px 20px 0;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.none__what {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 520;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.none__tip {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------------------------------------------------------------- the foot: the keys to use, or what was done */
.pal__foot {
  position: relative;
  height: 44px;
  border-top: 1px solid var(--edge);
  color: var(--muted);
  font-size: 12.5px;
}

.pal__hints,
.pal__done {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 16px;
}

.pal__hints {
  gap: 16px;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.hint .key {
  min-width: 20px;
  height: 20px;
  border-radius: 5px;
}

.hint .key + .key {
  margin-left: -2px;
}

.hint--touch {
  display: none;
}

/* on a phone there are no keys to tell about: the rows give their room to the sound */
@media (pointer: coarse) {
  .hint--keys,
  .cmd .keys,
  .open .keys {
    display: none;
  }

  .hint--touch {
    display: inline-flex;
  }
}

.pal__done {
  gap: 8px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 480;
  opacity: 0;
  pointer-events: none;
}

.pal__done span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pal__tick,
.pal__info {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pal__tick {
  stroke: var(--tick);
}

.pal__info {
  stroke: var(--muted);
  stroke-width: 1.8;
}

@media (max-width: 480px) {
  .pal__head {
    padding: 0 12px 0 16px;
  }

  .key--word {
    display: none;
  }

  .hint .key--word {
    display: inline-grid;
  }
}
