/* Deleting: the trash buttons, the undo toast and the confirm dialog. */

/* Delete a saved point or a whole conversation: a quiet trash button that
   shows on hover (always visible on touch screens), plus a short undo toast. */
.delete-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.15s ease,
    color 0.15s ease,
    background-color 0.15s ease;
}

.delete-button svg {
  width: 16px;
  height: 16px;
}

.issue-card:hover .delete-button,
.conversation > summary:hover .delete-button,
.delete-button:focus-visible {
  opacity: 1;
}

.delete-button:hover {
  background: #edb6ad55;
  color: #9f1239;
}

.delete-button:focus-visible {
  outline: 3px solid var(--butter);
  outline-offset: 2px;
}

@media (hover: none) {
  .delete-button {
    opacity: 0.7;
  }
}

/* The button floats in the empty middle of the row, just before the text at
   the row's end, so that text stays flush with the card edge. */
.issue-practice,
.conversation-meta {
  position: relative;
}

.issue-practice > .delete-button,
.conversation-meta > .delete-button {
  position: absolute;
  top: 50%;
  inset-inline-end: calc(100% + 6px);
  translate: 0 -50%;
}

/* Narrow screens have no empty middle; there the button sits after the text. */
@media (max-width: 620px) {
  .issue-practice > .delete-button,
  .conversation-meta > .delete-button {
    position: static;
    translate: none;
    vertical-align: middle;
  }
}

.undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px 10px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  translate: -50% 0;
  animation: undo-toast-in 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

html[dir="rtl"] .undo-toast {
  padding: 10px 16px 10px 12px;
}

.undo-toast[hidden] {
  display: none;
}

/* A thin line along the top that runs out with the time left to undo. */
.undo-toast {
  overflow: hidden;
}

.undo-toast::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: var(--brand);
  animation: undo-toast-time var(--undo-ms, 8s) linear forwards;
}

html[dir="rtl"] .undo-toast::before {
  transform-origin: right;
}

html[dir="ltr"] .undo-toast::before {
  transform-origin: left;
}

@keyframes undo-toast-time {
  to {
    transform: scaleX(0);
  }
}

.undo-toast button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--brand-strong);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.undo-toast button:hover {
  border-color: var(--brand);
}

@keyframes undo-toast-in {
  from {
    opacity: 0;
    translate: -50% 12px;
  }
}

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

/* "Are you sure?" before deleting a point or a conversation. */
.confirm-dialog {
  width: min(360px, calc(100vw - 40px));
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 18px 14px 17px 13px;
  background: var(--surface);
  color: var(--text);
}

.confirm-dialog::backdrop {
  background: #302c2859;
}

.confirm-dialog[open] {
  animation: confirm-dialog-in 0.25s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.confirm-dialog p {
  margin: 0;
  padding: 22px 22px 6px;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.5;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 20px;
}

.confirm-dialog button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.confirm-dialog button:hover {
  border-color: var(--brand);
}

.confirm-dialog button.danger {
  border-color: #b84d43;
  background: #b84d43;
  color: #fffefa;
}

.confirm-dialog button.danger:hover {
  background: #9f3f36;
}

.confirm-dialog button:focus-visible {
  outline: 3px solid var(--butter);
  outline-offset: 2px;
}

@keyframes confirm-dialog-in {
  from {
    opacity: 0;
    scale: 0.92;
  }
}

@media (prefers-reduced-motion: reduce) {
  .confirm-dialog[open] {
    animation: none;
  }
}
