/* ═══════════════════════════════════════════════════════════════
   Alert Toast — mobile-first live foul/card notifications
   Variables injected per-toast:
     --toast-color   border + accent colour
     --toast-bg      translucent background tint
     --dismiss-dur   auto-dismiss animation duration
═══════════════════════════════════════════════════════════════ */

#alert-toast-container {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw, 480px);
  padding: 10px 10px 0;
  z-index: 99999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* safe-area inset for notched phones */
  padding-top: max(10px, env(safe-area-inset-top, 10px));
}

/* ── Individual Toast ──────────────────────────────────────── */
.alert-toast {
  pointer-events: all;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 36px 14px 12px;
  border-radius: 12px;
  background: var(--bg-card, #1a1a20);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--toast-color, var(--red));
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  cursor: pointer;
  /* Entry animation */
  animation: toastSlideIn 0.32s cubic-bezier(0.34, 1.4, 0.64, 1) both;
  background-image: linear-gradient(135deg, var(--toast-bg, transparent) 0%, transparent 60%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.alert-toast:hover .toast-progress {
  animation-play-state: paused;
}

/* ── Exit ──────────────────────────────────────────────────── */
.alert-toast.toast-exit {
  animation: toastSlideOut 0.28s cubic-bezier(0.4, 0, 1, 1) both;
  pointer-events: none;
}

/* ── Icon ──────────────────────────────────────────────────── */
.toast-icon {
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Body ──────────────────────────────────────────────────── */
.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.toast-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--toast-color, var(--yellow));
}

.toast-minute {
  font-size: 0.63rem;
  color: var(--text-muted, #55555f);
  margin-left: auto;
  font-weight: 500;
}

.toast-player {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary, #f0f0f5);
  line-height: 1.2;
}

.toast-match {
  font-size: 0.68rem;
  color: var(--text-secondary, #9898a8);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-message {
  font-size: 0.72rem;
  color: var(--toast-color, var(--yellow));
  margin-top: 5px;
  font-weight: 500;
  line-height: 1.3;
}

/* Trust layer — brief explanation of why this alert triggered */
.toast-reason {
  font-size: 0.62rem;
  color: var(--text-muted, #55555f);
  margin-top: 5px;
  line-height: 1.4;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-style: italic;
}

/* ── Dismiss Button ────────────────────────────────────────── */
.toast-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted, #55555f);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 4px 5px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.toast-dismiss:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
}

/* ── Progress Bar (auto-dismiss countdown) ─────────────────── */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: var(--toast-color, var(--yellow));
  opacity: 0.45;
  transform-origin: left;
  animation: toastProgress var(--dismiss-dur, 7000ms) linear both;
}

/* ── Keyframes ─────────────────────────────────────────────── */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-110%) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    max-height: 120px;
    margin-bottom: 0;
  }
  to {
    opacity: 0;
    transform: translateY(-24px) scale(0.95);
    max-height: 0;
    margin-bottom: -8px;
    padding-top: 0;
    padding-bottom: 0;
  }
}

@keyframes toastProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Priority System ───────────────────────────────────────── */

/* Accent bar replaces the left border tint for priority-aware toasts */
.toast-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--toast-color, var(--yellow));
  border-radius: 12px 0 0 12px;
  flex-shrink: 0;
}

/* Icon wrapper (replaces old .toast-icon) */
.toast-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-icon-text {
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--toast-color, var(--yellow));
  line-height: 1;
}

