/* ==========================================
   SyntaxSprint - Minimalist Typing Test
   Inspired by MonkeyType
   ========================================== */

/* CSS Custom Properties - Theme Variables */
:root {
  /* Dark Theme (Default - MonkeyType style) */
  --bg-primary: #323437;
  --bg-secondary: #2d3135;
  --text-main: #d1d0c5;
  --text-sub: #9a9ca1;
  --text-active: #d1d0c5;
  --caret: #d1d0c5;
  --success: #9ece9a;
  --error: #e58a90;
  --error-sub: #7e3838;
  
  /* Spacing */
  --header-height: 60px;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #e8e8e8;
  --text-main: #323437;
  --text-sub: #5f6165;
  --text-active: #323437;
  --caret: #323437;
  --success: #2e7d32;
  --error: #c0392b;
  --error-sub: #e8b4b4;
}

/* Global Styles */
* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

/* Foco visible solo para navegación por teclado (RF-006-07, RNF-006-03) */
:focus-visible {
  outline: 2px solid var(--caret);
  outline-offset: 2px;
}

/* Mensaje de error del arranque del test */
.status-error {
  color: var(--error);
}

/* La interacción con puntero no necesita el anillo de foco */
:focus:not(:focus-visible) {
  outline: none;
}

/* Placeholder legible con el mismo contraste que el texto secundario */
::placeholder {
  color: var(--text-sub);
  opacity: 1;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-sub);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-active);
}

/* ==========================================
   Header
   ========================================== */
header {
  backdrop-filter: blur(8px);
  background: rgba(50, 52, 55, 0.8);
}

[data-theme="light"] header {
  background: rgba(245, 245, 245, 0.8);
}

/* ==========================================
   Borders
   ========================================== */
/* Tailwind no aplica modificadores de opacidad a colores arbitrarios basados
   en var(); estos utilitarios derivan del token secundario. */
.border-subtle {
  border-color: color-mix(in srgb, var(--text-sub) 20%, transparent);
}

.border-subtle-strong {
  border-color: color-mix(in srgb, var(--text-sub) 30%, transparent);
}

.border-faint {
  border-color: color-mix(in srgb, var(--text-sub) 10%, transparent);
}

/* ==========================================
   Typography
   ========================================== */
.font-mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ==========================================
   Buttons
   ========================================== */
button {
  cursor: pointer;
  transition: all 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

/* ==========================================
   Test Area
   ========================================== */
#prompt-display {
  min-height: 200px;
  padding: 20px;
  border-radius: 8px;
}

/* Letter styling */
#prompt-display letter {
  position: relative;
  color: var(--text-sub);
  transition: color 0.1s ease;
}

#prompt-display letter.correct {
  color: var(--success);
}

#prompt-display letter.incorrect {
  color: var(--error);
}

/* Caret / Active cursor */
#prompt-display letter.active {
  color: var(--text-active);
}

#prompt-display letter.active::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  background: var(--caret);
  animation: blink 1s infinite;
}

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

/* Active line highlight */
#prompt-display letter.active {
  background: rgba(209, 208, 197, 0.1);
}

[data-theme="light"] #prompt-display letter.active {
  background: rgba(50, 52, 55, 0.05);
}

/* ==========================================
   Focus Hint
   ========================================== */
#focus-hint {
  opacity: 0;
  transition: opacity 0.2s ease;
}

#focus-hint.visible {
  opacity: 0.5;
}

/* ==========================================
   Hidden Input
   ========================================== */
#words-input {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ==========================================
   Results
   ========================================== */
#results-section {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
    Language Select
    ========================================== */
#language-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239a9ca1'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

[data-theme="light"] #language-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%235f6165'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
}

/* Language Scroll Buttons */
#language-scroll {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#language-scroll::-webkit-scrollbar {
  display: none;
}

.lang-btn {
  color: var(--text-sub);
  border: 1px solid transparent;
}

.lang-btn:hover {
  color: var(--text-main);
  border-color: var(--text-sub)/20;
}

.lang-btn.active {
  background-color: var(--caret) !important;
  color: var(--bg-primary) !important;
}

/* ==========================================
   Utility Classes
   ========================================== */
.hidden {
  display: none !important;
}

.pointer-events-none {
  pointer-events: none;
}

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 640px) {
  html {
    font-size: 14px;
  }
  
  #prompt-display {
    font-size: 1rem !important;
  }
  
  .grid-cols-2 {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

/* ==========================================
   Animations
   ========================================== */
.pulse {
  animation: pulse 2s infinite;
}

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

/* Shake animation for errors */
.shake {
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}