/* ==========================================================================
   MODEL QUEST — A Visual Gamified Data & Dimensional Modelling Platform
   Design System, Interactive Metaphors, Canvas, Graphics & Visual Engine
   Tagline: "See it. Build it. Break it. Fix it. Master it."
   ========================================================================== */

:root {
  --mq-bg: #030712;
  --mq-panel-bg: rgba(15, 23, 42, 0.88);
  --mq-panel-dark: rgba(2, 6, 23, 0.95);
  --mq-border: rgba(56, 189, 248, 0.2);
  --mq-border-glow: rgba(56, 189, 248, 0.45);
  
  /* Core Semantic Roles */
  --mq-fact: #10b981;
  --mq-fact-glow: rgba(16, 185, 129, 0.35);
  --mq-fact-dark: rgba(16, 185, 129, 0.08);

  --mq-dim: #38bdf8;
  --mq-dim-glow: rgba(56, 189, 248, 0.35);
  --mq-dim-dark: rgba(56, 189, 248, 0.08);

  --mq-grain: #f59e0b;
  --mq-grain-glow: rgba(245, 158, 11, 0.35);
  --mq-grain-dark: rgba(245, 158, 11, 0.08);
  
  --mq-bridge: #a855f7;
  --mq-bridge-glow: rgba(168, 85, 247, 0.35);
  --mq-bridge-dark: rgba(168, 85, 247, 0.08);

  --mq-snow: #67e8f9;
  --mq-degen: #f97316;
  --mq-date: #6366f1;
  --mq-danger: #ef4444;
  --mq-danger-glow: rgba(239, 68, 68, 0.35);
  --mq-purple: #c084fc;
}

.mq-container {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #e2e8f0;
  background: radial-gradient(circle at 50% 0%, rgba(30, 58, 138, 0.18) 0%, rgba(3, 7, 18, 0.98) 70%);
  border-radius: 14px;
  border: 1px solid var(--mq-border);
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
  margin-bottom: 2rem;
  position: relative;
}

/* --- Top Header & Quest Stats Bar --- */
.mq-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.35rem;
  background: rgba(2, 6, 23, 0.96);
  border-bottom: 1px solid var(--mq-border);
  flex-wrap: wrap;
  gap: 0.85rem;
}

.mq-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mq-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981 0%, #38bdf8 50%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.mq-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #34d399, #38bdf8, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mq-subtitle {
  margin: 0;
  font-size: 0.74rem;
  color: #94a3b8;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.mq-stats-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.mq-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
}

.mq-pill-xp {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.1);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.mq-pill-streak {
  color: #fb923c;
  border-color: rgba(251, 146, 60, 0.4);
  background: rgba(251, 146, 60, 0.1);
}

.mq-pill-grain {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
}

.mq-level-select {
  background: rgba(15, 23, 42, 0.9);
  color: #f1f5f9;
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.2);
}

.mq-level-select:focus {
  border-color: #c084fc;
}

/* --- Quest Navigation Tabs --- */
.mq-nav-tabs {
  display: flex;
  overflow-x: auto;
  background: rgba(2, 6, 23, 0.92);
  border-bottom: 1px solid rgba(56, 189, 248, 0.15);
  padding: 0.35rem 0.65rem;
  gap: 0.3rem;
  scrollbar-width: thin;
}

.mq-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.73rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.mq-tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.06);
}

.mq-tab-btn.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  font-weight: 700;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.2);
}

/* --- Main Content Stage --- */
.mq-stage {
  padding: 1.25rem;
  min-height: 600px;
}

/* --- Universal Visual Card System --- */
.mq-card {
  background: var(--mq-panel-bg);
  border: 1px solid var(--mq-border);
  border-radius: 12px;
  padding: 1.15rem 1.35rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
  margin-bottom: 1.25rem;
}

.mq-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  margin-bottom: 0.75rem;
}

