/* Base layout shared by Mac + Windows sims. OS-specific files override
   prompt colors, fonts, window chrome. */

:root {
  --bg: #1a1a1f;
  --bg-terminal: #0d0d12;
  --bg-instruction: #14141b;
  --border: #2a2a35;
  --text: #e6e6e6;
  --text-dim: #8a8a95;
  --text-muted: #5a5a65;
  --accent: #58a6ff;
  --green: #7ee787;
  --orange: #d4a574;
  --orange-bright: #ff9c4f;
  --red: #ff7b72;
  --purple: #bc8cff;
  --yellow: #ffd700;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Cascadia Mono', 'Menlo', 'Consolas', monospace;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: var(--left-width, 1fr) 6px 1fr;
  height: 100vh;
  height: 100dvh;
  background: var(--border);
}

.resizer {
  background: var(--border);
  cursor: col-resize;
  position: relative;
  user-select: none;
  transition: background 150ms;
}
.resizer::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 36px;
  background: var(--text-muted);
  border-radius: 1px;
  opacity: 0.5;
  transition: opacity 150ms, background 150ms;
}
.resizer:hover,
.resizer.dragging {
  background: rgba(88, 166, 255, 0.25);
}
.resizer:hover::before,
.resizer.dragging::before {
  opacity: 1;
  background: var(--accent);
}
body.resizing {
  cursor: col-resize;
  user-select: none;
}
body.resizing * {
  pointer-events: none;
}

/* --- LEFT PANEL: instruction --- */
.instruction-panel {
  background: var(--bg-instruction);
  padding: 32px 36px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.instruction-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-link {
  color: var(--text-muted);
  text-decoration: none;
}

.brand-link:hover {
  color: var(--text-dim);
}

.switch-os {
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 1px;
  text-transform: lowercase;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 3px;
  transition: border-color 150ms, color 150ms;
}

.switch-os:hover {
  color: var(--text);
  border-color: var(--accent);
}

.switch-os::before {
  content: '← ';
}

.restart-link {
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 1px;
  text-transform: lowercase;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}

.restart-link:hover {
  color: var(--text);
  border-color: var(--yellow);
}

.restart-link::before {
  content: '↻ ';
}

.progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--green);
  width: 0%;
  transition: width 300ms ease;
}

.progress-text {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 50px;
  text-align: right;
}

#instruction {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#instruction .step-num {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

#instruction h2 {
  font-size: 24px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

#instruction p,
#instruction .step-body {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.6;
}

#instruction .step-body ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

#instruction .step-body ul li {
  margin-bottom: 6px;
}

#instruction code {
  background: rgba(212, 165, 116, 0.15);
  color: var(--orange);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 14px;
}

.cmd-hint {
  background: var(--bg-terminal);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cmd-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.cmd-show {
  font-size: 16px;
  color: var(--green);
  background: transparent;
  padding: 0;
}

.hint {
  background: rgba(255, 215, 0, 0.08);
  border-left: 3px solid var(--yellow);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text);
  border-radius: 4px;
  line-height: 1.5;
}

/* "Heads up" inline callout — flags non-obvious context about a step
   (e.g. this URL is a practice stand-in, not a real repo). */
.sim-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(88, 166, 255, 0.07);
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.55;
}

.sim-note-label {
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  padding-top: 2px;
}

.sim-note-body {
  color: var(--text);
}

.sim-note-body code,
.sim-note-body strong {
  color: var(--text);
  font-weight: 600;
}

/* Educational prose sections — "What this does" / "Why it matters". */
.edu-block {
  border-left: 2px solid var(--border);
  padding: 2px 0 2px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.edu-block .edu-label {
  font-size: 11px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.edu-block p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.65;
}

.edu-block p strong {
  color: var(--text);
  font-weight: 600;
}

.edu-block p em {
  color: var(--text);
  font-style: italic;
}

/* "Key idea" chip — a compact green takeaway line. */
.key-idea {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(126, 231, 135, 0.06);
  border: 1px solid rgba(126, 231, 135, 0.25);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.55;
}

.key-idea-label {
  flex-shrink: 0;
  font-size: 10px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--green);
  font-weight: 700;
  padding-top: 2px;
}

.key-idea-body {
  color: var(--text);
}

.key-idea-body code,
.edu-block code {
  background: rgba(212, 165, 116, 0.15);
  color: var(--orange);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
  font-family: 'JetBrains Mono', 'Cascadia Mono', monospace;
}

.instruction-footer {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#mode-badge {
  padding: 4px 10px;
  border-radius: 3px;
  background: var(--border);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 1px;
}

#mode-badge.claude {
  background: rgba(255, 156, 79, 0.15);
  color: var(--orange-bright);
  animation: pulse 2s infinite;
}

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

/* --- RIGHT PANEL: terminal --- */
.terminal-panel {
  background: var(--bg-terminal);
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #1c1c24;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.title-text {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* Small chip in the terminal titlebar that always shows which mode
   accepts what — reinforces the shell vs claude distinction. */
#mode-chip {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap;
  font-family: 'JetBrains Mono', 'Cascadia Mono', monospace;
}

