/**
 * STAR Early Literacy - Main Stylesheet
 * Imports Design System + Custom Overrides
 */

/* Import Design System */
@import url('design-system.css');

/* Legacy Compatibility Layer */
:root {
  --bg-gradient: linear-gradient(135deg, var(--star-50) 0%, var(--star-sky-50) 100%);
  --card-bg: var(--color-white);
  --text-color: var(--gray-800);
  --text-light: var(--gray-600);
  --border-radius: var(--radius-2xl);
  --shadow: var(--shadow-lg);
}

/* Additional custom styles */

/* Grade Selection Animation */
.grade-selection h2 {
  animation: fade-in-up 0.5s ease-out;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced Grade Card Hover Effects */
.grade-card {
  position: relative;
  overflow: hidden;
}

.grade-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s ease;
}

.grade-card:hover::before {
  left: 100%;
}

/* Reading Progress Indicator */
.reading-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--star-sun-100);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  margin: var(--space-4) 0;
}

.reading-progress .book-icon {
  font-size: 1.5rem;
}

.reading-progress .pages-read {
  font-weight: 700;
  color: var(--star-sun-700);
}

/* Word Bank */
.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  padding: var(--space-5);
  background: var(--star-sky-50);
  border-radius: var(--radius-xl);
  margin: var(--space-5) 0;
}

.word-bank .word {
  background: var(--color-white);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-family: var(--font-display);
  font-size: var(--text-body);
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--star-sky-200);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.word-bank .word:hover {
  background: var(--star-sky-100);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.word-bank .word.used {
  opacity: 0.5;
  background: var(--gray-100);
  border-color: var(--gray-300);
  cursor: default;
}

/* Sentence Builder */
.sentence-builder {
  min-height: 80px;
  background: var(--color-white);
  border: 3px dashed var(--star-300);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  margin: var(--space-5) 0;
}

.sentence-builder:empty::before {
  content: 'Build your sentence here...';
  color: var(--gray-400);
  font-style: italic;
}

.sentence-builder .word {
  background: var(--star-100);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  cursor: pointer;
  animation: word-pop 0.3s ease;
}

@keyframes word-pop {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Picture Card Grid */
.picture-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  max-width: 500px;
  margin: var(--space-6) auto;
}

.picture-card {
  aspect-ratio: 1;
  background: var(--color-white);
  border: 4px solid var(--gray-200);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md);
}

.picture-card:hover {
  border-color: var(--star-sky-400);
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.picture-card.selected {
  border-color: var(--star-500);
  background: var(--star-50);
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.2);
}

.picture-card.correct {
  border-color: var(--star-green-500);
  background: var(--star-green-50);
  animation: star-success-pulse 0.6s ease-out;
}

/* Rhyme Match Game */
.rhyme-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  margin: var(--space-4) 0;
}

.rhyme-word {
  background: var(--color-white);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-xl);
  font-family: var(--font-display);
  font-size: var(--text-h3);
  box-shadow: var(--shadow-md);
  border: 3px solid var(--gray-200);
}

.rhyme-connector {
  font-size: 2rem;
  color: var(--star-sky-400);
}

/* Letter Tracing Area */
.tracing-area {
  background: var(--color-white);
  border: 3px solid var(--star-sky-300);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  margin: var(--space-5) 0;
  text-align: center;
}

.tracing-letter {
  font-family: var(--font-display);
  font-size: 8rem;
  color: var(--star-sky-200);
  line-height: 1;
  position: relative;
}

.tracing-letter::after {
  content: attr(data-letter);
  position: absolute;
  top: 0;
  left: 0;
  color: transparent;
  -webkit-text-stroke: 3px var(--star-sky-400);
}

/* Audio Wave Animation */
.audio-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
}

.audio-wave span {
  width: 4px;
  background: var(--star-sky-500);
  border-radius: 2px;
  animation: audio-wave 1s ease-in-out infinite;
}

.audio-wave span:nth-child(1) { animation-delay: 0s; height: 10px; }
.audio-wave span:nth-child(2) { animation-delay: 0.1s; height: 20px; }
.audio-wave span:nth-child(3) { animation-delay: 0.2s; height: 15px; }
.audio-wave span:nth-child(4) { animation-delay: 0.3s; height: 25px; }
.audio-wave span:nth-child(5) { animation-delay: 0.4s; height: 12px; }

@keyframes audio-wave {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* Story Completion Animation */
.story-complete {
  text-align: center;
  padding: var(--space-10);
}

.story-complete .book-animation {
  font-size: 6rem;
  animation: book-open 1s ease-out;
}

@keyframes book-open {
  0% {
    transform: scale(0) rotate(-20deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(5deg);
  }
  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

/* Confetti for STAR */
.confetti-star {
  position: fixed;
  width: 12px;
  height: 12px;
  background: var(--star-400);
  animation: confetti-fall 3s ease-out forwards;
  z-index: var(--z-celebration);
}

.confetti-star:nth-child(2n) { background: var(--star-sky-400); }
.confetti-star:nth-child(3n) { background: var(--star-sun-400); }
.confetti-star:nth-child(4n) { background: var(--star-green-400); }

@keyframes confetti-fall {
  0% {
    transform: translateY(-100px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Vowel Highlighting */
.vowel {
  color: var(--star-500);
  font-weight: 700;
}

.consonant {
  color: var(--star-sky-600);
}

/* Sight Word Badge */
.sight-word-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: linear-gradient(135deg, var(--star-sun-400), var(--star-sun-300));
  color: var(--gray-800);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  margin-left: var(--space-2);
}

/* Reading Level Indicator */
.reading-level {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--star-sky-100);
  color: var(--star-sky-700);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 700;
}

.reading-level::before {
  content: '📚';
}

/* Achievement Unlocked Notification */
.achievement-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--color-white);
  border: 2px solid var(--star-sun-400);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-6);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  animation: toast-slide-in 0.5s ease, toast-slide-out 0.5s ease 4.5s forwards;
  z-index: var(--z-toast);
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.achievement-toast .icon {
  font-size: 2rem;
}

.achievement-toast .content h4 {
  color: var(--star-sun-600);
  margin: 0;
  font-size: var(--text-sm);
}

.achievement-toast .content p {
  margin: 0;
  font-weight: 700;
  color: var(--gray-800);
}

/* Responsive Adjustments */
@media (max-width: 480px) {
  .picture-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .picture-card {
    font-size: 3rem;
  }

  .tracing-letter {
    font-size: 5rem;
  }

  .rhyme-pair {
    flex-direction: column;
    gap: var(--space-4);
  }

  .rhyme-connector {
    transform: rotate(90deg);
  }
}