/* --- Role Badges --- */
.mq-fact-badge {
  background: var(--mq-fact-dark);
  border: 1px solid var(--mq-fact);
  color: var(--mq-fact);
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.68rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.mq-dim-badge {
  background: var(--mq-dim-dark);
  border: 1px solid var(--mq-dim);
  color: var(--mq-dim);
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.68rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.mq-grain-badge {
  background: var(--mq-grain-dark);
  border: 1px solid var(--mq-grain);
  color: var(--mq-grain);
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.68rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

/* --- Visual Learning Map Grid --- */
.mq-map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.mq-map-node {
  background: rgba(2, 6, 23, 0.8);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mq-map-node:hover {
  transform: translateY(-3px);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 10px 25px rgba(56, 189, 248, 0.25);
}

.mq-map-node.completed {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

.mq-map-node.active-node {
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
}

.mq-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.mq-node-progress {
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  margin-top: 0.6rem;
  overflow: hidden;
}

.mq-node-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #38bdf8);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* --- ER Diagram Interactive Stage --- */
.mq-er-canvas {
  background: rgba(2, 6, 23, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 12px;
  padding: 1.5rem;
  min-height: 380px;
  position: relative;
  overflow: auto;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
}

.mq-table-entity {
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  font-size: 0.72rem;
  min-width: 170px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.mq-table-entity:hover {
  transform: translateY(-2px);
  border-color: #38bdf8;
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.3);
}

.mq-table-entity.selected {
  border-color: #10b981;
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.5);
}

.mq-table-entity.highlight-process {
  border-color: #f59e0b;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.6);
  animation: mq-pulse-process 1.5s infinite;
}

@keyframes mq-pulse-process {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.mq-entity-head {
  padding: 0.45rem 0.75rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px 7px 0 0;
}

.mq-entity-body {
  padding: 0.5rem 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  line-height: 1.6;
}

/* --- Solar System Star Schema Graphic --- */
.mq-solar-system {
  position: relative;
  width: 100%;
  max-width: 680px;
  height: 420px;
  margin: 1.25rem auto;
  border-radius: 14px;
  background: radial-gradient(circle at center, rgba(16, 185, 129, 0.12) 0%, rgba(2, 6, 23, 0.95) 75%);
  border: 1px dashed rgba(56, 189, 248, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.mq-sun-fact {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, #059669 0%, #064e3b 100%);
  border: 3px solid #10b981;
  box-shadow: 0 0 40px rgba(16, 185, 129, 0.55), inset 0 0 20px rgba(255, 255, 255, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mq-sun-fact:hover {
  transform: scale(1.08);
  box-shadow: 0 0 50px rgba(16, 185, 129, 0.75);
}

.mq-orbit-line {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(56, 189, 248, 0.3);
  pointer-events: none;
}

.mq-planet-dim {
  position: absolute;
  width: 105px;
  height: 105px;
  border-radius: 50%;
  background: radial-gradient(circle, #0284c7 0%, #0c4a6e 100%);
  border: 2px solid #38bdf8;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mq-planet-dim:hover {
  transform: scale(1.1);
  box-shadow: 0 0 35px rgba(56, 189, 248, 0.7);
}

/* --- Camera Zoom Grain Simulator --- */
.mq-zoom-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(2, 6, 23, 0.75);
  padding: 0.6rem 0.85rem;
  border-radius: 30px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  gap: 0.3rem;
}

.mq-zoom-step {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.mq-zoom-step.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fbbf24;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

/* --- Interactive Receipt Transformation Stage --- */
.mq-receipt-box {
  background: #f8fafc;
  color: #0f172a;
  border-radius: 10px;
  padding: 1.15rem 1.35rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.74rem;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.55);
  border-top: 6px dashed #94a3b8;
  border-bottom: 6px dashed #94a3b8;
}

.mq-receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
  border-bottom: 1px dotted #cbd5e1;
}

/* --- Measure Lab Buckets --- */
.mq-measure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.mq-measure-bucket {
  border-radius: 10px;
  padding: 1rem;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
  background: rgba(2, 6, 23, 0.6);
  transition: all 0.18s ease;
}

.mq-bucket-additive { border-color: rgba(16, 185, 129, 0.45); }
.mq-bucket-semi { border-color: rgba(245, 158, 11, 0.45); }
.mq-bucket-non { border-color: rgba(239, 68, 68, 0.45); }
.mq-bucket-desc { border-color: rgba(56, 189, 248, 0.45); }

.mq-chip {
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.12s, box-shadow 0.12s;
}

.mq-chip:hover {
  transform: translateY(-1px);
}

/* --- Crime Scene Detective Cards --- */
.mq-crime-card {
  padding: 1.15rem 1.35rem;
  border-radius: 10px;
  border: 1.5px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.04);
  margin-bottom: 1rem;
  transition: border-color 0.2s ease;
}

.mq-crime-card:hover {
  border-color: rgba(239, 68, 68, 0.6);
}

/* --- Model Inspector Panel --- */
.mq-inspector {
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid #38bdf8;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 0 0 25px rgba(56, 189, 248, 0.25);
  margin-top: 1.25rem;
}

.mq-inspector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.mq-inspector-cell {
  background: rgba(2, 6, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
}

/* --- Action Buttons --- */
.mq-btn {
  padding: 0.5rem 1.1rem;
  font-size: 0.76rem;
  font-weight: 700;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.18s ease;
  border: 1px solid transparent;
}

.mq-btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #fff;
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 16px rgba(37, 99, 235, 0.4);
}

.mq-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(37, 99, 235, 0.6);
}

.mq-btn-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.mq-btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.6);
}

.mq-btn-amber {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  color: #fff;
  border-color: rgba(245, 158, 11, 0.4);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
}

.mq-btn-amber:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(245, 158, 11, 0.6);
}

.mq-btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.15);
}

.mq-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.mq-btn-why {
  padding: 0.25rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 5px;
  background: rgba(129, 140, 248, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.35);
  color: #a5b4fc;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mq-btn-why:hover {
  background: rgba(129, 140, 248, 0.3);
  color: #fff;
  box-shadow: 0 0 10px rgba(129, 140, 248, 0.3);
}

.mq-btn-showme {
  padding: 0.25rem 0.6rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 5px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mq-btn-showme:hover {
  background: rgba(16, 185, 129, 0.3);
  color: #fff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

/* Animations */
@keyframes mq-pulse-fact {
  0% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 45px rgba(16, 185, 129, 0.75); }
  100% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.4); }
}

.mq-pulse {
  animation: mq-pulse-fact 2.5s infinite ease-in-out;
}

@keyframes mq-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mq-animate-fade {
  animation: mq-fade-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .mq-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .mq-stats-group {
    width: 100%;
    justify-content: flex-start;
  }
  .mq-solar-system {
    height: 340px;
  }
  .mq-sun-fact {
    width: 110px;
    height: 110px;
  }
  .mq-planet-dim {
    width: 80px;
    height: 80px;
    font-size: 0.65rem;
  }
}
