/**
 * MySquad v2 Animation Engine CSS
 * Keyframes, reveal states, glow borders, pin halos, and motion utilities
 * Companion to mysquad-v2-animations.js
 */

/* ── Scroll Reveal States ── */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal="up"] {
  transform: translateY(24px);
}
[data-reveal="down"] {
  transform: translateY(-24px);
}
[data-reveal="left"] {
  transform: translateX(24px);
}
[data-reveal="right"] {
  transform: translateX(-24px);
}
[data-reveal="scale"] {
  transform: scale(0.92);
}
[data-reveal="fade"] {
  transform: none;
}

.msq-revealed {
  opacity: 1 !important;
  transform: none !important;
}

/* Stagger children delay helper */
[data-reveal-delay="0"]  { transition-delay: 0ms; }
[data-reveal-delay="1"]  { transition-delay: 80ms; }
[data-reveal-delay="2"]  { transition-delay: 160ms; }
[data-reveal-delay="3"]  { transition-delay: 240ms; }
[data-reveal-delay="4"]  { transition-delay: 320ms; }
[data-reveal-delay="5"]  { transition-delay: 400ms; }
[data-reveal-delay="6"]  { transition-delay: 480ms; }
[data-reveal-delay="7"]  { transition-delay: 560ms; }
[data-reveal-delay="8"]  { transition-delay: 640ms; }
[data-reveal-delay="9"]  { transition-delay: 720ms; }
[data-reveal-delay="10"] { transition-delay: 800ms; }

/* ── Animated Border Glow ── */
@keyframes msqBorderGlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.msq-glow-border,
.garage-card,
.oc-block {
  position: relative;
  overflow: hidden;
}

.msq-glow-border::before,
.garage-card::before,
.oc-block::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, transparent 40%, rgba(245, 158, 11, 0.4), rgba(34, 211, 238, 0.3), transparent 60%);
  background-size: 300% 300%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.msq-glow-border:hover::before,
.garage-card:hover::before,
.oc-block:hover::before {
  opacity: 1;
  animation: msqBorderGlow 3s ease infinite;
}

/* ── Pin Halo ── */
.msq-pin-halo {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(245, 158, 11, 0.3);
  opacity: 0;
  animation: msqPinHalo 2.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes msqPinHalo {
  0%, 100% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.3); opacity: 0.6; }
}

.nh-pin:hover .msq-pin-halo {
  animation-duration: 1.2s;
}

/* ── Ambient Particles Canvas ── */
#msq-ambient-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

/* ── Magnetic Button State ── */
.msq-magnetic,
.ms-btn,
.peek-btn,
.nh-tbtn,
.nh-launch-btn {
  transition: transform 0.15s ease-out, box-shadow 0.25s ease;
}

/* ── Card Tilt Base ── */
.msq-tilt,
.garage-card,
.oc-block,
.nh-tool {
  transform-style: preserve-3d;
  transition: transform 0.15s ease-out, box-shadow 0.3s ease;
}

/* ── Text Scramble ── */
[data-scramble],
[data-scramble-reveal] {
  font-variant-numeric: tabular-nums;
}

/* ── Cursor Glow Canvas ── */
#msq-cursor-glow {
  mix-blend-mode: screen;
}

/* ── Page Transition ── */
body {
  opacity: 1;
}

/* ── Enhanced Status Dot ── */
.garage-status .dot {
  position: relative;
}
.garage-status .dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--green);
  opacity: 0;
  animation: msqStatusRipple 2.5s ease-in-out infinite;
}

@keyframes msqStatusRipple {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ── Enhanced Progress Bar ── */
.progress-bar-fill {
  position: relative;
  overflow: hidden;
}
.progress-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  animation: msqProgressShimmer 2s infinite;
}

@keyframes msqProgressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ── Chat Message Slide In ── */
.chat-msg {
  animation: msqChatSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateX(-10px);
}

@keyframes msqChatSlide {
  to { opacity: 1; transform: translateX(0); }
}

/* ── Agent Control Pulse ── */
.agent-control .ac-status {
  position: relative;
}
.agent-control .ac-status::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--green);
  opacity: 0;
  animation: msqAgentPulse 3s ease-in-out infinite;
}

@keyframes msqAgentPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.6); opacity: 0; }
}

/* ── Toolbar Button Shine ── */
.nh-tbtn {
  position: relative;
  overflow: hidden;
}
.nh-tbtn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
  transition: left 0.5s ease;
}
.nh-tbtn:hover::after {
  left: 100%;
}

/* ── Floating Animation ── */
.msq-float {
  animation: msqFloat 4s ease-in-out infinite;
}

@keyframes msqFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ── Glow Text Pulse ── */
.msq-glow-pulse {
  animation: msqGlowPulse 3s ease-in-out infinite;
}

@keyframes msqGlowPulse {
  0%, 100% { text-shadow: 0 0 20px rgba(245, 158, 11, 0.2); }
  50% { text-shadow: 0 0 40px rgba(245, 158, 11, 0.5), 0 0 80px rgba(245, 158, 11, 0.15); }
}

/* ── Entrance Bounce ── */
.msq-bounce-in {
  animation: msqBounceIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes msqBounceIn {
  0% { opacity: 0; transform: scale(0.7) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Sidebar Link Glow Trail ── */
.nav-link {
  position: relative;
}
.nav-link::after {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  background: linear-gradient(180deg, var(--ms-amber), var(--ms-cyan));
  border-radius: 2px;
  transition: height 0.3s ease, top 0.3s ease;
  transform: translateY(-50%);
}
.nav-link:hover::after,
.nav-link.active::after {
  height: 70%;
}

/* ── Modal Entrance ── */
.modal {
  animation: msqModalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ── Hub Canvas Block Premium ── */
.oc-block {
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.oc-block:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), 0 0 0 1px rgba(245,158,11,0.1);
}
.oc-block--hero {
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(34,211,238,0.05)) !important;
}

/* ── Canvas Toolbar Shine ── */
.oc-toolbar {
  position: relative;
  overflow: hidden;
}
.oc-toolbar::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
  animation: msqToolbarShine 6s ease-in-out infinite;
}

@keyframes msqToolbarShine {
  0%, 100% { left: -100%; }
  50% { left: 140%; }
}

/* ── Bridge Strip Typing Cursor ── */
.nh-morale-text {
  position: relative;
}
.nh-morale-text::after {
  content: '|';
  animation: msqCursorBlink 1s step-end infinite;
  color: var(--ms-cyan, #22d3ee);
  margin-left: 2px;
}

@keyframes msqCursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── Notification Badge Bounce ── */
.notif-badge {
  animation: msqBadgeBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes msqBadgeBounce {
  0% { transform: scale(0); }
  70% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ── Hub Switcher Dropdown Entrance ── */
.hub-switcher-dropdown.open {
  animation: msqDropdownIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes msqDropdownIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Compute Status Counter ── */
.compute-val {
  font-variant-numeric: tabular-nums;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  .chat-msg,
  .modal,
  .msq-float,
  .msq-bounce-in,
  .msq-glow-pulse {
    animation: none !important;
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .msq-pin-halo,
  .garage-status .dot::after,
  .agent-control .ac-status::after {
    animation: none !important;
    opacity: 0 !important;
  }
}
