/**
 * scoi-type / public/scoi-type.css
 * --------------------------------------------------------------------------
 * C++ 打字练习界面样式（深色编程风格），挂载在站点根路径 /scoi-type.css。
 * --------------------------------------------------------------------------
 */

/* ---------- 全局（沉浸式，真正铺满浏览器视口，无滚动） ---------- */
.st-app {
  --st-bg: #0f1420;
  --st-panel: #171e2e;
  --st-panel2: #1d2536;
  --st-border: #2a3448;
  --st-text: #e6edf7;
  --st-dim: #8b98b0;
  --st-green: #4ade80;
  --st-red: #f87171;
  --st-yellow: #fbbf24;
  --st-blue: #60a5fa;
  --st-char: #c9d4e6;
  box-sizing: border-box;
  background: var(--st-bg);
  color: var(--st-text);
  font-family: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 24px 24px;
}
.st-app *,
.st-app *::before,
.st-app *::after { box-sizing: inherit; }
.st-app button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏（全宽） ---------- */
.st-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--st-border);
}
.st-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--st-text);
}
.st-brand .st-brand-kbd { color: var(--st-blue); }
.st-back {
  display: inline-flex; /* 整框 flex，文字可真正垂直居中 */
  align-items: center;
  justify-content: center;
  background: var(--st-panel);
  color: var(--st-dim);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  margin: 0;
  padding: 11px 22px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: all 0.15s;
}
/* 悬停：与模式按钮 .st-mode-btn:hover 一致，边框变蓝、文字变亮 */
.st-back:hover {
  color: var(--st-text);
  border-color: var(--st-blue);
}
/* 按下/聚焦：与模式按钮激活态 .st-mode-btn--active 一致，蓝底白字 */
.st-back:active,
.st-back:focus,
.st-back:focus-visible {
  background: var(--st-blue);
  border-color: var(--st-blue);
  color: #fff;
  font-weight: 600;
  outline: none;
  box-shadow: none;
}

/* ---------- 主体布局（flex 撑满剩余高度） ---------- */
.st-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 0 0;
}
.st-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- 模式切换 ---------- */
.st-modes {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.st-mode-btn {
  background: var(--st-panel);
  color: var(--st-dim);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  padding: 11px 22px;
  font-size: 15px;
  transition: all 0.15s;
}
.st-mode-btn:hover { color: var(--st-text); border-color: var(--st-blue); }
.st-mode-btn--active {
  background: var(--st-blue);
  border-color: var(--st-blue);
  color: #fff;
  font-weight: 600;
}

/* ---------- 打字舞台（flex:1 自动填满剩余高度，目标文本居中） ---------- */
.st-stage {
  flex: 1;
  min-height: 0;
  background: var(--st-panel);
  border: 1px solid var(--st-border);
  border-radius: 16px;
  padding: 22px 32px 28px;
  display: flex;
  flex-direction: column;
}
.st-piece-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.st-piece-no { color: var(--st-dim); font-size: 16px; font-weight: 500; }
.st-piece-brief {
  color: var(--st-yellow);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.5;
  max-width: 100%;
  word-break: break-word;
}
.st-piece-brief:empty { display: none; }
.st-target {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 56px;
  line-height: 1.6;
  letter-spacing: 1.5px;
  word-break: break-word;
  user-select: none;
  -webkit-user-select: none;
  padding: 16px 8px;
}
.st-char {
  color: var(--st-char);
  border-radius: 6px;
  transition: background 0.1s, color 0.1s;
  padding: 1px 0;
}
.st-char--space { text-decoration: underline; text-decoration-color: rgba(139, 152, 176, 0.35); }

/* ---------- 代码段切换分隔符 ---------- */
.st-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  color: var(--st-dim);
  font-size: 28px;
}
.st-sep-line {
  flex: 1;
  max-width: 140px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--st-border), transparent);
  border-radius: 1px;
}
.st-sep-text {
  white-space: nowrap;
  letter-spacing: 1px;
  color: var(--st-blue);
  font-weight: 600;
}

/* 片段切换时 brief 闪烁 */
.st-piece-brief.st-flash {
  animation: st-snippet-flash 0.85s ease;
}
@keyframes st-snippet-flash {
  0% {
    background: rgba(96, 165, 250, 0.25);
    border-color: rgba(96, 165, 250, 0.6);
    box-shadow: 0 0 24px rgba(96, 165, 250, 0.35);
  }
  100% {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    box-shadow: none;
  }
}
.st-char--cur {
  background: var(--st-blue);
  color: #0b1220;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.35);
}
.st-char--done { color: var(--st-green); }
.st-char--done-all { color: var(--st-green); text-shadow: 0 0 10px rgba(74, 222, 128, 0.6); }
.st-char--err {
  color: var(--st-red);
  background: rgba(248, 113, 113, 0.18);
  text-decoration: underline wavy var(--st-red);
}

/* ---------- 统计条（放大） ---------- */
.st-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 18px;
}
.st-stat {
  background: var(--st-panel2);
  border: 1px solid var(--st-border);
  border-radius: 14px;
  padding: 16px 10px;
  text-align: center;
}
.st-stat-num {
  display: block;
  font-size: 34px;
  font-weight: 700;
  color: var(--st-blue);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.st-stat-label { color: var(--st-dim); font-size: 13px; margin-top: 6px; display: block; }

/* ---------- 操作区（开始/暂停/继续 + 结束 + 重新开始） ---------- */
.st-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.st-btn {
  background: var(--st-panel2);
  color: var(--st-text);
  border: 1px solid var(--st-border);
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 500;
  transition: all 0.15s;
}
.st-btn:hover:not(:disabled) { border-color: var(--st-blue); color: #fff; }
.st-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.st-btn-primary { background: var(--st-blue); border-color: var(--st-blue); color: #fff; font-weight: 600; }
.st-btn-primary:hover:not(:disabled) { background: #3b82f6; }
.st-btn-stop { background: var(--st-red); border-color: var(--st-red); color: #fff; font-weight: 600; }
.st-btn-stop:hover:not(:disabled) { background: #ef4444; border-color: #ef4444; }
.st-sound { color: var(--st-dim); font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* ---------- 结算面板 ---------- */
.st-done {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.st-done[hidden] { display: none; }
.st-done-card {
  background: var(--st-panel);
  border: 1px solid var(--st-border);
  border-radius: 18px;
  padding: 34px 40px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.st-done-card h2 { margin: 0 0 20px; font-size: 24px; }
.st-done-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.st-done-stats div {
  background: var(--st-panel2);
  border: 1px solid var(--st-border);
  border-radius: 10px;
  padding: 12px 6px;
}
.st-done-stats b { display: block; font-size: 20px; color: var(--st-green); font-variant-numeric: tabular-nums; }
.st-done-stats span { color: var(--st-dim); font-size: 11px; }
.st-done-msg { color: var(--st-text); font-size: 14px; line-height: 1.8; margin-bottom: 20px; }
.st-done-tip { color: var(--st-dim); font-size: 12px; }
.st-done-tip--ok { color: var(--st-green); }
.st-done-btns { display: flex; gap: 10px; justify-content: center; }

/* 移动端适配 */
@media (max-width: 640px) {
  .st-app { padding: 0 10px 24px; }
  .st-target { font-size: 30px; }
  .st-stage { padding: 16px 14px; }
  .st-stat-num { font-size: 24px; }
  .st-done-card { padding: 24px 18px; }
}
