/* ──────────────────────────────────────────────────────────────────
   FYM Casino — Overlays (modaler / toasts / celebrations)
   Spec: docs/superpowers/specs/2026-05-10-track-b-modals-design.md
   Built on Track A tokens (tokens.css). Loaded BEFORE other stylesheets.
   ────────────────────────────────────────────────────────────────── */


/* ── Modal frame — Vault page ────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-md);
  animation: modal-fade-in var(--motion-small) var(--easing);
}

.modal-card {
  background: var(--surface);
  border: var(--border-default);
  border-radius: var(--r-3);
  padding: var(--sp-md);
  box-shadow: var(--shadow-elevated);
  max-width: 420px;
  width: 100%;
  position: relative;
  animation: modal-scale-in var(--motion-small) var(--easing);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: var(--r-1);
}
.modal-close:hover { color: var(--text); background: var(--raised); }

.modal-label {
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-uppercase);
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--sp-3xs);
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-h3);
  line-height: var(--lh-snug);
  color: var(--text);
  margin: 0 0 var(--sp-2xs);
}

.modal-divider {
  height: 0;
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 var(--sp-sm);
}

.modal-body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--muted);
  margin: 0 0 var(--sp-md);
}

.modal-actions {
  display: flex;
  gap: var(--sp-2xs);
}

.modal-btn {
  flex: 1;
  padding: 10px var(--sp-sm);
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-uppercase);
  text-transform: uppercase;
  font-weight: 600;
  border: none;
  border-radius: var(--r-1);
  cursor: pointer;
  transition: background var(--motion-micro) var(--easing);
}
.modal-btn--cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.modal-btn--cancel:hover { background: var(--raised); color: var(--text); }
.modal-btn--confirm {
  background: var(--accent);
  color: var(--bg);
}
.modal-btn--confirm:hover { background: var(--accent-hi); }
.modal-btn--danger {
  background: var(--loss);
  color: var(--text);
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}


/* ── Toast — Card-stack ───────────────────────────────────────
 * Anchored at the TOP of the viewport (Track I polish): bottom-
 * anchored toasts were colliding with the navigation bar, Telegram's
 * WebApp footer area, and the on-screen keyboard, so important
 * feedback like bonus-code redemption was invisible to users on
 * mobile. The top anchor leaves them well clear of all of those.
 * z-index sits ABOVE the topbar (z-50) but below modals (z-1000).
 */

.toast-stack {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--sp-md));
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2xs);
  max-width: 440px;
  width: calc(100% - var(--sp-md) * 2);
  pointer-events: none;
}

.toast {
  /* Beefier surface than the previous low-contrast card so users
     actually read what we are telling them. Higher opacity bg, a
     thicker border that picks up the toast type, larger font, and
     a generous tap-target sized padding. */
  background: color-mix(in oklch, var(--surface) 92%, black 8%);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  gap: var(--sp-2xs);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  pointer-events: auto;
  animation: toast-slide-down var(--motion-micro) var(--easing);
}

/* Type-coloured left edge so success / error / warn read at a glance. */
.toast[data-type="success"] { border-color: color-mix(in oklch, var(--win) 60%, transparent); }
.toast[data-type="error"]   { border-color: color-mix(in oklch, var(--loss) 60%, transparent); }
.toast[data-type="warn"]    { border-color: color-mix(in oklch, var(--warn) 60%, transparent); }
.toast[data-type="info"]    { border-color: color-mix(in oklch, var(--accent) 50%, transparent); }

.toast-icon {
  font-family: 'Material Symbols Outlined';
  font-size: 18px;
  line-height: 1;
  font-variation-settings: 'FILL' 1;
  flex-shrink: 0;
}
.toast[data-type="success"] .toast-icon { color: var(--win); }
.toast[data-type="error"]   .toast-icon { color: var(--loss); }
.toast[data-type="info"]    .toast-icon { color: var(--accent); }
.toast[data-type="warn"]    .toast-icon { color: var(--warn); }

.toast-body { flex: 1; }

.toast-action {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--r-1);
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-uppercase);
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--faint);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  flex-shrink: 0;
}
.toast-close:hover { color: var(--muted); }

.toast--leaving {
  animation: toast-slide-up-out var(--motion-micro) var(--easing) forwards;
}

@keyframes toast-slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-slide-down {
  /* Now used as the ENTRY animation — drops in from the top. */
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-slide-up-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}


/* ── Celebration — 3-tier Rays ──────────────────────────────── */

