/* ===================================================================
   Code Editor, Blank Slots, and Choice Chips Styling
   =================================================================== */

/* Code Display Area */
.code-container {
  flex: 1;
  overflow: auto;
  padding: 1.25rem 1.5rem;
  background: #0d121d;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.75;
  color: #e2e8f0;
  tab-size: 4;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

.code-line {
  display: flex;
  align-items: baseline;
  min-height: 1.85rem;
  gap: 1.25rem;
  min-width: max-content;
}

.code-line:hover {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
}

.line-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #475569;
  text-align: right;
  min-width: 2.2rem;
  user-select: none;
  opacity: 0.85;
  position: sticky;
  left: 0;
  background: #0d121d;
  padding-right: 0.35rem;
  z-index: 2;
}

.line-content {
  flex: 1;
  white-space: pre;
}

/* Syntax Highlighting Tokens */
.syn-keyword { color: #f472b6; font-weight: 600; }
.syn-func { color: #60a5fa; }
.syn-string { color: #a3e635; }
.syn-comment { color: #64748b; font-style: italic; }
.syn-number { color: #fb923c; }
.syn-param { color: #cbd5e1; }
.syn-op { color: #38bdf8; }

/* ===================================================================
   INTERACTIVE BLANK DROP SLOTS
   =================================================================== */
.blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  min-width: 130px;
  min-height: 38px;
  margin: 0 6px;
  padding: 4px 18px;
  background: rgba(30, 41, 59, 0.85);
  border: 1.5px dashed #475569;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  user-select: none;
}

.blank-slot:hover {
  border-color: var(--color-accent);
  background: rgba(56, 189, 248, 0.05);
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.2);
}

/* Slot states */
.blank-slot.drag-over {
  border-color: #38bdf8;
  border-style: solid;
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
  transform: scale(1.02);
}

.blank-slot.tap-target {
  border-color: var(--color-accent);
  border-style: solid;
  background: rgba(6, 182, 212, 0.15);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.25);
  animation: slot-pulse 1.2s infinite ease-in-out;
}

/* Active target slot waiting for next clicked option */
.blank-slot.is-active-target:not(.is-correct):not(.is-wrong) {
  border-color: var(--color-accent) !important;
  border-style: solid !important;
  background: rgba(6, 182, 212, 0.1) !important;
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.28) !important;
  animation: slot-pulse 1.5s infinite ease-in-out;
}

/* Blank Placeholder label when empty */
.slot-placeholder {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.slot-placeholder .slot-number {
  font-weight: 700;
  color: var(--color-accent);
  letter-spacing: 0.8px;
}

/* Correct Answer Slot State (Green Glow) */
.blank-slot.is-correct {
  border: 2px solid var(--color-correct) !important;
  background: var(--bg-correct-light) !important;
  box-shadow: var(--glow-correct) !important;
  cursor: default;
}

/* Wrong Answer Slot State (Red Glow + Shake) */
.blank-slot.is-wrong {
  border: 2px solid var(--color-wrong) !important;
  background: var(--bg-wrong-light) !important;
  box-shadow: var(--glow-wrong) !important;
}

/* Slot Content (Placed Chip) */
.placed-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-slot-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  margin-left: 6px;
  opacity: 0.75;
  transition: opacity var(--transition-fast);
}

.remove-slot-btn:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.7);
}

.blank-slot.is-correct .remove-slot-btn {
  display: none; /* Can't remove once correct */
}

/* ===================================================================
   CHOICE CHIPS IN THE RIGHT-SIDE BANK
   =================================================================== */
.choice-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  min-height: 40px;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e2e8f0;
  cursor: grab;
  user-select: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  touch-action: none; /* Critical for touch drag */
}

.choice-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), 0 0 12px rgba(56, 189, 248, 0.2);
}

.choice-chip:active {
  cursor: grabbing;
}

/* Dragging visual cue */
.choice-chip.is-dragging {
  opacity: 0.4;
  border-style: dashed;
  transform: scale(0.96);
}

/* Tap-to-Place Selected State (iPad & Mobile) */
.choice-chip.is-selected {
  outline: 2px solid var(--color-accent);
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--color-accent);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.5);
  transform: translateY(-2px);
}

/* Already Placed State in Choices Bank */
.choice-chip.is-placed {
  opacity: 0.35;
  background: var(--bg-primary);
  border-color: var(--border-subtle);
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: line-through;
  transform: none;
  box-shadow: none;
}

/* Touch clone while dragging on iPad/iPhone */
.touch-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  background: var(--bg-elevated);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6), 0 0 20px rgba(6, 182, 212, 0.5);
  transform: translate(-50%, -50%);
  opacity: 0.95;
}

/* ===================================================================
   HINT DRAWER / DETAILS
   =================================================================== */
.hint-active-slot {
  font-family: var(--font-mono);
  color: var(--color-accent);
  font-weight: 700;
}

.hint-why-bad {
  margin-top: 0.5rem;
  padding-left: 0.5rem;
  border-left: 3px solid var(--color-wrong);
  color: #fca5a5;
  font-size: 0.82rem;
}

.hint-direction {
  margin-top: 0.5rem;
  padding-left: 0.5rem;
  border-left: 3px solid var(--color-amber);
  color: #fef08a;
  font-size: 0.82rem;
}

/* ===================================================================
   INTERACTIONS LOCKED STATE (TIME-UP / COMPLETED)
   =================================================================== */
.interactions-locked {
  user-select: none;
}

.interactions-locked .choice-chip {
  cursor: not-allowed !important;
  opacity: 0.3 !important;
  pointer-events: none !important;
  transform: none !important;
  box-shadow: none !important;
}

.interactions-locked .blank-slot {
  cursor: default !important;
}

.interactions-locked .blank-slot:not(.is-correct) {
  border-color: #334155 !important;
  background: rgba(15, 23, 42, 0.6) !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}
