/* ==========================================================================
   NEXUSLAB SCIENCE REBIRTH — PREMIUM SUBJECT-THEMED LABORATORY DESIGN SYSTEM
   Chemistry: Deep Navy · Violet · Cyan · Magenta Glass Surfaces
   Biology:   Deep Emerald · Forest Green · Teal · Microscopy Lighting
   ========================================================================== */

:root {
  --nr-bg: #060b18;
  --nr-surface: rgba(13, 21, 40, 0.86);
  --nr-surface-strong: rgba(15, 23, 42, 0.96);
  --nr-border: rgba(148, 163, 184, 0.18);
  --nr-accent: #22d3ee;
  --nr-accent-2: #8b5cf6;
  --nr-accent-3: #e879f9;
  --nr-accent-soft: rgba(34, 211, 238, 0.14);
  --nr-text: #f1f5f9;
  --nr-muted: #94a3b8;
  --nr-radius: 18px;
}

body.nr-theme-chemistry {
  --nr-bg: #050a18;
  --nr-surface: rgba(12, 20, 44, 0.86);
  --nr-surface-strong: rgba(10, 17, 38, 0.96);
  --nr-border: rgba(99, 102, 241, 0.25);
  --nr-accent: #22d3ee;
  --nr-accent-2: #8b5cf6;
  --nr-accent-3: #e879f9;
  --nr-accent-soft: rgba(34, 211, 238, 0.13);
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(124, 58, 237, 0.16), transparent 65%),
    radial-gradient(760px 380px at 88% 0%, rgba(34, 211, 238, 0.12), transparent 62%),
    #050a18 !important;
}

body.nr-theme-biology {
  --nr-bg: #03130f;
  --nr-surface: rgba(7, 30, 24, 0.88);
  --nr-surface-strong: rgba(5, 24, 19, 0.96);
  --nr-border: rgba(16, 185, 129, 0.26);
  --nr-accent: #10b981;
  --nr-accent-2: #14b8a6;
  --nr-accent-3: #f59e0b;
  --nr-accent-soft: rgba(16, 185, 129, 0.14);
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(16, 185, 129, 0.15), transparent 65%),
    radial-gradient(760px 380px at 88% 0%, rgba(20, 184, 166, 0.12), transparent 62%),
    #03130f !important;
}

/* Glass Card Surface */
.nr-card {
  background: var(--nr-surface);
  border: 1px solid var(--nr-border);
  border-radius: var(--nr-radius);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.85);
}

/* 8-Step Inquiry Progress Stepper */
.nr-stepper-wrap {
  background: var(--nr-surface-strong);
  border: 1px solid var(--nr-border);
  border-radius: 16px;
  padding: 12px 14px;
}

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

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

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

.nr-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.55);
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

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

.nr-step-pill .nr-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;
}

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

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

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

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

/* Gamification Strip */
.nr-gamify-bar {
  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;
}

.nr-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(--nr-border);
  color: #e2e8f0;
  font-weight: 600;
}

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

.nr-pred-opt:hover:not(:disabled) {
  border-color: var(--nr-accent);
  background: var(--nr-accent-soft);
}

.nr-pred-opt.is-selected {
  border-color: var(--nr-accent);
  background: var(--nr-accent-soft);
  box-shadow: 0 0 0 1px var(--nr-accent);
  color: #ffffff;
}

.nr-pred-opt:disabled {
  cursor: not-allowed;
  opacity: 0.78;
}

/* Ranking Prediction List */
.nr-rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.75);
  color: #f1f5f9;
  font-size: 12px;
}

.nr-rank-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(30, 41, 59, 0.85);
  color: #e2e8f0;
  font-weight: 700;
  cursor: pointer;
}

.nr-rank-btn:hover:not(:disabled) {
  border-color: var(--nr-accent);
  color: var(--nr-accent);
}

/* Lock Gate Overlay over Lab Stage */
.nr-lab-lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(4, 9, 20, 0.84);
  backdrop-filter: blur(6px);
}

/* Primary Action Button */
.nr-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;
  letter-spacing: 0.01em;
  color: #020617;
  background: linear-gradient(135deg, var(--nr-accent), var(--nr-accent-2));
  border: none;
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

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

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

.nr-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.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* 2D / 3D Switcher Tabs */
.nr-view-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid var(--nr-border);
  gap: 3px;
}

.nr-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;
}

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

/* 3D Viewer Internal Overlay */
.nr3d-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 360px;
}

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

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

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

.nr3d-controls-mini {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

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

.nr3d-btn:hover {
  border-color: var(--nr-accent);
  color: var(--nr-accent);
}

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

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

.nr3d-tip-title {
  color: var(--nr-accent);
  font-size: 12px;
}

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

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

/* Toast Notification for Real-Action Achievements */
.nr-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(5, 16, 35, 0.96);
  border: 1px solid var(--nr-accent);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: nrToastPop 0.25s ease-out;
}

@keyframes nrToastPop {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Keyboard accessibility focus outline */
.nr-step-pill:focus-visible,
.nr-pred-opt:focus-visible,
.nr-btn-primary:focus-visible,
.nr-btn-secondary:focus-visible,
.nr-view-tab:focus-visible {
  outline: 2px solid var(--nr-accent);
  outline-offset: 2px;
}

/* Mobile & KaTeX horizontal overflow protection (390px+ viewports) */
html,
body {
  overflow-x: clip;
  max-width: 100%;
}

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

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

.katex {
  position: relative;
  max-width: 100%;
}

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