#mode-chip.claude {
  background: rgba(255, 156, 79, 0.15);
  color: var(--orange-bright);
  border-color: rgba(255, 156, 79, 0.4);
}

.terminal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.6;
}

.terminal-body::-webkit-scrollbar { width: 8px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.line {
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 2px;
}

.line-prompt { color: var(--text); }
.line-output { color: var(--text-dim); }
.line-system { color: var(--accent); font-style: italic; }
.line-error { color: var(--red); }
.line-ascii {
  color: var(--orange);
  font-size: 12px;
  line-height: 1.2;
  margin: 4px 0;
  font-family: inherit;
}

/* Teaching callout — warmer, softer than an error. Used when the sim
   spots a classic confusion (NL in shell, command in Claude mode). */
.line-teach {
  background: rgba(255, 156, 79, 0.07);
  border-left: 3px solid var(--orange-bright);
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 4px;
}
.line-teach .teach-title {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--orange-bright);
  margin-bottom: 6px;
}
.line-teach .teach-body {
  color: var(--text);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.55;
}

.input-line {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-top: 2px solid var(--green);
  background: #0a0a10;
  box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 2;
  transition: border-color 200ms, box-shadow 200ms;
}

.input-line.pulse {
  animation: input-pulse 900ms ease-out;
}

@keyframes input-pulse {
  0%   { box-shadow: 0 -10px 24px rgba(126, 231, 135, 0.55); }
  100% { box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.3); }
}

body.claude-mode .input-line {
  border-top-color: var(--orange-bright);
  box-shadow: 0 -8px 16px rgba(255, 156, 79, 0.15);
}

body.claude-mode .input-line.pulse {
  animation: input-pulse-claude 900ms ease-out;
}

@keyframes input-pulse-claude {
  0%   { box-shadow: 0 -10px 24px rgba(255, 156, 79, 0.6); }
  100% { box-shadow: 0 -8px 16px rgba(255, 156, 79, 0.15); }
}

#prompt {
  white-space: nowrap;
  margin-right: 4px;
}

#input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  caret-color: var(--green);
}

#input::placeholder { color: var(--text-muted); }

/* "working..." indicator shown during sim transitions (e.g. starting Claude). */
.busy-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  color: var(--orange-bright);
  font-size: 13px;
  font-style: italic;
}

.input-line.busy #prompt,
.input-line.busy #input {
  opacity: 0.35;
}

.input-line.busy .busy-indicator {
  display: inline-flex;
}

.busy-dots::after {
  content: '';
  display: inline-block;
  width: 18px;
  text-align: left;
  animation: busy-dots 1.2s steps(4, end) infinite;
}

@keyframes busy-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* claude mode visual treatment */
body.claude-mode .terminal-panel {
  border-left: 4px solid var(--orange-bright);
}

body.claude-mode #input {
  caret-color: var(--orange-bright);
}

.claude-prompt {
  color: var(--orange-bright);
  font-weight: bold;
}

/* completion overlay — covers the whole viewport so the card is always
   centered, regardless of desktop/mobile layout or viewport height. */
.completion {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 18, 0.97);
  z-index: 1000;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.completion.hidden { display: none; }

.completion-card {
  max-width: 480px;
  width: 100%;
  background: var(--bg-instruction);
  border: 1px solid var(--green);
  border-radius: 12px;
  padding: 36px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* Auto vertical margins center the card in a flex row container while
     still letting it scroll into view when taller than the viewport. */
  margin: auto 0;
  flex-shrink: 0;
}

.completion-icon {
  font-size: 48px;
  color: var(--green);
}

.completion-card h2 {
  font-size: 24px;
  color: var(--text);
  font-weight: 500;
}

.completion-card p {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
}

.completion-card p code {
  background: rgba(212, 165, 116, 0.15);
  color: var(--orange);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
  font-family: 'JetBrains Mono', 'Cascadia Mono', monospace;
}

.completion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.completion-note {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(88, 166, 255, 0.07);
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
  line-height: 1.55;
}

.completion-note-label {
  font-size: 10px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.completion-note-body {
  color: var(--text);
}

.completion-note-body code {
  background: rgba(212, 165, 116, 0.15);
  color: var(--orange);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
  font-family: 'JetBrains Mono', 'Cascadia Mono', monospace;
}

.completion-note-body strong {
  color: var(--text);
  font-weight: 600;
}

.reset {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}

.reset:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* mobile fallback */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    /* Cap the instruction panel so the terminal (and input line) always
       get at least ~55% of the viewport — otherwise tall step bodies push
       the prompt below the fold. */
    grid-template-rows: minmax(0, 45vh) 1fr;
  }
  .resizer { display: none; }
  .instruction-panel {
    padding: 20px 18px;
    max-height: 45vh;
  }
  #instruction h2 {
    font-size: 20px;
  }
  .terminal-body {
    font-size: 13px;
    padding: 12px 16px;
  }
  .input-line {
    padding: 12px 16px;
  }
  #input {
    font-size: 15px;
  }
}

/* Very short viewports (laptops, landscape phones). */
@media (max-height: 640px) {
  .instruction-panel {
    padding: 20px 24px;
    gap: 14px;
  }
  #instruction h2 { font-size: 20px; }
  .instruction-footer { padding-top: 12px; }
}