.celebration {
  position: fixed;
  inset: 0;
  z-index: 1100;
  isolation: isolate; /* Track C2.5.8 — contains hero-bg's negative z-index */
  background: oklch(0 0 0 / 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: cel-overlay-fade-in var(--motion-small) var(--easing);
}
.celebration[data-dismissable="true"] {
  pointer-events: auto;
  cursor: pointer;
}

.celebration-content {
  position: relative;
  z-index: 5;
  text-align: center;
}

.celebration-label {
  font-family: var(--font-body);
  font-size: var(--fs-caption);
  letter-spacing: 0.30em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--sp-2xs);
  animation: cel-label-fade-in 480ms var(--easing) both;
}

.celebration-amount {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: var(--fs-num-xl);
  line-height: var(--lh-tight);
  color: var(--accent-hi);
  font-variant-numeric: tabular-nums;
  margin: 0;
  animation: cel-amount-scale-in 480ms var(--easing) both;
}

.celebration-meta {
  font-family: var(--font-body);
  font-size: var(--fs-small);
  letter-spacing: 0.10em;
  color: var(--muted);
  margin: var(--sp-2xs) 0 0;
}

/* Rays — 8 lines radiating from center */
.celebration-rays {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.celebration-ray {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1px;
  height: 0;
  background: linear-gradient(to top,
    color-mix(in oklch, var(--accent) 50%, transparent) 0%,
    transparent 100%);
  transform-origin: bottom center;
  transform: translate(-50%, -100%) rotate(calc(var(--ray-i, 0) * 45deg));
  animation: cel-ray 2500ms var(--easing) calc(var(--ray-i, 0) * 80ms) forwards;
  opacity: 0;
}

/* Particles — 6 dots drifting up */
.celebration-particles {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.celebration-particle {
  position: absolute;
  bottom: 30%;
  left: calc(25% + (var(--p-i, 0) * 10%));
  width: 4px;
  height: 4px;
  background: var(--accent-hi);
  border-radius: 50%;
  animation: cel-particle 2200ms var(--easing) calc(150ms + var(--p-i, 0) * 150ms) forwards;
  opacity: 0;
}

/* Mid tier — fewer rays, no particles, lighter dim */
.celebration--mid { background: oklch(0 0 0 / 0.42); }
.celebration--mid .celebration-particles { display: none; }
.celebration--mid .celebration-ray:nth-child(n+5) { display: none; }
.celebration--mid .celebration-amount { font-size: var(--fs-num-lg); }

/* Light tier — inline halo, no overlay */
.celebration--light {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--sp-2xl));
  left: 50%;
  top: auto;
  right: auto;
  inset: auto;
  transform: translateX(-50%);
  background: var(--surface);
  border: var(--border-default);
  border-radius: var(--r-2);
  padding: var(--sp-sm) var(--sp-md);
  width: auto;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: auto;
  cursor: pointer;
}
.celebration--light .celebration-rays,
.celebration--light .celebration-particles { display: none; }
.celebration--light .celebration-content { text-align: left; }
.celebration--light .celebration-amount { font-size: var(--fs-num-md); }
.celebration--light::before {
  content: "";
  position: absolute;
  inset: -8px;
  background: radial-gradient(circle,
    color-mix(in oklch, var(--accent) 30%, transparent) 0%,
    transparent 70%);
  z-index: -1;
  border-radius: inherit;
  animation: cel-light-halo 1500ms var(--easing) forwards;
  pointer-events: none;
}

@keyframes cel-overlay-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes cel-label-fade-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cel-amount-scale-in {
  0%   { opacity: 0; transform: translateY(40px) scale(0.92); }
  60%  { opacity: 1; transform: translateY(0) scale(1.03); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes cel-ray {
  0%   { opacity: 0; height: 0; }
  30%  { opacity: 1; height: 130px; }
  100% { opacity: 0; height: 130px; }
}
@keyframes cel-particle {
  0%   { opacity: 0; transform: translateY(0); }
  30%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-180px); }
}
@keyframes cel-light-halo {
  0%   { opacity: 0; transform: scale(0.85); }
  40%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.15); }
}

/* Track C2.5.8 — game medallion as celebration hero background.
   Note: .celebration already has `position: fixed` above which establishes a
   positioning context for the absolutely-positioned hero-bg, so the spec's
   redundant `position: relative` is omitted here (it would override `fixed`
   and break the overlay layout). `isolation: isolate` is merged into the
   existing rule above to keep z-index: -1 contained. */
.celebration__hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.40;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
}
.celebration__hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .celebration__hero-bg { opacity: 0.25; }
}
