/**
 * Flash Cards CSS - Spaced Repetition Learning
 * 
 * Provides 3D card flip animations, modal overlay, and responsive design
 * for the immersive flashcard study experience.
 * 
 * Follows PrepEx Alternate Design Standards - Premium green palette (#5C6F5C)
 */

/* ============================================================================
   Modal Overlay
   ============================================================================ */

#flashcard-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background-color: #000000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#flashcard-modal.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================================================
   Modal Container
   ============================================================================ */

.flashcard-container {
  width: 100%;
  max-width: 1000px;
  height: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ============================================================================
   Header (Progress & Exit)
   ============================================================================ */

.flashcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}

.flashcard-progress {
  color: #5C6F5C;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.flashcard-exit-btn {
  background: transparent;
  border: none;
  color: #5C6F5C;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease;
}

.flashcard-exit-btn:hover {
  background-color: rgba(92, 111, 92, 0.2);
  color: #10B981;
}

/* ============================================================================
   Card Stage (3D Perspective)
   ============================================================================ */

.flashcard-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  min-height: 0;
}

.flashcard-flip-container {
  width: 100%;
  height: 100%;
  max-height: 550px;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.flashcard-flip-container.flipped {
  transform: rotateY(180deg);
}

/* ============================================================================
   Card Faces (Front & Back)
   ============================================================================ */

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: white;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}

