/* ============================================================
   FunCode OJ · 打字练习「浅蓝梦幻」皮肤 + 按键火花 (v42)
   ------------------------------------------------------------
   - 只在 templates/tools/typing.html 加载，位于 tools.css 之后，
     通过覆盖 .type-page 的自有 CSS 变量换肤，不改动原有布局与交互。
   - 浅蓝 / 天蓝 / 淡紫低饱和渐变；火花轻量、短时、数量受限（不夸张）。
   - 自动适配 html.dark；prefers-reduced-motion 下完全关闭动态效果。
   ============================================================ */

.type-page {
  --type-glass:        rgba(255, 255, 255, .72);
  --type-glass-2:      rgba(238, 248, 255, .58);
  --type-stroke:       rgba(146, 202, 244, .52);
  --type-glow-a:       rgba(124, 196, 255, .46);
  --type-glow-b:       rgba(168, 226, 255, .42);
  --type-glow-c:       rgba(199, 183, 255, .34);
  --type-ok:           #1f8fc9;
  --type-bad:          #e08aa6;
  --type-accent:       #3a8fd8;
  --type-ink-soft:     #6a89a7;
  --type-panel-shadow: 0 18px 46px rgba(66, 138, 202, .16);
  color: #2e5476;
}

html.dark .type-page {
  --type-glass:        rgba(20, 42, 64, .64);
  --type-glass-2:      rgba(22, 46, 70, .48);
  --type-stroke:       rgba(122, 190, 240, .24);
  --type-glow-a:       rgba(72, 152, 232, .34);
  --type-glow-b:       rgba(96, 178, 236, .28);
  --type-glow-c:       rgba(158, 138, 232, .24);
  --type-ok:           #79cdf5;
  --type-bad:          #ee9ab2;
  --type-accent:       #87cdf7;
  --type-ink-soft:     #9ab6cd;
  --type-panel-shadow: 0 18px 46px rgba(0, 0, 0, .42);
  color: #d5e9fa;
}

/* ---------- 梦境底光：更柔和的浅蓝渐层 + 细微星尘 ---------- */
.type-page .type-bg {
  background:
    radial-gradient(700px 400px at 6% -4%, rgba(158, 216, 255, .38), transparent 64%),
    radial-gradient(640px 380px at 98% 4%, rgba(190, 224, 255, .36), transparent 62%),
    radial-gradient(620px 440px at 50% 108%, rgba(203, 190, 255, .28), transparent 68%),
    linear-gradient(160deg, rgba(232, 246, 255, .46), rgba(245, 240, 255, .24) 55%, rgba(226, 244, 255, .40));
}
html.dark .type-page .type-bg {
  background:
    radial-gradient(700px 400px at 6% -4%, rgba(58, 128, 205, .30), transparent 64%),
    radial-gradient(640px 380px at 98% 4%, rgba(84, 152, 216, .26), transparent 62%),
    radial-gradient(620px 440px at 50% 108%, rgba(126, 104, 208, .22), transparent 68%),
    linear-gradient(160deg, rgba(16, 36, 60, .62), rgba(24, 40, 68, .40));
}
.type-page .type-orb { opacity: .42; filter: blur(34px); }
.type-page .type-spark {
  background: #ffffff;
  box-shadow: 0 0 12px 3px rgba(150, 210, 255, .72);
  opacity: .62;
}

