/* --- Google Font Import --- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap');

/* --- 🎨 Fun & Colorful Variables --- */
:root {
  /* Colorful Gradient for Accents */
  --primary-gradient: linear-gradient(135deg, #833ab4, #fd1d1d, #fcb045);
  
  /* Buttons */
  --go-gradient: linear-gradient(135deg, #00c853, #76ff03);
  --stop-gradient: linear-gradient(135deg, #ff5252, #ff1744);

  /* User Request: Green Links */
  --link-color: #00b341;
  --link-hover: #008f34;

  /* Typography & Main Colors */
  --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --text-color: #222;
  --light-text: #444;
  
  /* Backgrounds & Borders */
  --body-bg: linear-gradient(180deg, #f7f9fc 0%, #eef4ff 100vh);
  --card-bg: #ffffff;
  --border-color: #e0e6f1;
  
  /* Shadows */
  --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.05);
  --shadow-colorful: 0 8px 25px rgba(131, 58, 180, 0.15);
  --shadow-hover: 0 12px 30px rgba(131, 58, 180, 0.2);
}

body {
  font-family: var(--font-family);
  margin: 0;
  padding: 0;
  background: var(--body-bg);
  color: var(--text-color);
  line-height: 1.7;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 800;
}

p {
  margin-bottom: 1.25em;
  color: var(--light-text);
  font-size: 1.05rem;
}

/* --- ✅ User Request: Green Links --- */
a {
  color: var(--link-color);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* --- ✨ Gradient Header --- */
header {
  width: 100%;
  text-align: center;
  background: var(--primary-gradient);
  color: #fff;
  padding: 2.5rem 1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

header h1 {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 800;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

header p {
  margin: 0.25rem 0 0;
  font-size: 1.1rem;
  font-weight: 400;
  color: #fff;
  opacity: 0.9;
}

/* --- Navigation --- */
nav {
  display: flex;
  justify-content: center;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-light);
  padding: 0 1rem;
}

nav a {
  padding: 1rem 1.25rem;
  font-weight: 700;
  color: var(--link-color); /* Green Link */
  border-bottom: 4px solid transparent;
  transition: all 0.2s;
}

nav a:hover {
  background-color: #f7f9fc;
  text-decoration: none;
}

nav a.active {
  color: #833ab4; /* Purple to show it's active */
  border-bottom-color: #833ab4;
}

/* --- Main Content & Article --- */
.container {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

/* --- 🎨 Colorful Typing Tool --- */
.typing-container {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow-colorful);
  margin: 2.5rem 0;
}

#test-text {
  font-size: 1.4rem;
  line-height: 2.1;
  color: var(--light-text);
  background: #fcfdff;
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 600;
  border: 2px solid var(--border-color);
}

/* Word Styling */
#test-text span {
  padding: 2px 0;
  transition: background 0.1s, color 0.1s;
}
#test-text span.current {
  background: #fffb8f; /* Bright highlighter yellow */
  color: #000;
  border-radius: 4px;
}
#test-text span.correct {
  color: #00c853; /* Bright green */
  font-weight: 700;
}
#test-text span.incorrect {
  color: #ff3d00; /* Bright red */
  text-decoration: line-through;
  background: #fff0f0;
}
#test-text span.incorrect-live {
  background: #fff0f0;
  outline: 1px solid #ff3d00;
}

#input-area {
  width: 100%;
  height: 100px;
  font-size: 1.25rem;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  outline: none;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: 'Courier New', Courier, monospace;
}

#input-area:focus {
  border-color: #833ab4;
  box-shadow: 0 0 0 4px rgba(131, 58, 180, 0.2);
}

#input-area:disabled {
  background-color: #f7f9fc;
  opacity: 0.7;
}

/* --- 🎨 Colorful Controls --- */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1.5rem 0;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.controls select {
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.2s;
}
.controls select:hover {
  border-color: #833ab4;
}

.controls .buttons {
  display: flex;
  gap: 1rem;
}

.controls button {
  padding: 0.8rem 1.75rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
.controls button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
.controls button:active {
  transform: translateY(-1px);
}

#start-btn {
  background: var(--go-gradient);
}

#reset-btn {
  background: var(--stop-gradient);
}

/* --- 📊 Colorful Stats --- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1.25rem;
  padding-top: 1rem;
  margin-top: 1rem;
}

.stat-box {
  background: var(--card-bg);
  padding: 1.25rem;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-light);
  border-top: 4px solid;
}
/* Assign different colors to each stat box */
.stat-box:nth-child(1) { border-color: #0078d4; } /* WPM - Blue */
.stat-box:nth-child(2) { border-color: #00c853; } /* CPM - Green */
.stat-box:nth-child(3) { border-color: #ff9800; } /* Accuracy - Orange */
.stat-box:nth-child(4) { border-color: #833ab4; } /* Time - Purple */


.stat-box strong {
  color: var(--light-text);
  font-size: 1rem;
  font-weight: 700;
  display: block;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.stat-box span {
  color: var(--text-color);
  font-size: 2rem;
  font-weight: 800;
}

/* --- 📄 Colorful Lesson Cards --- */
.lesson-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.lesson-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow-light);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.lesson-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-hover);
}

.lesson-card h3 {
  margin-top: 0;
}

.lesson-card h3 a {
  text-decoration: none;
  color: var(--link-color); /* Green Link */
}
.lesson-card h3 a:hover {
  color: var(--link-hover); /* Darker Green */
}

.lesson-card p {
  margin-bottom: 0;
  color: var(--light-text);
}

/* --- ✨ Gradient Footer --- */
footer {
  text-align: center;
  margin-top: 4rem;
  padding: 2rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  background: var(--primary-gradient);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .lesson-grid {
    grid-template-columns: 1fr;
  }
  
  .controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .controls select,
  .controls .buttons {
    width: 100%;
  }
  
  .controls .buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 2rem;
  }
  header p {
    font-size: 1rem;
  }
  
  nav a {
    padding: 0.75rem;
    font-size: 0.9rem;
  }
  
  .container {
    margin: 1.5rem auto;
    padding: 0 1rem;
  }
  
  .typing-container {
    padding: 1.5rem 1rem;
  }
  
  #test-text {
    font-size: 1.15rem;
    line-height: 1.9;
  }
  
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  
  .stat-box {
    padding: 1rem;
  }
  
  .stat-box span {
    font-size: 1.5rem;
  }
}