/* ==========================================================================
   IMMERSIVE SHELL — Apex Nexus / Nova Bastion
   Deep-space ambience + glass panels + glow accents.
   Layered ON TOP of existing theme.css / apex_surreal_theme.css.
   ========================================================================== */

/* ------------------------------------------------------------------
   1. Immersive Background: deep-space gradient + constellation mesh
   ------------------------------------------------------------------ */
#nx-immersive-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;

  /* Deep space gradient */
  background:
    radial-gradient(ellipse 120% 80% at 30% 20%, rgba(6, 214, 160, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 100% 70% at 75% 70%, rgba(56, 189, 248, 0.04) 0%, transparent 55%),
    linear-gradient(160deg, #060a12 0%, #0b0f17 40%, #0d1221 100%);

  /* Constellation / neural-mesh overlay via SVG data-URI */
  background-size: cover;
}

#nx-immersive-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.12;
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 45%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 10%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 65%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 30%, rgba(255,255,255,0.45) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 80%, rgba(255,255,255,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 90%, rgba(255,255,255,0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 5%, rgba(255,255,255,0.55) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 88%, rgba(255,255,255,0.4) 0%, transparent 100%);
  background-size: 200% 200%;
  animation: nx-constellation-drift 90s linear infinite;
}

@keyframes nx-constellation-drift {
  0%   { background-position: 0% 0%; }
  50%  { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

/* Soft parallax via CSS custom properties (set by immersive.js) */
#nx-immersive-bg::after {
  content: "";
  position: absolute;
  inset: -20px;
  background: inherit;
  transform: translate(
    calc(var(--nx-mx, 0) * 8px),
    calc(var(--nx-my, 0) * 8px)
  );
  transition: transform 0.6s ease-out;
  opacity: 0.55;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   2. Glass panels — transparent frost with glow border
   ------------------------------------------------------------------ */
.card,
.panel,
.options-page,
.learn-library-card,
article.card {
  background: rgba(17, 24, 39, 0.65) !important;
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid rgba(99, 179, 237, 0.1) !important;
  box-shadow:
    0 0 12px rgba(6, 214, 160, 0.03),
    0 4px 24px rgba(0, 0, 0, 0.25);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover,
.panel:hover,
.learn-library-card:hover {
  border-color: rgba(6, 214, 160, 0.2) !important;
  box-shadow:
    0 0 18px rgba(6, 214, 160, 0.06),
    0 6px 30px rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------------------------------
   3. Button glow on hover
   ------------------------------------------------------------------ */
.btn:not(:disabled) {
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.btn:not(:disabled):hover {
  box-shadow: 0 0 14px rgba(6, 214, 160, 0.25), 0 0 4px rgba(6, 214, 160, 0.1);
}

.btn--primary:not(:disabled):hover {
  box-shadow: 0 0 18px rgba(6, 214, 160, 0.35), 0 0 6px rgba(6, 214, 160, 0.15);
}

/* ------------------------------------------------------------------
   4. Gentle page transitions
   ------------------------------------------------------------------ */
.main {
  animation: nx-fade-up 0.4s ease-out;
}

@keyframes nx-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------
   5. Nova Presence Node (orb + panel)
   ------------------------------------------------------------------ */

/* Orb button */
#nx-nova-node {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #38bdf8 0%, #06d6a0 55%, #0b0f17 100%);
  box-shadow: 0 0 20px rgba(6, 214, 160, 0.3), 0 0 60px rgba(56, 189, 248, 0.1);
  animation: nx-orb-pulse 3s ease-in-out infinite;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

#nx-nova-node::after {
  content: "N";
  font-size: 1.1rem;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(255,255,255,0.4);
}

#nx-nova-node:hover {
  transform: scale(1.15);
  box-shadow: 0 0 30px rgba(6, 214, 160, 0.45), 0 0 80px rgba(56, 189, 248, 0.15);
}

#nx-nova-node:hover::after {
  content: "Nova";
  font-size: 0.7rem;
}

@keyframes nx-orb-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(6, 214, 160, 0.25), 0 0 50px rgba(56, 189, 248, 0.08); }
  50%      { box-shadow: 0 0 28px rgba(6, 214, 160, 0.4), 0 0 70px rgba(56, 189, 248, 0.15); }
}

/* Panel drawer */
#nx-nova-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 370px;
  max-width: 92vw;
  height: 100vh;
  z-index: 9001;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid rgba(6, 214, 160, 0.15);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.5);
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#nx-nova-panel.is-open {
  right: 0;
}

