/* ============================================================================
 * GRADE 1 MONTESSORI INTERACTIVE MINI-LABS (`interactive_labs.css`)
 * Replaces old abstract 3D boxes with crisp, bright, self-explanatory
 * hands-on interactive simulations & games across all 16 lessons.
 * ============================================================================ */

#toyStageWrap.ilab-mode {
  background: linear-gradient(180deg, #FFFDF7 0%, #F4F8FF 100%) !important;
  border: 3.5px solid #D9B362 !important;
  border-radius: 22px !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
  align-items: stretch;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.8), 0 8px 24px rgba(15, 23, 42, 0.22) !important;
}

#toyStageWrap.ilab-mode #threeStageContainer {
  display: none !important;
}

#toyStageWrap.ilab-mode #widgetCanvas {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  flex: 1 1 auto !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  overflow: hidden;
}

.ilab-shell {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  color: #1E293B;
  user-select: none;
  overflow: hidden;
}

/* Top Mission Header */
.ilab-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: linear-gradient(90deg, #FFF8E7 0%, #FFFFFF 55%, #F0F9FF 100%);
  border-bottom: 2px solid #E2E8F0;
  flex-shrink: 0;
  z-index: 5;
}

.ilab-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.ilab-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
  color: #FFFFFF;
  background: #E11D48;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.ilab-mission {
  font-size: 16px;
  font-weight: 900;
  color: #1E293B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ilab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ilab-progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #FEF3C7;
  border: 2px solid #F59E0B;
  color: #92400E;
  font-size: 14px;
  font-weight: 900;
}
.ilab-progress-pill.done {
  background: #DCFCE7;
  border-color: #16A34A;
  color: #15803D;
}

.ilab-mini-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 2px solid #CBD5E1;
  background: #FFFFFF;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 #CBD5E1;
  transition: transform 0.12s, background 0.12s;
}
.ilab-mini-btn:hover {
  background: #F8FAFC;
  transform: translateY(-1px);
}
.ilab-mini-btn:active {
  transform: translateY(2px);
}

/* Main Lab Body */
.ilab-body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 10px 16px 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  overflow: hidden;
}

/* Keep bottom-left clear so floating Palworld companion & speech card never cover interactive pills */
.ilab-safe-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding-left: 470px;
  padding-right: 12px;
  flex-shrink: 0;
}

@media (max-width: 1180px) {
  .ilab-safe-footer {
    justify-content: center;
    padding-left: 160px;
    padding-right: 12px;
  }
}