/* Card icon squares (replaces emoji) */
.toast-card-icon {
  display: inline-block;
  width: 16px;
  height: 20px;
  border-radius: 2px;
  flex-shrink: 0;
}
.toast-card-yellow { background: #f4a01c; }
.toast-card-red    { background: var(--red, #e63946); }

/* Team name in player row */
.toast-team {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted, #55555f);
  margin-left: 5px;
}

/* ── Priority: Warning ─────────────────────────────────────── */
.toast-priority-warning .toast-accent {
  background: var(--yellow, #f4a01c);
}

/* ── Priority: Danger ──────────────────────────────────────── */
.toast-priority-danger {
  border-left-color: rgba(230, 57, 70, 0.5);
}
.toast-priority-danger .toast-accent {
  background: var(--red, #e63946);
}

/* ── Priority: Critical ────────────────────────────────────── */
.toast-priority-critical {
  border-left-color: var(--red, #e63946);
  box-shadow:
    0 4px 28px rgba(230, 57, 70, 0.22),
    0 0 0 1px rgba(230, 57, 70, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  animation:
    toastSlideIn 0.32s cubic-bezier(0.34, 1.4, 0.64, 1) both,
    criticalPulse 2.2s ease-in-out 0.4s infinite;
}
.toast-priority-critical .toast-accent {
  background: var(--red, #e63946);
  width: 4px;
}

@keyframes criticalPulse {
  0%, 100% { box-shadow: 0 4px 28px rgba(208,80,32,0.20), 0 0 0 1px rgba(208,80,32,0.14); }
  50%       { box-shadow: 0 4px 32px rgba(208,80,32,0.34), 0 0 0 1px rgba(208,80,32,0.26); }
}

/* Critical badge pill */
.toast-critical-badge {
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red, #e63946);
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(230, 57, 70, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* ── Reduced-motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .alert-toast,
  .alert-toast.toast-exit,
  .toast-progress,
  .toast-priority-critical {
    animation: none;
  }
  .alert-toast.toast-exit { opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   Validation Notifier — ambient amber banner, slides up from
   just above the bottom nav. Subtle, premium, non-alarming.
═══════════════════════════════════════════════════════════════ */

#vn-container {
  position: fixed;
  top: max(56px, calc(44px + env(safe-area-inset-top, 0px)));
  left: 50%;
  transform: translateX(-50%);
  width: min(100vw - 24px, 420px);
  z-index: 88888;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vn-banner {
  pointer-events: all;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 36px 12px 14px;
  border-radius: 14px;
  background: rgba(22, 22, 28, 0.97);
  border: 1px solid rgba(245, 158, 11, 0.22);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(245, 158, 11, 0.08),
    0 2px 8px rgba(245, 158, 11, 0.1);
  overflow: hidden;
  cursor: pointer;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: vnSlideUp 0.36s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.vn-banner:active { opacity: 0.85; }

.vn-banner.vn-exit {
  animation: vnSlideDown 0.32s cubic-bezier(0.4, 0, 1, 1) both;
  pointer-events: none;
}

/* Amber left accent bar */
.vn-accent {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, #f59e0b, #d97706);
  border-radius: 14px 0 0 14px;
}

/* Check-mark icon in amber circle */
.vn-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  flex-shrink: 0;
}

/* Body */
.vn-body { flex: 1; min-width: 0; }

.vn-headline {
  font-size: 0.82rem;
  font-weight: 700;
  color: #f0f0f5;
  line-height: 1.25;
  margin-bottom: 2px;
}

.vn-sub {
  font-size: 0.72rem;
  color: #f59e0b;
  font-weight: 500;
  line-height: 1.3;
}

.vn-match {
  font-size: 0.64rem;
  color: rgba(152, 152, 168, 0.75);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dismiss × */
.vn-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: rgba(152, 152, 168, 0.55);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}
.vn-dismiss:hover { color: rgba(152, 152, 168, 0.9); }

/* Auto-dismiss countdown bar */
.vn-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  opacity: 0.5;
  transform-origin: left;
  animation: vnProgress var(--vn-dismiss-dur, 4500ms) linear both;
}

/* Keyframes */
@keyframes vnSlideUp {
  from { opacity: 0; transform: translateY(-14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)      scale(1);   }
}

@keyframes vnSlideDown {
  from { opacity: 1; transform: translateY(0)      scale(1);   }
  to   { opacity: 0; transform: translateY(-10px)  scale(0.95); }
}

@keyframes vnProgress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .vn-banner, .vn-banner.vn-exit, .vn-progress-bar { animation: none; }
  .vn-banner.vn-exit { opacity: 0; }
}
