/* =========================================================
   Developer Mode — IDE Experience Styles
   VS Code Dark+ palette, JetBrains Mono font
   ========================================================= */

/* ── Color Tokens ─────────────────────────────────────── */
:root {
  --syn-keyword:  #569cd6;
  --syn-fn:       #dcdcaa;
  --syn-var:      #9cdcfe;
  --syn-value:    #ce9178;
  --syn-comment:  #6a9955;
  --syn-string:   #4ec9b0;
  --syn-control:  #c586c0;
  --syn-linenum:  #3c3c3c;
  --syn-text:     #d4d4d4;
  --syn-op:       #d4d4d4;
  --syn-punct:    #808080;

  --ide-bg:         #151515;
  --ide-bg-sidebar: #1e1e1e;
  --ide-bg-tabbar:  #252526;
  --ide-bg-tab:     #2d2d2d;
  --ide-bg-tabact:  #1e1e1e;
  --ide-bg-status:  #007acc;
  --ide-bg-term:    #0d0d0d;
  --ide-border:     #2d2d2d;
  --ide-accent:     #008dff;
  --ide-text:       #cccccc;
  --ide-text-muted: #9ba4b5;
  --ide-text-head:  #f0f0f0;
}

/* ── Hide normal content when IDE is active ───────────── */
.dev-hidden {
  visibility: hidden;
  height: 0 !important;
  overflow: hidden;
  position: absolute;
  pointer-events: none;
}

/* ── IDE Root Shell ───────────────────────────────────── */
.ide-shell {
  display: grid;
  grid-template-rows: 36px 1fr auto 26px;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  width: 100%;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--ide-bg);
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  color: var(--ide-text);
  overflow: hidden;
  animation: ide-fade-in 0.2s ease forwards;
}

.ide-tabbar {
  grid-column: 1 / -1;
  grid-row: 1;
  background: var(--ide-bg-tabbar);
  border-bottom: 1px solid var(--ide-border);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
}

.ide-sidebar {
  grid-column: 1;
  grid-row: 2;
  background: var(--ide-bg-sidebar);
  border-right: 1px solid var(--ide-border);
  overflow-y: auto;
  overflow-x: hidden;
}

.ide-editor {
  grid-column: 2;
  grid-row: 2;
  background: var(--ide-bg);
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
}

.ide-terminal {
  grid-column: 2;
  grid-row: 3;
  background: var(--ide-bg-term);
  border-top: 1px solid var(--ide-border);
  display: flex;
  flex-direction: column;
  max-height: 280px;
  min-height: 180px;
}

.ide-statusbar {
  grid-column: 1 / -1;
  grid-row: 4;
  background: var(--ide-bg-status);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 0.7rem;
  color: #fff;
  user-select: none;
}

/* ── Animations ───────────────────────────────────────── */
@keyframes ide-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes ide-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

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

@keyframes type-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes boot-fade-out {
  0%   { opacity: 1; }
  100% { opacity: 0; pointer-events: none; }
}

@keyframes scanline-flicker {
  0%   { opacity: 0.97; }
  25%  { opacity: 1; }
  50%  { opacity: 0.98; }
  75%  { opacity: 1; }
  100% { opacity: 0.97; }
}

/* ── Boot Sequence Overlay ────────────────────────────── */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  animation: scanline-flicker 0.15s linear infinite;
  transition: opacity 0.4s ease;
}

.boot-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
}

.boot-overlay.boot-exit {
  animation: boot-fade-out 0.4s ease forwards;
}

.boot-terminal {
  max-width: 640px;
  width: 90%;
  padding: 2rem;
}

.boot-prompt {
  color: #569cd6;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.boot-line {
  color: #4ec9b0;
  font-size: 0.85rem;
  line-height: 2;
  animation: type-in 0.12s ease forwards;
}

.boot-line-err {
  color: #f44747;
}

.boot-cursor-wrap {
  margin-top: 0.25rem;
}

.boot-cursor {
  display: inline-block;
  width: 8px;
  height: 1rem;
  background: #4ec9b0;
  animation: blink 0.7s step-end infinite;
  vertical-align: text-bottom;
}

/* ── File Tree ────────────────────────────────────────── */
.file-tree {
  padding: 0;
  height: 100%;
  font-size: 0.78rem;
}

