﻿/* =========================================================
   Typing Speed - Live Typing Test Screen & HUD Stylesheet
   Matches Reference Photo: White Container, Monospace Text,
   HUD Banner, Character-Level DOM Diffing & Action Buttons
   ========================================================= */

/* Top Main Title */
.typing-test-main-title {
  font-size: clamp(2rem, 4.5vw, 2.85rem);
  font-weight: 800;
  color: var(--text-main);
  text-align: center;
  margin-bottom: 0.35rem;
  letter-spacing: -0.025em;
}

/* Subtitle for Test Number and Difficulty (e.g. Test #2 â€¢ EASY) */
.test-meta-subtitle {
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
}

/* Centered Duration Capsule Bar */
.duration-capsule-wrapper {
  text-align: center;
  margin-bottom: 2rem;
}

.test-duration-capsule-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-full);
}

.duration-capsule-btn {
  padding: 0.45rem 1.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.duration-capsule-btn:hover {
  color: var(--text-main);
}

.duration-capsule-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  font-weight: 700;
}

[data-theme="dark"] .test-duration-capsule-bar {
  background: #111827;
  border-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .duration-capsule-btn.active {
  background: #1e293b;
  color: #818cf8;
}

/* =========================================================
   HUD Banner (Horizontal Floating Card matching photo)
   ========================================================= */
.typing-stats-hud-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

[data-theme="dark"] .typing-stats-hud-banner {
  background: #151d2f;
  border-color: rgba(255, 255, 255, 0.08);
}

/* Left Time Left Box */
.hud-time-left-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.hud-clock-circle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: #ede9fe;
  color: #7c3aed;
  border: 2px solid #c4b5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

[data-theme="dark"] .hud-clock-circle {
  background: rgba(124, 58, 237, 0.2);
  border-color: #7c3aed;
  color: #c4b5fd;
}

.hud-time-left-content {
  display: flex;
  flex-direction: column;
}

.hud-stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hud-time-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-heading);
  line-height: 1.1;
}

/* Right Metric Items Group */
.hud-metrics-group {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.hud-metric-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.hud-metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.icon-purple {
  background: #ede9fe;
  color: #7c3aed;
}
.icon-green {
  background: #dcfce7;
  color: #16a34a;
}
.icon-red {
  background: #fee2e2;
  color: #dc2626;
}

[data-theme="dark"] .icon-purple { background: rgba(124, 58, 237, 0.2); color: #c4b5fd; }
[data-theme="dark"] .icon-green { background: rgba(22, 163, 74, 0.2); color: #86efac; }
[data-theme="dark"] .icon-red { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }

.hud-metric-data {
  display: flex;
  flex-direction: column;
}

.hud-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-heading);
  line-height: 1.1;
}

/* =========================================================
   Typing Passage Card & Character Styling
   ========================================================= */
.typing-passage-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: clamp(1.85rem, 3.5vw, 2.75rem);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.03);
  min-height: 230px;
  max-height: 380px;
  overflow-y: auto;
  cursor: text;
  position: relative;
  margin-bottom: 1.5rem;
  user-select: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.typing-passage-card.focused {
  border-color: #cbd5e1;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.05);
}

/* Custom Scrollbar */
.typing-passage-card::-webkit-scrollbar {
  width: 8px;
}
.typing-passage-card::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 8px;
}
.typing-passage-card::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 8px;
}
.typing-passage-card::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

[data-theme="dark"] .typing-passage-card {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
[data-theme="dark"] .typing-passage-card.focused {
  border-color: rgba(255, 255, 255, 0.18);
}
[data-theme="dark"] .typing-passage-card::-webkit-scrollbar-track {
  background: #1e293b;
}
[data-theme="dark"] .typing-passage-card::-webkit-scrollbar-thumb {
  background: #475569;
}

.typing-passage-text {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: clamp(1.2rem, 2.1vw, 1.42rem);
  line-height: 2.15;
  letter-spacing: 0.035em;
  color: #556980;
  word-break: normal;
  white-space: pre-wrap;
}

[data-theme="dark"] .typing-passage-text {
  color: #889bb2;
}

/* Line-by-Line Stability Container */
.typing-line {
  display: block;
  min-height: 2.2rem;
  line-height: 2.2;
  margin-bottom: 0.4rem;
  white-space: pre-wrap;
  word-break: normal;
}

/* Word Atomic Wrappers (Prevents words from jumping between lines) */
.word {
  display: inline-block;
  white-space: nowrap;
  vertical-align: baseline;
  margin: 0;
  padding: 0;
  transition: color 0.08s ease;
}

.word.word-correct {
  color: #228B22 !important; /* Forest Green */
}

[data-theme="dark"] .word.word-correct {
  color: #4ade80 !important;
}

/* Character states (Forest Green for typed characters) */
.char {
  display: inline-block;
  position: relative;
  transition: color 0.05s ease, background 0.05s ease;
  box-sizing: border-box;
}

/* Typed words & characters shine in Forest Green (#228B22) */
.char-correct {
  color: #228B22 !important; /* Authentic Forest Green */
  font-weight: 600;
}

[data-theme="dark"] .char-correct {
  color: #4ade80 !important; /* Radiant Forest Green in Dark Mode */
  font-weight: 600;
}

.char-incorrect {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.15);
  border-bottom: 2px solid #ef4444;
  border-radius: 2px;
  font-weight: 700;
}

/* Active Caret without width-expanding padding (Zero text reflow or jumping) */
.char-active {
  color: #0f172a !important;
  background: rgba(34, 139, 34, 0.16);
  border-bottom: 3px solid #228B22;
  border-radius: 2px;
  font-weight: 700;
  animation: pulse-caret 1s ease infinite alternate;
}

