/* ==========================================================================
   APEX SURREAL THEME — "Surreal Intelligence" Visual Layer
   Calm sci-fi, spatial, living-data interface.
   Layered ON TOP of existing theme.css / components.css — never overrides
   layout, routes, or data flow.
   ========================================================================== */

/* ---------- Step 1: Surreal Design Tokens ---------- */
:root {
  /* Backgrounds */
  --apex-bg:          #070b14;
  --apex-bg-soft:     #0b1020;
  --apex-surface:     rgba(255,255,255,0.04);
  --apex-glass:       rgba(255,255,255,0.06);
  --apex-border:      rgba(255,255,255,0.12);

  /* Glow accents */
  --apex-glow-blue:   #4cc9ff;
  --apex-glow-purple: #9b7cff;
  --apex-glow-cyan:   #5ef0d6;

  /* Text */
  --apex-text:        #e6f0ff;
  --apex-text-dim:    #9fb3d9;

  /* Spatial shaping */
  --apex-radius:      14px;
  --apex-depth-shadow: 0 10px 30px rgba(0,0,0,0.45);
  --apex-soft-shadow:  0 4px 12px rgba(0,0,0,0.35);

  /* Cursor glow position (set by JS) */
  --apex-cursor-x:    50%;
  --apex-cursor-y:    50%;
}

/* ---------- Step 2: Global Background Atmosphere ---------- */
body {
  background:
    radial-gradient(circle at 20% 20%, rgba(76,201,255,0.08), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(155,124,255,0.06), transparent 40%),
    linear-gradient(180deg, #05070d, #0a0f1f) !important;
  color: var(--apex-text);
}

/* ---------- Step 3: Glass Surfaces System ---------- */
.card,
.panel,
.modal,
.intel-card,
.alert-card,
.explain-modal__dialog {
  background: var(--apex-surface);
  border: 1px solid var(--apex-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: var(--apex-radius);
  box-shadow: var(--apex-depth-shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

/* Hover lift */
.card:hover,
.alert-card:hover,
.intel-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.55);
}

/* ---------- Step 4: Float + Depth Glow Border ---------- */
.card,
.alert-card,
.intel-card {
  position: relative;
}

.card::before,
.alert-card::before,
.intel-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(
    120deg,
    rgba(76,201,255,0.18),
    transparent 40%,
    rgba(155,124,255,0.18)
  );
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
  z-index: 0;
}

.card:hover::before,
.alert-card:hover::before,
.intel-card:hover::before {
  opacity: 1;
}

/* Ensure card content stays above the glow overlay */
.card > *,
.alert-card > *,
.intel-card > * {
  position: relative;
  z-index: 1;
}

/* ---------- Step 5: Living Data Pulse ---------- */
.value-live {
  animation: apexPulse 2.8s infinite ease-in-out;
}

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

/* ---------- Step 6: Intel Appear Animation ---------- */
.alert-card,
.intel-card {
  opacity: 0;
  transform: translateY(6px);
  animation: apexFadeUp 260ms ease forwards;
}

@keyframes apexFadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger for lists – first 12 items get progressive delay */
.alert-card:nth-child(1)  { animation-delay:  0ms; }
.alert-card:nth-child(2)  { animation-delay: 40ms; }
.alert-card:nth-child(3)  { animation-delay: 80ms; }
.alert-card:nth-child(4)  { animation-delay: 120ms; }
.alert-card:nth-child(5)  { animation-delay: 160ms; }
.alert-card:nth-child(6)  { animation-delay: 200ms; }
.alert-card:nth-child(7)  { animation-delay: 240ms; }
.alert-card:nth-child(8)  { animation-delay: 280ms; }
.alert-card:nth-child(9)  { animation-delay: 320ms; }
.alert-card:nth-child(10) { animation-delay: 360ms; }
.alert-card:nth-child(11) { animation-delay: 400ms; }
.alert-card:nth-child(12) { animation-delay: 440ms; }

/* ---------- Step 7: Focus Mode Dim ---------- */
body.apex-focus::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 40;
  pointer-events: none;
}

/* Drawers / modals sit above the focus dim */
.explain-modal,
.modal,
[role="dialog"] {
  z-index: 50;
}

/* ---------- Step 8: Cursor Light Reactive (CSS part) ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(
      180px circle at var(--apex-cursor-x) var(--apex-cursor-y),
      rgba(76,201,255,0.12),
      transparent 60%
    );
  z-index: 0;
  transition: background 80ms ease;
}

/* ---------- Step 9: Button Energy Style ---------- */
.btn--primary,
.btn--accent {
  background: linear-gradient(
    135deg,
    rgba(76,201,255,0.9),
    rgba(155,124,255,0.9)
  );
  border: none;
  color: #041020;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(76,201,255,0.35);
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.btn--primary:hover:not(:disabled),
.btn--accent:hover:not(:disabled) {
  box-shadow: 0 10px 28px rgba(155,124,255,0.45);
  transform: translateY(-1px);
}

/* ---------- Step 11: Panel Header Glass ---------- */
.panel__header {
  background: var(--apex-glass);
  border-bottom: 1px solid var(--apex-border);
}

/* ---------- Step 12: Motion Safety ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
