@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600;700&display=swap');

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

:root {
  --orange:  #e1510a;
  --orange-shadow: #a33a06;
  --black:   #111111;
  --fg:      #333333;
  --white:   #ffffff;
  --bg:      #1a1a1a;
  --panel:   #131313;
  --muted:   #a7acb2;
  --border:  #232323;
  --topbar-height: 56px;
}

body {
  font-family: 'Source Code Pro', ui-monospace, monospace;
  background: var(--bg);
  color: var(--white);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top Bar ── */
#topbar {
  height: var(--topbar-height);
  background: var(--fg);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  flex-shrink: 0;
  border-bottom: 1px solid #444;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 40%;
  min-width: 0;
}

#topbar-lesson-title {
  font-size: 0.72rem;
  font-weight: 400;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 18px rgba(255, 106, 0, 0.6);
  flex-shrink: 0;
}

.logo-chip {
  padding: 3px 8px;
  border: 1px solid #555;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.04em;
}

#lesson-select {
  flex: 1;
  max-width: 320px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid #555;
  border-radius: 6px;
  background: #222;
  color: var(--white);
  cursor: pointer;
  outline: none;
}

#lesson-select:focus { border-color: var(--orange); }
#lesson-select option { background: #222; }

.spacer { flex: 1; }

/* ── Buttons ── */
.btn {
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s;
  letter-spacing: 0.03em;
}

#btn-run {
  background: var(--orange);
  color: var(--black);
  box-shadow: 0 4px 0 var(--orange-shadow);
}

#btn-run:hover { background: #f05b0e; }

#btn-run:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--orange-shadow);
}

#btn-map {
  background: #2e2e2e;
  color: var(--white);
  box-shadow: 0 4px 0 #000;
  text-decoration: none;
}

#btn-map:hover { background: #3a3a3a; }

#btn-map:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #000;
}

#btn-complete {
  background: #2ecc71;
  color: #000;
  box-shadow: 0 4px 0 #1a7a44;
  font-weight: 900;
}

#btn-complete:hover { background: #35e07d; }

#btn-complete:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1a7a44;
}

#btn-reset {
  background: #2e2e2e;
  color: var(--white);
  box-shadow: 0 4px 0 #000;
}

#btn-reset:hover { background: #3a3a3a; }

#btn-reset:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #000;
}

/* ── Tabs ── */
#tab-bar {
  display: flex;
  background: #0f0f0f;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tab {
  flex: 1;
  padding: 10px 6px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover:not(.tab-locked) { color: var(--white); }

.tab-locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.tab-lock {
  font-size: 0.65rem;
  margin-left: 4px;
  color: #555;
  font-weight: 400;
}

.tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.tab-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2ecc71;
  color: #000;
  font-size: 12px;
  font-weight: 900;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1;
}

/* ── Challenge Panel ── */
#challenge-section {
  background: #0b0b0b;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#challenge-content {
  padding: 20px 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.challenge-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(225, 81, 10, 0.15);
  border: 1px solid rgba(225, 81, 10, 0.4);
  color: var(--orange);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.challenge-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 10px;
  line-height: 1.3;
}

.challenge-desc {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 14px;
}

.challenge-hints {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 16px;
}

.challenge-hints-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
  margin-bottom: 2px;
}

.challenge-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  background: #161616;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s;
}

.challenge-hint:hover { border-color: #444; }

.hint-label {
  color: var(--orange);
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.hint-label::after { content: ' — reveal'; font-weight: 400; color: #555; }

.hint-text {
  color: #a0a0a0;
}

/* Locked state — text hidden */
.challenge-hint.locked .hint-text {
  filter: blur(4px);
  pointer-events: none;
  color: #555;
}

.challenge-hint.locked .hint-label::after { content: ' — click to reveal'; font-weight: 400; color: #555; }

/* ── Main Split Layout ── */
#main {
  flex: 1;
  display: grid;
  grid-template-columns: 40fr 60fr;
  overflow: hidden;
}

/* ── Left Panel — Video + Commands ── */
#panel-video {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #000;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Video portion — fixed aspect ratio area */
#video-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #000;
  border-bottom: 1px solid var(--border);
}

#video-player {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  display: block;
  background: #000;
}

#vimeo-player {
  width: 100%;
}