/* Tactile Pills & Cards */
.ilab-pill {
  padding: 7px 14px;
  border-radius: 14px;
  border: 2.5px solid #CBD5E1;
  background: #FFFFFF;
  color: #1E293B;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #CBD5E1;
  transition: all 0.14s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ilab-pill:hover {
  transform: translateY(-2px);
  border-color: #94A3B8;
}
.ilab-pill.active {
  background: #FEF08A;
  border-color: #F59E0B;
  color: #92400E;
  box-shadow: 0 3px 0 #D97706;
}
.ilab-pill.done-item {
  border-color: #22C55E;
  background: #F0FDF4;
}

.ilab-cta-btn {
  padding: 8px 20px;
  border-radius: 999px;
  border: 2.5px solid #0284C7;
  background: linear-gradient(180deg, #38BDF8 0%, #0284C7 100%);
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 0 #0369A1;
  transition: transform 0.12s, filter 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ilab-cta-btn:hover {
  filter: brightness(1.06);
}
.ilab-cta-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0369A1;
}
.ilab-cta-btn.green {
  border-color: #15803D;
  background: linear-gradient(180deg, #4ADE80 0%, #16A34A 100%);
  box-shadow: 0 4px 0 #14532D;
}
.ilab-cta-btn.orange {
  border-color: #C2410C;
  background: linear-gradient(180deg, #FB923C 0%, #EA580C 100%);
  box-shadow: 0 4px 0 #9A3412;
}

/* Split Panels */
.ilab-grid-2 {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 14px;
  align-items: stretch;
}

.ilab-card {
  background: #FFFFFF;
  border: 2.5px solid #E2E8F0;
  border-radius: 20px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
  min-height: 0;
}

/* Universal Draggable Token */
.ilab-draggable {
  touch-action: none;
  cursor: grab;
  transition: box-shadow 0.15s, transform 0.15s;
  position: relative;
  z-index: 10;
}
.ilab-draggable:hover {
  transform: scale(1.06);
}
.ilab-draggable.dragging {
  cursor: grabbing;
  z-index: 90 !important;
  transition: none !important;
  filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.26));
}

.ilab-dropzone {
  transition: transform 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.ilab-dropzone.drop-hover {
  border-color: #F59E0B !important;
  background: #FEF9C3 !important;
  transform: scale(1.04);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.28) !important;
}

/* Toast Feedback Banner inside Lab */
.ilab-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  opacity: 0;
  pointer-events: none;
  padding: 7px 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #FEF08A;
  border: 2px solid #FACC15;
  font-size: 16px;
  font-weight: 900;
  z-index: 120;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ilab-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.ilab-toast.warn {
  background: #FFF1F2;
  color: #BE123C;
  border-color: #FB7185;
}
.ilab-toast.ok {
  background: #ECFDF5;
  color: #15803D;
  border-color: #22C55E;
}

/* FX Particle Canvas Overlay */
.ilab-fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 110;
}

/* Specific Mini-Lab Helpers */
.tianzige-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  border: 4px solid #DC2626;
  border-radius: 14px;
  background: #FFFDF9;
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.12);
  touch-action: none;
}
.tianzige-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* Montessori 5-Frame */
.m5-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 12px;
  background: #FEF3C7;
  border: 4px solid #D97706;
  border-radius: 20px;
  box-shadow: inset 0 3px 8px rgba(180, 83, 9, 0.12), 0 5px 0 #B45309;
  width: 100%;
  max-width: 430px;
}
.m5-slot {
  aspect-ratio: 1;
  min-height: 64px;
  background: #FFFBEB;
  border: 2.5px dashed #F59E0B;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  cursor: pointer;
  position: relative;
  transition: transform 0.14s, background 0.14s;
}
.m5-slot.filled {
  background: #FFFFFF;
  border-style: solid;
  border-color: #22C55E;
  box-shadow: 0 3px 8px rgba(34, 197, 94, 0.18);
}
.m5-slot-num {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 12px;
  font-weight: 900;
  color: #92400E;
}

/* Balance Scale */
.seesaw-stage {
  position: relative;
  width: 100%;
  max-width: 620px;
  height: 195px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.seesaw-beam {
  width: 88%;
  height: 12px;
  background: linear-gradient(90deg, #D97706, #F59E0B, #D97706);
  border: 2px solid #92400E;
  border-radius: 999px;
  position: relative;
  transform-origin: center center;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin-bottom: 46px;
}
.seesaw-pan {
  position: absolute;
  bottom: 12px;
  width: 156px;
  min-height: 68px;
  background: rgba(255, 255, 255, 0.94);
  border: 3px solid #0284C7;
  border-bottom-width: 6px;
  border-radius: 16px;
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 26px;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.seesaw-pan.left {
  left: -12px;
}
.seesaw-pan.right {
  right: -12px;
}
.seesaw-pivot {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

/* Number Bond Baskets */
.bond-baskets-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
}
.bond-basket {
  flex: 1;
  max-width: 240px;
  min-height: 124px;
  background: linear-gradient(180deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 3.5px solid #D97706;
  border-radius: 22px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 5px 0 #B45309;
}
.bond-apple-chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #FF6B6B, #DC2626);
  border: 2px solid #991B1B;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 #7F1D1D;
  cursor: grab;
}

/* Sorting Bins */
.sort-bins-row {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.sort-bin {
  flex: 1;
  max-width: 220px;
  min-height: 112px;
  border-radius: 20px;
  border: 3.5px dashed #64748B;
  background: #F8FAFC;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.sort-bin-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  min-height: 52px;
}
