/* ENG3000 — flashcard học từ vựng */
:root {
  --bg: #f2f6ff;
  --card: #ffffff;
  --ink: #1c2340;
  --muted: #6b7390;
  --brand: #4f6ef7;
  --brand-2: #7c4df7;
  --accent: #ffb347;
  --ok: #22b573;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(28, 35, 64, 0.12);
  font-size: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
body.embed { background: transparent; }

/* ---------- header ---------- */
header {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 20px 16px 26px;
  text-align: center;
  border-radius: 0 0 28px 28px;
}
body.embed header { display: none; }
header h1 { font-size: 1.45rem; letter-spacing: 0.3px; }
header p { opacity: 0.9; margin-top: 6px; font-size: 0.95rem; }
.lang-switch {
  display: flex; justify-content: center; gap: 8px; margin-top: 14px;
}
.lang-switch button {
  border: 1px solid rgba(255,255,255,0.55); background: rgba(255,255,255,0.12);
  color: #fff; border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: 0.9rem;
}
.lang-switch button.active { background: #fff; color: var(--brand); font-weight: 700; }

main { max-width: 900px; margin: 0 auto; padding: 20px 14px 60px; }
body.embed main { padding: 8px 8px 16px; }

/* ---------- tìm từ ---------- */
.search-wrap { position: relative; margin: 4px 4px 16px; }
.search-input {
  width: 100%; border: 2px solid #dfe5f7; border-radius: 14px; padding: 12px 16px;
  font-size: 1rem; background: #fff; box-shadow: var(--shadow); outline: none;
  font-family: inherit;
}
.search-input:focus { border-color: var(--brand); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: #fff; border-radius: 14px; box-shadow: 0 16px 40px rgba(28,35,64,0.2);
  max-height: 380px; overflow-y: auto;
}
.search-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid #f0f2fa;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #f4f6ff; }
.search-item img { width: 52px; height: 40px; object-fit: cover; border-radius: 8px; background: #eef1fb; flex: 0 0 auto; }
.search-item .si-main { flex: 1; min-width: 0; }
.search-item .si-ipa { color: var(--muted); font-size: 0.85rem; margin-left: 6px; }
.search-item .si-meaning { color: var(--muted); font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 14px; color: var(--muted); text-align: center; }

/* ---------- level grid ---------- */
.section-title { font-size: 1.15rem; margin: 12px 4px 14px; font-weight: 700; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.level-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; cursor: pointer; transition: transform 0.15s ease; position: relative; overflow: hidden;
  border: 2px solid transparent;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--brand); }
.level-card.locked { opacity: 0.55; cursor: default; }
.level-card.locked:hover { transform: none; border-color: transparent; }
.level-badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700; color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  border-radius: 999px; padding: 3px 10px; margin-bottom: 8px;
}
.level-card h3 { font-size: 1.1rem; margin-bottom: 4px; }
.level-card .ielts { color: var(--accent); font-weight: 700; font-size: 0.85rem; }
.level-card p.desc { color: var(--muted); font-size: 0.85rem; margin-top: 6px; min-height: 2.4em; }
.level-progress { margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
.bar { height: 8px; background: #e8ecfa; border-radius: 999px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), #7be0b0); border-radius: 999px; }

/* ---------- deck ---------- */
.deck-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.deck-top .left { display: flex; align-items: center; gap: 10px; }
.btn {
  border: none; border-radius: 12px; padding: 9px 16px; cursor: pointer; font-size: 0.92rem;
  background: #fff; color: var(--ink); box-shadow: var(--shadow); font-weight: 600;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.ok { background: var(--ok); color: #fff; }
.deck-progress { flex: 1 1 100%; }
.deck-progress .bar { height: 10px; }
.deck-progress .txt { font-size: 0.8rem; color: var(--muted); margin-top: 4px; text-align: right; }

/* ---------- flashcard ---------- */
.card-stage { perspective: 1400px; max-width: 520px; margin: 0 auto; }
.flashcard {
  position: relative; width: 100%; aspect-ratio: 5 / 7; max-height: 78vh;
  transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.3, 1);
  cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.face.back { transform: rotateY(180deg); }

.face .img-wrap { width: 100%; aspect-ratio: 4 / 3; background: #eef1fb; flex: 0 0 auto; position: relative; }
.face .img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face .img-wrap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; z-index: 2; }
.video-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 3;
  border: none; border-radius: 999px; width: 44px; height: 44px; font-size: 1.2rem;
  background: rgba(28,35,64,0.75); color: #fff; cursor: pointer; box-shadow: var(--shadow);
}
.video-btn:hover { background: var(--brand); }
.face .img-wrap .img-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 4rem; background: linear-gradient(135deg, #e8ecfa, #f6e9ff);
}
.face .body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 18px 16px; text-align: center; gap: 6px; }
.face .word { font-size: 2.2rem; font-weight: 800; letter-spacing: 0.5px; }
.face .pos { color: var(--brand-2); font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.face .ipa { color: var(--muted); font-size: 0.98rem; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.audio-row { display: flex; gap: 10px; margin-top: 8px; }
.audio-btn {
  border: 2px solid var(--brand); background: #fff; color: var(--brand);
  border-radius: 999px; padding: 7px 16px; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.audio-btn.playing { background: var(--brand); color: #fff; }
.flip-hint { color: var(--muted); font-size: 0.78rem; margin-top: 8px; }

.face.back .body { justify-content: flex-start; padding-top: 20px; overflow-y: auto; }
.back .word-sm { font-size: 1.4rem; font-weight: 800; }
.meaning-block { width: 100%; background: #f4f6ff; border-radius: 14px; padding: 10px 14px; margin-top: 8px; text-align: left; }
.meaning-block .lang-tag { font-size: 0.72rem; font-weight: 700; color: var(--brand); text-transform: uppercase; }
.meaning-block .txt { font-size: 1.02rem; margin-top: 2px; }
.example-block { width: 100%; border-left: 4px solid var(--accent); background: #fff8ec; border-radius: 0 14px 14px 0; padding: 10px 14px; margin-top: 10px; text-align: left; }
.example-block .en { font-weight: 600; font-style: italic; }
.example-block .tr { color: var(--muted); font-size: 0.9rem; margin-top: 3px; }
.example-block .play-ex { margin-top: 8px; }

/* ---------- deck controls ---------- */
.deck-controls { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.deck-controls .btn.known-on { background: var(--ok); color: #fff; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 20px 0 30px; }
body.embed footer { display: none; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .face .word { font-size: 1.8rem; }
  header h1 { font-size: 1.2rem; }
}
