/* ============================================================
   extras.css — 快捷键练习 + 代码练习（TypingMaster 扩展视图）
   依赖 style.css 的主题变量（--accent / --card / --char-* 等）
   ============================================================ */

/* ============ 视图容器 ============ */
.view-shortcuts,
.view-code {
  display: none;
}
.view-shortcuts.active,
.view-code.active {
  display: block;
  animation: viewIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ============================================================
   快捷键练习
   ============================================================ */
.sc-cats { justify-content: center; margin-bottom: 18px; }

.sc-panel { padding: 26px 28px 22px; }

.sc-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.sc-counter {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light, #5C5448);
  background: var(--accent-light, rgba(193,138,74,0.10));
  padding: 4px 12px;
  border-radius: 14px;
}
.sc-cat-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-deep, #9C6A33);
  border: 1px solid var(--accent-glow, rgba(193,138,74,0.28));
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}
.sc-score { margin-left: auto; font-size: 13px; color: var(--text-muted, #8E8472); }
.sc-score b.ok { color: #3d9440; }
.sc-score b.err { color: var(--char-wrong, #C24A3F); }

.sc-stage {
  background: var(--card-alt, #FDF9F0);
  border: 1px solid var(--border, rgba(74,56,32,0.09));
  border-radius: 14px;
  padding: 44px 24px 40px;
  text-align: center;
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
  outline: none;
}
.sc-stage.ok-flash {
  border-color: rgba(76, 175, 80, 0.55);
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.12), var(--glow-sm, none);
}
.sc-stage.err-flash {
  border-color: rgba(194, 74, 63, 0.55);
  box-shadow: 0 0 0 4px rgba(194, 74, 63, 0.10), var(--glow-sm, none);
  animation: scShake 0.36s ease;
}
@keyframes scShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  55% { transform: translateX(6px); }
  80% { transform: translateX(-3px); }
}

.sc-desc {
  font-size: 21px;
  font-weight: 700;
  color: var(--text, #2A2620);
  margin-bottom: 20px;
  line-height: 1.5;
}
.sc-keys {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 64px;
}
.sc-keys .keycap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 46px;
  padding: 0 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--card, #FFFCF5), var(--bg-deep, #F5EEDF));
  border: 1px solid var(--border-strong, rgba(74,56,32,0.16));
  border-bottom-width: 3px;
  box-shadow: 0 2px 0 rgba(74,56,32,0.06), var(--glow-sm, none);
  font-family: var(--font-mono, 'JetBrains Mono', Consolas, monospace);
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #2A2620);
  letter-spacing: 0.02em;
}
.sc-keys .keycap.kc-hidden {
  filter: blur(10px);
  opacity: 0.5;
  user-select: none;
  pointer-events: none;
}
.sc-keys .sc-plus {
  color: var(--text-faint, #B8AE99);
  font-weight: 700;
}
.sc-keys .sc-arrow {
  color: var(--text-faint, #B8AE99);
  font-size: 18px;
  padding: 0 6px;
}

.sc-feedback {
  margin-top: 22px;
  font-size: 13.5px;
  color: var(--text-muted, #8E8472);
  min-height: 20px;
  transition: color 0.15s ease;
}
.sc-feedback.ok { color: #3d9440; font-weight: 600; }
.sc-feedback.err { color: var(--char-wrong, #C24A3F); font-weight: 600; }

.sc-progress-track {
  height: 5px;
  background: var(--canvas, #F2E8D5);
  border-radius: 3px;
  margin: 18px 0 16px;
  overflow: hidden;
}
.sc-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent, #C18A4A), var(--accent-warm, #D9A368));
  transition: width 0.3s ease;
}

.sc-tip { font-size: 12px; color: var(--text-faint, #B8AE99); margin-left: 6px; }

/* 完成面板 */
.sc-done { text-align: center; padding: 34px 28px 28px; }
.sc-done-actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
.sc-wrong-list {
  text-align: left;
  max-width: 520px;
  margin: 0 auto;
}
.sc-wrong-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--card-alt, #FDF9F0);
  border: 1px solid var(--border, rgba(74,56,32,0.09));
  margin-bottom: 8px;
  font-size: 13.5px;
}
.sc-wrong-item .sc-w-desc { flex: 1; color: var(--text, #2A2620); }
.sc-wrong-item .sc-w-keys { display: flex; gap: 5px; align-items: center; }
.sc-wrong-item .keycap {
  min-width: 30px; height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px;
  border-bottom-width: 2px;
}

/* ============================================================
   代码练习 —— 深色代码编辑器主题
   ============================================================ */
.code-lang-chips { justify-content: center; margin-bottom: 18px; }

/* ---- 编辑器外壳 ---- */
.code-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #26211A, #1E1A14);
  border: 1px solid rgba(193,138,74,0.22);
  border-radius: 14px;
  overflow: hidden;
  cursor: text;
  box-shadow: 0 18px 44px -18px rgba(30, 22, 10, 0.45), inset 0 1px 0 rgba(255,240,210,0.05);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.code-stage.focused {
  border-color: rgba(232,161,92,0.45);
  box-shadow: 0 18px 44px -16px rgba(30, 22, 10, 0.5), 0 0 0 3px rgba(193,138,74,0.14), inset 0 1px 0 rgba(255,240,210,0.06);
}
.code-stage.error-flash { border-color: rgba(224,108,117,0.6); }
.code-stage.ed-done {
  border-color: rgba(156,193,119,0.55);
  box-shadow: 0 18px 44px -16px rgba(30, 22, 10, 0.5), 0 0 0 3px rgba(156,193,119,0.16);
}

/* ---- 编辑器 chrome（macOS 窗口点 + 文件标签） ---- */
.ed-chrome {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255,236,200,0.04);
  border-bottom: 1px solid rgba(255,236,200,0.07);
  user-select: none;
}
.ed-dots { display: inline-flex; gap: 6px; }
.ed-dots i {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block;
}
.ed-dots i:nth-child(1) { background: #E06C60; }
.ed-dots i:nth-child(2) { background: #E2B54B; }
.ed-dots i:nth-child(3) { background: #8FBE6A; }
.ed-tab {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 12.5px;
  font-weight: 600;
  color: #E8DFC9;
  background: rgba(232,161,92,0.14);
  border: 1px solid rgba(232,161,92,0.2);
  border-bottom: none;
  padding: 4px 14px;
  border-radius: 8px 8px 0 0;
  position: relative;
  top: 11px;
  margin-top: -11px;
  padding-bottom: 10px;
}
.ed-lang {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232,223,201,0.45);
}

/* ---- 编辑器主体：行号 + 代码 ---- */
.ed-body {
  display: flex;
  overflow: auto;
  max-height: 430px;
  scroll-behavior: smooth;
  padding: 14px 0 18px;
}
.ed-gutter {
  flex: none;
  width: 52px;
  padding: 0 12px 0 0;
  text-align: right;
  user-select: none;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.85;
  color: rgba(232,223,201,0.18);
  background: linear-gradient(90deg, rgba(255,236,200,0.03), rgba(255,236,200,0));
  border-right: 1px solid rgba(255,236,200,0.06);
}
.ed-gutter .gl { transition: color 0.15s ease; }
.ed-gutter .gl.active { color: rgba(232,161,92,0.85); font-weight: 700; }

/* ---- 双栏：目标代码 + 我的代码 ---- */
.code-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .code-split { grid-template-columns: 1fr; }
}

/* 我的编辑器（textarea 叠加高亮层） */
.ed-user .ed-body { padding-bottom: 14px; }
.ed-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 260px;
}
.ed-highlight,
.ed-input {
  margin: 0;
  padding: 0 16px;
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre;
  tab-size: 4;
  border: 0;
}
.ed-highlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: #E8E0D0;
  pointer-events: none;
}
.ed-highlight .code-line { min-height: 1.85em; border-radius: 4px; }
.ed-highlight .code-line.active { background: rgba(232,161,92,0.09); }
.ed-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  color: transparent;
  caret-color: #E8A15C;
  resize: none;
  outline: none;
  overflow: auto;
}
.ed-input::selection { background: rgba(232,161,92,0.30); }
.ed-user.ed-done { border-color: rgba(156,193,119,0.55); }

/* ---- 代码文本 ---- */
.code-text {
  flex: 1;
  min-width: 0;
  padding: 0 20px 0 16px;
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre;
  tab-size: 4;
}
.code-line { min-height: 1.85em; border-radius: 4px; transition: background 0.15s ease; }
.code-line.active { background: rgba(232,161,92,0.07); box-shadow: inset 2px 0 0 rgba(232,161,92,0.5); }

/* 字符基础态：token 色 + 未输入时压暗 */
.code-text .ch {
  border-radius: 3px;
  position: relative;
  transition: color 0.12s ease, background 0.12s ease, opacity 0.15s ease;
}
.code-text .ch:not(.correct):not(.completed):not(.wrong) { opacity: 0.42; }
.code-text .ch.current { opacity: 1; background: rgba(232,161,92,0.16); }
/* 编辑器竖条光标 */
.code-text .ch.current::after {
  content: '';
  position: absolute;
  left: -1px;
  top: 0.1em;
  width: 2px;
  height: 1.5em;
  background: #E8A15C;
  border-radius: 1px;
  animation: caretBlink 1.05s steps(1) infinite;
}
@keyframes caretBlink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.code-text .ch.correct { opacity: 1; }
.code-text .ch.completed { opacity: 1; font-weight: 600; filter: brightness(1.12); }
.code-text .ch.wrong {
  opacity: 1;
  color: #2A1614 !important;
  background: rgba(224,108,117,0.75);
  font-weight: 700;
}
.code-text .ch.wrong.fresh { animation: wrongPop 0.5s var(--ease, ease); }

/* 换行符：不可见占位（宽度 0），仅供 Enter 判定 */
.code-text .ch.nl { width: 0; display: inline-block; overflow: hidden; }
.code-text .ch.space { /* 空格保持原样 */ }

/* ---- 语法高亮色板（暖色 IDE） ---- */
.code-text .tk-plain, .ed-highlight .tk-plain { color: #E8E0D0; }
.code-text .tk-kw, .ed-highlight .tk-kw    { color: #E8A15C; }  /* 关键字 */
.code-text .tk-fn, .ed-highlight .tk-fn    { color: #E5C07B; }  /* 函数名 */
.code-text .tk-str, .ed-highlight .tk-str   { color: #9CC177; }  /* 字符串 */
.code-text .tk-com, .ed-highlight .tk-com   { color: #7A7263; font-style: italic; }  /* 注释 */
.code-text .tk-num, .ed-highlight .tk-num   { color: #7FB4C9; }  /* 数字 */
.code-text .tk-pre, .ed-highlight .tk-pre   { color: #C893D6; }  /* 预处理 / DOCTYPE */
.code-text .tk-tag, .ed-highlight .tk-tag   { color: #E06C75; }  /* HTML 标签名 */
.code-text .tk-attr, .ed-highlight .tk-attr  { color: #D19A66; }  /* HTML 属性名 */
.code-text .tk-punc, .ed-highlight .tk-punc  { color: #A89B85; }  /* 标点 */

/* 题目卡片 */
.code-card {
  background: var(--card, #FFFCF5);
  border: 1px solid var(--border, rgba(74,56,32,0.09));
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  transition: transform 0.18s var(--ease, ease), box-shadow 0.18s var(--ease, ease), border-color 0.18s ease;
  box-shadow: var(--glow-sm, none);
  animation: viewIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.code-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-glow, rgba(193,138,74,0.28));
  box-shadow: var(--glow-md, none);
}
.cc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cc-diff {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
}
.cc-diff-basic    { background: rgba(76,175,80,0.12);  color: #3d9440; }
.cc-diff-medium   { background: var(--accent-light, rgba(193,138,74,0.10)); color: var(--accent-deep, #9C6A33); }
.cc-diff-advanced { background: rgba(194,74,63,0.10);  color: var(--char-wrong, #C24A3F); }
.cc-lines { font-size: 12px; color: var(--text-faint, #B8AE99); font-family: 'JetBrains Mono', Consolas, monospace; }
.cc-title { font-size: 16px; font-weight: 700; color: var(--text, #2A2620); margin-bottom: 6px; }
.cc-desc {
  font-size: 13px;
  color: var(--text-muted, #8E8472);
  line-height: 1.6;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* 卡片内代码预览条 */
.cc-preview {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-muted, #8E8472);
  background: var(--card-alt, #FDF9F0);
  border: 1px solid var(--border, rgba(74,56,32,0.08));
  border-radius: 8px;
  padding: 8px 12px;
  white-space: pre;
  overflow: hidden;
  max-height: 3.7em;
  margin-bottom: 14px;
  position: relative;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
}

/* 面板里的控制按钮间距（复用 typing-controls） */
.panel-typing .typing-controls { margin-top: 16px; }

/* 移动端适配 */
@media (max-width: 640px) {
  .sc-panel { padding: 20px 16px 18px; }
  .sc-stage { padding: 30px 12px 28px; }
  .sc-desc { font-size: 17px; }
  .sc-keys .keycap { min-width: 42px; height: 38px; font-size: 13px; padding: 0 10px; }
  .code-stage { border-radius: 12px; }
  .ed-body { max-height: 330px; }
  .ed-gutter { display: none; }
  .code-text { font-size: 12px; white-space: pre-wrap; word-break: break-all; padding: 0 12px; }
  .ed-highlight, .ed-input { font-size: 12px; white-space: pre-wrap; word-break: break-all; padding: 0 12px; }
  .ed-wrap { min-height: 200px; }
  .sc-top { flex-wrap: wrap; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sc-stage.err-flash { animation: none; }
  .code-text .ch.current::after { animation: none; }
  .view-shortcuts.active,
  .view-code.active { animation: none; }
}

/* 用户编辑器行号栏：随 textarea 滚动同步（overflow hidden） */
.ed-user .ed-gutter { overflow: hidden; }
