/* VAL — Welcome, ripples, micro-interactions */

/* ── Welcome screen ── */
.welcome-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: welcomeBgIn 0.5s var(--ease) both;
}
.welcome-overlay.leaving {
  animation: welcomeBgOut 0.45s var(--ease) forwards;
}
@keyframes welcomeBgIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes welcomeBgOut { to { opacity: 0; pointer-events: none; } }

.welcome-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 40px 32px 32px;
  background: var(--surface-1);
  border: 1px solid var(--border-hover);
  border-radius: 24px;
  box-shadow: 0 0 0 1px var(--border), 0 32px 80px rgba(0,0,0,.5), 0 0 120px var(--accent-glow);
  animation: welcomeCardIn 0.6s var(--ease-spring) 0.1s both;
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: welcomeShine 2s ease infinite;
}
@keyframes welcomeShine { 0%,100% { opacity: .4; } 50% { opacity: 1; } }
@keyframes welcomeCardIn {
  from { opacity: 0; transform: scale(0.92) translateY(24px); }
  to { opacity: 1; transform: none; }
}
.welcome-overlay.leaving .welcome-card {
  animation: welcomeCardOut 0.4s var(--ease) forwards;
}
@keyframes welcomeCardOut {
  to { opacity: 0; transform: scale(0.95) translateY(-16px); }
}

.welcome-avatar-ring {
  width: 96px; height: 96px; margin: 0 auto 20px;
  border-radius: 50%; padding: 3px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, transparent));
  animation: welcomePulse 2.5s ease infinite;
  box-shadow: 0 0 40px var(--accent-glow);
}
@keyframes welcomePulse {
  0%, 100% { box-shadow: 0 0 30px var(--accent-glow); transform: scale(1); }
  50% { box-shadow: 0 0 50px var(--accent-glow); transform: scale(1.03); }
}
.welcome-avatar {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; background: var(--surface-3);
  border: 3px solid var(--surface-1);
}
.welcome-greeting {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--accent); margin-bottom: 8px;
  animation: fadeUp 0.5s var(--ease) 0.25s both;
}
.welcome-name {
  font-size: 28px; font-weight: 700; letter-spacing: -0.04em;
  margin: 0 0 6px; animation: fadeUp 0.5s var(--ease) 0.32s both;
}
.welcome-username {
  font-size: 14px; color: var(--text-tertiary); margin-bottom: 16px;
  animation: fadeUp 0.5s var(--ease) 0.38s both;
}
.welcome-plan {
  display: inline-flex; margin-bottom: 20px;
  animation: fadeUp 0.5s var(--ease) 0.44s both;
}
.welcome-msg {
  font-size: 14px; color: var(--text-secondary); line-height: 1.6;
  margin: 0 0 28px; max-width: 320px; margin-left: auto; margin-right: auto;
  animation: fadeUp 0.5s var(--ease) 0.5s both;
}
.welcome-actions {
  display: flex; flex-direction: column; gap: 10px;
  animation: fadeUp 0.5s var(--ease) 0.56s both;
}
.welcome-enter {
  position: relative; overflow: hidden;
  padding: 14px 28px !important; font-size: 15px !important;
  border-radius: 12px !important;
}
.welcome-skip {
  background: none; border: none; color: var(--text-tertiary);
  font: inherit; font-size: 13px; cursor: pointer; padding: 8px;
  transition: color 0.15s;
}
.welcome-skip:hover { color: var(--text-secondary); }

/* Particles */
.welcome-particles {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  border-radius: 24px;
}
.welcome-particle {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: 0;
  animation: particleBurst 0.8s var(--ease) forwards;
}
@keyframes particleBurst {
  0% { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0); }
}

/* ── Ripple effect ── */
.ripple-host { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0);
  animation: rippleAnim 0.55s var(--ease) forwards;
  pointer-events: none;
}
[data-theme="val-light"] .ripple { background: rgba(0, 0, 0, 0.08); }
@keyframes rippleAnim {
  to { transform: scale(4); opacity: 0; }
}

/* ── Touch / press feedback ── */
.pressable {
  transition: transform 0.12s var(--ease-spring), box-shadow 0.15s, border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.pressable:active:not(:disabled) { transform: scale(0.97); }
.btn.pressable:active:not(:disabled) { transform: scale(0.96); }
.nav-item.pressable:active { transform: scale(0.98); }
.bento-stat.pressable:hover { transform: translateY(-3px); }
.quick-chip.pressable:active { transform: scale(0.95); }

/* ── Page transitions ── */
.main-content { perspective: 1200px; }
.page {
  display: none;
  transform-origin: top center;
}
.page.active {
  display: block;
  animation: pageEnter 0.4s var(--ease) both;
}
.page.leaving {
  animation: pageLeave 0.22s var(--ease) forwards;
}
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px) scale(0.99); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes pageLeave {
  to { opacity: 0; transform: translateY(-8px) scale(0.995); filter: blur(2px); }
}

/* Stagger children */
.stagger-in > * {
  animation: fadeUp 0.45s var(--ease) both;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.04s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.08s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.12s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.16s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.24s; }

/* ── Enhanced modals / drawers ── */
.overlay {
  animation: overlayIn 0.25s ease both;
}
.overlay.leaving { animation: overlayOut 0.2s ease forwards; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayOut { to { opacity: 0; } }

.drawer.leaving { animation: drawerOut 0.28s var(--ease) forwards; }
@keyframes drawerOut { to { transform: translateX(100%); opacity: 0; } }

.cmd-palette.leaving { animation: cmdOut 0.2s var(--ease) forwards; }
@keyframes cmdOut {
  to { opacity: 0; transform: translateX(-50%) scale(0.96) translateY(-8px); }
}

.modal-overlay.leaving { animation: welcomeBgOut 0.25s ease forwards; }
.modal.leaving { animation: welcomeCardOut 0.25s ease forwards; }

/* ── Focus glow on inputs ── */
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-muted), 0 0 20px var(--accent-glow);
}

/* ── Nav active indicator slide ── */
.nav-item.active {
  position: relative;
}
.nav-item.active::before {
  content: "";
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 0 4px 4px 0;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: navIndicator 0.3s var(--ease-spring) both;
}
@keyframes navIndicator {
  from { height: 0; opacity: 0; }
  to { height: 60%; opacity: 1; }
}

/* ── FAB enhanced ── */
.fab {
  animation: fabIn 0.5s var(--ease-spring) 0.8s both;
}
@keyframes fabIn {
  from { opacity: 0; transform: scale(0) rotate(-90deg); }
  to { opacity: 1; transform: none; }
}
.fab::after {
  content: "";
  position: absolute; inset: -4px; border-radius: 18px;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: fabRing 2s ease infinite;
}
@keyframes fabRing {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ── Toast enhanced ── */
.toast-item {
  animation: toastPop 0.4s var(--ease-spring) both;
}
@keyframes toastPop {
  from { opacity: 0; transform: translateX(24px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

/* ── Loading bar (top) ── */
.top-loader {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 9999;
  background: var(--surface-3); overflow: hidden; pointer-events: none;
}
.top-loader-bar {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: topLoader 1.2s ease infinite;
}
@keyframes topLoader {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
