/**
 * Toasts.
 *
 * Top right, stacked, self-dismissing. They sit on the bone/gold
 * palette rather than the usual green-and-red, so a confirmation still
 * looks like it belongs to this site.
 */

.toasts {
  position: fixed;
  top: clamp(0.9rem, 2vw, 1.6rem);
  right: clamp(0.9rem, 2vw, 1.6rem);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  pointer-events: none;
  max-width: min(24rem, calc(100vw - 2rem));
}

.toast {
  --toast-accent: var(--gold, #c9a227);

  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  width: max-content;
  max-width: 100%;
  padding: 0.85rem 0.95rem;
  overflow: hidden;
  pointer-events: auto;

  color: var(--bone, #ede7db);
  background: linear-gradient(155deg, #16151a 0%, #0d0c10 100%);
  border-radius: 6px;

  /* Three layers: a hairline, a lifted shadow and an inner highlight.
     That combination is what reads as a solid object rather than a
     translucent panel. */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px rgba(237, 231, 219, 0.1),
    0 18px 38px -18px rgba(0, 0, 0, 0.9),
    0 4px 10px -6px rgba(0, 0, 0, 0.7);

  /* Enters rotated slightly out of the screen plane and settles flat. */
  transform: translate3d(28px, -6px, 0) rotateY(-14deg) scale(0.94);
  opacity: 0;
  transition:
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.35s ease,
    height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    margin 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
}

.toast.is-in {
  transform: translate3d(0, 0, 0) rotateY(0) scale(1);
  opacity: 1;
}

.toast.is-going {
  transform: translate3d(28px, -4px, 0) rotateY(10deg) scale(0.96);
  opacity: 0;
  padding-block: 0;
}

.toast--ok   { --toast-accent: #7fb069; }
.toast--bad  { --toast-accent: #d9534f; }
.toast--info { --toast-accent: var(--gold, #c9a227); }
.toast--work { --toast-accent: #8fa6c4; }

/* The accent edge. */
.toast::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--toast-accent);
  box-shadow: 0 0 14px -1px var(--toast-accent);
}

.toast__icon {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-left: 0.2rem;
  border-radius: 50%;
  color: var(--toast-accent);
  background: color-mix(in srgb, var(--toast-accent) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--toast-accent) 34%, transparent);
}

.toast__icon svg { width: 0.95rem; height: 0.95rem; display: block; }

.toast__spin { animation: toast-spin 0.9s linear infinite; transform-origin: 50% 50%; }
@keyframes toast-spin { to { transform: rotate(360deg); } }

.toast__msg {
  margin: 0;
  font-family: var(--font-ui, "Poppins", system-ui, sans-serif);
  font-size: 0.82rem;
  line-height: 1.35;
  letter-spacing: 0.005em;
}

.toast__x {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-500, #9c9385);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 0.15rem;
  transition: color 0.25s ease;
}

.toast__x:hover { color: var(--bone, #ede7db); }

/* A quiet countdown, so a toast about to leave is not a surprise. */
.toast__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1px;
  width: 100%;
  transform-origin: left center;
  background: var(--toast-accent);
  opacity: 0.45;
  animation: toast-bar linear forwards;
}

@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.2s ease; transform: none; }
  .toast.is-in, .toast.is-going { transform: none; }
  .toast__bar, .toast__spin { animation: none; }
}
