/* ============================================================
   Learn Languages — Flashcard Mode Styles (Kids Design)
   Loaded only on lesson.php
   ============================================================ */

/* ---- Tokens ----------------------------------------------- */
:root {
  --fc-purple:  #7c3aed;
  --fc-blue:    #0369a1;
  --fc-orange:  #f97316;
  --fc-cyan:    #06b6d4;
  --fc-green:   #22c55e;
  --fc-yellow:  #eab308;
  --fc-teal:    #0d9488;
  --fc-bg:      #fef9f0;
  --fc-card-bg: #ffffff;
  --fc-radius:  1.5rem;
  --fc-font:    'Nunito', 'Poppins', system-ui, sans-serif;
}

/* ---- Overlay ---------------------------------------------- */
.lrn-flashcard-overlay {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: linear-gradient(160deg, #e0f2fe 0%, #ede9fe 50%, #fef9f0 100%);
  color: #1e1b4b;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--fc-font);
}

.lrn-flashcard-overlay[hidden] { display: none; }

.lrn-flashcard-overlay .lrn-lang-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 1;
}

.lrn-flashcard-overlay .lrn-lang-icon svg,
.lrn-flashcard-overlay .lrn-lang-icon img {
  width: 1.25em;
  height: 1.25em;
  display: block;
  object-fit: contain;
}

/* ---- Floating blobs (decorative) -------------------------- */
.lrn-flashcard-overlay::before,
.lrn-flashcard-overlay::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
}
.lrn-flashcard-overlay::before {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, #7dd3fc, transparent 70%);
  top: -80px;
  right: -80px;
  animation: fcBlobA 8s ease-in-out infinite alternate;
}
.lrn-flashcard-overlay::after {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #fbbf24, transparent 70%);
  bottom: -60px;
  left: -60px;
  animation: fcBlobB 10s ease-in-out infinite alternate;
}

@keyframes fcBlobA {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(20px, 30px) scale(1.15); }
}
@keyframes fcBlobB {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-20px, -15px) scale(1.1); }
}

/* All children above the blobs */
.lrn-fc-header,
.lrn-fc-progress-wrap,
.lrn-fc-score-bar,
.lrn-fc-stage,
.lrn-fc-footer,
.lrn-fc-complete { position: relative; z-index: 1; }

/* ---- Header ----------------------------------------------- */
.lrn-fc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  flex-shrink: 0;
}

.lrn-fc-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--fc-purple);
  letter-spacing: -0.01em;
}

.lrn-fc-close {
  background: rgba(124,58,237,.12);
  border: 2px solid rgba(124,58,237,.2);
  color: var(--fc-purple);
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, transform 0.2s;
}
.lrn-fc-close:hover {
  background: rgba(124,58,237,.22);
  transform: rotate(90deg) scale(1.1);
}

/* ---- Progress --------------------------------------------- */
.lrn-fc-progress-wrap {
  padding: 0.25rem 1.25rem 0;
  flex-shrink: 0;
}

.lrn-fc-progress-bar-track {
  height: 10px;
  background: rgba(124,58,237,.12);
  border-radius: 9999px;
  overflow: hidden;
}

.lrn-fc-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--fc-purple), var(--fc-cyan), var(--fc-orange));
  border-radius: 9999px;
  transition: width 0.4s cubic-bezier(.34,1.56,.64,1);
  width: 0%;
  position: relative;
}

.lrn-fc-progress-bar-fill::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(50%, -50%);
  width: 14px;
  height: 14px;
  background: #fff;
  border: 3px solid var(--fc-purple);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(124,58,237,.2);
}

.lrn-fc-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9580ff;
  margin-top: 0.5rem;
}

/* ---- Score ------------------------------------------------ */
.lrn-fc-score-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.25rem 1.25rem 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: #7c3aed;
  flex-shrink: 0;
}

.lrn-fc-score-val {
  font-weight: 900;
  font-size: 1rem;
  color: var(--fc-orange);
  text-shadow: 0 1px 0 rgba(249,115,22,.3);
}

