/* =========================================================================
   RouterBaba Lab Page
   The in-lab layout: mission brief sidebar, sim canvas (map + console),
   hint trail, completion modal.
   ========================================================================= */

.lab-body {
  background: var(--bg, #0C1E2F);
  color: var(--text, #E8EEF5);
  margin: 0;
}

.lab-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header header"
    "sidebar canvas";
  height: 100vh;
  overflow: hidden;
}

/* ---------- Lab header strip ---------- */

.lab-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: rgba(0,0,0,0.25);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 10;
}

.lab-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lab-header .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.lab-header .brand img {
  width: 24px;
  height: 24px;
}

.lab-header .brand-name {
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  font-weight: 600;
}

.lab-breadcrumb {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  color: rgba(232, 238, 245, 0.5);
}

.lab-breadcrumb .crumb-arrow {
  margin: 0 0.5rem;
  color: rgba(232, 238, 245, 0.3);
}

.lab-breadcrumb .crumb-current {
  color: rgba(232, 238, 245, 0.9);
}

.lab-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lab-header-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(232, 238, 245, 0.85);
  padding: 0.4rem 0.875rem;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.lab-header-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.18);
}

.lab-header-btn[aria-expanded="true"] {
  background: rgba(245, 166, 35, 0.15);
  border-color: rgba(245, 166, 35, 0.3);
  color: #F7B84B;
}

/* ---------- Sidebar ---------- */

.lab-sidebar {
  grid-area: sidebar;
  background: rgba(0,0,0,0.15);
  border-right: 1px solid rgba(255,255,255,0.08);
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.lab-sidebar::-webkit-scrollbar {
  width: 6px;
}

.lab-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

/* ---------- Mission brief panel ---------- */

#mission-brief .brief-header {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

#mission-brief .brief-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(245, 166, 35, 0.12);
  color: #F5A623;
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
}

#mission-brief .brief-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: rgba(232, 238, 245, 0.5);
  display: flex;
  align-items: center;
}

#mission-brief .brief-title {
  font-family: 'Crimson Pro', serif;
  font-size: 1.625rem;
  font-weight: 700;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

#mission-brief .brief-headline {
  font-size: 1rem;
  font-weight: 500;
  color: rgba(232, 238, 245, 0.95);
  margin: 0 0 1rem;
  line-height: 1.5;
  padding-left: 0.875rem;
  border-left: 2px solid #F5A623;
}

#mission-brief .brief-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: rgba(232, 238, 245, 0.72);
  margin: 0 0 1rem;
}

#mission-brief .brief-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

#mission-brief .brief-meta-label {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(232, 238, 245, 0.4);
  margin-bottom: 0.25rem;
}

#mission-brief .brief-meta-value {
  display: block;
  font-size: 0.8125rem;
  color: rgba(232, 238, 245, 0.85);
}

/* ---------- Hint trail ---------- */

#hint-trail {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1.5rem;
}

.hint-trail-title {
  font-family: 'Crimson Pro', serif;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.375rem;
}

.hint-trail-sub {
  font-size: 0.8125rem;
  color: rgba(232, 238, 245, 0.55);
  margin: 0 0 1rem;
}

.hint-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hint-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  overflow: hidden;
}

.hint-reveal-btn {
  width: 100%;
  background: none;
  border: none;
  color: rgba(232, 238, 245, 0.85);
  padding: 0.625rem 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  font-size: 0.8125rem;
}

.hint-reveal-btn:hover {
  background: rgba(255,255,255,0.04);
}

.hint-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: rgba(245, 166, 35, 0.85);
}

.hint-icon {
  font-family: 'JetBrains Mono', monospace;
  color: rgba(232, 238, 245, 0.5);
  font-size: 0.875rem;
  width: 16px;
  text-align: center;
}

.hint-body {
  padding: 0 0.875rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: rgba(232, 238, 245, 0.78);
}

.hint-trail-foot {
  font-size: 0.75rem;
  color: rgba(232, 238, 245, 0.45);
  margin: 1rem 0 0;
  font-style: italic;
}

/* ---------- Learning outcomes ---------- */

