/* ============================================================
   Debugger — Find It. Fix It.
   Palette follows the main CyberProgram site (teal / orange / aqua).
   ============================================================ */

:root {
  --teal:        #145C68;
  --teal-bright: #1fb6a8;
  --teal-light:  #1c8a9e;
  --teal-glow:   rgba(31,182,168,.35);
  --orange:      #FF5B00;
  --orange-glow: rgba(255,91,0,.35);
  --lime:        #D3CE16;
  --yellow:      #FACF00;
  --aqua:        #A0DAEF;
  --aqua-glow:   rgba(160,218,239,.22);
  --ok:          #4fe0a0;
  --err:         #ff6b7a;

  --bg-void:  #040d12;
  --bg-deep:  #071520;
  --bg-panel: #0b2030;
  --bg-card:  #0d2535;
  --bg-code:  #05121a;
  --border:   rgba(160,218,239,.14);
  --border-lit: rgba(160,218,239,.30);

  --text-primary:   #e8f4f8;
  --text-secondary: #88b8c8;
  --text-muted:     #4a7a8a;

  --font-display: 'Orbitron', sans-serif;
  --font-body:    'Exo 2', sans-serif;
  --font-mono:    'JetBrains Mono', 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;

  --bar-h: 60px;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* .btn sets display:inline-flex, which would otherwise beat the UA [hidden] rule */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg-void);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(160,218,239,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(160,218,239,.035) 1px, transparent 1px);
  background-size: 52px 52px;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
::selection { background: rgba(31,182,168,.35); }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(160,218,239,.16); border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(160,218,239,.3); }

/* ────────────────────────────────────────────────
   APP BAR
   ──────────────────────────────────────────────── */

.app-bar {
  flex: 0 0 var(--bar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: rgba(7,21,32,.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 20;
}
.app-bar::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg,transparent,var(--teal-bright),var(--orange),var(--lime),var(--teal-bright),transparent);
  background-size: 300% 100%;
  animation: scan 7s linear infinite;
  opacity: .8;
  /* Isolate this element's paint so the game's own frequent repaints
     (canvas redraws, mousemove) don't interrupt the gradient mid-cycle
     and make it look like it's flashing instead of fading smoothly. */
  contain: paint;
  will-change: background-position;
}
@keyframes scan { 0% { background-position: 0% 50%; } 100% { background-position: 300% 50%; } }

.brand { display: flex; align-items: center; gap: 11px; }
.brand__mark {
  width: 34px; height: 34px; flex: none;
  border: 2px solid var(--teal-bright); border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 900; font-size: 15px;
  color: var(--teal-bright);
  box-shadow: inset 0 0 14px rgba(31,182,168,.22), 0 0 12px rgba(31,182,168,.15);
}
.brand__text h1 {
  font-family: var(--font-display); font-size: 14px; font-weight: 700;
  letter-spacing: 2.6px; text-transform: uppercase;
}
.brand__text h1 span { color: var(--teal-bright); }
.brand__text p { font-size: 10.5px; color: var(--text-muted); letter-spacing: 1.1px; margin-top: 2px; }

.bar-spacer { flex: 1; }

.bar-track {
  display: none; align-items: center; gap: 9px;
  padding: 5px 13px 5px 8px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-panel);
  font-size: 12.5px;
}
.bar-track.show { display: flex; }
.bar-track__icon { font-family: var(--font-mono); font-size: 12px; color: var(--bg-void); background: var(--teal-bright);
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.bar-track__meter { width: 88px; height: 5px; border-radius: 3px; background: rgba(160,218,239,.14); overflow: hidden; }
.bar-track__fill { height: 100%; width: 0; background: linear-gradient(90deg,var(--teal-bright),var(--lime)); transition: width .45s ease; }
.bar-track__count { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-secondary); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 13px; font-weight: 500;
  transition: border-color .18s, background .18s, transform .12s, color .18s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-lit); background: var(--bg-card); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 2px; }
.btn--run { border-color: rgba(31,182,168,.45); color: var(--teal-bright); }
.btn--run:hover { background: rgba(31,182,168,.12); border-color: var(--teal-bright); }
.btn--check { border-color: rgba(255,91,0,.5); color: var(--orange); font-weight: 600; }
.btn--check:hover { background: rgba(255,91,0,.12); border-color: var(--orange); }
.btn--ghost { background: transparent; color: var(--text-secondary); }
.btn--sm { padding: 6px 11px; font-size: 12px; }
.btn[disabled] { opacity: .4; pointer-events: none; }