.file-tree-header {
  padding: 8px 12px 4px;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--ide-text-muted);
  text-transform: uppercase;
  user-select: none;
}

.file-tree-folder {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  color: var(--ide-text-muted);
  font-size: 0.75rem;
  user-select: none;
  cursor: default;
}

.file-tree-folder .folder-arrow {
  font-size: 0.6rem;
  color: var(--ide-text-muted);
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 28px;
  cursor: pointer;
  color: var(--ide-text);
  font-size: 0.78rem;
  border-left: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  user-select: none;
}

.file-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.file-item.file-active {
  background: rgba(0, 141, 255, 0.1);
  border-left-color: var(--ide-accent);
  color: var(--ide-text-head);
}

.file-icon {
  font-size: 0.7rem;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  color: var(--ide-text-muted);
}

.file-item.file-active .file-icon {
  color: var(--ide-accent);
}

/* ── Tab Bar ──────────────────────────────────────────── */
.tab-bar {
  display: flex;
  align-items: stretch;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.tab-bar::-webkit-scrollbar { height: 2px; }
.tab-bar::-webkit-scrollbar-track { background: var(--ide-bg-tabbar); }
.tab-bar::-webkit-scrollbar-thumb { background: #555; }

.ide-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border: none;
  border-right: 1px solid var(--ide-border);
  background: var(--ide-bg-tab);
  color: var(--ide-text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
  position: relative;
}

.ide-tab:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ide-text);
}

.ide-tab.tab-active {
  background: var(--ide-bg-tabact);
  color: var(--ide-text-head);
  border-top: 1px solid var(--ide-accent);
}

.tab-icon {
  font-size: 0.65rem;
  color: var(--ide-text-muted);
}

.ide-tab.tab-active .tab-icon {
  color: var(--ide-accent);
}

.tab-close {
  background: none;
  border: none;
  color: var(--ide-text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  font-family: inherit;
}

.ide-tab:hover .tab-close,
.ide-tab.tab-active .tab-close {
  opacity: 1;
}

.tab-close:hover {
  color: #f44747;
}

/* ── Syntax Colors ────────────────────────────────────── */
.syn-kw  { color: var(--syn-keyword); }
.syn-fn  { color: var(--syn-fn); }
.syn-var { color: var(--syn-var); }
.syn-val { color: var(--syn-value); }
.syn-cm  { color: var(--syn-comment); font-style: italic; }
.syn-str { color: var(--syn-string); }
.syn-ctl { color: var(--syn-control); }
.syn-op  { color: var(--syn-op); }
.syn-num { color: #b5cea8; }
.syn-prop{ color: var(--syn-fn); }

/* ── Code View ────────────────────────────────────────── */
.code-view {
  display: flex;
  min-height: 100%;
  font-size: 0.82rem;
  line-height: 1.7;
  tab-size: 2;
}

.code-gutter {
  min-width: 48px;
  padding: 1.5rem 12px 1.5rem 0;
  text-align: right;
  color: var(--syn-linenum);
  background: var(--ide-bg);
  border-right: 1px solid var(--ide-border);
  user-select: none;
  flex-shrink: 0;
  font-size: 0.75rem;
  line-height: 1.7;
  position: sticky;
  left: 0;
}

.code-gutter .ln {
  display: block;
  padding-right: 2px;
}

.code-body {
  flex: 1;
  padding: 1.5rem 2rem;
  white-space: pre;
  overflow-x: auto;
  min-width: 0;
}

.code-line {
  display: block;
  white-space: pre;
}

/* Blinking text cursor at end of code */
.code-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--ide-text);
  animation: blink 0.7s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}

/* Clickable references in code */
.code-link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(78, 201, 176, 0.4);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.code-link:hover {
  text-decoration-color: var(--syn-string);
}

/* ── Terminal ─────────────────────────────────────────── */
.term-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: #1a1a1a;
  border-bottom: 1px solid var(--ide-border);
  font-size: 0.68rem;
  color: var(--ide-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.term-title-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
}

