/* ============================================================
   TechKriti Web Platform — Interactive Learning Labs & Studio
   Dark Luxury & Developer Studio Aesthetics
   ============================================================ */

/* ------------------------------------------------------------
   1. LABS CATALOG & MODULE BROWSER (Standard Shell)
   ------------------------------------------------------------ */
.labs-catalog-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
}

.labs-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-5);
}

.lab-course-card {
  background: linear-gradient(135deg, #1C1917 0%, #14110E 100%);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  position: relative;
  overflow: hidden;
}

.lab-course-card:hover {
  transform: translateY(-3px);
  border-color: rgba(194, 65, 12, 0.45);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.lab-course-card.locked {
  opacity: 0.65;
  filter: grayscale(0.2);
}
.lab-course-card.locked:hover {
  transform: none;
  border-color: var(--line-dark);
}

.lab-course-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.lab-course-icon {
  font-size: 2.2rem;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(194, 65, 12, 0.15);
  border: 1px solid rgba(194, 65, 12, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--saffron);
}

.lab-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
}
.lab-badge.active-badge {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.lab-badge.soon-badge {
  background: rgba(168, 162, 158, 0.12);
  color: #A8A29E;
  border: 1px solid rgba(168, 162, 158, 0.25);
}

.lab-course-card h3 {
  font-size: 1.3rem;
  color: var(--ink-inv);
  margin: 0;
}

.lab-course-card p {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-inv-2);
  margin: 0;
  flex: 1;
}

.lab-course-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line-dark);
  font-size: 0.8rem;
  color: var(--ink-3);
}

/* Modules List */
.labs-modules-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-4);
}

.lab-module-card {
  background: linear-gradient(135deg, #1A1714 0%, #12100E 100%);
  border: 1px solid var(--line-dark);
  border-radius: var(--r-xl);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-5);
  transition: all 0.2s ease;
}

.lab-module-card:hover {
  border-color: rgba(194, 65, 12, 0.45);
  transform: translateX(4px);
}

.lab-module-card.locked {
  opacity: 0.6;
}
.lab-module-card.locked:hover {
  border-color: var(--line-dark);
  transform: none;
}