/* ────────────────────────────────────────────────
   PICKER (language chooser)
   ──────────────────────────────────────────────── */

.view { flex: 1; min-height: 0; position: relative; z-index: 1; }
.view[hidden] { display: none; }

.picker { height: 100%; overflow-y: auto; padding: 46px 24px 60px; }
.picker__inner { max-width: 1080px; margin: 0 auto; }

.eyebrow {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--orange); margin-bottom: 12px;
}
.picker h2 {
  font-family: var(--font-display); font-size: clamp(26px, 4vw, 40px);
  font-weight: 900; letter-spacing: 1px; line-height: 1.15;
}
.picker h2 em { font-style: normal; color: var(--teal-bright); }
.picker__lead {
  color: var(--text-secondary); max-width: 62ch; line-height: 1.65;
  margin-top: 16px; font-size: 15.5px;
}
.rule { height: 2px; width: 74px; margin: 22px 0 34px;
  background: linear-gradient(90deg,var(--orange),var(--teal-bright)); border-radius: 2px; }

.lang-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.lang-card {
  position: relative; overflow: hidden;
  text-align: left; width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 22px 20px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.lang-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
}
.lang-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 14px 34px rgba(0,0,0,.4); }
.lang-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.lang-card__icon {
  font-family: var(--font-mono); font-size: 20px; font-weight: 700;
  color: var(--accent); margin-bottom: 14px; letter-spacing: -1px;
}
.lang-card__name {
  font-family: var(--font-display); font-size: 19px; font-weight: 700;
  letter-spacing: 1.2px; margin-bottom: 8px;
}
.lang-card__tag { font-size: 12px; color: var(--accent); letter-spacing: .6px; margin-bottom: 12px; font-family: var(--font-mono); }
.lang-card__desc { font-size: 13.6px; line-height: 1.6; color: var(--text-secondary); flex: 1; }
.lang-card__foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--text-muted); font-family: var(--font-mono);
}
.lang-card__bar { flex: 1; height: 4px; border-radius: 2px; background: rgba(160,218,239,.13); overflow: hidden; }
.lang-card__bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s; }

.picker__note {
  margin-top: 34px; padding: 16px 18px;
  border-left: 2px solid var(--orange);
  background: rgba(255,91,0,.06);
  border-radius: 0 8px 8px 0;
  font-size: 13.5px; line-height: 1.65; color: var(--text-secondary);
}
.picker__note strong { color: var(--text-primary); }

/* ────────────────────────────────────────────────
   LESSON VIEW
   ──────────────────────────────────────────────── */

.lesson {
  height: 100%;
  display: grid;
  grid-template-columns: 330px minmax(0,1fr) minmax(0,1fr);
  min-height: 0;
}

/* ---- rail ---- */

.rail {
  border-right: 1px solid var(--border);
  background: var(--bg-deep);
  overflow-y: auto;
  display: flex; flex-direction: column;
}

