/**
 * MESL DIGITAL UNIVERSE — QUANTUM NEXUS
 * Section 9: Dedicated Interaction Stylesheet
 * 
 * Includes:
 * 9.1 Quantum Core Pulse
 * 9.2 Neural Connection (SVG Signal Flow)
 * 9.3 Node Focus & Accessibility Glow
 * 9.4 Data Panel Expand & Collapse
 * 9.5 Signal Scan (Lightweight Cyber Scanlines)
 * 9.6 Magnetic Hover Transform Foundation
 * 9.7 Stepped Reveal (Hierarchical Stagger)
 * 9.8 Elastic Interaction (Natural Spring Feedback)
 * 9.9 Data Stream (Network Topology SVG Packet Stream)
 * 9.10 Reduced Motion & Mobile Battery Optimization
 */

/* ============================================================
   9.1 QUANTUM CORE PULSE (Low-frequency Breathing)
   ============================================================ */
@keyframes quantumCorePulseSlow {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
    filter: drop-shadow(0 0 15px rgba(82, 214, 232, 0.35));
  }
  50% {
    transform: scale(1.035);
    opacity: 1;
    filter: drop-shadow(0 0 35px rgba(82, 214, 232, 0.75));
  }
}

@keyframes coreMatrixFlicker {
  0%, 100% { opacity: 0.7; }
  25% { opacity: 0.85; }
  50% { opacity: 0.65; }
  75% { opacity: 0.9; }
}

.quantum-core-pulse {
  transform-origin: center;
  animation: quantumCorePulseSlow 5.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.core-matrix-grid-fx {
  animation: coreMatrixFlicker 8s ease-in-out infinite;
}

/* ============================================================
   9.2 NEURAL CONNECTION (Slow Signal Flow Along Paths)
   ============================================================ */
@keyframes neuralSignalFlow {
  from {
    stroke-dashoffset: 160;
  }
  to {
    stroke-dashoffset: 0;
  }
}

.neural-line-active,
.neural-connection {
  stroke-dasharray: 6 14;
  animation: neuralSignalFlow 4.5s linear infinite;
}

.neural-line-fast {
  stroke-dasharray: 4 10;
  animation: neuralSignalFlow 2.8s linear infinite;
}

/* ============================================================
   9.3 NODE FOCUS (Keyboard & Hover Enhanced State)
   ============================================================ */
.topology-node-group,
.node-item {
  cursor: pointer;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.topology-node-group:hover,
.topology-node-group:focus-visible,
.node-item:hover,
.node-item:focus-visible {
  transform: scale(1.08);
}

.topology-node-group:focus-visible circle {
  stroke: var(--quantum-cyan) !important;
  stroke-width: 3px !important;
  filter: drop-shadow(0 0 12px var(--quantum-cyan));
}

.topology-node-group.active circle {
  stroke: var(--quantum-green) !important;
  stroke-width: 3.5px !important;
  filter: drop-shadow(0 0 18px rgba(167, 230, 195, 0.8));
}

/* ============================================================
   9.4 DATA PANEL EXPAND (Deep Info Collapsible)
   ============================================================ */
.data-expandable-panel {
  position: relative;
  border: 1px solid var(--border-panel);
  border-radius: 6px;
  background: var(--bg-surface);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.data-expandable-panel.is-expanded {
  border-color: rgba(82, 214, 232, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.panel-toggle-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--quantum-cyan);
  cursor: pointer;
  border-top: 1px dashed rgba(220, 229, 235, 0.1);
  transition: background 0.2s ease;
}

.panel-toggle-trigger:hover {
  background: rgba(82, 214, 232, 0.08);
}

.panel-toggle-icon {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.data-expandable-panel.is-expanded .panel-toggle-icon {
  transform: rotate(180deg);
}

.panel-expandable-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.data-expandable-panel.is-expanded .panel-expandable-content {
  grid-template-rows: 1fr;
}

.panel-expandable-inner {
  min-height: 0;
  padding: 0 16px 14px 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ============================================================
   9.5 SIGNAL SCAN (Lightweight Laser Scanline)
   ============================================================ */
@keyframes scanlineSweep {
  0% {
    top: -100%;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 1;
  }
  100% {
    top: 200%;
    opacity: 0;
  }
}

.signal-scan-box {
  position: relative;
  overflow: hidden;
}

.signal-scan-box::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(82, 214, 232, 0.6), transparent);
  box-shadow: 0 0 8px var(--quantum-cyan);
  opacity: 0;
  pointer-events: none;
}

.signal-scan-box:hover::after,
.signal-scan-box.active-scan::after {
  animation: scanlineSweep 3s ease-in-out infinite;
}

/* ============================================================
   9.6 MAGNETIC HOVER (Hardware-Accelerated Positioning)
   ============================================================ */
.magnetic-btn {
  display: inline-flex;
  will-change: transform;
  transform-style: preserve-3d;
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ============================================================
   9.7 STEPPED REVEAL (Hierarchical Scroll Reveal)
   ============================================================ */
.stepped-reveal-group {
  /* Parent container for stagger */
}

.stepped-reveal-item {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1), transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.stepped-reveal-item.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.stepped-reveal-group .stepped-reveal-item:nth-child(1) { transition-delay: 0.05s; }
.stepped-reveal-group .stepped-reveal-item:nth-child(2) { transition-delay: 0.12s; }
.stepped-reveal-group .stepped-reveal-item:nth-child(3) { transition-delay: 0.19s; }
.stepped-reveal-group .stepped-reveal-item:nth-child(4) { transition-delay: 0.26s; }
.stepped-reveal-group .stepped-reveal-item:nth-child(5) { transition-delay: 0.33s; }
.stepped-reveal-group .stepped-reveal-item:nth-child(6) { transition-delay: 0.40s; }

/* ============================================================
   9.8 ELASTIC INTERACTION (Spring State Feedback)
   ============================================================ */
.btn-cyber,
.doc-action-btn,
.cat-btn,
.status-filter-pill,
.panel-toggle-trigger,
.elastic-interaction {
  transform: scale(1);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), 
              background-color 0.2s ease, 
              border-color 0.2s ease, 
              box-shadow 0.2s ease;
}

.btn-cyber:active,
.doc-action-btn:active,
.cat-btn:active,
.status-filter-pill:active,
.elastic-interaction:active {
  transform: scale(0.95);
  transition: transform 0.08s ease;
}

/* ============================================================
   9.9 DATA STREAM (Topology SVG Packet Animation)
   ============================================================ */
@keyframes dataPacketMove {
  0% {
    offset-distance: 0%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

.data-stream,
.data-stream-flow,
.data-stream-glow-line {
  stroke: var(--quantum-cyan);
  stroke-width: 2px;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--quantum-cyan));
}

/* ============================================================
   9.10 REDUCED MOTION & MOBILE BATTERY OPTIMIZATION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .quantum-core-pulse,
  .neural-line-active,
  .neural-line-fast,
  .radar-sweep-arm,
  .signal-waveguide,
  .core-hex-center,
  .signal-scan-box::after {
    animation: none !important;
    transform: none !important;
  }

  .stepped-reveal-item {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .magnetic-btn {
    transform: none !important;
  }
}

@media (max-width: 768px) {
  /* Mobile optimizations: reduce heavy animation loops */
  .signal-waveguide {
    animation-duration: 12s; /* Slower to save CPU/battery */
  }
  .radar-sweep-arm {
    animation-duration: 20s;
  }
  .signal-scan-box::after {
    display: none; /* Turn off laser scanlines on touch screens */
  }
}
