/* =========================================================================
   C//RT — design tokens
   Grounded in the subject: amber-phosphor CRT terminals (DEC VT220 / Wyse
   era) for the primary signal, a cool circuit-trace cyan for secondary
   information, and a hard coral for compiler errors. Everything else stays
   quiet so those three colors carry all the meaning.
   ========================================================================= */

:root {
  --bg-void: #0b0e14;
  --bg-panel: #11151c;
  --bg-panel-raised: #161b24;
  --border-subtle: #232b38;

  --ink: #e6e8eb;
  --ink-muted: #6e7887;

  --phosphor-amber: #ffb000;
  --phosphor-amber-dim: #997000;
  --circuit-cyan: #4fd1c5;
  --error-coral: #ff6b6b;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-void);
  color: var(--ink);
  font-family: var(--font-mono);
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------------------------------------------------------------------- */
/* Top bar                                                                 */
/* ---------------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand__mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.brand__slashes {
  color: var(--phosphor-amber);
}

.brand__tag {
  font-size: 0.7rem;
  color: var(--ink-muted);
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.topbar__file {
  font-size: 0.85rem;
  color: var(--ink-muted);
  padding: 3px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}

.topbar__controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--ink-muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  text-transform: lowercase;
}

.status-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.status-pill[data-stage="compiling"] .status-pill__dot {
  background: var(--phosphor-amber);
  animation: pulse 0.9s ease-in-out infinite;
}

.status-pill[data-stage="running"] .status-pill__dot {
  background: var(--circuit-cyan);
  animation: pulse 0.9s ease-in-out infinite;
}

.status-pill[data-stage="error"] .status-pill__dot {
  background: var(--error-coral);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .status-pill__dot { animation: none !important; }
}

.btn {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--circuit-cyan);
  outline-offset: 2px;
}

.btn--run {
  background: var(--phosphor-amber);
  color: #1a1200;
}

.btn--run:hover:not(:disabled) { filter: brightness(1.1); }

.btn--stop {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--ink-muted);
}

.btn--stop:hover:not(:disabled) { border-color: var(--error-coral); color: var(--error-coral); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------------- */
/* Workspace: editor + console split                                      */
/* ---------------------------------------------------------------------- */

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pane--editor {
  border-right: 1px solid var(--border-subtle);
}

.pane--editor .CodeMirror {
  height: 100%;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  background: var(--bg-void) !important;
  line-height: 1.55;
}

.pane--editor .CodeMirror-gutters {
  background: var(--bg-void) !important;
  border-right: 1px solid var(--border-subtle) !important;
}

.pane--editor .CodeMirror-linenumber {
  color: var(--ink-muted) !important;
}

.pane--editor .CodeMirror-cursor {
  border-left: 2px solid var(--phosphor-amber) !important;
}

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

.pane--console {
  position: relative;
  background: var(--bg-panel);
}

.console {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.console__line { display: block; }
.console__line--stdout { color: var(--ink); }
.console__line--stderr { color: var(--error-coral); }
.console__line--system { color: var(--ink-muted); }
.console__line--cmd { color: var(--circuit-cyan); }
.console__line--echo { color: var(--phosphor-amber); }

.console::-webkit-scrollbar { width: 8px; }
.console::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }

.console:focus { outline: none; }
.console:focus-visible { box-shadow: inset 0 0 0 1px var(--phosphor-amber-dim); }

/* The text the user has typed but not yet sent (no Enter pressed yet) -
   rendered inline at the end of the console, same color as a finalized
   echo line so it reads as "this is what you're about to send". */
.console__pending { color: var(--phosphor-amber); }

/* Blinking block cursor, sits right after whatever has been typed so far -
   this is what makes the console feel like a live terminal prompt rather
   than a passive output log. */
.console__cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 1px;
  background: var(--phosphor-amber);
  vertical-align: text-bottom;
  animation: blink-cursor 1s steps(1) infinite;
}

@keyframes blink-cursor {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .console__cursor { animation: none; }
}

/* Real input element kept for keyboard capture (desktop key events +
   mobile virtual keyboard), but never actually shown - the console div
   above renders everything the user sees. */
.stdin-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: none;
  padding: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------------- */
/* Status bar — surfaces the literal gcc invocation, nothing hidden       */
/* ---------------------------------------------------------------------- */

.statusbar {
  flex-shrink: 0;
  padding: 7px 18px;
  font-size: 0.75rem;
  color: var(--ink-muted);
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
}

.statusbar--error { color: var(--error-coral); }
.statusbar--ok { color: var(--circuit-cyan); }

/* ---------------------------------------------------------------------- */
/* Responsive: stack panes on narrow viewports                            */
/* ---------------------------------------------------------------------- */

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .pane--editor {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }
  .brand__tag { display: none; }
  .topbar__file { display: none; }
}
