@layer components {
  .toast-container {
    position: fixed;
    bottom: calc(104px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    z-index: 10000;
    max-width: 92vw;
    pointer-events: none;
  }

  .toast {
    /* Per-variant accent — overridden below for goal/red-card/follow.
     * Used both as the static border colour and as the pulse colour
     * during the entrance emphasis animation. */
    --toast-accent: var(--color-border);

    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--color-surface);
    border: 1px solid var(--toast-accent);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-toast);
    min-width: 220px;
    max-width: 90vw;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transition:
      opacity var(--duration-base) var(--easing-default),
      transform var(--duration-base) cubic-bezier(0.2, 0.85, 0.4, 1.05);
    pointer-events: none;
  }

  .toast--clickable {
    cursor: pointer;
    pointer-events: auto;
  }

  .toast--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  .toast--hiding {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }

  /* Border + halo emphasis on entrance for the high-signal variants
   * (goal, red-card). The slide/scale/fade above announces "something
   * appeared"; this pulse adds a quick directional cue with the variant
   * colour so the user's eye lands on the toast at the end of the
   * entrance instead of having to scan for it. Capped at 1.2s so it
   * never overlaps with the toast's own dismissal timer. */
  @keyframes toast-emphasis {
    0% {
      box-shadow: var(--shadow-toast);
    }

    35% {
      box-shadow:
        0 0 0 2px color-mix(in oklab, var(--toast-accent) 35%, transparent),
        0 0 18px 2px color-mix(in oklab, var(--toast-accent) 28%, transparent),
        var(--shadow-toast);
    }

    100% {
      box-shadow: var(--shadow-toast);
    }
  }

  .toast--goal.toast--visible,
  .toast--red-card.toast--visible {
    animation: toast-emphasis 1.2s ease-out 120ms 1 both;
  }

  .toast__logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 6px;
  }

  .toast__body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
  }

  .toast__title {
    font-family: var(--font-title);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text);
  }

  .toast__subtitle {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .toast__score {
    font-family: var(--font-title);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-left: auto;
    padding-left: 8px;
    flex-shrink: 0;
  }

  /* ── Variants ── */

  .toast--goal {
    --toast-accent: color-mix(in oklab, var(--color-accent) 50%, transparent);
  }

  .toast--goal .toast__title {
    color: var(--color-accent);
  }

  .toast--red-card {
    --toast-accent: color-mix(in oklab, var(--color-card-red) 55%, transparent);
  }

  .toast--red-card .toast__title {
    color: var(--color-live);
  }

  .toast--follow {
    --toast-accent: color-mix(in oklab, var(--color-accent) 25%, transparent);
  }

  .toast--follow .toast__title {
    color: var(--color-accent);
  }

  .toast--unfollow .toast__title {
    color: var(--color-text-muted);
  }

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

    .toast--goal.toast--visible,
    .toast--red-card.toast--visible {
      animation: none;
    }
  }
}
