/* ============================================================
 * Longlight - 长光雨滴小站 | 页面样式：index / 通用文本编辑器（vim）
 * pages/index/editor.css
 * 区块：整屏遮罩、编辑器主体、底部状态行、对话框 / 通知条
 * 说明：CodeMirror 5 自带的 codemirror.css / dialog.css 由 modules/index/editor/vendor.js
 *       在首次进入编辑器时动态注入，晚于本文件；故本文件的选择器一律以 .cui-editor 前缀
 *       提高优先级，覆盖其默认的黑白配色与 300px 固定高度，使编辑器与终端同肤（FE-07）
 *       分层：整屏遮罩置于 z-index:100（高于悬浮播放器 7 与点击涟漪 9，低于开屏 1000）
 *       不在本文件重复定义 :root / [data-theme]，颜色一律引用 tokens.css 令牌
 * ============================================================ */

/* ========== 整屏遮罩 ========== */
.cui-editor {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  animation: editorIn var(--duration-enter) var(--ease-out);
}

@keyframes editorIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ========== 编辑器主体 ========== */
.cui-editor-main {
  position: relative;   /* CodeMirror 绝对定位铺满于此 */
  flex: 1;
  min-height: 0;        /* flex 子项允许收缩，编辑器内部自行滚动 */
}

.cui-editor .CodeMirror {
  position: absolute;
  inset: 0;
  height: auto;         /* 覆盖 vendor 默认的 300px */
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 18px;    /* 与终端输出行同排版 */
  background: var(--bg-primary);
  color: var(--text-primary);
}

.cui-editor .CodeMirror-lines { padding: var(--space-card) 0; }

/* 行号栏 */
.cui-editor .CodeMirror-gutters {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
}
.cui-editor .CodeMirror-linenumber { color: var(--text-secondary); }

/* 光标与选区 */
.cui-editor .CodeMirror-cursor { border-left: 1px solid var(--green-primary); }
.cui-editor .CodeMirror-selected { background: color-mix(in srgb, var(--green-vibrant) 22%, transparent); }
.cui-editor .CodeMirror-focused .CodeMirror-selected { background: color-mix(in srgb, var(--green-vibrant) 30%, transparent); }
.cui-editor .CodeMirror-line::selection,
.cui-editor .CodeMirror-line > span::selection,
.cui-editor .CodeMirror-line > span > span::selection {
  background: color-mix(in srgb, var(--green-vibrant) 30%, transparent);
}

/* 滚动条填补块（与滚动条同色，避免露出白底） */
.cui-editor .CodeMirror-scrollbar-filler,
.cui-editor .CodeMirror-gutter-filler { background-color: var(--bg-surface); }

/* 括号匹配（matchbrackets.js） */
.cui-editor .CodeMirror-matchingbracket { color: var(--green-primary); font-weight: 600; }
.cui-editor .CodeMirror-nonmatchingbracket { color: var(--error); }

/* 中文输入法组字下划线 */
.cui-editor .CodeMirror-composing { border-bottom: 2px solid var(--green-primary); }

/* ========== 底部状态行 ========== */
.cui-editor-status {
  flex-shrink: 0;
  padding: var(--space-input) var(--space-page-mobile);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  font: var(--text-mono);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== 对话框 / 通知条（vim 的提示与 : 命令行） ========== */
/* 由 dialog.js 追加到 CodeMirror 包装元素内，位于编辑器底部 */
.cui-editor .CodeMirror-dialog {
  font: var(--text-mono);
  color: var(--text-primary);
  background: var(--bg-surface-emphasis);
}
.cui-editor .CodeMirror-dialog-bottom { border-top: 1px solid var(--border); }
.cui-editor .CodeMirror-dialog input {
  font-family: var(--font-mono);
  color: var(--text-primary);
  caret-color: var(--green-primary);
}
.cui-editor .CodeMirror-dialog button {
  color: var(--text-primary);
  background: var(--bg-surface);
  border: var(--border-default);
  border-radius: var(--radius-btn);
}