.term-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.term-action-btn {
  background: none;
  border: none;
  color: var(--ide-text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.1s;
  font-family: inherit;
}

.term-action-btn:hover {
  color: var(--ide-text-head);
}

.term-output {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 0.78rem;
  line-height: 1.8;
}

.term-output::-webkit-scrollbar { width: 4px; }
.term-output::-webkit-scrollbar-track { background: transparent; }
.term-output::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.term-line-cmd { color: var(--ide-text-head); }
.term-line-out { color: #9ba4b5; }
.term-line-err { color: #f44747; }
.term-line-ok  { color: #4ec9b0; }

.term-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--ide-border);
  flex-shrink: 0;
}

.term-ps1 {
  color: #4ec9b0;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.term-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--ide-text-head);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  caret-color: #4ec9b0;
}

/* ── Status Bar ───────────────────────────────────────── */
.status-left,
.status-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.status-seg {
  padding: 0 8px;
  height: 26px;
  display: flex;
  align-items: center;
  font-size: 0.68rem;
  cursor: default;
  transition: background 0.1s;
}

.status-seg:hover {
  background: rgba(255, 255, 255, 0.1);
}

.status-seg-branch {
  background: rgba(255, 255, 255, 0.08);
}

.status-seg-hire {
  background: #16825d;
  color: #fff;
}

/* ── Dev Mode Toggle Pill ─────────────────────────────── */
.dev-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid #3c3c3c;
  border-radius: 100px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: #9ba4b5;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}

.dev-toggle-pill:hover {
  border-color: var(--ide-accent);
  color: var(--ide-text-head);
}

.dev-toggle-pill.dev-toggle-active {
  border-color: var(--ide-accent);
  color: var(--ide-accent);
  background: rgba(0, 141, 255, 0.08);
}

.dev-toggle-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3c3c3c;
  transition: background 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.dev-toggle-pill.dev-toggle-active .dev-toggle-dot {
  background: var(--ide-accent);
  box-shadow: 0 0 6px var(--ide-accent);
}

/* ── Mobile fallback ──────────────────────────────────── */
.ide-mobile-msg {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--ide-bg);
  color: var(--ide-text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  flex-direction: column;
  gap: 1rem;
}

.ide-mobile-msg p {
  color: var(--ide-text-muted);
  font-size: 0.75rem;
  line-height: 1.7;
}

/* ── Scrollbars (IDE areas) ───────────────────────────── */
.ide-editor::-webkit-scrollbar,
.ide-sidebar::-webkit-scrollbar { width: 6px; height: 6px; }
.ide-editor::-webkit-scrollbar-track,
.ide-sidebar::-webkit-scrollbar-track { background: transparent; }
.ide-editor::-webkit-scrollbar-thumb,
.ide-sidebar::-webkit-scrollbar-thumb { background: #3c3c3c; border-radius: 3px; }

/* ── Markdown code view (project detail) ─────────────── */
.md-view {
  padding: 2rem 2.5rem;
  max-width: 780px;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--ide-text);
}

.md-h1 { color: var(--ide-text-head); font-size: 1.3rem; margin-bottom: 0.5rem; font-weight: 700; }
.md-h2 { color: var(--syn-fn); font-size: 1rem; margin: 1.5rem 0 0.5rem; font-weight: 600; }
.md-h3 { color: var(--syn-var); font-size: 0.88rem; margin: 1rem 0 0.25rem; font-weight: 600; }
.md-p  { color: var(--ide-text-muted); margin-bottom: 0.75rem; }
.md-blockquote { border-left: 3px solid var(--ide-accent); padding-left: 1rem; color: var(--ide-text-muted); font-style: italic; margin: 0.75rem 0; }
.md-ul { list-style: none; padding: 0; margin: 0.5rem 0; }
.md-li { padding: 2px 0; color: var(--ide-text-muted); }
.md-li::before { content: '- '; color: var(--ide-text-muted); }
.md-link { color: var(--ide-accent); text-decoration: none; }
.md-link:hover { text-decoration: underline; }
.md-hr { border: none; border-top: 1px solid var(--ide-border); margin: 1.5rem 0; }
.md-tag-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.5rem 0; }
.md-tag { background: rgba(0, 141, 255, 0.12); color: var(--ide-accent); border-radius: 4px; padding: 2px 8px; font-size: 0.68rem; }
.md-meta { color: var(--syn-comment); font-size: 0.7rem; font-style: italic; }

@media (max-width: 768px) {
  .ide-shell {
    display: none;
  }
  .ide-mobile-msg {
    display: flex;
  }
}
