﻿/*
 * ============================================================================
 * Copyright (c) 2025 ATH SOLUTIONS (PTY) LTD. All rights reserved.
 * KwaZulu-Natal, Republic of South Africa.
 * ============================================================================
 *
 * @BEGIN Developer Log Header Block
 * @FILENAME: toast.css
 * @TITLE: Wexford Lodge - Member Portal
 * @DESCRIPTION: Toast notification component. Top-right stacking toasts with 4 semantic variants, auto-dismiss progress bar, slide-in/slide-out animation, and hover-pause. All values from tokens.css.
 * @AUTHOR: Ary van der Pijl
 * @COMPANY: ATH SOLUTIONS (PTY) LTD
 * @WEBSITE: https://www.ath.solutions/
 * @EMAIL: info@ath.solutions
 * @COPYRIGHT: All Rights Reserved
 * @LICENSE: ATH SOLUTIONS - PROPRIETARY SOFTWARE LICENCE AGREEMENT (https://www.ath.solutions/documents/ath_solutions_software_licence_agreement.pdf)
 *
 * BEGIN CHANGELOG
 * @IMPORTANT NOTICE: Developers working on these files MUST update and maintain the Developers Change Log, failure to do is not an option:
 * !==================================================================================================================================================================
 * VERSION 1.0.0.3
 * - File Modified | Ary van der Pijl | 2026/07/11 | JS-004 | Added a prefers-reduced-motion override (matching the pattern already used in tokens.css/animations.css) so toast-in/toast-out/toast-progress collapse to near-zero duration instead of never firing animationend; paired with a setTimeout fallback in toast.js so dismissal can no longer leak DOM nodes for reduced-motion users. |
 * VERSION 1.0.0.2
 * - File Modified | Ary van der Pijl | 2026/06/19 | STANDARDS-COMPLIANCE | Applied ATH Solutions 2026 coding standards. |
 * VERSION 1.0.0.1
 * + File Created, Ary van der Pijl, 2026/06/13
 * ==================================================================================================================================================================!
 * END CHANGELOG
 */

/* ─────────────────────────────────────────────────────────────────────────
   TOAST CONTAINER
───────────────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  top: calc(var(--topbar-height) + var(--space-4));
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 380px;
  width: calc(100vw - var(--space-8));
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────
   TOAST
───────────────────────────────────────────────────────────────────────── */

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  pointer-events: auto;
  position: relative;

  animation: toast-in var(--transition-base) var(--ease-spring) both;
}

.toast--out {
  animation: toast-out var(--transition-base) var(--ease-in) both;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(calc(100% + var(--space-6)));
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
    max-height: 200px;
    margin-bottom: 0;
  }

  to {
    opacity: 0;
    transform: translateX(calc(100% + var(--space-6)));
    max-height: 0;
    margin-bottom: calc(-1 * var(--space-3));
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   TOAST INNER
───────────────────────────────────────────────────────────────────────── */

.toast__inner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}

.toast__icon {
  font-size: 1.125rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  margin-bottom: var(--space-0-5);
}

.toast__message {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--line-height-snug);
}

.toast__close {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.toast__close:hover {
  background: var(--color-surface-3);
  color: var(--color-text-primary);
}

/* ─────────────────────────────────────────────────────────────────────────
   PROGRESS BAR
───────────────────────────────────────────────────────────────────────── */

.toast__progress {
  height: 3px;
  background: var(--color-border);
  position: relative;
  overflow: hidden;
}

.toast__progress-bar {
  height: 100%;
  background: var(--color-accent);
  transform-origin: left;
  animation: toast-progress linear both;
}

.toast:hover .toast__progress-bar {
  animation-play-state: paused;
}

@keyframes toast-progress {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   VARIANTS
───────────────────────────────────────────────────────────────────────── */

.toast--success .toast__icon {
  color: var(--color-success);
}

.toast--success .toast__progress-bar {
  background: var(--color-success);
}

.toast--warning .toast__icon {
  color: var(--color-warning);
}

.toast--warning .toast__progress-bar {
  background: var(--color-warning);
}

.toast--danger .toast__icon {
  color: var(--color-danger);
}

.toast--danger .toast__progress-bar {
  background: var(--color-danger);
}

.toast--info .toast__icon {
  color: var(--color-info);
}

.toast--info .toast__progress-bar {
  background: var(--color-info);
}

@media (max-width: 576px) {
  .toast-container {
    top: auto;
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
    width: auto;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   REDUCED MOTION
───────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {

  .toast,
  .toast--out,
  .toast__progress-bar {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}