[data-theme="dark"] .char-active {
  color: #f8fafc !important;
  background: rgba(74, 222, 128, 0.22);
  border-bottom-color: #4ade80;
}

@keyframes pulse-caret {
  0% { border-bottom-color: #228B22; }
  100% { border-bottom-color: transparent; }
}

.char.char-active[data-space="true"] {
  min-width: 0.55em;
  background: rgba(34, 139, 34, 0.25);
  border-bottom: 3px solid #228B22;
}

.char-pending {
  color: #556980;
}

[data-theme="dark"] .char-pending {
  color: #889bb2;
}

/* Line break indicator */
.char-newline {
  color: #94a3b8;
  font-size: 0.85em;
  opacity: 0.7;
}

.char-newline.char-correct {
  color: #228B22 !important;
  opacity: 1;
}

[data-theme="dark"] .char-newline.char-correct {
  color: #4ade80 !important;
}

/* Hidden input element */
.typing-hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: -9999px;
}

/* Pro tip bar */
.typing-protip-banner {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.typing-protip-banner strong {
  color: var(--text-main);
}

/* Actions Row (4 Buttons matching photo) */
.typing-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3.5rem;
}

.btn-emerald {
  background: #10b981;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.25);
}

.btn-emerald:hover {
  background: #059669;
  transform: translateY(-2px);
  color: #ffffff;
}

@media (max-width: 767px) {
  .typing-stats-hud-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.25rem;
  }
  .hud-metrics-group {
    width: 100%;
    justify-content: space-between;
    gap: 1rem;
  }
  .typing-actions-row {
    flex-direction: column;
    width: 100%;
  }
  .typing-actions-row .btn {
    width: 100%;
  }
}

/* Split Pane Layout CSS */
.split-pane-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 2rem !important;
  background: var(--glass-bg);
  border-radius: 24px;
  box-shadow: 0 10px 40px -10px rgba(0,0,0,0.1);
  border: 1px solid var(--glass-border);
}

.split-top {
  position: relative;
  max-height: 220px;
  overflow-y: auto;
  border: 2px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  padding: 1.5rem;
  background: var(--bg-color, #f8fafc);
  font-size: 1.6rem;
  line-height: 2.2;
  scroll-behavior: smooth;
  box-shadow: inset 0 4px 12px rgba(0,0,0,0.03);
}

.split-top::before {
  content: "REFERENCE TEXT";
  position: absolute;
  top: 0;
  right: 0;
  background: var(--border-color, #e2e8f0);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-bottom-left-radius: 12px;
}

[data-theme="dark"] .split-top {
  border-color: #334155;
  background: #0f172a;
  box-shadow: inset 0 4px 12px rgba(0,0,0,0.2);
}
[data-theme="dark"] .split-top::before {
  background: #334155;
}

.typing-textarea-wrapper {
  position: relative;
  width: 100%;
}

.typing-textarea.split-bottom {
  width: 100%;
  border: 2px solid var(--border-color, #cbd5e1);
  border-radius: 16px;
  padding: 1.5rem;
  font-size: 1.6rem;
  line-height: 2.2;
  font-family: 'Noto Sans Devanagari', Mangal, sans-serif;
  resize: vertical;
  background: var(--surface);
  color: var(--text-main);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.typing-textarea.split-bottom:hover {
  border-color: #94a3b8;
}
[data-theme="dark"] .typing-textarea.split-bottom:hover {
  border-color: #475569;
}

.typing-textarea.split-bottom:focus {
  outline: none;
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 8px 24px rgba(99, 102, 241, 0.1);
  background: var(--bg-color);
}

.word-active {
  background-color: #fde047; /* Bright Yellow */
  color: #1e293b !important;
  border-radius: 6px;
  padding: 2px 4px;
  margin: 0 -4px; /* offset padding */
  box-shadow: 0 2px 8px rgba(253, 224, 71, 0.4);
  font-weight: 600;
  transition: all 0.15s ease;
}

[data-theme="dark"] .word-active {
  background-color: #d97706; /* Amber/Orange for dark mode */
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

/* Exam UI Card Override */
.exam-ui-card {
  background-color: #f8fafc;
  border-radius: 16px;
  padding: 2.5rem;
  margin-bottom: 2rem;
  border: 1px solid #e2e8f0;
}
[data-theme="dark"] .exam-ui-card {
  background-color: #0f172a;
  border-color: #1e293b;
}

.hud-white-card {
  background: #ffffff !important;
  border-radius: 16px;
  padding: 1.5rem 2rem !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-bottom: 2rem;
  border: 1px solid #f1f5f9;
}
[data-theme="dark"] .hud-white-card {
  background: #1e293b !important;
  border-color: #334155;
  box-shadow: none;
}

.hud-white-card .hud-metric-item {
  display: flex;
  align-items: center;
  gap: 16px !important;
}

.hud-white-card .hud-metric-icon {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem !important;
}

.hud-stat-value {
  font-size: 1.5rem !important;
  font-weight: 800 !important;
}

.test-meta-subtitle {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #64748b;
  margin-bottom: 1.5rem;
  text-transform: uppercase;
}

.typing-actions-row {
  margin-top: 2rem !important;
  margin-bottom: 0 !important;
}


.duration-capsule-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 16px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.duration-capsule-btn:hover {
  color: #0f172a;
}

.duration-capsule-btn.active {
  background: #ffffff;
  color: #4f46e5;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.15);
  font-weight: 700;
}
