/* Typing Quest — Keyboard-themed styles
   Uses app theme vars (--color-*) for light/dark/blue mode compat */

/* ======== HOME SCREEN ======== */
.typing-home {
  padding: var(--space-4) var(--space-6);
  max-width: 900px;
  margin: 0 auto;
}

.typing-home h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.typing-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.typing-stats-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.typing-stat-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.typing-stat-chip .stat-icon {
  font-size: var(--text-base);
}

/* ======== MODE CARDS ======== */
.typing-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.typing-mode-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-align: center;
  border: 2px solid transparent;
}

.typing-mode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--color-primary);
}

.typing-mode-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-2);
}

.typing-mode-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.typing-mode-card p {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin: 0;
}

.typing-arcade-best {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
}

/* ======== LESSON LIST ======== */
.typing-tier-section {
  margin-bottom: var(--space-5);
}

.typing-tier-label {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-3);
}

.typing-lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.typing-lesson-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  border: 2px solid transparent;
}

.typing-lesson-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--color-primary);
}

.typing-lesson-card.completed {
  border-color: #4CAF50;
}

.typing-card-status {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: var(--text-sm);
}

.typing-card-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-1);
}

.typing-card-title {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.typing-card-desc {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.typing-card-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.typing-card-score {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
}

/* ======== LESSON / SPEED VIEW ======== */
.typing-lesson-view,
.typing-speed-view {
  padding: var(--space-4) var(--space-6);
  max-width: 900px;
  margin: 0 auto;
}

.typing-lesson-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.typing-lesson-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
  flex: 1;
}

.typing-back-btn {
  background: var(--color-surface-2);
  border: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s;
}

.typing-back-btn:hover {
  background: var(--color-surface-3, var(--color-border));
}

.typing-live-stats {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
}

/* ======== TEXT DISPLAY ======== */
.typing-text-display {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: var(--text-lg);
  line-height: 2.2;
  padding: var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  min-height: 80px;
  word-break: break-word;
}

.typing-char {
  transition: color 0.1s;
  border-radius: 2px;
  padding: 0 1px;
}

.typing-char.correct {
  color: #4CAF50;
}

.typing-char.incorrect {
  color: #f44336;
  background: rgba(244, 67, 54, 0.15);
  text-decoration: underline;
}

.typing-char.current {
  border-bottom: 3px solid var(--color-primary);
  animation: typing-cursor-blink 1s step-end infinite;
}

@keyframes typing-cursor-blink {
  0%, 100% { border-bottom-color: var(--color-primary); }
  50% { border-bottom-color: transparent; }
}

.typing-hidden-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ======== VIRTUAL KEYBOARD ======== */
.typing-keyboard {
  max-width: 620px;
  margin: 0 auto;
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.typing-keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.typing-key {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  border: 1px solid rgba(0,0,0,0.1);
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
}

.typing-key.highlight {
  transform: scale(1.15);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6), 0 0 4px rgba(59, 130, 246, 0.4);
  animation: typing-key-pulse 0.8s ease-in-out infinite;
  z-index: 1;
  border: 2px solid #3b82f6;
}

.typing-key-space {
  width: 240px !important;
}

@keyframes typing-key-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(59, 130, 246, 0.6); }
  50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.9); }
}

/* Hide keyboard on mobile — the on-screen keyboard serves the purpose */
@media (max-width: 600px) {
  .typing-keyboard {
    display: none;
  }
  .typing-key {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }
  .typing-key-space {
    width: 160px !important;
  }
  .typing-text-display {
    font-size: var(--text-base);
    line-height: 2;
  }
}

/* ======== ARCADE VIEW ======== */
.typing-arcade-view {
  padding: var(--space-4) var(--space-6);
  max-width: 700px;
  margin: 0 auto;
}

.typing-arcade-hud {
  display: flex;
  justify-content: space-around;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
}

.typing-hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.typing-hud-label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.typing-hud-value {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-text);
}

.typing-arcade-powerup {
  text-align: center;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
  animation: typing-powerup-flash 0.5s ease-in-out 3;
}