.flashcard-front {
  transform: rotateY(0deg);
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(135deg, #0a0f0a 0%, #1a1f1a 100%);
  padding-top: 4rem !important;
  overflow-y: auto;
  overflow-x: hidden;
  justify-content: flex-start;
  align-items: center;
}

/* Card Content */
.flashcard-word {
  font-size: 2.75rem;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
  margin-bottom: 0.5rem;
  word-wrap: break-word;
  max-width: 100%;
}

.flashcard-phonetic {
  font-size: 1.125rem;
  color: #6b7280;
  text-align: center;
  margin-bottom: 0.5rem;
  font-style: italic;
}

.flashcard-pos {
  font-size: 0.875rem;
  color: #5C6F5C;
  background: rgba(92, 111, 92, 0.08);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.flashcard-hint {
  margin-top: 2rem;
  font-size: 0.875rem;
  color: #9ca3af;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flashcard-definition {
  font-size: 1.375rem;
  color: #e5e7eb;
  line-height: 1.6;
  text-align: center;
  margin-bottom: 1.25rem;
  max-width: 650px;
}

.flashcard-examples {
  width: 100%;
  max-width: 650px;
  margin-top: 1.25rem;
}

.flashcard-examples-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #10B981;
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flashcard-examples-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.flashcard-examples-list li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
  color: #d1d5db;
  font-size: 1rem;
  line-height: 1.5;
}

.flashcard-examples-list li::before {
  content: "•";
  position: absolute;
  left: 0.5rem;
  color: #10B981;
  font-weight: bold;
}

.flashcard-synonyms {
  width: 100%;
  max-width: 650px;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(92, 111, 92, 0.3);
}

.flashcard-synonyms-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #10B981;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flashcard-synonyms-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.flashcard-synonym-tag {
  background: rgba(92, 111, 92, 0.3);
  color: #10B981;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ============================================================================
   Custom Card Images & Attribution
   ============================================================================ */

.flashcard-image {
  float: right;
  margin-left: 1.25rem;
  margin-bottom: 0.75rem;
  width: 200px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(92, 111, 92, 0.15);
  background: #f9fafb;
}

.flashcard-image img {
  width: 100%;
  height: auto;
  max-height: 140px;
  object-fit: contain;
  display: block;
}

.flashcard-attribution {
  padding: 0.5rem 0.625rem;
  background: rgba(92, 111, 92, 0.04);
  border-top: 1px solid rgba(92, 111, 92, 0.1);
  font-size: 0.625rem;
  color: #6b7280;
  text-align: center;
  line-height: 1.3;
}

.flashcard-attribution a {
  color: #5C6F5C;
  text-decoration: none;
  font-weight: 500;
}

.flashcard-attribution a:hover {
  text-decoration: underline;
}

/* Clear float after all content */
.flashcard-back::after {
  content: "";
  display: table;
  clear: both;
}

/* Rich Text Content Styling */
.flashcard-definition p {
  margin-bottom: 0.75rem;
}

.flashcard-definition p:last-child {
  margin-bottom: 0;
}

.flashcard-definition strong {
  color: #10B981;
  font-weight: 600;
}

.flashcard-definition ol,
.flashcard-definition ul {
  margin: 0.5rem 0 0.75rem 1.5rem;
  padding-left: 0;
}

.flashcard-definition li {
  margin-bottom: 0.375rem;
  line-height: 1.6;
}

.flashcard-definition li:last-child {
  margin-bottom: 0;
}

/* ============================================================================
   Navigation Footer
   ============================================================================ */

.flashcard-footer {
  padding: 1.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.flashcard-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.flashcard-nav-btn {
  background: white;
  color: #374151;
  border: 2px solid #e5e7eb;
  padding: 0.75rem 2rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flashcard-nav-btn:hover:not(:disabled) {
  background: #f9fafb;
  border-color: #5C6F5C;
  color: #5C6F5C;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 111, 92, 0.25);
}

.flashcard-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.flashcard-nav-btn:active:not(:disabled) {
  transform: translateY(0);
}

/* ============================================================================
   SRS Rating Buttons
   ============================================================================ */

.flashcard-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.flashcard-rating-title {
  color: #10B981;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
  letter-spacing: 0.05em;
}

.flashcard-rating-btn {
  background: white;
  border: 2px solid transparent;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.flashcard-rating-btn.rating-again {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.flashcard-rating-btn.rating-again:hover {
  background: #fee2e2;
  border-color: #dc2626;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

.flashcard-rating-btn.rating-hard {
  background: #fef3c7;
  color: #d97706;
  border-color: #fde68a;
}

.flashcard-rating-btn.rating-hard:hover {
  background: #fde68a;
  border-color: #d97706;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.2);
}

.flashcard-rating-btn.rating-good {
  background: #dbeafe;
  color: #2563eb;
  border-color: #bfdbfe;
}

.flashcard-rating-btn.rating-good:hover {
  background: #bfdbfe;
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.flashcard-rating-btn.rating-easy {
  background: #d1fae5;
  color: #1f2937;
  border-color: #a7f3d0;
}

.flashcard-rating-btn.rating-easy:hover {
  background: #a7f3d0;
  border-color: #6ee7b7;
  box-shadow: 0 4px 12px rgba(92, 111, 92, 0.25);
}

.flashcard-rating-btn:active {
  transform: scale(0.95);
}

/* ============================================================================
   Instructions
   ============================================================================ */

.flashcard-instructions {
  text-align: center;
  color: #5C6F5C;
  font-size: 0.8125rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(92, 111, 92, 0.3);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 640px) {
  .flashcard-container {
    max-height: 90vh;
  }

  .flashcard-stage {
    min-height: 300px;
  }

  .flashcard-flip-container {
    max-height: 500px;
  }

  .flashcard-face {
    padding: 1.5rem 1.25rem;
  }

  .flashcard-word {
    font-size: 1.875rem;
  }

  .flashcard-phonetic {
    font-size: 1rem;
  }

  .flashcard-definition {
    font-size: 1.125rem;
  }

  .flashcard-nav {
    flex-direction: column;
    width: 100%;
  }

  .flashcard-nav-btn {
    width: 100%;
    justify-content: center;
  }

  .flashcard-rating {
    flex-wrap: wrap;
  }

  .flashcard-rating-btn {
    flex: 1;
    min-width: 70px;
  }

  .flashcard-instructions {
    font-size: 0.75rem;
  }
}

/* ============================================================================
   Animations
   ============================================================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.flashcard-modal.active .flashcard-container {
  animation: fadeIn 0.3s ease;
}

/* ============================================================================
   Empty State
   ============================================================================ */

.flashcard-empty-state {
  text-align: center;
  color: white;
  padding: 2rem;
}

.flashcard-empty-state h3 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.flashcard-empty-state p {
  color: #d1d5db;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.flashcard-empty-btn {
  background: #5C6F5C;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  border: 2px solid #5C6F5C;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.flashcard-empty-btn:hover {
  background: #2d5f4d;
  border-color: #2d5f4d;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 111, 92, 0.25);
}

