/* ==========================================================================
   TypeMaster - Test Workspace Stylesheet
   Soft Aesthetic Typography Colors, Permanent Block Caret █ & Hard Mode
   ========================================================================== */

/* Modern Floating Test Control Toolbar */
.test-config-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
  background: var(--bg-glass-card);
  backdrop-filter: blur(16px);
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  margin: 0 auto 1.75rem;
  width: fit-content;
  max-width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: all var(--transition-normal);
}

.config-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.config-group-divider {
  width: 1px;
  height: 22px;
  background: var(--border-color);
}

.config-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.config-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.config-btn.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 700;
}

/* Custom Time Modal Input */
.custom-time-input-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Code Title & Difficulty Header */
.code-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  margin: 0 auto 1rem;
  padding: 0 0.5rem;
}
.code-snippet-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.01em;
}
.badge-difficulty {
  padding: 0.25rem 0.85rem;
  background: rgba(79, 70, 229, 0.15);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Live Stats Display Header */
.live-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1040px;
  margin: 0 auto 1.25rem;
  padding: 0 0.5rem;
  transition: opacity 0.3s ease;
}
.live-stats-bar.blind-mode-active .stat-value {
  filter: blur(8px);
  user-select: none;
}

.stat-item {
  display: flex;
  flex-direction: column;
}
.stat-item .stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-subtle);
  letter-spacing: 0.05em;
}
.stat-item .stat-value {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--primary);
  transition: filter 0.3s ease;
}

.timer-large {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

/* Status Indicator Pill */
.status-pill-wrapper {
  text-align: center;
  margin-bottom: 1.25rem;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 1.15rem;
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.15);
}

/* Main Typing Container Box */
.typing-box-wrapper {
  position: relative;
  max-width: 1040px;
  margin: 0 auto;
  min-height: 280px;
  padding: 2rem 2.25rem;
  background: var(--bg-glass-card);
  border: 1.5px solid rgba(79, 70, 229, 0.35);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.45),
    0 0 35px rgba(79, 70, 229, 0.18);
  border-radius: var(--radius-lg);
  display: flex;
  gap: 1.25rem;
  transition: all var(--transition-normal);
}
.typing-box-wrapper:hover {
  border-color: var(--primary);
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.5),
    0 0 45px rgba(79, 70, 229, 0.25);
}

.typing-box-wrapper.code-mode-wrapper {
  min-height: 500px;
}

/* Line Numbers Gutter */
.line-numbers-gutter {
  display: flex;
  flex-direction: column;
  padding-right: 1rem;
  border-right: 1.5px solid var(--border-color);
  user-select: none;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  line-height: 1.75;
  color: var(--text-subtle);
  text-align: right;
  min-width: 38px;
}
.line-num {
  height: 1.75em;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0.5;
  transition: all 0.1s ease;
}
.line-num.active {
  color: var(--primary);
  opacity: 1;
  font-weight: 700;
}

/* Words Container */
.words-container {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 1.75;
  height: 240px;
  overflow: hidden;
  position: relative;
  user-select: none;
  padding: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.4em 0.6em;
  transition: opacity 0.2s ease;
}

.words-container.code-mode {
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0;
  height: auto;
  min-height: 480px;
  overflow-y: visible;
}

.words-container.blurred .word:not(.current) {
  filter: blur(4px);
  opacity: 0.5;
}

/* Code Line Container */
.code-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35em;
  width: 100%;
  height: 1.75em;
  margin: 0;
  padding: 0;
}

/* Word & Character Elements */
.word {
  display: inline-flex;
  position: relative;
  white-space: pre;
  margin-right: 0.1em;
}

.char {
  position: relative;
  color: var(--text-untyped);
  transition:
    color 0.08s ease,
    background 0.08s ease;
}

/* Soft, Pleasant Emerald Green for Correct Letters */
.char.correct {
  color: #10b981 !important;
  font-weight: 500;
}

/* Soft, Pleasant Coral Red & Subtle Background for Incorrect Letters */
.char.incorrect {
  color: #f87171 !important;
  font-weight: 500;
  background: rgba(248, 113, 113, 0.14);
  border-radius: 2px;
  text-decoration: none !important;
}

.char.extra {
  color: #f87171 !important;
  font-weight: 500;
  text-decoration: none !important;
  opacity: 0.9;
}

/* Permanent Glowing Block Caret █ */
.caret {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  top: 0;
  left: 0;
  width: 0.72em !important;
  height: 1.4em !important;
  background: var(--primary) !important;
  opacity: 0.45 !important;
  border-radius: 3px;
  box-shadow: 0 0 12px var(--primary);
  visibility: visible !important;
  transition:
    left 0.06s cubic-bezier(0.1, 0.9, 0.2, 1),
    top 0.06s cubic-bezier(0.1, 0.9, 0.2, 1);
  animation: caretBlink 1s infinite;
}

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

/* Restart Prompt Overlay / Button */
.test-actions-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.75rem;
}
.key-hint {
  font-size: 0.82rem;
  color: var(--text-subtle);
  background: var(--bg-tertiary);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: var(--font-mono);
}

/* Compact Virtual Keyboard */
.keyboard-wrapper {
  max-width: 720px;
  margin: 1.75rem auto 0;
  background: var(--bg-glass-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
  transform: scale(0.92);
  transform-origin: top center;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
}

.key {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  min-width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.08s ease;
  user-select: none;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.key.key-wide {
  min-width: 58px;
}
.key.key-extra-wide {
  min-width: 76px;
}
.key.key-space {
  flex: 1;
  max-width: 260px;
}

.key.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(2px);
  box-shadow: 0 0 12px var(--primary);
}

/* Results Modal Specifics */
.results-header {
  text-align: center;
  margin-bottom: 2rem;
}
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  font-size: 2.2rem;
  font-weight: 900;
  box-shadow: var(--shadow-glow);
  margin-bottom: 1rem;
}

/* Replace modal grade badge with brand logo when present */
.modal-overlay .grade-badge {
  display: none;
}

.results-logo {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0 auto 1rem;
  background: transparent;
  border-radius: 50%;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.result-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  text-align: center;
}
.result-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.result-card .value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 0.25rem;
}
.result-card.highlight {
  background: var(--primary-light);
  border-color: var(--primary);
}
.result-card.highlight .value {
  color: var(--primary);
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .words-container {
    font-size: 1.1rem;
    height: 180px;
  }
  .typing-box-wrapper {
    padding: 1.25rem;
    min-height: 220px;
  }
  .timer-large {
    font-size: 2.5rem;
  }
  .results-grid {
    grid-template-columns: 1fr 1fr;
  }
  .keyboard-wrapper {
    display: none;
  }
}