.typing-arcade-powerup.freeze {
  background: linear-gradient(90deg, #bbdefb, #e3f2fd);
  color: #1565c0;
}

.typing-arcade-powerup.blast {
  background: linear-gradient(90deg, #ffccbc, #fbe9e7);
  color: #d84315;
}

.typing-arcade-powerup.shield {
  background: linear-gradient(90deg, #c8e6c9, #e8f5e9);
  color: #2e7d32;
}

@keyframes typing-powerup-flash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.typing-arcade-area {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #0d1117 0%, #161b22 50%, #1a1a2e 100%);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  margin: 0 auto var(--space-3);
}

.typing-arcade-word {
  position: absolute;
  color: #e0e0e0;
  font-weight: 700;
  font-size: var(--text-base);
  font-family: 'SF Mono', 'Fira Code', monospace;
  text-shadow: 0 0 8px rgba(79, 172, 255, 0.5);
  white-space: nowrap;
  pointer-events: none;
}

.typing-arcade-word .typed-part {
  color: #4CAF50;
  text-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.typing-arcade-input-wrap {
  max-width: 400px;
  margin: 0 auto;
}

.typing-arcade-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-lg);
  font-family: 'SF Mono', 'Fira Code', monospace;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.typing-arcade-input:focus {
  border-color: var(--color-primary);
}

/* ======== RESULTS ======== */
.typing-results {
  text-align: center;
  padding: var(--space-6);
  max-width: 500px;
  margin: 0 auto;
}

.typing-results-icon {
  font-size: 4rem;
  margin-bottom: var(--space-3);
}

.typing-results h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xl);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.typing-results-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
}

.typing-result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.typing-result-num {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
}

.typing-result-label {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

.typing-stars {
  margin-bottom: var(--space-3);
  font-size: 2rem;
}

.typing-stars .star {
  margin: 0 var(--space-1);
  opacity: 0.3;
  transition: opacity 0.3s;
}

.typing-stars .star.earned {
  opacity: 1;
}

.typing-xp-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ffd700, #ffb700);
  color: #333;
  font-weight: 800;
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-3);
}

.typing-new-best {
  font-size: var(--text-base);
  font-weight: 700;
  color: #ffd700;
  margin-bottom: var(--space-3);
  animation: typing-powerup-flash 0.5s ease-in-out 3;
}

.typing-leaderboard {
  background: var(--color-surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  text-align: left;
}

.typing-leaderboard h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.typing-lb-row {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding: var(--space-1) 0;
}

.typing-results-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-4);
}

.typing-results-actions button {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  border: none;
  background: var(--color-surface-2);
  color: var(--color-text);
  transition: background 0.15s;
}

.typing-results-actions button:hover {
  background: var(--color-surface-3, var(--color-border));
}

.typing-results-actions button.primary {
  background: var(--color-primary);
  color: white;
}

.typing-results-actions button.primary:hover {
  opacity: 0.9;
}

/* ======== FINGER GUIDE ======== */
.typing-finger-guide {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0 var(--space-4);
  min-height: 130px;
}

.typing-finger-label {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
}

.typing-finger-name {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  color: #1a1a1a;
  font-weight: 800;
  margin: 0 4px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  border: 1px solid rgba(0,0,0,0.15);
}

/* Hands (visual diagram) */
.typing-hands {
  display: flex;
  gap: 50px;
  justify-content: center;
  align-items: flex-end;
}

.typing-hand {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.typing-hand-fingers {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: -4px;
  z-index: 2;
  position: relative;
}

.typing-finger {
  width: 14px;
  border-radius: 6px 6px 2px 2px;
  border: 1px solid rgba(0,0,0,0.15);
  opacity: 0.45;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

/* Per-finger heights (approximate hand anatomy) */
.typing-hand-left .typing-finger-pinky    { height: 32px; }
.typing-hand-left .typing-finger-ring     { height: 44px; }
.typing-hand-left .typing-finger-middle   { height: 50px; }
.typing-hand-left .typing-finger-index    { height: 44px; }
.typing-hand-right .typing-finger-index   { height: 44px; }
.typing-hand-right .typing-finger-middle  { height: 50px; }
.typing-hand-right .typing-finger-ring    { height: 44px; }
.typing-hand-right .typing-finger-pinky   { height: 32px; }

.typing-finger.active {
  opacity: 1;
  transform: translateY(-6px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.3);
  animation: typing-finger-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes typing-finger-bounce {
  to { transform: translateY(-12px); box-shadow: 0 10px 20px rgba(0,0,0,0.35); }
}

.typing-thumb {
  position: absolute;
  bottom: 6px;
  width: 14px;
  height: 28px;
  border-radius: 6px 6px 2px 2px;
  border: 1px solid rgba(0,0,0,0.15);
  opacity: 0.45;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
  z-index: 1;
}

.typing-thumb-left {
  right: -10px;
  transform: rotate(35deg);
  transform-origin: bottom center;
}

.typing-thumb-right {
  left: -10px;
  transform: rotate(-35deg);
  transform-origin: bottom center;
}

.typing-thumb.active {
  opacity: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.typing-thumb-left.active  { transform: rotate(35deg) translateY(-4px); }
.typing-thumb-right.active { transform: rotate(-35deg) translateY(-4px); }

.typing-palm {
  width: 70px;
  height: 28px;
  border-radius: 12px 12px 16px 16px;
  background: var(--color-surface-2, #d4a574);
  border: 1px solid rgba(0,0,0,0.15);
  opacity: 0.55;
}

.typing-hand-label {
  margin-top: 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-secondary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* F and J home-row anchor bumps */
.typing-key.bump {
  position: relative;
}
.typing-key.bump::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 2px;
  background: rgba(0,0,0,0.45);
  border-radius: 2px;
}

/* Hide hand diagram on small screens (kid still sees the text label) */
@media (max-width: 600px) {
  .typing-hands {
    transform: scale(0.85);
    gap: 30px;
  }
}
