/* 18-vocab.css — Vocabulary trainer (/vocab/<subject>/<topic>).
   Page-scoped: loaded via train.html {% block extra_head %}, NOT in app.bundle.css.
   Endless practice + game feel: glass card, live score, celebratory FX.
   Theme matches the site (slate/cyan glass on the space background). */

.vocab-trainer { max-width: 40rem; margin: 0 auto; position: relative; }

/* [hidden] must win: the display rules below (e.g. .vt-btn{display:inline-flex})
   otherwise override the UA-stylesheet [hidden]{display:none}, leaking elements
   the JS toggles (the caught-up hint, the screens). */
.vocab-trainer [hidden] { display: none !important; }

/* ── Session top bar: score (exit is the breadcrumb above) ── */
.vt-topbar { display: flex; align-items: center; gap: 0.6rem; margin-top: 1.5rem; }

/* Score chip (identity total; mirrors the global header badge). */
.vt-score {
  position: relative; margin-left: auto;
  display: inline-flex; align-items: center; gap: 0.35rem; line-height: 1;
  padding: 0.28rem 0.75rem; border-radius: 9999px;
  border: 1px solid rgba(250, 204, 21, 0.32);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.18), rgba(245, 158, 11, 0.12));
  color: #fde68a; font-size: 0.95rem; font-weight: 800;
}
.vt-score-icon { width: 1rem; height: 1rem; color: #fbbf24; filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5)); flex-shrink: 0; }
.vt-score-value { font-variant-numeric: tabular-nums; }
.vt-score.is-bumping { animation: score-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
/* "+N" floats up out of the chip on a gain; absolute so it never reflows the row. */
.vt-score-gain {
  position: absolute; right: 0.7rem; top: -0.1rem; opacity: 0; pointer-events: none;
  font-size: 0.85rem; font-weight: 800; color: #fde68a; white-space: nowrap;
  text-shadow: 0 1px 6px rgba(245, 158, 11, 0.5);
}
.vt-score-gain.is-floating { animation: vt-gain-float 0.9s ease-out; }

/* ── Deck mastery bar (full width, live) ── */
.vt-deckbar { display: flex; align-items: center; gap: 0.75rem; margin-top: 1rem; }
.vt-deckbar-track {
  position: relative; flex: 1; height: 8px; border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
/* Two-tone: a lighter "learning" segment (box≥1) behind the green "mastered"
   segment, so the bar moves after the first session instead of sitting at 0. */
.vt-deckbar-fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%;
  border-radius: 9999px; transition: width 0.4s ease;
}
.vt-deckbar-fill-learning { background: rgba(251, 191, 36, 0.5); }
.vt-deckbar-fill-mastered { background: linear-gradient(90deg, #22d3ee, #34d399); }
.vt-deckbar-label { font-size: 0.8rem; color: #94a3b8; white-space: nowrap; }

/* ── "All caught up — reviewing for fun" hint (cosmetic cycle) ── */
.vt-caughtup {
  margin-top: 0.85rem; padding: 0.6rem 0.85rem; border-radius: 0.7rem;
  font-size: 0.85rem; color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.25); background: rgba(52, 211, 153, 0.08);
}

/* ── Buttons ── */
.vt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  cursor: pointer; border-radius: 0.7rem; padding: 0.6rem 1.1rem;
  font-size: 0.9rem; font-weight: 600; text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0; transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.vt-btn:hover { background: rgba(255, 255, 255, 0.09); }
.vt-btn:active { transform: translateY(1px); }
.vt-btn-primary {
  border-color: transparent;
  background: linear-gradient(90deg, #06b6d4, #4f46e5); color: #fff;
}
.vt-btn-primary:hover { background: linear-gradient(90deg, #22d3ee, #6366f1); }
.vt-btn-ghost { background: transparent; }

/* ── Card stage ── */
.vt-stage { margin-top: 1.5rem; position: relative; outline: none; }
.vt-stage.vt-flash-correct { animation: vt-flash-correct 0.55s ease; }
.vt-stage.vt-flash-wrong { animation: vt-shake 0.4s ease; }

.vt-cardbox {
  position: relative; width: 100%; min-height: 13rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.75rem; text-align: center; cursor: pointer;
  border-radius: 1.25rem; padding: 2.25rem 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 20px 40px -24px rgba(0, 0, 0, 0.6),
    0 0 60px -30px rgba(34, 211, 238, 0.25);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}
.vt-cardbox:hover { border-color: rgba(34, 211, 238, 0.3); transform: translateY(-2px); }
.vt-cardbox:focus-visible { outline: 2px solid rgba(34, 211, 238, 0.6); outline-offset: 2px; }
.vt-cardbox.is-flipped {
  background: linear-gradient(160deg, rgba(34, 211, 238, 0.1), rgba(99, 102, 241, 0.06));
  border-color: rgba(34, 211, 238, 0.25);
}

/* Grade cue: a small directional swipe on the outgoing card (know = right/green,
   don't-know = left/red, hard = amber pulse). Subtle, then it's re-rendered away.
   Reduced-motion swaps the slide for a static colour (see the media query below). */
.vt-cardbox.vt-grade-good  { animation: vt-swipe-right 0.2s ease forwards; }
.vt-cardbox.vt-grade-again { animation: vt-swipe-left 0.2s ease forwards; }
.vt-cardbox.vt-grade-hard  { animation: vt-pulse-hard 0.22s ease forwards; }

.vt-prompt-wrap { position: relative; text-align: center; margin-bottom: 1.25rem; }
.vt-prompt { font-size: 1.9rem; font-weight: 600; color: #f1f5f9; line-height: 1.2; }
.vt-prompt-zh { font-size: 2.2rem; }
.vt-reveal { display: flex; flex-direction: column; gap: 0.25rem; }
.vt-reveal[hidden] { display: none; }
.vt-zh { font-size: 2rem; font-weight: 600; color: #a5f3fc; }
.vt-py { font-size: 1rem; color: #94a3b8; font-style: normal; }
.vt-fliphint { font-size: 0.8rem; color: #64748b; }

/* ── Card visual: a picture or concept icon shown together with the word ──────── */
/* Fixed-height box so a late-loading thumbnail never shifts the card. The word is
   always shown alongside, so the visual is supportive (dual-coding), not the answer. */
.vt-card-image {
  display: block; height: 8.25rem; max-width: 100%;
  margin: 0 auto 0.25rem; object-fit: contain;
  border-radius: 0.75rem; padding: 0.4rem;
  background: #f8fafc;  /* light panel keeps dark-stroke diagrams legible on the dark card */
  box-shadow: 0 8px 20px -14px rgba(0, 0, 0, 0.7);
}
.vt-card-icon {
  display: flex; align-items: center; justify-content: center;
  height: 6rem; margin: 0 auto 0.25rem; color: #67e8f9;  /* cyan accent, matches the card */
}
.vt-card-icon svg { width: 5rem; height: 5rem; }
/* The MC/typing header is not a flex column, so add explicit spacing below the visual. */
.vt-prompt-wrap .vt-card-image, .vt-prompt-wrap .vt-card-icon { margin-bottom: 0.9rem; }
@media (max-width: 640px) {
  .vt-card-image { height: 6.5rem; }
  .vt-card-icon { height: 5rem; }
  .vt-card-icon svg { width: 4rem; height: 4rem; }
}
.vt-fliphint[hidden] { display: none; }

/* ── Rating row (flashcard): three symbol buttons. The outer two (✕ / ✓) mirror the
   card's left/right click-zones (don't-know / know); the middle ~ is "hard". ── */
.vt-rating { display: flex; align-items: center; justify-content: center; gap: 1.4rem; margin-top: 1.25rem; }
.vt-rating[hidden] { display: none; }
.vt-rate {
  position: relative; flex: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  width: 3.3rem; height: 3.3rem; border-radius: 9999px; color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}
.vt-rate svg { width: 1.5rem; height: 1.5rem; }
.vt-rate:hover { transform: translateY(-2px); }
.vt-rate:active { transform: translateY(0); }
.vt-rate:focus-visible { outline: 2px solid rgba(34, 211, 238, 0.6); outline-offset: 2px; }
.vt-rate-again { color: #fca5a5; }
.vt-rate-again:hover { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.45); }
.vt-rate-hard { color: #fcd34d; width: 2.8rem; height: 2.8rem; }   /* middle: smaller, lower-emphasis */
.vt-rate-hard svg { width: 1.3rem; height: 1.3rem; }
.vt-rate-hard:hover { background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.45); }
.vt-rate-good { color: #6ee7b7; }
.vt-rate-good:hover { background: rgba(52, 211, 153, 0.16); border-color: rgba(52, 211, 153, 0.45); }
/* Standing affordance: ← beside ✕, → beside ✓ — telegraphs the card-zone / arrow-key gesture. */
.vt-rate-again::before, .vt-rate-good::after {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 0.95rem; color: #64748b; pointer-events: none;
}
.vt-rate-again::before { content: "←"; right: 100%; margin-right: 0.5rem; }
.vt-rate-good::after { content: "→"; left: 100%; margin-left: 0.5rem; }

/* ── Multiple choice ── */
.vt-options { display: flex; flex-direction: column; gap: 0.6rem; }
.vt-option {
  width: 100%; min-height: 3rem; cursor: pointer; text-align: left;
  padding: 0.85rem 1.1rem; border-radius: 0.8rem; font-size: 1.05rem; color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.vt-option:hover:not([disabled]) { background: rgba(34, 211, 238, 0.1); border-color: rgba(34, 211, 238, 0.35); transform: translateY(-1px); }
.vt-option[disabled] { cursor: default; }
.vt-option.is-correct { background: rgba(52, 211, 153, 0.18); border-color: rgba(52, 211, 153, 0.55); color: #bbf7d0; }
.vt-option.is-wrong { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.5); color: #fecaca; }

/* ── Typing ── */
.vt-input {
  width: 100%; margin-top: 0.25rem; padding: 0.85rem 1rem; border-radius: 0.8rem;
  font-size: 1.15rem; color: #f1f5f9; background: rgba(2, 6, 23, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
.vt-input::placeholder { color: #64748b; }
.vt-input:focus { outline: none; border-color: rgba(34, 211, 238, 0.45); box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.18); }
.vt-input.vt-shake { animation: vt-shake 0.4s ease; }
.vt-type-row { display: flex; gap: 0.6rem; margin-top: 0.8rem; }

/* ── Feedback ── */
.vt-feedback { margin-top: 1.1rem; font-size: 0.95rem; }
.vt-feedback:empty { display: none; }
.vt-feedback.is-correct { color: #a7f3d0; }
.vt-feedback.is-almost { color: #fde68a; }
.vt-feedback.is-wrong { color: #fecaca; }
.vt-feedback.is-hint { color: #94a3b8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; }
.vt-fb-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem; }
.vt-fb-answer { font-weight: 700; color: #f1f5f9; }
.vt-fb-reason { color: #94a3b8; }
.vt-next { margin-top: 0.85rem; }

/* ── Celebrations: confetti burst + mastery toast (DOM kept inside .vocab-trainer) ── */
.vt-confetti { position: fixed; left: 50%; top: 38%; width: 0; height: 0; pointer-events: none; z-index: 60; }
.vt-confetti-bit {
  position: absolute; left: 0; top: 0; width: 9px; height: 9px; border-radius: 2px;
  background: hsl(var(--h, 50), 90%, 60%);
  animation: vt-confetti-fly 1s ease-out forwards;
}
.vt-toast {
  position: fixed; left: 50%; bottom: 2rem; z-index: 60; opacity: 0;
  transform: translate(-50%, 1rem);
  padding: 0.65rem 1.05rem; border-radius: 0.85rem;
  font-size: 0.9rem; font-weight: 600; color: #f0fdf4;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.92));
  box-shadow: 0 14px 32px -12px rgba(0, 0, 0, 0.6), 0 0 28px -8px rgba(16, 185, 129, 0.5);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.vt-toast.is-in { opacity: 1; transform: translate(-50%, 0); }

/* ── Keyframes ── */
@keyframes score-pop { 0% { transform: scale(1); } 40% { transform: scale(1.28); } 100% { transform: scale(1); } }
@keyframes vt-gain-float { 0% { opacity: 0; transform: translateY(0); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(-1.5rem); } }
@keyframes vt-flash-correct {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
  30% { box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.5), 0 0 28px -2px rgba(52, 211, 153, 0.4); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
@keyframes vt-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
@keyframes vt-confetti-fly {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, -80px)) rotate(var(--rot, 180deg)); opacity: 0; }
}
@keyframes vt-swipe-right {
  to { transform: translateX(16px); opacity: 0.9; border-color: rgba(52, 211, 153, 0.55);
       box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.5), 0 0 26px -4px rgba(52, 211, 153, 0.45); }
}
@keyframes vt-swipe-left {
  to { transform: translateX(-16px); opacity: 0.9; border-color: rgba(248, 113, 113, 0.55);
       box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.5), 0 0 26px -4px rgba(248, 113, 113, 0.45); }
}
@keyframes vt-pulse-hard {
  50% { border-color: rgba(251, 191, 36, 0.55);
        box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45), 0 0 22px -4px rgba(251, 191, 36, 0.4); }
}

@media (max-width: 480px) {
  .vt-prompt { font-size: 1.55rem; }
  .vt-prompt-zh { font-size: 1.85rem; }
  .vt-zh { font-size: 1.7rem; }
}

/* Respect reduced-motion: kill BOTH transitions and the new keyframe animations
   (state is always conveyed without motion — flip via show/hide, score via the
   number itself, correct/wrong via colour). */
@media (prefers-reduced-motion: reduce) {
  .vt-deckbar-fill, .vt-cardbox, .vt-btn, .vt-rate, .vt-option, .vt-toast { transition: none; }
  .vt-score.is-bumping, .vt-score-gain.is-floating,
  .vt-stage.vt-flash-correct, .vt-stage.vt-flash-wrong, .vt-input.vt-shake,
  .vt-confetti-bit,
  .vt-cardbox.vt-grade-good, .vt-cardbox.vt-grade-again, .vt-cardbox.vt-grade-hard { animation: none; }
  /* Motion-free grade cue: colour the border so the result still reads clearly. */
  .vt-cardbox.vt-grade-good  { border-color: rgba(52, 211, 153, 0.6); }
  .vt-cardbox.vt-grade-again { border-color: rgba(248, 113, 113, 0.6); }
  .vt-cardbox.vt-grade-hard  { border-color: rgba(251, 191, 36, 0.6); }
}
