/* TypeFlow CSS - Design System & Themes */

/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables for themes */
:root {
  /* Dark theme (default) */
  --bg-primary: #0f0f0f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #6b7280;
  --accent-primary: #f59e0b;
  --correct: #22c55e;
  --error: #ef4444;
  --border: #374151;
  
  /* Font families */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Spacing & sizing */
  --border-radius: 12px;
  --transition: all 0.2s ease;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #f9fafb;
  --bg-card: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --accent-primary: #f59e0b;
  --correct: #22c55e;
  --error: #ef4444;
  --border: #e5e7eb;
}

/* Retro theme */
[data-theme="retro"] {
  --bg-primary: #0a0a0a;
  --bg-card: #1a1a1a;
  --text-primary: #00ff41;
  --text-secondary: #00aa2b;
  --accent-primary: #00ff41;
  --correct: #00ff41;
  --error: #ff4444;
  --border: #00aa2b;
}

/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: var(--transition);
}

/* Navigation */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text-primary);
  text-decoration: none;
}

.nav-brand .icon {
  color: var(--accent-primary);
  font-size: 1.5rem;
}

.nav-links {
  display: flex;
  gap: 1rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  border-radius: 25px;
  text-decoration: none;
  color: var(--text-secondary);
  transition: var(--transition);
  font-weight: 500;
}

.nav-link.active,
.nav-link:hover {
  background: var(--accent-primary);
  color: #000;
}

.theme-selector {
  display: flex;
  gap: 0.5rem;
}

.theme-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.theme-btn:hover {
  transform: scale(1.1);
}

.theme-btn.active::after {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2px solid var(--accent-primary);
  border-radius: 8px;
}

.theme-dark { background: #1a1a2e; }
.theme-light { background: #f9fafb; border: 1px solid #e5e7eb; }
.theme-retro { background: #0a0a0a; border: 1px solid #00aa2b; }

/* Main content */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
}

.hero {
  text-align: center;
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero .highlight {
  color: var(--accent-primary);
}

.hero p {
  font-size: 1.25rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 2rem;
  margin-bottom: 2rem;
  transition: var(--transition);
}

.card:hover {
  border-color: var(--accent-primary);
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
}

.control-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.toggle, .btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  font-size: 0.9rem;
}

.toggle:hover, .btn:hover {
  border-color: var(--accent-primary);
}

.toggle.active, .btn.primary {
  background: var(--accent-primary);
  color: #000;
  border-color: var(--accent-primary);
}

.btn.secondary {
  background: transparent;
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.reset-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.5rem;
}

.reset-btn:hover {
  color: var(--accent-primary);
}

/* Timer */
.timer {
  text-align: center;
  margin-bottom: 2rem;
}

.timer-display {
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

/* Typing area */
.typing-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--border-radius);
  padding: 2rem;
  margin-bottom: 2rem;
  min-height: 200px;
  position: relative;
}

.typing-card.focused {
  border-color: var(--accent-primary);
}

.typing-text {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.typing-text .char {
  position: relative;
}

.typing-text .char.correct {
  color: var(--correct);
  background: rgba(34, 197, 94, 0.1);
}

.typing-text .char.incorrect {
  color: var(--error);
  background: rgba(239, 68, 68, 0.2);
}

.typing-text .char.current {
  background: var(--accent-primary);
  color: #000;
  animation: blink 1s infinite;
}

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

.typing-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: transparent;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
}

/* Results */
.results {
  text-align: center;
  padding: 2rem;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  margin-bottom: 2rem;
}

.results.show {
  display: block;
}

.results.hide {
  display: none;
}

.wpm-display {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Accuracy display */
.accuracy-display {
  text-align: center;
  margin-bottom: 2rem;
}

.accuracy-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent-primary);
}

/* Action cards */
.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.action-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.action-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.action-card .icon {
  font-size: 2.5rem;
  color: var(--accent-primary);
  margin-bottom: 1rem;
  display: block;
}

.action-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.action-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Lessons */
.lesson-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
}

.lesson-card:hover:not(.locked) {
  border-color: var(--accent-primary);
}

.lesson-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.lesson-number {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
}

.lesson-card.locked .lesson-number {
  background: var(--text-secondary);
}

.lesson-content {
  flex: 1;
}

.lesson-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.lesson-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.lesson-arrow {
  color: var(--accent-primary);
  font-size: 1.2rem;
}

.lesson-card.locked .lesson-arrow {
  color: var(--text-secondary);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent-primary);
  transition: width 0.3s ease;
}

/* AdSense placeholders */
.ad-unit {
  margin: 2rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border: 1px dashed var(--border);
  border-radius: var(--border-radius);
}

.ad-leaderboard {
  width: 100%;
  max-width: 728px;
  height: 90px;
}

.ad-rectangle {
  width: 300px;
  height: 250px;
}

/* Back button */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 2rem;
  transition: var(--transition);
}

.back-btn:hover {
  color: var(--accent-primary);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .navbar {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }
  
  .nav-links {
    order: -1;
  }
  
  .container {
    padding: 8rem 1rem 2rem;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
  
  .hero p {
    font-size: 1.1rem;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .control-group {
    justify-content: center;
  }
  
  .timer-display {
    font-size: 3rem;
  }
  
  .typing-text {
    font-size: 1.1rem;
  }
  
  .wpm-display {
    font-size: 2.5rem;
  }
  
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .action-cards {
    grid-template-columns: 1fr;
  }
  
  .ad-leaderboard {
    width: 100%;
    max-width: 320px;
    height: 50px;
  }
  
  .ad-rectangle {
    width: 100%;
    max-width: 300px;
    height: 250px;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 1.5rem;
  }
  
  .typing-card {
    padding: 1.5rem;
  }
  
  .hero h1 {
    font-size: 1.75rem;
  }
  
  .timer-display {
    font-size: 2.5rem;
  }
  
  .typing-text {
    font-size: 1rem;
    line-height: 1.6;
  }
  
  .stats {
    grid-template-columns: 1fr;
  }
}

/* Utilities */
.text-center { text-align: center; }
.text-amber { color: var(--accent-primary); }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-2 { margin-top: 2rem; }
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 1rem; }