/* editor.css: Code editor, line numbers, syntax highlight overlay */

/* -------------------------------------------------------------------------
   Main panel layout
------------------------------------------------------------------------- */
#main-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* -------------------------------------------------------------------------
   Two-pane main content: instructions column + editor/feedback column
------------------------------------------------------------------------- */
#main-columns {
  height: 100%;
  min-height: 0;
}
#info-col,
#editor-col {
  min-height: 0;
}

/* Below the two-pane breakpoint (Tailwind's lg, 1024px) #main-columns
   drops to a stacked column: without an explicit height split here,
   the instructions column would size to its content and push the editor
   column down, reintroducing page-level scrolling. */
@media (max-width: 1023px) {
  #info-col   { flex: 0 1 40%; }
  #editor-col { flex: 1 1 60%; }
}

/* Level intro entries have no code to run: hide the editor column
   entirely and let the instructions take the full width. */
#app.intro-mode #editor-col {
  display: none;
}
#app.intro-mode #info-col {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  border-right: none;
}
.intro-start-btn {
  display: block;
  margin: 24px 0 8px;
}

/* Challenge info + instructions */
#challenge-info {
  padding: 16px 20px 0;
  height: 100%;
  overflow-y: auto;
  border-bottom: 1px solid var(--border);
}

.challenge-header { margin-bottom: 10px; }

.challenge-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.challenge-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
}

.topic-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
}

.done-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
}

.project-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--accent-teal);
  color: var(--accent-teal);
}

.project-source {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
  margin: -2px 0 10px;
}

.instructions {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-primary);
  padding-bottom: 12px;
  max-width: 72ch;
}

.instructions p { margin-bottom: 8px; }
.instructions p:last-child { margin-bottom: 0; }
.instructions ul, .instructions ol { padding-left: 20px; }
.instructions li { margin-bottom: 4px; }
.instructions code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-surface0);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-teal);
}
.instructions strong { color: var(--accent); }

.task-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 20px 0 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.task-line { margin: 0 0 4px; }

.example-block {
  margin: 14px 0;
}
.example-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 8px;
}
/* Only the task's own "Example" label (the one after "Your Task") gets the
   purple treatment: the concept-level "Quick Example" stays plain, and
   "INPUT"/"OUTPUT" underneath it stay the same muted style either way. */
.task-label ~ .example-block .example-label {
  color: var(--accent-purple);
}
.io-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
}
.io-key {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.io-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  background: var(--bg-mantle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.note-block {
  display: block;
  margin: 10px 0 4px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
}
.note-label {
  font-weight: 700;
  color: var(--accent);
}
.note-label::after {
  content: ":";
}

.blueprint-line {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--bg-surface0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin: 10px 0;
  color: var(--accent-teal);
}
.blueprint-line code {
  background: none;
  padding: 0;
  color: inherit;
}

.example-block pre {
  background: var(--bg-surface0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0;
  overflow-x: auto;
}
.example-block pre code {
  display: block;
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-primary);
  font-size: 12.5px;
}
.code-line {
  display: block;
  line-height: 1.6;
}
.line-no {
  display: inline-block;
  width: 16px;
  color: var(--text-faint);
  user-select: none;
}
.line-code {
  white-space: pre;
}

/* Sits directly under the Quick Example's code block, sharing its border so
   the two read as one continuous box divided by a hairline. */
.example-block:has(+ .example-output) pre {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.example-output {
  background: var(--bg-surface0);
  border: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px 16px;
  margin: -14px 0 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
}
.example-output-val {
  color: var(--accent-green);
}


/* -------------------------------------------------------------------------
   Editor region
------------------------------------------------------------------------- */
.editor-region {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.editor-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: var(--bg-mantle);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.editor-filename { font-family: var(--font-mono); color: var(--accent-teal); }

/* Editor wrapper: holds line numbers + textarea + highlight overlay */
.editor-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-mantle);
}

/* Line numbers */
#line-numbers {
  width: 42px;
  padding: 12px 0;
  background: var(--bg-mantle);
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  text-align: right;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}

#line-numbers div {
  padding-right: 8px;
  height: calc(1.6em);
}

/* Syntax highlight overlay (behind textarea) */
#highlight-layer {
  position: absolute;
  left: 42px;
  top: 0;
  right: 0;
  bottom: 0;
  padding: 12px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: transparent;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  word-break: keep-all;
}

/* Actual textarea */
#code-editor {
  position: absolute;
  left: 42px;
  top: 0;
  right: 0;
  bottom: 0;
  padding: 12px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: transparent;       /* text hidden: highlight layer shows it */
  caret-color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  white-space: pre;
  overflow: auto;
  tab-size: 4;
  -moz-tab-size: 4;
  spellcheck: false;
}

/* Fallback: show text if highlight layer unavailable */
#code-editor:not(:focus) { color: transparent; }
#code-editor:focus { color: transparent; }

/* -------------------------------------------------------------------------
   Action bar (Run, Reset, Hint, Solution, Prev, Next)
------------------------------------------------------------------------- */
.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-mantle);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.action-bar .spacer { flex: 1; }

/* Keyboard shortcut labels */
.kbd {
  font-size: 10px;
  padding: 1px 5px;
  border: 1px solid var(--bg-surface1);
  border-radius: 3px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* -------------------------------------------------------------------------
   Feedback and output panels
------------------------------------------------------------------------- */
.feedback-zone {
  flex-shrink: 0;
  max-height: 28%;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

#hint-area {
  background: var(--bg-surface0);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--accent-yellow);
  display: none;
}

#hint-text strong { color: var(--text-primary); }

.feedback-panel {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.55;
  border-top: 1px solid var(--border);
}

.feedback-panel.success {
  background: color-mix(in srgb, var(--accent-green) 8%, transparent);
  color: var(--accent-green);
}

.feedback-panel.error {
  background: color-mix(in srgb, var(--accent-red) 8%, transparent);
  color: var(--accent-red);
}

.fb-icon {
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.fb-text { white-space: pre-line; }

.fb-traceback {
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg-mantle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-x: auto;
}

#explanation-panel {
  display: none;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.explanation {
  background: color-mix(in srgb, var(--accent-blue) 6%, transparent);
  border-left: 3px solid var(--accent-blue);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
}

.explanation strong {
  display: block;
  color: var(--accent-blue);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.explanation code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-surface0);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-teal);
}

.explanation p { margin-bottom: 6px; }
.explanation p:last-child { margin-bottom: 0; }

/* -------------------------------------------------------------------------
   Syntax highlight token colours
------------------------------------------------------------------------- */
.hl-keyword     { color: var(--accent); }
.hl-builtin     { color: var(--accent-teal); }
.hl-string      { color: var(--accent-green); }
.hl-number      { color: var(--accent-orange); }
.hl-comment     { color: var(--text-faint); font-style: italic; }
.hl-decorator   { color: var(--accent-yellow); }
.hl-function    { color: var(--accent-teal); }
.hl-operator    { color: var(--text-primary); }
.hl-punctuation { color: var(--text-muted); }