#learning-outcomes {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1.5rem;
}

#learning-outcomes h3 {
  font-family: 'Crimson Pro', serif;
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.875rem;
}

.learning-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.learning-list li {
  position: relative;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: rgba(232, 238, 245, 0.72);
  margin-bottom: 0.625rem;
}

.learning-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  background: #F5A623;
  border-radius: 50%;
}

/* ---------- Canvas (where the simulator goes) ---------- */

.lab-canvas {
  grid-area: canvas;
  position: relative;
  overflow: hidden;
  background: #0A1825;
}

#sim-canvas {
  width: 100%;
  height: 100%;
}

/* Placeholder shown if engine is not yet wired */
.sim-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 2rem;
}

.sim-placeholder-card {
  max-width: 480px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 2rem;
}

.sim-placeholder-card h2 {
  font-family: 'Crimson Pro', serif;
  margin: 0 0 0.75rem;
}

.sim-placeholder-card p {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: rgba(232, 238, 245, 0.7);
  margin: 0 0 1rem;
}

.sim-placeholder-card code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.3);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  color: #F7B84B;
}

/* ---------- Help panel (walkthrough) ---------- */

.help-panel {
  position: fixed;
  top: 60px;
  right: 1.5rem;
  width: 380px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: #142838;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 1.25rem;
  z-index: 50;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}

.help-panel h3 {
  font-family: 'Crimson Pro', serif;
  margin: 0 0 0.75rem;
  font-size: 1.125rem;
}

.help-panel ol {
  padding-left: 1.25rem;
  margin: 0 0 1rem;
}

.help-panel li {
  font-size: 0.875rem;
  line-height: 1.55;
  color: rgba(232, 238, 245, 0.78);
  margin-bottom: 0.5rem;
}

.help-panel code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.3);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  color: #F7B84B;
}

/* ---------- Completion modal ---------- */

body.modal-open {
  overflow: hidden;
}

.completion-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modal-fade-in 0.3s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.completion-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(6px);
}

.completion-card {
  position: relative;
  max-width: 540px;
  width: 100%;
  background: linear-gradient(180deg, #1a3247 0%, #142838 100%);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 14px;
  padding: 2rem 2rem 1.75rem;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: modal-card-in 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-card-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.completion-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.completion-check {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.18);
  color: #4ADE80;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.completion-card h2 {
  font-family: 'Crimson Pro', serif;
  font-size: 1.5rem;
  margin: 0;
  font-weight: 600;
}

.completion-subtitle {
  font-size: 1.125rem;
  color: rgba(232, 238, 245, 0.72);
  margin: 0 0 1.5rem;
  font-style: italic;
}

.completion-learnings {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.completion-learnings h3 {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #F5A623;
  margin: 0 0 0.625rem;
}

.completion-learnings ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.completion-learnings li {
  position: relative;
  padding-left: 1.125rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: rgba(232, 238, 245, 0.85);
  margin-bottom: 0.5rem;
}

.completion-learnings li::before {
  content: "\u2713";
  position: absolute;
  left: 0;
  color: #4ADE80;
  font-weight: 700;
}

.completion-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.completion-actions .btn {
  flex: 1;
  min-width: 140px;
  text-align: center;
}

.completion-capstone-note {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.completion-capstone-note p {
  font-size: 0.9375rem;
  line-height: 1.55;
  color: rgba(232, 238, 245, 0.78);
  margin: 0;
}

/* ---------- Lab error state ---------- */

.lab-error {
  text-align: center;
  padding: 2rem;
}

.lab-error h2 {
  font-family: 'Crimson Pro', serif;
  margin: 0 0 1rem;
  color: #FF6B6B;
}

.lab-error p {
  color: rgba(232, 238, 245, 0.72);
  margin: 0 0 1.5rem;
}

/* ---------- Mobile ---------- */

@media (max-width: 880px) {
  .lab-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header"
      "sidebar"
      "canvas";
    height: auto;
    overflow: visible;
  }

  .lab-sidebar {
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .lab-canvas {
    min-height: 60vh;
  }

  .help-panel {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .completion-modal,
  .completion-card {
    animation: none;
  }
}
