/* ==========================================================================
   NEXUSLAB PHYSICS — DARK GRAPHITE / NAVY / ELECTRIC CYAN GAME LAB SYSTEM
   Strictly isolated to Physics pages (zero impact on Chemistry or Biology).
   ========================================================================== */

:root {
  --np-bg: #050914;
  --np-surface: rgba(11, 18, 36, 0.88);
  --np-surface-strong: rgba(9, 14, 29, 0.96);
  --np-border: rgba(56, 189, 248, 0.22);
  --np-accent: #22d3ee;
  --np-accent-2: #3b82f6;
  --np-amber: #f59e0b;
  --np-emerald: #10b981;
  --np-accent-soft: rgba(34, 211, 238, 0.13);
  --np-text: #f1f5f9;
  --np-muted: #94a3b8;
  --np-radius: 18px;
}

body.np-theme-physics {
  --np-bg: #050914;
  background:
    radial-gradient(960px 440px at 14% -8%, rgba(56, 189, 248, 0.14), transparent 65%),
    radial-gradient(760px 380px at 88% 4%, rgba(59, 130, 246, 0.12), transparent 60%),
    #050914 !important;
  color: var(--np-text);
}

.np-card {
  background: var(--np-surface);
  border: 1px solid var(--np-border);
  border-radius: var(--np-radius);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 42px -24px rgba(0, 0, 0, 0.85);
}

/* 7-Step Adaptive Learning Flow Stepper */
.np-stepper-wrap {
  background: var(--np-surface-strong);
  border: 1px solid var(--np-border);
  border-radius: 16px;
  padding: 12px 14px;
}

.np-stepper {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 960px) {
  .np-stepper {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .np-stepper {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.np-step-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.58);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
}

.np-step-pill:hover {
  border-color: var(--np-accent);
  color: #f8fafc;
}

.np-step-pill .np-step-num {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
  flex-shrink: 0;
}

.np-step-pill.is-active {
  border-color: var(--np-accent);
  background: var(--np-accent-soft);
  color: #ffffff;
}

.np-step-pill.is-active .np-step-num {
  background: var(--np-accent);
  color: #020617;
}

.np-step-pill.is-done {
  border-color: rgba(16, 185, 129, 0.45);
  color: #a7f3d0;
}

.np-step-pill.is-done .np-step-num {
  background: #10b981;
  color: #022c22;
}

.np-status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 11px;
}

.np-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--np-border);
  color: #e2e8f0;
  font-weight: 600;
}

/* View Switcher (3D Interactive vs 2D Lab) */
.np-view-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.78);
  border: 1px solid var(--np-border);
  gap: 3px;
}

.np-view-tab {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.np-view-tab.is-active {
  background: var(--np-accent);
  color: #020617;
}

/* 3D WebGL Viewport & Game Overlay */
.np3d-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 360px;
  touch-action: none;
  user-select: none;
  background: radial-gradient(circle at 50% 42%, #0c1931 0%, #050b18 72%);
}

.np3d-stage:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
}

.np3d-drag-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(52, 211, 153, 0.5);
  color: #6ee7b7;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.np3d-drag-tag.hidden {
  display: none;
}

.np3d-stage.hidden {
  display: none !important;
  pointer-events: none !important;
}

.np3d-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px;
  z-index: 12;
}

.np3d-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.np3d-badge {
  pointer-events: auto;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid var(--np-border);
  color: #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  max-width: 340px;
}

.np3d-controls-mini {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.np3d-fps {
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.84);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
}

.np3d-quality,
.np3d-btn {
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #e2e8f0;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.np3d-btn:hover,
.np3d-btn.is-active {
  border-color: var(--np-accent);
  color: var(--np-accent);
}

.np3d-tooltip {
  pointer-events: auto;
  align-self: flex-start;
  max-width: 380px;
  padding: 10px 13px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.92);
  border: 1px solid var(--np-accent);
  color: #f1f5f9;
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
}

.np3d-tooltip.hidden {
  display: none;
}

/* Primary & Secondary Action Buttons */
.np-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: #020617;
  background: linear-gradient(135deg, var(--np-accent), var(--np-accent-2));
  border: none;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.np-btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.np-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.np-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.28);
  cursor: pointer;
}

.np-btn-secondary:hover:not(:disabled) {
  border-color: var(--np-accent);
  color: #ffffff;
}

/* Prediction Options */
.np-pred-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.65);
  color: #e2e8f0;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  width: 100%;
}

.np-pred-opt:hover:not(:disabled),
.np-pred-opt.is-selected {
  border-color: var(--np-accent);
  background: var(--np-accent-soft);
  color: #ffffff;
}

/* Scientific Integrity 5-Badge Grid */
.np-integrity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.np-integrity-box {
  padding: 12px;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.16);
  font-size: 12px;
  line-height: 1.55;
}

/* Toast Notification */
.np-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(5, 14, 32, 0.96);
  border: 1px solid var(--np-accent);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
}

/* Accessibility & Mobile Overflow Protection (390px+) */
.np-step-pill:focus-visible,
.np-pred-opt:focus-visible,
.np-btn-primary:focus-visible,
.np-btn-secondary:focus-visible,
.np-view-tab:focus-visible,
.np3d-btn:focus-visible {
  outline: 2px solid var(--np-accent);
  outline-offset: 2px;
}

html,
body {
  overflow-x: clip;
  max-width: 100%;
}

main,
.np-card,
#tabTheory {
  max-width: 100%;
  min-width: 0;
}

.katex-display {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

@media (max-width: 640px) {
  .np3d-tooltip {
    max-width: calc(100% - 16px);
  }
  .np-toast {
    width: calc(100vw - 24px);
    max-width: 360px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