#video-placeholder {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #0b0b0b;
}

#video-placeholder .icon { font-size: 3rem; }

#video-placeholder p {
  font-size: 0.8rem;
  text-align: center;
  max-width: 200px;
  line-height: 1.6;
  color: var(--muted);
}

#lesson-desc {
  padding: 8px 14px;
  background: var(--panel);
  color: var(--white);
  font-size: 0.92rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

/* Commands reference */
#commands-section {
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

#lesson-info {
  padding: 16px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lesson-summary {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.7;
}

.lesson-cmds-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--orange);
}

.lesson-cmds {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmd-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid #1e1e1e;
}

.cmd-item:last-child { border-bottom: none; }

.cmd-item code {
  font-family: 'Source Code Pro', ui-monospace, monospace;
  font-size: 0.78rem;
  color: #7dd3fc;
  white-space: nowrap;
  flex-shrink: 0;
}

.cmd-item span {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ── Right Panel — Editor + Canvas ── */
#panel-code {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
}

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

#editor-resize {
  height: 6px;
  background: var(--border);
  cursor: ns-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}

#editor-resize:hover,
#editor-resize.dragging {
  background: var(--orange);
}

.section-label {
  padding: 5px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: #0f0f0f;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}


#editor-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Ace editor */
#editor-wrapper {
  position: relative;
}

.ace_editor {
  font-family: 'Source Code Pro', ui-monospace, monospace !important;
  line-height: 1.65 !important;
}

.ace_gutter {
  background: #0f0f0f !important;
  border-right: 1px solid var(--border) !important;
}

/* Canvas section */
#canvas-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#turtle-output {
  flex: 1;
  background: #1a1a1a;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#skulpt-target {
  width: 100%;
  height: 100%;
  position: relative;
}

#output-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #888;
  pointer-events: none;
  background: #1a1a1a;
  z-index: 1;
}

#output-placeholder .icon { font-size: 2.5rem; }
#output-placeholder p { font-size: 0.8rem; color: #555; }

/* Console / error output */
#console-output {
  padding: 6px 14px;
  background: #0f0f0f;
  color: #ff6b6b;
  font-family: inherit;
  font-size: 0.78rem;
  max-height: 80px;
  overflow-y: auto;
  display: none;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#console-output.has-output { display: block; }
#console-output.info { color: #6ee7b7; }

/* ── Inline complete / submit button ── */
.btn-inline {
  display: block;
  margin-top: 16px;
  margin-left: auto;
  padding: 8px 18px;
  font-size: 0.85rem;
  background: #2ecc71;
  color: #000;
  box-shadow: 0 4px 0 #1a7a44;
  font-weight: 700;
}

.btn-inline:hover { background: #35e07d; }

.btn-inline:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #1a7a44;
}

.btn-inline.btn-video-locked,
.btn-inline:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-inline.btn-done {
  background: #1e5c38;
  color: #2ecc71;
  box-shadow: 0 2px 0 #0f2e1c;
  cursor: default;
}

.btn-inline.btn-done:hover { background: #1e5c38; }
.btn-inline.btn-done:active { transform: none; box-shadow: 0 2px 0 #0f2e1c; }

/* ── Toast notification ── */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 12px 24px;
  border-radius: 99px;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  z-index: 1000;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Input modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: #2a2a2a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 300px;
}

.modal-label {
  font-size: 0.9rem;
  color: var(--white);
  white-space: pre-wrap;
}

.modal-input {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--white);
  font-family: 'Source Code Pro', ui-monospace, monospace;
  font-size: 0.9rem;
  padding: 8px 10px;
  outline: none;
}

.modal-input:focus { border-color: var(--orange); }