.rail__head { padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
.rail__back { font-size: 12px; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.rail__back:hover { color: var(--teal-bright); }

.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.step {
  width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  font-family: var(--font-mono); font-size: 12px; color: var(--text-muted);
  display: grid; place-items: center;
  position: relative;
  transition: all .16s;
}
.step:hover { border-color: var(--border-lit); color: var(--text-primary); }
.step.is-debug { border-style: dashed; }
.step.is-done { background: rgba(79,224,160,.13); border-color: rgba(79,224,160,.5); color: var(--ok); }
.step.is-done::after { content: '✓'; font-size: 13px; }
.step.is-done span { display: none; }
.step.is-current {
  border-color: var(--teal-bright); color: var(--teal-bright);
  box-shadow: 0 0 0 2px rgba(31,182,168,.18);
}
.step.is-done.is-current { color: var(--ok); box-shadow: 0 0 0 2px rgba(79,224,160,.2); }
.steps__legend { font-size: 10.5px; color: var(--text-muted); margin-top: 10px; font-family: var(--font-mono); letter-spacing: .4px; }

.rail__body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 14px; }

.kicker {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 2.4px;
  text-transform: uppercase; display: flex; align-items: center; gap: 8px;
}
.kicker::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.kicker--learn { color: var(--teal-bright); }
.kicker--debug { color: var(--orange); }

.rail h2 {
  font-family: var(--font-display); font-size: 16px; font-weight: 700;
  line-height: 1.35; letter-spacing: .6px;
}

.prose { font-size: 14px; line-height: 1.68; color: var(--text-secondary); }
.prose p + p { margin-top: 10px; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose em { color: var(--aqua); font-style: normal; }
.prose code {
  font-family: var(--font-mono); font-size: 12.4px;
  color: var(--teal-bright); background: rgba(31,182,168,.1);
  padding: 1.5px 5px; border-radius: 4px;
  border: 1px solid rgba(31,182,168,.16);
}
.prose ul { margin: 10px 0 0 2px; list-style: none; }
.prose li { position: relative; padding-left: 18px; margin-bottom: 7px; }
.prose li::before {
  content: '▸'; position: absolute; left: 0; top: -1px;
  color: var(--teal-bright); font-size: 12px;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.panel--brief { border-left: 2px solid var(--orange); }
.panel--goal { border-left: 2px solid var(--aqua); }
.panel--cta { border-left: 2px solid var(--orange); display: flex; flex-direction: column; gap: 10px; }
.panel--cta .btn { align-self: flex-start; }

.btn--back-lesson { border-color: var(--border-lit); color: var(--text-secondary); }
.btn--back-lesson:hover { background: rgba(255,255,255,.04); }

.panel__title {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 9px;
}

/* checklist */
.checks { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checks li {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
}
.checks .mark {
  flex: 0 0 17px; height: 17px; margin-top: 1px; border-radius: 5px;
  border: 1.5px solid var(--text-muted);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--bg-void);
  transition: all .25s;
}
.checks li.pass .mark { background: var(--ok); border-color: var(--ok); }
.checks li.pass .mark::after { content: '✓'; }
.checks li.pass { color: var(--text-primary); }
.checks li.fail .mark { border-color: var(--err); color: var(--err); }
.checks li.fail .mark::after { content: '✕'; color: var(--err); }

/* hints */
.hint-box { margin-top: auto; }
.hint {
  border: 1px solid rgba(250,207,0,.28);
  background: rgba(250,207,0,.06);
  border-radius: 8px; padding: 11px 13px;
  font-size: 13px; line-height: 1.6; color: #f4e3a8;
  margin-bottom: 8px;
  animation: fadeIn .3s ease;
}
.hint b { color: var(--yellow); display: block; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 1.6px; text-transform: uppercase; margin-bottom: 5px; }
.hint code { font-family: var(--font-mono); font-size: 12.2px; color: var(--yellow); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.hint-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn--hint { border-color: rgba(250,207,0,.35); color: var(--yellow); }
.btn--hint:hover { background: rgba(250,207,0,.1); border-color: var(--yellow); }

.verdict {
  border-radius: 8px; padding: 11px 13px; font-size: 13.5px; line-height: 1.55;
  margin-bottom: 10px; animation: fadeIn .3s ease;
}
.verdict--win { background: rgba(79,224,160,.1); border: 1px solid rgba(79,224,160,.4); color: #b6f5da; }
.verdict--win strong { color: var(--ok); }
.verdict--no { background: rgba(255,107,122,.08); border: 1px solid rgba(255,107,122,.32); color: #ffc9ce; }
.verdict--no strong { color: var(--err); }

.rail__foot {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; background: var(--bg-deep);
  position: sticky; bottom: 0;
}
.rail__foot .btn { flex: 1; justify-content: center; }

/* ---- editor column ---- */

.col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.col + .col { border-left: 1px solid var(--border); }

.col__bar {
  flex: 0 0 42px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.col__label {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text-muted); white-space: nowrap;
}
.col__bar .spacer { flex: 1; }

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 5px 11px; border-radius: 6px 6px 0 0;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--text-muted);
  border: 1px solid transparent; border-bottom: none;
  white-space: nowrap;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--teal-bright); background: var(--bg-code); border-color: var(--border); }
.tab .lock { opacity: .55; margin-left: 5px; font-size: 10px; }

/* code editor */
.editor { flex: 1; position: relative; min-height: 0; background: var(--bg-code); display: flex; }
.gutter {
  flex: 0 0 46px; padding: 12px 8px 12px 0;
  text-align: right;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  color: rgba(74,122,138,.65);
  background: rgba(4,13,18,.5);
  border-right: 1px solid var(--border);
  overflow: hidden;
  user-select: none;
}
.gutter i { display: block; font-style: normal; }
.gutter i.mark-line { color: var(--err); font-weight: 700; }

.code-wrap { flex: 1; position: relative; min-width: 0; }

/* highlight layer + textarea must match exactly */
.code-layer {
  position: absolute; inset: 0;
  margin: 0; padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px; line-height: 1.6;
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  border: 0;
}
.code-hl { pointer-events: none; z-index: 1; color: var(--text-secondary); overflow: hidden; }
.code-ta {
  z-index: 2; resize: none; outline: none;
  background: transparent; color: transparent; caret-color: var(--teal-bright);
  -webkit-text-fill-color: transparent;
}
.code-ta::selection { background: rgba(31,182,168,.3); }
.code-ta[readonly] { caret-color: transparent; }
.editor.is-locked .code-hl { opacity: .62; }

.locked-note {
  position: absolute; right: 12px; bottom: 10px; z-index: 3;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 1px;
  color: var(--text-muted); background: rgba(4,13,18,.85);
  border: 1px solid var(--border); border-radius: 5px; padding: 4px 8px;
  pointer-events: none;
}

/* syntax colours */
.t-com  { color: #4a6b78; font-style: italic; }
.t-tag  { color: #ff7a3d; }
.t-atr  { color: var(--lime); }
.t-str  { color: #8fe3b0; }
.t-num  { color: #ffc46b; }
.t-key  { color: #6fb8ff; }
.t-fn   { color: var(--teal-bright); }
.t-sel  { color: var(--yellow); }
.t-prop { color: var(--teal-bright); }
.t-val  { color: #ffb27a; }
.t-punc { color: #6d90a0; }
.t-bltn { color: #c79bff; }

/* ---- output column ---- */

.out { flex: 1; min-height: 0; position: relative; background: #ffffff; }
.out--dark { background: var(--bg-code); }
.out iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

.console {
  height: 100%; overflow: auto; padding: 12px 14px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.62;
  color: #cfe3ef; white-space: pre-wrap; word-break: break-word;
}
.console .ln { padding: 1px 0; }
.console .ln--err { color: var(--err); }
.console .ln--warn { color: var(--yellow); }
.console .ln--info { color: var(--text-muted); }
.console .traceback {
  color: var(--err); background: rgba(255,107,122,.07);
  border-left: 2px solid var(--err); padding: 8px 11px;
  border-radius: 0 6px 6px 0; margin-top: 8px; white-space: pre-wrap;
}
.console .empty { color: var(--text-muted); font-style: italic; }
.console .stamp {
  color: var(--text-muted); font-size: 11px; letter-spacing: 1px;
  border-bottom: 1px dashed var(--border); padding-bottom: 6px; margin-bottom: 8px;
}

.split-out { display: flex; flex-direction: column; height: 100%; }
.split-out .out { flex: 1; min-height: 0; }
.split-out .console-pane {
  flex: 0 0 40%; min-height: 0; border-top: 1px solid var(--border);
  background: var(--bg-code); display: flex; flex-direction: column;
}
.console-pane__title {
  flex: none; padding: 6px 12px; font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.console-pane .console { flex: 1; }

.expected {
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 10px 14px;
  flex: none; max-height: 34%; overflow: auto;
}
.expected__title {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--aqua); margin-bottom: 7px;
}
.expected pre {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  color: var(--aqua); white-space: pre-wrap;
}
.expected p { font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--bg-card); border: 1px solid var(--teal-bright);
  color: var(--text-primary); padding: 12px 20px; border-radius: 999px;
  font-size: 13.5px; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.win { border-color: var(--ok); }

/* ────────────────────────────────────────────────
   RESPONSIVE
   ──────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .lesson { grid-template-columns: 290px minmax(0,1fr) minmax(0,1fr); }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .lesson {
    grid-template-columns: 1fr;
    grid-template-rows: auto 60vh 60vh;
    height: auto;
  }
  .rail { border-right: none; border-bottom: 1px solid var(--border); overflow: visible; }
  .rail__foot { position: static; }
  .col + .col { border-left: none; border-top: 1px solid var(--border); }
  .view { overflow: visible; }
}

@media (max-width: 640px) {
  /* let the bar wrap instead of pushing Run/Reset off the right edge */
  .app-bar { flex: none; height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand__text { display: none; }
  .bar-spacer { display: none; }
  .bar-track__meter { display: none; }
  .picker { padding: 30px 16px 50px; }
  .picker h2 { font-size: 26px; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
