/* ═══════════════════════════════════════
   LatexCraft v4.0 — editor.css
   Textarea, line numbers, syntax overlay, cursor, find bar
   ═══════════════════════════════════════ */

.editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-surface);
  position: relative;
}
.editor-wrap.focused {
  box-shadow: inset 0 0 0 1px var(--border-default);
}

.editor-area {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.line-numbers {
  width: 48px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-ghost);
  font: 400 12px/1.75 var(--font-editor);
  color: var(--text-muted);
  text-align: right;
  padding: 14px 8px 14px 0;
  user-select: none;
  overflow: hidden;
  white-space: pre;
}
.line-numbers .ln {
  display: block;
  padding-right: 4px;
  border-left: 2px solid transparent;
  margin-left: -4px;
  padding-left: 2px;
}
.line-numbers .ln.active { color: var(--text-secondary); font-weight: 600; }
.line-numbers .ln.error { border-left-color: var(--color-error); }
.line-numbers .ln.warn { border-left-color: var(--color-warning); }

.editor-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.editor-highlight, .editor-textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 14px 24px 14px 14px;
  font: 400 14px/1.75 var(--font-editor);
  white-space: pre;
  tab-size: 2;
  -moz-tab-size: 2;
  border: none;
  outline: none;
  background: transparent;
}

.editor-highlight {
  pointer-events: none;
  color: var(--text-primary);
  z-index: 1;
  overflow: hidden;
}
.editor-highlight.wrap { white-space: pre-wrap; word-break: break-word; }

.editor-textarea {
  z-index: 2;
  resize: none;
  color: transparent;
  caret-color: var(--accent);
  overflow: auto;
  width: 100%; height: 100%;
}
.editor-textarea.wrap { white-space: pre-wrap; word-break: break-word; }
.editor-textarea::selection { background: var(--bg-selection); }
.editor-textarea::-moz-selection { background: var(--bg-selection); }

/* Syntax tokens */
.tk-cmd     { color: var(--syn-command); }
.tk-env     { color: var(--syn-env); font-weight: 500; }
.tk-math    { color: var(--syn-math); }
.tk-comment { color: var(--syn-comment); font-style: italic; }
.tk-brace   { color: var(--syn-brace); }
.tk-bracket { color: var(--syn-option); }
.tk-string  { color: var(--syn-string); }
.tk-num     { color: var(--syn-num); }

/* Multi-cursor (extra carets) */
.multi-caret {
  position: absolute;
  width: 2px;
  background: var(--accent);
  opacity: 0.7;
  animation: pulse 1.1s infinite;
  pointer-events: none;
  z-index: 3;
}

/* Find bar */
.find-bar {
  height: 38px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
}
.find-bar .input { width: 200px; }
.find-bar .find-count {
  font: 600 10px/1 var(--font-editor);
  color: var(--text-muted);
  min-width: 56px;
  text-align: right;
}

/* Lint bar (issue list under editor) */
.lint-bar {
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font: 400 11px/1.4 var(--font-ui);
  color: var(--text-secondary);
  max-height: 110px;
  overflow-y: auto;
}
.lint-issue {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: background var(--t-fast);
}
.lint-issue:hover { background: var(--bg-hover); }
.lint-issue .ico {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lint-issue.error .ico { background: var(--color-error); }
.lint-issue.warn .ico { background: var(--color-warning); }
.lint-issue .ln {
  font-family: var(--font-editor);
  color: var(--text-muted);
  font-size: 10px;
}

/* Equation hover preview */
.eq-tooltip {
  position: fixed;
  z-index: 800;
  background: #fefefe;
  border: 1px solid #e0e0d8;
  border-radius: var(--r-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 16px;
  max-width: 480px;
  pointer-events: none;
  color: #1a1a2e;
  animation: fadeIn 150ms var(--ease-snap);
}
.eq-tooltip .katex { color: #1a1a2e; }

/* Find match highlights (we render them as decorations in the highlight overlay) */
.find-mark {
  background: rgba(245,158,11,0.30);
  border-radius: 2px;
}
.find-mark.current {
  background: rgba(245,158,11,0.55);
  outline: 1px solid var(--accent);
}
