/**
 * Typing Engine & Virtual Keyboard Styles
 */

/* Typing Room Layout */
.typing-container {
  max-width: 1000px;
  margin: 0 auto;
}

/* Typing Text Display Box */
.typing-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  min-height: 180px;
  max-height: 250px;
  overflow-y: hidden;
  scroll-behavior: smooth;
  user-select: none;
  line-height: 2.1;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: border-color 0.2s, box-shadow 0.2s;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.typing-box::-webkit-scrollbar {
  display: none;
}

.typing-box:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.typing-box.hindi-mode {
  font-family: var(--font-hindi);
  font-size: 1.55rem;
  line-height: 2.3;
}

/* Character Highlights */
.char {
  position: relative;
  border-radius: 3px;
  transition: background-color 0.08s ease, color 0.08s ease;
}

.char.correct {
  color: var(--success-color);
}

.char.partial {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
  border-bottom: 2px dashed var(--primary-color);
  border-radius: 2px;
}

.char.incorrect {
  color: var(--danger-color);
  background-color: var(--danger-subtle);
  border-bottom: 2px solid var(--danger-color);
}

.char.current {
  background-color: var(--primary-subtle);
  color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-color);
  border-radius: 4px;
}

/* Blinking Cursor Bar */
.caret-cursor {
  position: absolute;
  width: 2px;
  height: 1.4em;
  background-color: var(--primary-color);
  animation: caretBlink 1s infinite ease-in-out;
  pointer-events: none;
}

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

/* Hidden input that captures real physical keystrokes */
.typing-hidden-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: default;
  z-index: 10;
}

/* Virtual Keyboard */
.virtual-keyboard {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  user-select: none;
  margin-top: 1.5rem;
}

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

.keyboard-key {
  min-width: 44px;
  height: 48px;
  padding: 4px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 2px 0 var(--border-color);
  transition: all 0.08s ease;
  position: relative;
}

.keyboard-key.hindi-key {
  font-family: var(--font-hindi);
  font-size: 1rem;
}

.keyboard-key .sub-char {
  font-size: 0.7rem;
  color: var(--text-dim);
  align-self: flex-start;
}

.keyboard-key .main-char {
  font-size: 0.95rem;
  align-self: flex-end;
}

/* Physical English Secondary Key Indicator */
.keyboard-key .phys-char {
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 0.65rem;
  font-family: var(--font-sans);
  color: var(--text-dim);
  font-weight: 700;
  opacity: 0.8;
  pointer-events: none;
  line-height: 1;
}

.keyboard-key.key-active .phys-char {
  color: rgba(255, 255, 255, 0.95);
}

/* Key Special Widths */
.keyboard-key.key-backspace { min-width: 80px; }
.keyboard-key.key-tab { min-width: 65px; }
.keyboard-key.key-caps { min-width: 75px; }
.keyboard-key.key-enter { min-width: 85px; }
.keyboard-key.key-shift { min-width: 95px; }
.keyboard-key.key-space { min-width: 320px; }

/* Active Key Highlight */
.keyboard-key.key-active {
  background: var(--primary-color) !important;
  color: #fff !important;
  border-color: var(--primary-hover) !important;
  box-shadow: 0 0 12px var(--primary-glow) !important;
  transform: translateY(1px);
}

.keyboard-key.key-active .sub-char {
  color: rgba(255, 255, 255, 0.7);
}

.keyboard-key.key-pressed {
  transform: translateY(2px);
  box-shadow: none;
}

/* Finger guide indicators */
.finger-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
}
.finger-left-pinky { background-color: #f43f5e; }
.finger-left-ring  { background-color: #f59e0b; }
.finger-left-middle{ background-color: #10b981; }
.finger-left-index { background-color: #06b6d4; }
.finger-right-index{ background-color: #3b82f6; }
.finger-right-middle{ background-color: #8b5cf6; }
.finger-right-ring { background-color: #ec4899; }
.finger-right-pinky{ background-color: #f97316; }

/* Floating Live Performance Widget (HUD) */
.floating-hud {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  z-index: 1050;
  overflow: hidden;
  backdrop-filter: blur(12px);
  transition: width 0.2s ease-in-out, opacity 0.2s;
  touch-action: none;
}

.floating-hud.dragging {
  opacity: 0.92;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  user-select: none;
}

.floating-hud.collapsed {
  width: 140px;
}

.floating-hud.collapsed .hud-body {
  display: none;
}

.hud-header {
  padding: 0.6rem 0.85rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
}

.hud-header:active {
  cursor: grabbing;
}

.hud-body {
  padding: 0.75rem 1rem;
}

/* Speedometer Gauge in HUD */
.hud-speedometer-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0 0.15rem;
}

.hud-tachometer-svg {
  width: 175px;
  height: 95px;
  display: block;
  margin: 0 auto;
}

.hud-gauge-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 9;
  stroke-linecap: round;
}

.hud-gauge-fill {
  fill: none;
  stroke: url(#tachometerGradient);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s ease-out;
}

.hud-speedo-value {
  font-size: 1.85rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
  line-height: 1;
  margin-top: -30px;
}

.hud-speedo-unit {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.hud-targets-badge-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0 0.25rem 0.45rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
  font-size: 0.73rem;
}

.hud-target-pill {
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-muted);
}

.hud-target-pill span {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.hud-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
}

.hud-stat-label {
  color: var(--text-muted);
}

.hud-stat-val {
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Exam Simulation Mode */
.exam-banner {
  background: linear-gradient(90deg, #dc2626, #b91c1c);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.exam-timer-display {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .typing-box {
    font-size: 1.15rem;
    padding: 1.25rem 1rem;
    max-height: 200px;
  }
  .virtual-keyboard {
    display: none; /* Hide virtual keyboard on mobile screens */
  }
  .floating-hud {
    bottom: 10px;
    right: 10px;
    width: calc(100% - 20px);
  }
}