/* ---- Stage (card area) ------------------------------------ */
.lrn-fc-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem 0.5rem;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* ---- Card ------------------------------------------------- */
.lrn-fc-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border: 3px solid transparent;
  border-radius: var(--fc-radius);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 8px 40px rgba(124,58,237,.14), 0 2px 8px rgba(0,0,0,.06);
  user-select: none;
  transition: transform 0.28s cubic-bezier(.34,1.56,.64,1), opacity 0.22s ease;
  position: relative;
  /* animated top border */
  background-clip: padding-box;
}

/* Colorful top accent bar */
.lrn-fc-card::before {
  content: '';
  position: absolute;
  top: -3px; left: -3px; right: -3px;
  height: 8px;
  background: linear-gradient(90deg, var(--fc-blue), var(--fc-purple), var(--fc-orange));
  border-radius: var(--fc-radius) var(--fc-radius) 0 0;
  z-index: 2;
}

.lrn-fc-card.slide-out-left  { transform: translateX(-130%) rotate(-6deg); opacity: 0; }
.lrn-fc-card.slide-out-right { transform: translateX(130%) rotate(6deg);  opacity: 0; }
.lrn-fc-card.slide-in        { animation: fcSlideIn 0.3s cubic-bezier(.34,1.56,.64,1) forwards; }

@keyframes fcSlideIn {
  from { transform: translateX(50px) scale(0.95); opacity: 0; }
  to   { transform: translateX(0)    scale(1);    opacity: 1; }
}

/* ---- Phrase illustration ---------------------------------- */
.lrn-fc-illustration {
  text-align: center;
}

.lrn-fc-illustration img {
  border-radius: 1rem;
  max-height: 160px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border: 3px solid #ede9fe;
  box-shadow: 0 4px 16px rgba(124,58,237,.15);
}

/* ---- Phrase image (injected by games.js / renderCard) ----- */
.lrn-fc-card-img {
  text-align: center;
  margin-bottom: 0.25rem;
}

.lrn-fc-card-img img {
  border-radius: 1rem;
  max-height: 180px;
  width: auto;
  max-width: 100%;
  object-fit: cover;
  border: 3px solid #ede9fe;
  box-shadow: 0 4px 16px rgba(124,58,237,.15);
}

@media (max-width: 480px) {
  .lrn-fc-card-img img { max-height: 120px; }
}

/* ---- Source phrase (always visible) ----------------------- */
.lrn-fc-source {
  text-align: center;
}

.lrn-fc-source-lang {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--fc-purple);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
  background: rgba(124,58,237,.08);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  display: inline-flex;
}

.lrn-fc-phrase {
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 900;
  line-height: 1.25;
  color: #1e1b4b;
  letter-spacing: -0.01em;
}

.lrn-fc-phrase.lrn-chinese {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  letter-spacing: 0.05em;
}

.lrn-fc-roman {
  font-size: 0.95rem;
  color: #9580ff;
  font-style: italic;
  margin-top: 0.3rem;
  font-weight: 600;
}

/* ---- Listen button on card -------------------------------- */
.lrn-fc-listen-btn {
  align-self: center;
  background: linear-gradient(135deg, #ede9fe, #e0f2fe);
  border: 2px solid rgba(124,58,237,.2);
  color: var(--fc-purple);
  border-radius: 9999px;
  padding: 0.45rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}
.lrn-fc-listen-btn:hover {
  background: linear-gradient(135deg, #ddd6fe, #bae6fd);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(124,58,237,.2);
}
.lrn-fc-listen-btn.playing {
  background: linear-gradient(135deg, var(--fc-purple), var(--fc-cyan));
  color: #fff;
  border-color: transparent;
  animation: fcListenPulse 1s ease infinite;
}

@keyframes fcListenPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,.4); }
  50%       { box-shadow: 0 0 0 8px rgba(124,58,237,0); }
}

/* ---- Divider + Reveal ------------------------------------- */
.lrn-fc-divider {
  border: none;
  border-top: 2px dashed rgba(124,58,237,.15);
  margin: 0;
}

.lrn-fc-reveal-btn {
  align-self: center;
  background: linear-gradient(135deg, var(--fc-purple), var(--fc-cyan));
  border: none;
  color: #fff;
  border-radius: 9999px;
  padding: 0.7rem 2rem;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 6px 20px rgba(124,58,237,.35);
  letter-spacing: 0.01em;
}
.lrn-fc-reveal-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(124,58,237,.45);
}
.lrn-fc-reveal-btn:active { transform: scale(0.98); }