/* Panel backdrop */
#nx-nova-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8999;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#nx-nova-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Panel header */
.nx-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(99, 179, 237, 0.12);
}

.nx-panel__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.04em;
}

.nx-panel__subtitle {
  font-size: 0.75rem;
  color: var(--color-text-secondary, #8892a4);
  margin-top: 0.15rem;
}

.nx-panel__close {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-secondary, #8892a4);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}

.nx-panel__close:hover {
  border-color: rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
}

/* Panel action buttons */
.nx-panel__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nx-panel__action-btn {
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.nx-panel__action-btn:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.1);
}

/* Panel content area */
.nx-panel__content {
  flex: 1;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--color-text-secondary, #8892a4);
  min-height: 80px;
}

.nx-panel__content p {
  margin: 0 0 0.6rem;
}

.nx-panel__content .nx-thinking {
  font-style: italic;
  color: rgba(56, 189, 248, 0.6);
}

/* Panel video slot */
.nx-panel__video-slot {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(99, 179, 237, 0.15);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-secondary, #8892a4);
  font-size: 0.8rem;
}

.nx-panel__video-slot video {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

/* ------------------------------------------------------------------
   6. Cognition Hover Hints (tooltip)
   ------------------------------------------------------------------ */
#nx-hint-tooltip {
  position: fixed;
  z-index: 9500;
  max-width: 300px;
  padding: 0.75rem 1rem;
  background: rgba(11, 15, 23, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(6, 214, 160, 0.2);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 12px rgba(6, 214, 160, 0.06);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--color-text-secondary, #8892a4);
}

#nx-hint-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

#nx-hint-tooltip .nx-hint__label {
  font-size: 0.65rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

#nx-hint-tooltip .nx-hint__thinking {
  font-style: italic;
  color: rgba(6, 214, 160, 0.7);
  margin-bottom: 0.25rem;
}

#nx-hint-tooltip .nx-hint__explain {
  color: var(--color-text, #e2e8f0);
}

/* ------------------------------------------------------------------
   7. Learning Progress (V1)
   ------------------------------------------------------------------ */
.nx-progress-section {
  margin-bottom: 1.5rem;
}

.nx-progress-ring {
  width: 80px;
  height: 80px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nx-progress-ring svg {
  transform: rotate(-90deg);
}

.nx-progress-ring__bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 5;
}

.nx-progress-ring__fill {
  fill: none;
  stroke: #06d6a0;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.nx-progress-ring__text {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 700;
  color: #06d6a0;
}

.nx-track-progress {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.nx-track-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, #06d6a0, #38bdf8);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.nx-mark-done-btn {
  background: rgba(6, 214, 160, 0.1);
  border: 1px solid rgba(6, 214, 160, 0.2);
  color: #06d6a0;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.2s, box-shadow 0.2s;
}

.nx-mark-done-btn:hover {
  background: rgba(6, 214, 160, 0.2);
  box-shadow: 0 0 8px rgba(6, 214, 160, 0.15);
}

.nx-reset-btn {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.2s;
}

.nx-reset-btn:hover {
  background: rgba(255, 107, 107, 0.15);
}

/* Confirm modal */
.nx-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9600;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.nx-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.nx-modal {
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid rgba(255, 107, 107, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 340px;
  width: 90%;
  text-align: center;
}

.nx-modal__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text, #e2e8f0);
  margin-bottom: 0.5rem;
}

.nx-modal__text {
  font-size: 0.82rem;
  color: var(--color-text-secondary, #8892a4);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.nx-modal__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ------------------------------------------------------------------
   8. Reduced motion
   ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #nx-immersive-bg::before {
    animation: none;
  }
  #nx-immersive-bg::after {
    transition: none;
    transform: none;
  }
  #nx-nova-node {
    animation: none;
  }
  .main {
    animation: none;
  }
  #nx-hint-tooltip {
    transition: none;
  }
  #nx-nova-panel {
    transition: none;
  }
  .nx-track-progress__fill {
    transition: none;
  }
  .nx-progress-ring__fill {
    transition: none;
  }
}