/* ---------- 标题 / 状态胶囊 ---------- */
.type-page .type-title {
  background: linear-gradient(105deg, #2f7fc4 0%, #4aa6e0 40%, #8b8ce4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 6px 22px rgba(90, 160, 230, .18);
}
html.dark .type-page .type-title {
  background-image: linear-gradient(105deg, #8ed0ff 0%, #a7d8ff 42%, #c3b6ff 100%);
}
.type-page .type-subtitle { color: var(--type-ink-soft); }
.type-page .type-status {
  color: #2b78bc;
  background: linear-gradient(135deg, rgba(226, 244, 255, .88), rgba(240, 234, 255, .80));
  border-color: rgba(140, 198, 244, .55);
  box-shadow: 0 5px 16px rgba(100, 170, 230, .16);
}
html.dark .type-page .type-status {
  color: #a8d8ff;
  background: linear-gradient(135deg, rgba(32, 64, 96, .82), rgba(46, 58, 100, .72));
  border-color: rgba(122, 190, 240, .26);
}

/* ---------- 面板：更通透的玻璃蓝 ---------- */
.type-page .type-panel {
  background: var(--type-glass);
  border-color: var(--type-stroke);
  box-shadow: var(--type-panel-shadow), inset 0 1px 0 rgba(255, 255, 255, .55);
}
html.dark .type-page .type-panel { box-shadow: var(--type-panel-shadow), inset 0 1px 0 rgba(255, 255, 255, .05); }
.type-page .type-board {
  position: relative;
  background: linear-gradient(155deg, rgba(255, 255, 255, .80), rgba(232, 246, 255, .66));
  border-color: rgba(146, 202, 244, .58);
}
html.dark .type-page .type-board {
  background: linear-gradient(155deg, rgba(20, 44, 68, .74), rgba(26, 50, 80, .62));
}

/* ---------- 控制台 ---------- */
.type-page .type-mode-btn.type-is-active {
  background: linear-gradient(135deg, #63b4ee, #8fc6f5 55%, #b3aaf2);
  box-shadow: 0 8px 20px -6px rgba(80, 150, 230, .68);
  color: #fff;
}
.type-page .type-mode-btn:hover { border-color: #7cc0ee; }
.type-page .type-select { background: var(--type-glass-2); border-color: var(--type-stroke); }

/* ---------- 实时数据 / 进度 ---------- */
.type-page .type-stat {
  background: linear-gradient(155deg, rgba(255, 255, 255, .76), rgba(230, 245, 255, .60));
  border-color: rgba(146, 202, 244, .48);
}
html.dark .type-page .type-stat { background: rgba(20, 44, 68, .58); }
.type-page .type-stat__value {
  color: #2b7fc6;
  text-shadow: 0 3px 14px rgba(90, 165, 230, .22);
}
html.dark .type-page .type-stat__value { color: #a5daff; }
.type-page .type-stat__value--combo { color: #8a86dd; text-shadow: 0 3px 14px rgba(150, 140, 230, .28); }
.type-page .type-progress__track { background: rgba(150, 200, 240, .28); }
.type-page .type-progress__fill {
  background: linear-gradient(90deg, #6fc2f3, #86b4f2 60%, #b6a4ef);
  box-shadow: 0 0 14px rgba(110, 180, 240, .52);
}

/* ---------- 打字区字符 ---------- */
.type-page .type-text { color: #8ea9c1; }
.type-page .type-char.type-is-correct {
  color: var(--type-ok);
  background: rgba(100, 190, 240, .14);
}
.type-page .type-char.type-is-wrong { background: var(--type-bad); color: #fff; }
.type-page .type-char.type-is-current {
  color: #1f5f96;
  background: rgba(120, 190, 245, .22);
  box-shadow: inset 0 0 0 1px rgba(90, 165, 230, .55);
}
html.dark .type-page .type-char.type-is-current { color: #d8efff; }
.type-page .type-char.type-is-current::before {
  background: #4aa5e8;
  box-shadow: 0 0 10px 2px rgba(100, 180, 245, .85);
}
.type-page .type-key.type-is-next {
  background: linear-gradient(135deg, #69b9ee, #9fd0f5);
  color: #fff;
  box-shadow: 0 5px 14px rgba(80, 155, 225, .42);
}

/* 未开始时的提示：给足实底与阴影，避免半透明背景让下方练习文字透上来、
   看起来像文字重叠/乱码（原样式背景过透）。 */
.type-page .type-focus-hint {
  bottom: 12px;
  z-index: 7;
  color: #1f6fae;
  background: linear-gradient(135deg, rgba(255, 255, 255, .97), rgba(226, 244, 255, .95));
  border: 1px solid rgba(140, 198, 244, .66);
  box-shadow: 0 7px 20px rgba(80, 150, 220, .24);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
html.dark .type-page .type-focus-hint {
  color: #bfe4ff;
  background: linear-gradient(135deg, rgba(24, 48, 74, .97), rgba(30, 56, 88, .95));
  border-color: rgba(122, 190, 240, .36);
}

/* ---------- 按钮 / 成绩卡 ---------- */
.type-page .type-btn--primary {
  background: linear-gradient(135deg, #5eb2ec, #8fc5f3 55%, #ada7ee);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px -6px rgba(80, 150, 230, .60);
}
.type-page .type-result__card {
  border: 1px solid rgba(146, 202, 244, .58);
  background: linear-gradient(155deg, rgba(255, 255, 255, .94), rgba(232, 245, 255, .90));
  box-shadow: 0 22px 60px rgba(70, 140, 205, .24);
}
html.dark .type-page .type-result__card {
  background: linear-gradient(155deg, rgba(20, 44, 68, .96), rgba(28, 52, 84, .92));
  border-color: rgba(122, 190, 240, .28);
}
.type-page .type-result__item { background: rgba(226, 242, 255, .68); border-color: rgba(146, 202, 244, .40); }
html.dark .type-page .type-result__item { background: rgba(28, 54, 82, .70); }
.type-page .type-result__item b { color: #2b7fc6; }
html.dark .type-page .type-result__item b { color: #a5daff; }

/* ============================================================
   按键火花：JS 动态创建 <i class="fx-spark">，650ms 后自动移除
   ============================================================ */
.fx-spark-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}
/* v43：用户反馈「火花没实现」。真实原因是旧粒子只有 3~5 粒 5px 的白色小点，
   又画在接近白色的玻璃面板上、只在「打对」时出现 0.6 秒，几乎不可见。
   现在改为：每次按键都溅出彩色发光粒子（正确蓝金 / 错误淡粉），尺寸翻倍、
   亮度与时长提升、附一道短拖尾，仍然克制（单次最多 7 粒、总量上限 64）。 */
.fx-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #7cc9ff 34%, rgba(70, 150, 255, 0) 76%);
  box-shadow: 0 0 14px 4px rgba(70, 165, 255, .85);
  opacity: 0;
  will-change: transform, opacity;
  animation: fxSparkFly var(--fx-dur, 820ms) cubic-bezier(.16, .7, .3, 1) forwards;
}
.fx-spark::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 20px;
  margin: -2px 0 0 -2px;
  border-radius: 999px;
  background: linear-gradient(to top, rgba(120, 195, 255, .75), transparent);
  transform-origin: 50% 0;
  transform: rotate(var(--fx-tail, 200deg));
  opacity: .75;
}
.fx-spark--star {
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  background: radial-gradient(circle, #ffffff 0%, #ffd979 30%, rgba(255, 176, 92, 0) 74%);
  box-shadow: 0 0 20px 7px rgba(255, 196, 96, .9);
  clip-path: polygon(50% 0, 61% 35%, 100% 50%, 61% 65%, 50% 100%, 39% 65%, 0 50%, 39% 35%);
}
.fx-spark--star::after { display: none; }
.fx-spark--violet {
  background: radial-gradient(circle, #ffffff 0%, #c6a8ff 34%, rgba(150, 110, 255, 0) 76%);
  box-shadow: 0 0 15px 5px rgba(170, 130, 255, .85);
}
.fx-spark--wrong {
  background: radial-gradient(circle, #ffffff 0%, #ff9fbd 34%, rgba(230, 110, 150, 0) 76%);
  box-shadow: 0 0 12px 3px rgba(235, 130, 165, .72);
}
@keyframes fxSparkFly {
  0%   { transform: translate(0, 0) scale(.35) rotate(0deg); opacity: 0; }
  12%  { opacity: 1; }
  55%  { opacity: .92; }
  100% { transform: translate(var(--fx-dx, 0px), var(--fx-dy, -18px)) scale(.35) rotate(90deg); opacity: 0; }
}

/* 打对时当前字符短促发光，让「火花」在视觉上更确定 */
.type-page .type-char.type-is-hit { animation: fxCharHit .52s ease-out; }
@keyframes fxCharHit {
  0%   { background: rgba(110, 195, 255, .78); box-shadow: 0 0 18px 5px rgba(100, 185, 255, .75); }
  100% { background: transparent; box-shadow: none; }
}
.type-page .type-board.fx-spark-wrong { animation: fxBoardWrong .32s ease-out; }
@keyframes fxBoardWrong {
  0%   { box-shadow: inset 0 0 0 2px rgba(235, 140, 170, .55); }
  100% { box-shadow: none; }
}

/* 连击到 10 的倍数时，打字区泛起一圈很淡的光环（不夸张） */
.type-page .type-board.fx-spark-combo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(140, 195, 250, .70), inset 0 0 42px rgba(120, 185, 250, .24);
  animation: fxComboGlow .62s ease-out forwards;
}
@keyframes fxComboGlow {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .fx-spark { animation: none !important; display: none !important; }
  .type-page .type-board.fx-spark-combo::after { animation: none !important; display: none !important; }
  .type-page .type-char.type-is-hit { animation: none !important; }
}

/* ============================================================
   v43：一屏化布局 —— 压缩上方控件、折叠说明与虚拟键盘，
   让打字页在常见桌面高度（≥720px）下无需上下拖动。
   ============================================================ */
.type-page.type-page--fitscreen { max-width: 1120px; padding: 6px 2px 12px; }
.type-page--fitscreen .type-header { padding: 7px 6px 9px; gap: 8px; align-items: center; }
.type-page--fitscreen .type-title {
  margin: 0 0 2px; font-size: clamp(1.2rem, 2.3vw, 1.55rem);
}
.type-title__tag {
  display: inline-block; vertical-align: middle;
  font-size: .66rem; font-weight: 700; letter-spacing: 0;
  padding: 2px 9px; border-radius: 999px;
  color: #1f6fae; background: rgba(226, 244, 255, .9);
  border: 1px solid rgba(140, 198, 244, .6);
  -webkit-text-fill-color: #1f6fae;
}
html.dark .type-title__tag { color: #bfe4ff; -webkit-text-fill-color: #bfe4ff; background: rgba(32, 64, 96, .8); }
.type-page--fitscreen .type-subtitle { font-size: .78rem; line-height: 1.45; margin: 0; }
.type-page--fitscreen .type-header__side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.type-page--fitscreen .type-status { font-size: .74rem; padding: 4px 11px; }
.type-page--fitscreen .type-controls { padding: 9px 12px; margin-bottom: 9px; }
.type-page--fitscreen .type-control-row { gap: 6px 10px; }
.type-page--fitscreen .type-control-row + .type-control-row { margin-top: 0; padding-top: 0; border-top: 0; }
.type-page--fitscreen .type-control-label { font-size: .74rem; }
.type-page--fitscreen .type-mode-btn { padding: 5px 12px; font-size: .8rem; }
.type-page--fitscreen .type-select { padding: 4px 8px; font-size: .78rem; }
.type-page--fitscreen .type-sound { font-size: .78rem; }
.type-page--fitscreen .type-stats { gap: 9px; margin-bottom: 9px; }
.type-page--fitscreen .type-stat { padding: 7px 6px; gap: 1px; border-radius: 12px; }
.type-page--fitscreen .type-stat__label { font-size: .67rem; }
.type-page--fitscreen .type-stat__value { font-size: 1.32rem; }
.type-page--fitscreen .type-progress { margin-bottom: 9px; }
.type-page--fitscreen .type-progress__track { height: 7px; }
.type-page--fitscreen .type-progress__meta { margin-top: 5px; font-size: .73rem; }
.type-page--fitscreen .type-board { padding: 13px 17px; margin-bottom: 9px; min-height: 128px; }
.type-page--fitscreen .type-text {
  max-height: 122px; font-size: clamp(1rem, 1.9vw, 1.24rem); line-height: 1.8;
}
.type-page--fitscreen .type-actions { gap: 9px; margin-bottom: 8px; }
.type-page--fitscreen .type-btn { padding: 7px 20px; font-size: .84rem; }
.type-page--fitscreen .type-keyboard-wrap { padding: 10px 12px 8px; margin-bottom: 0; }
.type-page--fitscreen .type-key { height: 30px; min-width: 32px; font-size: .76rem; }
.type-page--fitscreen .type-keyboard__tip { margin-top: 6px; font-size: .72rem; }

/* 折叠块：默认只占一行，展开后内容完整 */
.type-fold {
  border-radius: 10px;
  border: 1px solid var(--type-stroke, rgba(146, 202, 244, .5));
  background: var(--type-glass, rgba(255, 255, 255, .62));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.type-fold > summary {
  cursor: pointer; list-style: none;
  padding: 6px 12px; font-size: .76rem; font-weight: 700;
  color: #2b78bc; user-select: none;
}
.type-fold > summary::-webkit-details-marker { display: none; }
.type-fold > summary::before { content: '▸ '; font-weight: 700; }
.type-fold[open] > summary::before { content: '▾ '; }
.type-fold__hint { font-weight: 500; color: var(--type-ink-soft, #6a89a7); font-size: .7rem; }
.type-fold__body {
  padding: 0 12px 9px; font-size: .76rem; line-height: 1.65;
  color: var(--type-ink-soft, #6a89a7); max-width: 780px;
}
.type-fold--intro { min-width: 190px; }
.type-fold--keyboard { margin-bottom: 6px; }
.type-fold--keyboard > .type-panel { border: 0; box-shadow: none; background: transparent; }
html.dark .type-fold > summary { color: #a8d8ff; }

/* 矮屏再收一档，保证 768px 高的笔记本也不用来回拖 */
@media (max-height: 780px) {
  .type-page--fitscreen .type-board { min-height: 106px; padding: 10px 15px; }
  .type-page--fitscreen .type-text { max-height: 100px; line-height: 1.7; }
  .type-page--fitscreen .type-stat { padding: 5px 6px; }
  .type-page--fitscreen .type-stat__value { font-size: 1.15rem; }
  .type-page--fitscreen .type-header { padding-top: 4px; padding-bottom: 6px; }
}

