/* Wave 4: swipe actions on phone rows, the keyboard highlight, the command
   palette and the shortcuts sheet. Loads after hub.css and the wave 2 and 3
   files, so an equal selector here wins. */

/* ---- Swipe rows --------------------------------------------------------
   The wrapper holds the row and the panels behind it. The row keeps its
   own class and grid; only its position moves. Panels exist in the markup
   everywhere and show only where the pointer cannot hover. */

.swipe {
  position: relative;
  --swipe-ground: var(--surface-solid);
}

.card-plain .swipe {
  --swipe-ground: var(--surface-soft);
}

/* The row used to be the list's child, so the hairline rules that keyed on
   first and last child move to the wrapper. */
.swipe > .needs-row {
  border-top: 1px solid var(--line-soft);
}

.swipe:first-child > .needs-row {
  border-top: none;
}

.swipe > .person-row {
  border-bottom: 1px solid var(--line);
}

.swipe:last-child > .person-row {
  border-bottom: none;
}

.swipe-actions {
  display: none;
}

@media (hover: none) {
  .swipe.swipe-enabled {
    overflow: hidden;
  }

  .swipe.swipe-enabled > [data-swipe-target="content"] {
    position: relative;
    z-index: 1;
    background: var(--swipe-ground);
    touch-action: pan-y;
    will-change: transform;
  }

  .swipe.swipe-enabled .swipe-actions {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: stretch;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
  }

  .swipe.swipe-enabled.is-revealing-start .swipe-actions-start,
  .swipe.swipe-enabled.is-revealing-end .swipe-actions-end {
    opacity: 1;
  }

  .swipe-actions-start {
    left: 0;
  }

  .swipe-actions-end {
    right: 0;
  }

  .swipe-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    min-width: 72px;
    padding: 0 6px;
    border: 0;
    margin: 0;
    font-family: "Quicksand", ui-rounded, sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    color: #fff;
    background: var(--ink);
    cursor: pointer;
  }

  .swipe-action-snooze {
    background: var(--warn);
    color: #fff;
  }

  .swipe-action-done {
    background: var(--forest);
    color: var(--lime);
  }

  .swipe-action-message,
  .swipe-action-whatsapp {
    background: #25D366;
    color: #06341a;
  }

  .swipe-action-copy {
    background: var(--forest);
    color: #fff;
  }

  .swipe-action.is-success {
    background: var(--ok);
    color: #fff;
  }

  /* The label flashes once when the panel catches, and the main action
     grows when a full swipe is armed. */
  .swipe-actions.is-caught .swipe-action {
    animation: swipe-catch 320ms var(--ease-pop);
  }

  .swipe.is-full .swipe-actions-end .swipe-action-done,
  .swipe.is-full .swipe-actions-end .swipe-action-copy,
  .swipe.is-full .swipe-actions-start .swipe-action {
    flex: 1;
  }

  .swipe-actions .swipe-action {
    transition: flex var(--dur-base) var(--ease-out);
  }

  /* The panel grows with the finger past its resting width (the controller
     sets it), so the last action fills what the row has uncovered. */
  .swipe.swipe-enabled .swipe-actions {
    min-width: 0;
  }

  @keyframes swipe-catch {
    0% { transform: scale(1); }
    40% { transform: scale(1.08); }
    100% { transform: scale(1); }
  }
}

@media (prefers-reduced-motion: reduce) {
  .swipe-actions.is-caught .swipe-action {
    animation: none;
  }

  .swipe-actions .swipe-action {
    transition: none;
  }
}

/* ---- Keyboard highlight ------------------------------------------------ */

.needs-row.is-keyed {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-sm);
}

.needs-row.is-keyed:focus {
  outline: none;
}

.page-help-shortcuts {
  display: block;
  margin-top: 10px;
  font-size: var(--fs-sm);
}

@media (hover: none) {
  .page-help-shortcuts {
    display: none;
  }
}

/* ---- The command palette ---------------------------------------------- */

.palette-dialog {
  width: min(560px, calc(100vw - 32px));
  margin-top: max(12vh, 64px);
  background: var(--surface-raised);
}

.palette-body {
  padding: 8px 8px 10px;
}

.palette-input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  font-family: "Quicksand", ui-rounded, sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.palette-input::placeholder {
  color: var(--ink-mute);
}

.palette-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.palette-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: min(50vh, 420px);
  overflow-y: auto;
}

/* Results focus into place: a fade, a short rise and a blur that clears,
   each one a beat after the last. */
.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-xs);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  animation: palette-in var(--dur-enter) var(--ease-out) both;
}

@keyframes palette-in {
  from { opacity: 0; transform: translateY(6px); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}

.palette-item[aria-selected="true"] {
  background: var(--surface-soft);
}

.palette-item:active {
  transform: scale(.98);
}

.palette-item-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-item-hint {
  flex: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-faint);
}

.palette-item-row .palette-item-label::before {
  content: "›";
  margin-right: 8px;
  color: var(--ink-mute);
}

.palette-empty {
  margin: 10px 12px 4px;
}

.palette-hint {
  margin: 8px 12px 0;
  font-size: var(--fs-label);
  color: var(--ink-mute);
}

.palette-hint kbd,
.shortcuts-list kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  box-shadow: var(--ring);
  font-family: "Quicksand", ui-rounded, sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}

@media (hover: none) {
  .palette-hint {
    display: none;
  }
}

@media (max-width: 840px) {
  /* The phone keyboard is wanted here: it is a search. The box sits high
     so the list has room above the keys. */
  .palette-dialog {
    margin-top: calc(12px + var(--safe-t));
  }
}

@media (prefers-reduced-motion: reduce) {
  .palette-item {
    animation: none;
  }
}

/* ---- The shortcuts sheet ---------------------------------------------- */

.shortcuts-holder {
  display: contents;
}

.shortcuts-list {
  margin: 6px 0 0;
  padding: 0;
}

.shortcuts-list > div {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
  font-size: var(--fs-body);
}

.shortcuts-list > div:first-child {
  border-top: 0;
}

.shortcuts-list dt {
  display: flex;
  gap: 4px;
}

.shortcuts-list dd {
  margin: 0;
  color: var(--ink-soft);
}
