/* Action feedback (feedback.js): one floating card for the outcome of an owner action.
 * Graded: success (lit, short icon motion) > quiet (plain) ; unclear (amber "?") and error (rosé)
 * stay until closed. It floats over the content layer like the dock -- never in the reading flow,
 * never blocking it: the region ignores the pointer, only the card takes clicks. */

.feedback-region {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--s-6) + var(--safe-bottom));
  /* Above the compose window (65) and a contact ping (60); below the media lightbox (1000). */
  z-index: 70;
  display: flex;
  justify-content: center;
  padding: 0 var(--s-4);
  pointer-events: none;
}

.feedback {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: min(28rem, 100%);
  padding: var(--s-3) var(--s-2) var(--s-3) var(--s-3);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(120, 170, 255, 0.08), rgba(120, 170, 255, 0.02)), var(--night-2);
  box-shadow: inset 0 1px 0 var(--highlight-top), inset 0 0 0 1px var(--hairline-strong), var(--shadow-2);
  color: var(--ink-1);
  pointer-events: auto;
  animation: feedback-in var(--dur-3) var(--spring-snappy) both;
}

.feedback[data-leaving='true'] {
  animation: feedback-out var(--dur-2) var(--ease-out) both;
}

.feedback--success {
  box-shadow: inset 0 1px 0 rgba(var(--ok-rgb), 0.3), inset 0 0 0 1px rgba(var(--ok-rgb), 0.24), var(--shadow-2), 0 0 32px rgba(var(--ok-rgb), 0.12);
}

.feedback--unclear {
  box-shadow: inset 0 1px 0 rgba(var(--warn-rgb), 0.3), inset 0 0 0 1px rgba(var(--warn-rgb), 0.3), var(--shadow-2);
}

.feedback--error {
  box-shadow: inset 0 1px 0 rgba(var(--error-rgb), 0.3), inset 0 0 0 1px rgba(var(--error-rgb), 0.3), var(--shadow-2);
}

.feedback__icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  overflow: hidden;
}

.feedback--success .feedback__icon {
  background: rgba(var(--ok-rgb), 0.14);
  color: var(--ok);
}

.feedback--unclear .feedback__icon {
  background: rgba(var(--warn-rgb), 0.14);
  color: var(--warn);
}

.feedback--error .feedback__icon {
  background: rgba(var(--error-rgb), 0.14);
  color: var(--error);
}

.feedback__glyph {
  grid-area: 1 / 1;
  width: 1.375rem;
  height: 1.375rem;
}

/* The action's symbol leaves in the direction of travel, then the check arrives. */
.feedback__glyph--from {
  animation: feedback-leave 520ms var(--ease-in-out) both;
}

.feedback__glyph--to {
  animation: feedback-check var(--dur-3) var(--spring-soft) 380ms both;
}

.feedback__glyph--only {
  animation-delay: 80ms;
}

.feedback--success .feedback__icon {
  width: 3rem;
  height: 3rem;
}

.feedback--success .feedback__glyph {
  width: 1.6rem;
  height: 1.6rem;
}

.feedback--success .feedback__title {
  font-size: var(--fs-lead);
}

.feedback__mark {
  font-size: var(--fs-lead);
  font-weight: 700;
  line-height: 1;
}

.feedback__text {
  flex: 1;
  min-width: 0;
}

.feedback__title {
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: var(--lh-tight);
}

.feedback__detail {
  margin: 0.2rem 0 0;
  font-size: var(--fs-small);
  line-height: 1.35;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.feedback__close {
  flex: none;
  width: var(--touch);
  height: var(--touch);
  min-height: var(--touch);
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: none;
  color: var(--ink-3);
}

.feedback__close-icon {
  width: 1.1rem;
  height: 1.1rem;
}

@keyframes feedback-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes feedback-out {
  to { opacity: 0; transform: translateY(8px); }
}

@keyframes feedback-leave {
  0% { opacity: 1; transform: none; }
  35% { opacity: 1; transform: translateX(-2px); }
  100% { opacity: 0; transform: translate(26px, -10px) rotate(-10deg) scale(0.86); }
}

@keyframes feedback-check {
  from { opacity: 0; transform: scale(0.55); }
  to { opacity: 1; transform: none; }
}

/* Phone: above the floating dock. */
@media (max-width: 768px) {
  .feedback-region {
    bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--s-2));
  }

  /* The compose window covers the dock on a phone. */
  html.compose-open .feedback-region {
    bottom: calc(var(--s-4) + var(--safe-bottom));
  }
}

/* Reduced motion: no travel, no scale -- the check is simply there; the text says it all. */
@media (prefers-reduced-motion: reduce) {
  .feedback,
  .feedback[data-leaving='true'],
  .feedback__glyph--to {
    animation: none;
  }

  .feedback__glyph--from {
    display: none;
  }
}
