/* ============================================================
   ConceptTyping — Typing Practice CSS
   ============================================================ */

/* ─── Test Configuration Screen ─────────────────────────────────────────── */
.test-config {
  max-width: 780px; margin: 0 auto; padding: 2rem 0 4rem;
}
.config-section {
  margin-bottom: 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.config-section h5 {
  font-size: 0.8rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 1rem;
}
.option-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill {
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.pill:hover { border-color: var(--border-hover); color: var(--text-primary); }
.pill.selected {
  background: var(--blue-glow);
  border-color: var(--blue);
  color: var(--blue-light);
  font-weight: 600;
}
.pill.selected-green {
  background: var(--green-glow);
  border-color: var(--green);
  color: var(--green);
}

.config-toggles { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.toggle-opt {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.5rem 0.9rem;
  cursor: pointer; font-size: 0.83rem; color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}
.toggle-opt:hover { border-color: var(--border-hover); color: var(--text-primary); }
.toggle-opt.active { border-color: var(--blue); color: var(--blue); background: var(--blue-glow); }
.toggle-opt .toggle-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); transition: background var(--transition); }
.toggle-opt.active .toggle-dot { background: var(--blue); }

/* ─── Typing Interface ───────────────────────────────────────────────────── */
#typing-interface {
  max-width: 900px; margin: 0 auto; padding: 1rem 0 3rem;
  display: none;
}
#typing-interface.active { display: block; animation: fadeInUp 0.3s ease; }

/* Stats Bar */
.stats-bar {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 768px) { .stats-bar { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 480px) { .stats-bar { grid-template-columns: repeat(2, 1fr); } }

.stat-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.stat-pill .sp-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; display: block; }
.stat-pill .sp-value { font-size: 1.3rem; font-weight: 800; font-family: var(--font-mono); display: block; line-height: 1.2; }
.stat-pill.timer   .sp-value { color: var(--orange); }
.stat-pill.wpm     .sp-value { color: var(--green); }
.stat-pill.acc     .sp-value { color: var(--blue); }
.stat-pill.correct .sp-value { color: var(--green); }
.stat-pill.errors  .sp-value { color: var(--red); }

/* Typing Area */
.typing-area-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  position: relative;
  transition: border-color var(--transition);
}
.typing-area-wrapper.focused { border-color: var(--border-hover); }
.typing-area-wrapper.unfocused::after {
  content: 'Click to focus';
  position: absolute; inset: 0;
  background: rgba(15,15,17,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-xl);
}

/* The displayed words/paragraph */
#words-display {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  line-height: 2.2;
  height: calc(3 * 2.2 * 1.35rem); /* Show exactly 3 lines */
  overflow: hidden;
  position: relative;
  user-select: none;
  margin-bottom: 1.5rem;
  letter-spacing: 0.01em;
}
#words-display .word {
  display: inline-block;
  margin-right: 0.6rem;
  position: relative;
}
#words-display .word.current-word {
  background: rgba(255,255,255,0.04);
  border-radius: 3px;
  padding: 0 2px;
}
#words-display .word.correct-word { color: var(--text-muted); }
#words-display .word.incorrect-word .uncorrected { color: var(--red); }

.char { position: relative; }
.char.correct  { color: var(--green); }
.char.incorrect { color: var(--red); text-decoration: underline; text-decoration-color: rgba(232,85,85,0.5); }
.char.current  { color: var(--orange); position: relative; }
.char.current::before {
  content: ''; position: absolute; left: 0; bottom: -2px;
  width: 2px; height: 1.1em;
  background: var(--orange);
  animation: blinkCursor 1s ease infinite;
}
.char.upcoming { color: var(--text-disabled); }
.extra-char { color: var(--red); }

@keyframes blinkCursor { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* The hidden input that captures typing */
#typing-input {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none;
  top: 0; left: 0;
  width: 1px; height: 1px;
}

/* Current word underline */
.word-underline {
  position: absolute; bottom: -4px; left: 0;
  height: 2px; background: var(--blue);
  border-radius: 1px;
  transition: width 0.1s ease;
}

/* ─── Post-test Actions ───────────────────────────────────────────────────── */
.typing-actions {
  display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap;
  margin-top: 1.5rem;
}
.countdown-display {
  text-align: center; padding: 4rem 2rem;
  font-size: 5rem; font-weight: 900; font-family: var(--font-mono);
  color: var(--blue);
  animation: pulse 1s ease infinite;
}

/* ─── Result Page ─────────────────────────────────────────────────────────── */
.result-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3rem;
  text-align: center;
  position: relative; overflow: hidden;
  margin-bottom: 2rem;
}
.result-hero::before {
  content: ''; position: absolute; top: -100px; left: 50%; transform: translateX(-50%);
  width: 500px; height: 500px;
  background: radial-gradient(ellipse, rgba(57,211,83,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.result-wpm {
  font-size: 6rem; font-weight: 900;
  font-family: var(--font-mono);
  color: var(--green);
  line-height: 1;
  text-shadow: 0 0 40px rgba(57,211,83,0.3);
}
.result-wpm-label { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.result-grade {
  font-size: 4rem; font-weight: 900;
  line-height: 1;
}
.grade-S { color: #ffd700; text-shadow: 0 0 30px rgba(255,215,0,0.4); }
.grade-A { color: var(--green); }
.grade-B { color: var(--blue); }
.grade-C { color: var(--orange); }
.grade-D { color: var(--red); }

.result-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem;
  margin: 2rem 0;
}
.result-stat-item {
  background: var(--bg-elevated); border-radius: var(--radius-md);
  padding: 1rem; text-align: center;
}
.result-stat-item .val { font-size: 1.6rem; font-weight: 800; font-family: var(--font-mono); display: block; line-height: 1.1; }
.result-stat-item .lbl { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.personal-best {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(255,215,0,0.1); border: 1px solid rgba(255,215,0,0.3);
  color: #ffd700; padding: 0.4rem 1rem; border-radius: var(--radius-full);
  font-size: 0.85rem; font-weight: 600;
  animation: glow 2s ease infinite;
}

/* ─── Misc ─────────────────────────────────────────────────────────────────── */
.test-complete-msg {
  text-align: center; padding: 2rem;
  color: var(--text-muted); font-size: 0.9rem;
}
.caret-block { display: inline-block; width: 2px; height: 1.2em; background: var(--orange); animation: blinkCursor 1s ease infinite; vertical-align: middle; margin-left: 1px; }

/* On-screen keyboard */
.on-screen-keyboard {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-top: 1rem;
}
.keyboard-row { display: flex; gap: 4px; justify-content: center; margin-bottom: 4px; }
.key {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 5px; padding: 6px 4px;
  min-width: 36px; height: 36px;
  font-size: 0.7rem; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}
.key.active  { background: var(--blue); color: #fff; border-color: var(--blue); transform: scale(0.92); }
.key.correct { background: var(--green-glow); border-color: var(--green); color: var(--green); }
.key.error   { background: var(--red-glow);   border-color: var(--red);   color: var(--red); }
.key.space   { min-width: 200px; }