.module-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.module-top-tags {
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-title {
  font-size: 1.25rem;
  color: #FAF6EE;
  margin: 0;
}

.module-desc {
  font-size: 0.86rem;
  line-height: 1.5;
  color: #A8A29E;
  margin: 0;
  max-width: 780px;
}

.module-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.module-tag-chip {
  font-size: 0.72rem;
  background: #241F1A;
  color: #D6D3D1;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #332C24;
}

/* ------------------------------------------------------------
   2. FULLSCREEN SIMULATION STUDIO (No Sidebar, 100vh, Zero-Scroll)
   ------------------------------------------------------------ */
.lab-fullscreen-root {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: #0C0A09;
  color: #FAF6EE;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
}

/* Studio Header Nav (48px) */
.lab-top-nav {
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  background: #14110E;
  border-bottom: 1px solid #241F1A;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
  gap: 12px;
}

.lab-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-back-lab {
  background: #1F1B17;
  color: #FAF6EE;
  border: 1px solid #332C24;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.btn-back-lab:hover {
  background: #2A241F;
  border-color: var(--saffron);
  color: #FFF;
}

.lab-breadcrumbs {
  font-size: 0.8rem;
  color: #78716C;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lab-breadcrumbs b {
  color: #FAF6EE;
}

.lab-top-presets {
  display: flex;
  align-items: center;
  gap: 6px;
}

.preset-chip-btn {
  background: #1C1814;
  color: #A8A29E;
  border: 1px solid #29241E;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-chip-btn:hover {
  background: #27211B;
  color: #FFF;
  border-color: #574B3E;
}
.preset-chip-btn.active {
  background: rgba(194, 65, 12, 0.25);
  border-color: var(--saffron);
  color: #FFF;
}

/* Status Pill */
.gd-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}
.badge-optimal {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border-color: rgba(16, 185, 129, 0.35);
}
.badge-vanishing {
  background: rgba(245, 158, 11, 0.18);
  color: #F59E0B;
  border-color: rgba(245, 158, 11, 0.4);
}
.badge-exploding {
  background: rgba(239, 68, 68, 0.22);
  color: #EF4444;
  border-color: rgba(239, 68, 68, 0.5);
  animation: explodePulse 1.2s infinite alternate;
}
.badge-converged {
  background: rgba(6, 182, 212, 0.15);
  color: #06B6D4;
  border-color: rgba(6, 182, 212, 0.35);
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
@keyframes explodePulse {
  0% { transform: scale(0.95); opacity: 0.85; }
  100% { transform: scale(1.05); opacity: 1; }
}

/* Main Studio Viewport Grid (100% height - 48px header) */
.gd-studio-grid {
  flex: 1;
  min-height: 0;
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 10px;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Left Column: Visualizers */
.gd-visual-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.gd-canvas-card {
  background: #13100E;
  border: 1px solid #241F1A;
  border-radius: 8px;
  padding: 8px 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.gd-canvas-card.card-surface {
  flex: 1.15;
  min-height: 0;
}

.gd-canvas-card.card-loss {
  flex: 0.85;
  min-height: 0;
}

.card-head-compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.card-head-compact h4 {
  font-size: 0.88rem;
  color: #FAF6EE;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-head-compact .sub-info {
  font-size: 0.74rem;
  color: #78716C;
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #0E0C0A;
}

.canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Right Column: Code & Controls */
.gd-control-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Algorithm Switcher Bar */
.algo-tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  flex-shrink: 0;
}

.algo-tab-btn {
  background: #171411;
  border: 1px solid #26211C;
  border-radius: 6px;
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #A8A29E;
}
.algo-tab-btn:hover {
  background: #201B17;
  color: #FAF6EE;
  border-color: #383027;
}
.algo-tab-btn.active {
  background: rgba(194, 65, 12, 0.2);
  border-color: var(--saffron);
  color: #FAF6EE;
}
.algo-tab-btn .tab-name {
  font-size: 0.8rem;
  font-weight: 700;
  display: block;
}
.algo-tab-btn .tab-sub {
  font-size: 0.68rem;
  color: #78716C;
  display: block;
}
.algo-tab-btn.active .tab-sub {
  color: var(--saffron);
}

/* Synchronized Code Terminal */
.code-terminal-card {
  background: #110E0C;
  border: 1px solid #241F1A;
  border-radius: 8px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.term-topbar {
  height: 26px;
  background: #181411;
  border-bottom: 1px solid #241F1A;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
}

.term-dots {
  display: flex;
  gap: 5px;
}
.term-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.term-dot.r { background: #EF4444; }
.term-dot.y { background: #F59E0B; }
.term-dot.g { background: #10B981; }

.term-filename {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #78716C;
}

.term-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.48;
}

.term-line {
  display: flex;
  align-items: baseline;
  padding: 2px 10px;
  transition: background 0.12s ease;
  position: relative;
}

.term-line.active-line {
  background: rgba(194, 65, 12, 0.28);
  border-left: 3px solid var(--saffron);
}

.term-ln {
  width: 22px;
  color: #574B3E;
  font-size: 0.7rem;
  user-select: none;
  flex-shrink: 0;
}

.term-text {
  color: #D6D3D1;
  white-space: pre;
}
.term-comment { color: #6B6357; font-style: italic; }
.term-kw      { color: #F97316; font-weight: 600; }
.term-var     { color: #38BDF8; }
.term-num     { color: #A78BFA; }

/* Active Line Explanation HUD */
.term-explainer {
  background: #181411;
  border-top: 1px solid #241F1A;
  padding: 5px 10px;
  font-size: 0.73rem;
  color: #FAF6EE;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.term-explainer .exp-icon {
  color: var(--saffron);
  font-weight: bold;
}

/* Controls & HUD Card */
.gd-controls-card {
  background: #13100E;
  border: 1px solid #241F1A;
  border-radius: 8px;
  padding: 8px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls-sliders-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #A8A29E;
}
.slider-label-row b {
  color: #FAF6EE;
  font-family: var(--font-mono);
}

.gd-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: #26211C;
  outline: none;
}
.gd-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--saffron);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(194, 65, 12, 0.6);
}

/* Playback Actions Bar */
.playback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ctrl {
  background: #1F1B17;
  color: #FAF6EE;
  border: 1px solid #332C24;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.btn-ctrl:hover {
  background: #2A241F;
  border-color: #574B3E;
}
.btn-ctrl.btn-play {
  background: var(--saffron);
  color: #FFF;
  border-color: var(--saffron);
}
.btn-ctrl.btn-play:hover {
  background: #EA580C;
}

.speed-group {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.speed-btn {
  background: #1A1713;
  color: #78716C;
  border: 1px solid #26211C;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}
.speed-btn.active {
  background: #C2410C;
  color: #FFF;
  border-color: #C2410C;
}

/* Telemetry HUD Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #0E0C0A;
  border: 1px solid #1E1A16;
  border-radius: 6px;
  padding: 6px 10px;
}

.telem-box {
  display: flex;
  flex-direction: column;
}
.telem-box .lbl {
  font-size: 0.66rem;
  color: #78716C;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.telem-box .val {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #FAF6EE;
}
.val-alert {
  color: #EF4444 !important;
}

/* Alert Banner (Vanishing / Exploding) */
.gd-alert-toast {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.74rem;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 8px;
}
.gd-alert-toast.toast-vanishing {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #FDE68A;
}
.gd-alert-toast.toast-exploding {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #FCA5A5;
}

/* Theory Drawer / Modal Overlay */
.gd-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gd-modal-content {
  background: #14110E;
  border: 1px solid #332C24;
  border-radius: 12px;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-sizing: border-box;
  color: #FAF6EE;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #26211C;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #A8A29E;
  font-size: 1.4rem;
  cursor: pointer;
}
.btn-close-modal:hover { color: #FFF; }

/* ============================================================
   LAB SHELL — Studio / Theory tab wrapper
   ============================================================ */
.lab-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px);
  min-height: 0;
}
.lab-shell-tabs {
  display: flex;
  gap: 6px;
  padding: 6px 10px 0;
  flex-shrink: 0;
  border-bottom: 1px solid #241F1A;
  background: #110E0C;
}
.lab-shell-tab {
  background: #171411;
  border: 1px solid #26211C;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: #A8A29E;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lab-shell-tab:hover { color: #FAF6EE; background: #201B17; }
.lab-shell-tab.active {
  background: rgba(194, 65, 12, 0.18);
  border-color: var(--saffron);
  color: #FAF6EE;
}
.lab-shell-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lab-shell-content .gd-studio-grid {
  height: calc(100vh - 48px - 42px);
  max-height: calc(100vh - 48px - 42px);
}

/* ============================================================
   THEORY PAGES
   ============================================================ */
.th-page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 26px 60px;
  box-sizing: border-box;
  color: #D6D3D1;
}
.th-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(194, 65, 12, 0.16), rgba(20, 17, 14, 0.6));
  border: 1px solid #332C24;
  border-radius: 12px;
  margin-bottom: 20px;
}
.th-hero-icon { font-size: 2.2rem; }
.th-hero-text { flex: 1; }
.th-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
  color: #FAF6EE;
  font-family: var(--font-display, "Fraunces", serif);
}
.th-subtitle { margin: 0; font-size: 0.86rem; color: #A8A29E; }
.th-back-btn { flex-shrink: 0; }

.th-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 22px;
  align-items: start;
}
.th-toc {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #14110E;
  border: 1px solid #241F1A;
  border-radius: 10px;
  padding: 12px;
}
.th-toc-head {
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  color: #78716C;
  margin-bottom: 8px;
}
.th-toc-link {
  display: block;
  padding: 6px 8px;
  border-radius: 6px;
  color: #A8A29E;
  text-decoration: none;
  font-size: 0.78rem;
  line-height: 1.35;
  transition: all 0.12s ease;
}
.th-toc-link:hover { background: #1F1B17; color: #FAF6EE; }
.th-toc-studio { margin-top: 10px; font-size: 0.78rem; padding: 8px; }

.th-body { max-width: 860px; }
.th-section {
  background: #14110E;
  border: 1px solid #241F1A;
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 16px;
  scroll-margin-top: 10px;
}
.th-section-title {
  margin: 0 0 12px;
  font-size: 1.02rem;
  color: #FAF6EE;
  border-bottom: 1px solid #26211C;
  padding-bottom: 8px;
}
.th-p { font-size: 0.87rem; line-height: 1.75; margin: 0 0 12px; color: #D6D3D1; }
.th-p b, .th-ul b, .th-ol b { color: #FAF6EE; }
.th-ul, .th-ol { margin: 0 0 12px; padding-left: 22px; font-size: 0.86rem; line-height: 1.75; }
.th-ul li, .th-ol li { margin-bottom: 5px; }
.th-formula {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  color: #FDBA74;
  background: #0E0C0A;
  border: 1px solid #2B241E;
  border-left: 3px solid var(--saffron);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 10px 0 14px;
  overflow-x: auto;
  white-space: nowrap;
}
.th-callout {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.83rem;
  line-height: 1.65;
  margin: 10px 0 14px;
}
.th-callout-info {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #BAE6FD;
}
.th-callout-warn {
  background: rgba(245, 158, 11, 0.09);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #FDE68A;
}
.th-callout-danger {
  background: rgba(239, 68, 68, 0.09);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #FCA5A5;
}
.th-table-wrap { overflow-x: auto; margin: 10px 0 14px; }
.th-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.th-table th {
  text-align: left;
  padding: 8px 10px;
  background: #1F1B17;
  color: #FAF6EE;
  border: 1px solid #2B241E;
  white-space: nowrap;
}
.th-table td {
  padding: 8px 10px;
  border: 1px solid #221D18;
  color: #D6D3D1;
  line-height: 1.5;
  vertical-align: top;
}
.th-table tr:nth-child(even) td { background: rgba(255, 255, 255, 0.015); }

@media (max-width: 900px) {
  .th-layout { grid-template-columns: 1fr; }
  .th-toc { position: static; }
  .th-page { padding: 14px 12px 40px; }
}