/* ---- Translations area ------------------------------------ */
.lrn-fc-translations {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: fcReveal 0.25s cubic-bezier(.34,1.56,.64,1);
}

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

.lrn-fc-trans-item {
  background: linear-gradient(135deg, #faf5ff, #e0f2fe);
  border: 2px solid #ede9fe;
  border-radius: 1rem;
  padding: 0.65rem 0.875rem;
}

.lrn-fc-trans-item:nth-child(2) { background: linear-gradient(135deg, #f0fdf4, #ecfeff); border-color: #bbf7d0; }
.lrn-fc-trans-item:nth-child(3) { background: linear-gradient(135deg, #fff7ed, #fefce8); border-color: #fed7aa; }

.lrn-fc-trans-lang {
  font-size: 0.68rem;
  font-weight: 900;
  color: var(--fc-purple);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lrn-fc-trans-item:nth-child(2) .lrn-fc-trans-lang { color: var(--fc-green); }
.lrn-fc-trans-item:nth-child(3) .lrn-fc-trans-lang { color: var(--fc-orange); }

.lrn-fc-trans-text {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e1b4b;
  line-height: 1.3;
}

.lrn-fc-trans-roman {
  font-size: 0.78rem;
  color: #9580ff;
  font-style: italic;
  margin-top: 0.1rem;
  font-weight: 600;
}

/* ---- Practice / Recognition ------------------------------- */
.lrn-fc-practice-btn {
  align-self: center;
  background: linear-gradient(135deg, var(--fc-cyan), #6366f1);
  border: none;
  color: #fff;
  border-radius: 9999px;
  padding: 0.7rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(6,182,212,.35);
}
.lrn-fc-practice-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(6,182,212,.45);
}
.lrn-fc-practice-btn:active { transform: scale(0.97); }
.lrn-fc-practice-btn.listening {
  background: linear-gradient(135deg, #dc2626, var(--fc-orange));
  box-shadow: 0 6px 20px rgba(220,38,38,.4);
  animation: fcRecordPulse 1s ease infinite;
}

@keyframes fcRecordPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); }
  50%       { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
}

/* ---- Feedback banner -------------------------------------- */
.lrn-fc-feedback {
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: 0.875rem;
  font-size: 0.9rem;
  font-weight: 800;
  display: none;
  animation: fcFeedback 0.25s cubic-bezier(.34,1.56,.64,1);
}
.lrn-fc-feedback.visible { display: block; }

@keyframes fcFeedback {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.lrn-fc-feedback.great  {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
  border: 2px solid #6ee7b7;
}
.lrn-fc-feedback.almost {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #78350f;
  border: 2px solid #fcd34d;
}
.lrn-fc-feedback.retry  {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #7f1d1d;
  border: 2px solid #fca5a5;
}

.lrn-fc-recognized-text {
  font-size: 0.78rem;
  color: #7c3aed;
  font-style: italic;
  margin-top: 0.25rem;
  font-weight: 600;
}

/* ---- Notes on card ---------------------------------------- */
.lrn-fc-notes {
  font-size: 0.8rem;
  color: #6b5e8a;
  background: #f5f3ff;
  border: 2px solid #ede9fe;
  border-radius: 0.75rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  font-weight: 600;
}

/* ---- Footer controls -------------------------------------- */
.lrn-fc-footer {
  padding: 0.75rem 1.25rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}

.lrn-fc-nav-btn {
  background: #fff;
  border: 2.5px solid #ede9fe;
  color: var(--fc-purple);
  border-radius: 9999px;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  min-width: 6.5rem;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(124,58,237,.1);
}
.lrn-fc-nav-btn:hover {
  background: #ede9fe;
  border-color: var(--fc-purple);
  transform: scale(1.05);
}
.lrn-fc-nav-btn:active { transform: scale(0.97); }
.lrn-fc-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ---- Complete screen -------------------------------------- */
.lrn-fc-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1.5rem;
  flex: 1;
  animation: fcSlideIn 0.4s cubic-bezier(.34,1.56,.64,1);
}

.lrn-fc-complete-icon {
  font-size: 4.5rem;
  margin-bottom: 0.75rem;
  animation: fcBounce 0.6s cubic-bezier(.34,1.56,.64,1) 0.2s both;
}

@keyframes fcBounce {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);   opacity: 1; }
}

.lrn-fc-complete h2 {
  font-size: 2rem;
  font-weight: 900;
  color: #1e1b4b;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.lrn-fc-complete-score {
  font-size: 3.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--fc-purple), var(--fc-cyan), var(--fc-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4rem;
  line-height: 1;
}

.lrn-fc-complete-subtitle {
  font-size: 0.9rem;
  color: #6b5e8a;
  font-weight: 600;
  margin-bottom: 2rem;
}

.lrn-fc-complete-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.lrn-fc-btn-restart {
  background: linear-gradient(135deg, var(--fc-purple), var(--fc-cyan));
  border: none;
  color: #fff;
  border-radius: 9999px;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(124,58,237,.35);
}
.lrn-fc-btn-restart:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 10px 28px rgba(124,58,237,.45);
}

.lrn-fc-btn-exit {
  background: #fff;
  border: 2.5px solid #ede9fe;
  color: var(--fc-purple);
  border-radius: 9999px;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  box-shadow: 0 3px 10px rgba(124,58,237,.1);
}
.lrn-fc-btn-exit:hover { background: #ede9fe; border-color: var(--fc-purple); }

/* ---- Swipe hint ------------------------------------------- */
.lrn-fc-swipe-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9580ff;
  margin-top: 0.4rem;
  animation: fcFadeOut 2s ease 3s forwards;
}

@keyframes fcFadeOut {
  to { opacity: 0; visibility: hidden; }
}

/* ---- Responsive — Mobile first ---------------------------- */
@media (max-width: 480px) {
  .lrn-fc-header { padding: 0.5rem 0.875rem; }
  .lrn-fc-title  { font-size: 0.8rem; }
  .lrn-fc-close  { width: 2rem; height: 2rem; font-size: 1rem; }

  .lrn-fc-progress-wrap { padding: 0.2rem 0.875rem 0; }
  .lrn-fc-progress-bar-track { height: 8px; }
  .lrn-fc-progress-bar-fill::after { width: 12px; height: 12px; }
  .lrn-fc-progress-label { font-size: 0.68rem; margin-top: 0.35rem; }

  .lrn-fc-score-bar { padding: 0.15rem 0.875rem 0; font-size: 0.72rem; }
  .lrn-fc-score-val { font-size: 0.9rem; }

  .lrn-fc-stage { padding: 0.4rem 0.75rem 0.25rem; align-items: flex-start; }

  .lrn-fc-card {
    padding: 1.25rem 1rem;
    border-radius: 1.25rem;
    gap: 0.75rem;
    /* Ensure card fits without forcing scroll */
    max-height: none;
  }

  .lrn-fc-illustration img { max-height: 110px; }

  .lrn-fc-phrase { font-size: clamp(1.1rem, 6vw, 1.5rem); }
  .lrn-fc-phrase.lrn-chinese { font-size: clamp(1.4rem, 7vw, 1.8rem); }

  .lrn-fc-reveal-btn { padding: 0.6rem 1.5rem; font-size: 0.88rem; }
  .lrn-fc-practice-btn { padding: 0.6rem 1.25rem; font-size: 0.85rem; }

  .lrn-fc-trans-text { font-size: 1rem; }

  .lrn-fc-footer { padding: 0.5rem 0.75rem 0.75rem; gap: 0.5rem; }
  .lrn-fc-nav-btn { padding: 0.5rem 0.875rem; font-size: 0.82rem; min-width: 5.5rem; }

  .lrn-fc-complete { padding: 1.5rem 1rem; }
  .lrn-fc-complete-icon { font-size: 3.5rem; }
  .lrn-fc-complete h2 { font-size: 1.5rem; }
  .lrn-fc-complete-score { font-size: 2.75rem; }
  .lrn-fc-btn-restart,
  .lrn-fc-btn-exit { padding: 0.65rem 1.5rem; font-size: 0.9rem; }
}

/* Very short screens (landscape phone) */
@media (max-height: 560px) {
  .lrn-fc-illustration img { max-height: 70px; }
  .lrn-fc-card { gap: 0.5rem; padding: 0.875rem 0.875rem; }
  .lrn-fc-header { padding: 0.4rem 0.875rem; }
  .lrn-fc-footer { padding: 0.4rem 0.875rem 0.5rem; }
}
