/* css/components/achievement-toast.css — TinkyTown SDR Achievement Toast
 *
 * Companion to /js/components/achievement-toast.js. Renders a celebratory,
 * non-blocking notification when /api/missions/* or /api/outreach/* returns
 * `achievements_unlocked`.
 *
 * UX bar:
 *   - Top-right on desktop, bottom-center on mobile (thumb-reach).
 *   - Amber border + 🏆 icon + crisp label → color-blind safe (icon + label,
 *     not colour-only signal).
 *   - prefers-reduced-motion strips every animation + transform.
 *   - 44px min tap target on close button (WCAG 2.5.5).
 *   - Fraunces (heading) + General Sans (body) — same family as mission-card.
 *
 * Brand tokens: --surface-deep #0d0b10 · --amber #e8a33d · --green #22c55e
 * · --green-soft #4ade80. Raw hex only as token-fallback (matches the pattern
 * used in mission-card.css). z-index 9500 sits above modal-backdrop (4500)
 * and BottomSheet (3000) so unlocks remain visible during modal flows.
 */

/* ── Host stack ──────────────────────────────────────────────────────── */
.achievement-toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  pointer-events: none; /* clicks pass through gaps; individual toasts re-enable */
}

/* ── Toast card ──────────────────────────────────────────────────────── */
.achievement-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 44px 1fr 32px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 92%, transparent);
  border: 1px solid var(--amber, #e8a33d);
  border-left: 4px solid var(--amber, #e8a33d);
  border-radius: 12px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px color-mix(in srgb, var(--green-soft, #4ade80) 18%, transparent);
  color: var(--text-primary, #f4f1ea);
  font-family: 'General Sans', system-ui, sans-serif;
  cursor: pointer;
  /* Celebratory entrance — slight overshoot, then settle. */
  animation: achievement-toast-in 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: top right;
}

.achievement-toast:focus-visible {
  outline: 2px solid var(--green-soft, #4ade80);
  outline-offset: 2px;
}

.achievement-toast-leaving {
  animation: achievement-toast-out 200ms ease-out forwards;
}

/* ── Icon (🏆 default) ───────────────────────────────────────────────── */
.achievement-toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  background: color-mix(in srgb, var(--amber, #e8a33d) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #e8a33d) 45%, transparent);
}

/* ── Text body ───────────────────────────────────────────────────────── */
.achievement-toast-body {
  min-width: 0; /* allow flex children to ellipsize */
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.achievement-toast-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--amber, #e8a33d);
}

.achievement-toast-label {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.02rem;
  line-height: 1.25;
  color: var(--text-primary, #f4f1ea);
  /* Single-line ellipsis if the catalog label runs long. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.achievement-toast-desc {
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--text-muted, rgba(255, 255, 255, 0.72));
  /* Allow 2 lines max on description. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.achievement-toast-xp {
  display: inline-block;
  align-self: flex-start;
  margin-top: 4px;
  padding: 0.14rem 0.6rem;
  background: color-mix(in srgb, var(--green-soft, #4ade80) 18%, transparent);
  color: var(--green-soft, #4ade80);
  border: 1px solid color-mix(in srgb, var(--green, #22c55e) 50%, transparent);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

/* ── Close button (44×44 tap target) ─────────────────────────────────── */
.achievement-toast-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
  border: 0;
  border-radius: 8px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.achievement-toast-close:hover {
  background: color-mix(in srgb, var(--amber, #e8a33d) 14%, transparent);
  color: var(--text-primary, #fff);
}

.achievement-toast-close:focus-visible {
  outline: 2px solid var(--amber, #e8a33d);
  outline-offset: 2px;
}

/* ── Animations (only when motion is allowed) ─────────────────────────── */
@keyframes achievement-toast-in {
  0%   { opacity: 0; transform: translateY(-8px) scale(0.92); }
  60%  { opacity: 1; transform: translateY(2px)  scale(1.02); }
  100% { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes achievement-toast-out {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(8px); }
}

/* ── prefers-reduced-motion: instant show + dwell + instant hide ─────── */
@media (prefers-reduced-motion: reduce) {
  .achievement-toast,
  .achievement-toast-leaving {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
  .achievement-toast-close { transition: none !important; }
}

/* ── Mobile: bottom-center, full-width minus gutter ──────────────────── */
@media (max-width: 768px) {
  .achievement-toast-host {
    top: auto;
    right: 8px;
    left: 8px;
    bottom: 16px;
    max-width: none;
    /* Respect iOS home-indicator + bottom toolbar safe areas. */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .achievement-toast {
    transform-origin: bottom center;
  }
  @keyframes achievement-toast-in {
    0%   { opacity: 0; transform: translateY(12px) scale(0.96); }
    60%  { opacity: 1; transform: translateY(-2px) scale(1.01); }
    100% { opacity: 1; transform: translateY(0)    scale(1);    }
  }
}
