/* Demo D · 多邻国风：白底、Feather Green 立体按钮、底部反馈横幅、心与连击。
   色板与字体规则来自 Duolingo 公开设计规范的整理（github.com/virgiliojr94/duolingo-ux-reference），
   仅风格致敬，不含 Duolingo 商标与素材。
   Nunito（SIL OFL 开源）为本地自托管 latin 子集，中文字符回退系统字体。 */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/nunito-400.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/nunito-700.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/nunito-800.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("fonts/nunito-900.woff2") format("woff2");
}
:root {
  /* Duolingo 公开色板 */
  --green: #58cc02;
  --green-dark: #58a700;
  --green-soft: #d7ffb8;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --blue-soft: #ddf4ff;
  --blue-edge: #84d8ff;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --red-soft: #ffdfe0;
  --gold: #ffc800;
  --eel: #4b4b4b;
  --wolf: #777777;
  --hare: #afafaf;
  --swan: #e5e5e5;
  --polar: #f7f7f7;
  --snow: #ffffff;
  --radius: 16px;
  --tap: 48px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--snow);
  color: var(--eel);
  font-family: "Nunito", ui-rounded, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: clamp(15px, 0.4vw + 14px, 16px);
  line-height: 1.5;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏：✕ + 心 + 连击 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 14px calc(16px + env(safe-area-inset-left));
  background: var(--snow);
}
.topbar h1 {
  flex: 1; min-width: 0; margin: 0;
  font-size: 17px; font-weight: 900;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  flex: none; width: 36px; height: 36px;
  border: none; border-radius: 12px;
  background: transparent; color: var(--wolf);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--polar); }
.status { display: flex; align-items: center; gap: 10px; flex: none; }
.hearts { font-size: 15px; letter-spacing: 2px; white-space: nowrap; }
.hearts .full { color: var(--red); }
.hearts .lost { color: var(--swan); }
.combo { font-weight: 900; color: var(--gold); white-space: nowrap; }

/* ---------- 主体 ---------- */
main {
  max-width: 640px; margin: 0 auto;
  padding: 8px 16px calc(120px + env(safe-area-inset-bottom));
}
.hero { padding: 8px 2px 18px; }
.hero-eyebrow { color: var(--wolf); font-size: 13px; font-weight: 800; margin: 0 0 2px; }
.hero-title { font-size: clamp(24px, 1.6vw + 20px, 30px); font-weight: 900; margin: 0; line-height: 1.15; }
.home-hint { color: var(--wolf); font-size: 13.5px; margin: 0 2px 14px; }

/* ---------- 题库卡片（纵向 flex：描述定高截断，按钮行钉底对齐） ---------- */
.bank-list { display: grid; gap: 14px; }
.card {
  background: var(--snow);
  border: 2px solid var(--swan); border-radius: var(--radius);
  padding: 20px;
}
.bank-card { display: flex; flex-direction: column; }
.bank-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bank-card h3 { margin: 0; font-size: 16.5px; font-weight: 900; }
.bank-star { flex: none; color: var(--gold); font-size: 12px; letter-spacing: 2px; }
.bank-count { flex: none; color: var(--wolf); font-size: 13px; font-weight: 800; }
.bank-desc {
  color: var(--wolf); font-size: 13.5px; font-weight: 600; margin: 6px 0 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  height: 3em; /* 恰好两行（line-height 1.5），保证多卡内容区等高 */
}
.bank-meta { display: flex; gap: 14px; font-size: 13px; color: var(--wolf); margin-bottom: 14px; }
.bank-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: auto; }
.bank-actions .btn3d { padding: 10px 6px; font-size: 13.5px; letter-spacing: 0; white-space: nowrap; }

/* ---------- 立体按钮（多邻国手感核心） ---------- */
.btn3d {
  min-height: var(--tap); padding: 12px 20px;
  border: none; border-radius: 14px;
  font: inherit; font-size: 14px; font-weight: 900; letter-spacing: .8px;
  cursor: pointer; color: var(--snow);
  background: var(--green); box-shadow: 0 4px 0 var(--green-dark);
  transition: transform .06s ease, box-shadow .06s ease, filter .12s ease;
}
.btn3d:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--green-dark); }
.btn3d:hover:not(:disabled) { filter: brightness(1.05); }
.btn3d:disabled { background: var(--swan); color: var(--hare); box-shadow: 0 4px 0 var(--polar); cursor: not-allowed; }
.btn3d.inverse-blue { background: var(--snow); color: var(--blue); box-shadow: inset 0 0 0 2px var(--swan), 0 4px 0 var(--swan); }
.btn3d.inverse-blue:active:not(:disabled) { transform: translateY(4px); box-shadow: inset 0 0 0 2px var(--swan), 0 0 0 var(--swan); }
.btn3d.inverse-red { background: var(--snow); color: var(--red); box-shadow: inset 0 0 0 2px var(--swan), 0 4px 0 var(--swan); }
.btn3d.inverse-red:active:not(:disabled) { transform: translateY(4px); box-shadow: inset 0 0 0 2px var(--swan), 0 0 0 var(--swan); }
.btn3d:focus-visible, .opt:focus-visible, .icon-btn:focus-visible, .blank-input:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.link-btn {
  border: none; background: none; color: var(--wolf);
  font: inherit; font-size: 13px; font-weight: 800;
  cursor: pointer; padding: 6px 8px; min-height: 32px; border-radius: 8px;
}
.link-btn:hover:not(:disabled) { background: var(--polar); }
.link-btn:disabled { color: var(--swan); cursor: not-allowed; }

/* ---------- 练习页 ---------- */
.quiz-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 2px 10px; color: var(--wolf); font-size: 13px; font-weight: 800;
}
.progress { height: 16px; border-radius: 999px; background: var(--swan); overflow: hidden; }
.progress-bar {
  width: 0; height: 100%; border-radius: 999px;
  background: var(--green);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .12);
  transition: width .3s ease;
}
.question-card { padding: 24px; }
.q-type {
  display: inline-block; margin-bottom: 12px;
  font-size: 11px; font-weight: 900; letter-spacing: 1px;
  color: var(--blue); background: var(--blue-soft);
  border-radius: 8px; padding: 3px 10px;
}
.q-content {
  white-space: pre-line;
  font-size: clamp(20px, 1vw + 17px, 25px); font-weight: 800; line-height: 1.45;
}
.blank-input {
  display: inline-block; width: 7em; margin: 0 4px; padding: 0 4px;
  border: none; border-bottom: 3px solid var(--blue);
  background: transparent; font: inherit; font-weight: 800; text-align: center; color: var(--eel);
}
.blank-input:focus { outline: none; border-bottom-color: var(--red); }
.q-body { margin-top: 20px; }
.q-actions { min-height: 20px; margin-top: 10px; font-size: 13px; font-weight: 800; color: var(--red); }

/* ---------- 选项（白底 + 实体底边，选中变蓝） ---------- */
.opts { display: grid; gap: 12px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 54px; padding: 12px 16px;
  background: var(--snow);
  border: 2px solid var(--swan); border-radius: 14px;
  box-shadow: 0 4px 0 var(--swan);
  font: inherit; font-weight: 700; color: var(--eel); cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease, border-color .12s ease, background .12s ease;
}
.opt:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--swan); }
.opt.selected { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 4px 0 var(--blue-edge); color: var(--blue-dark); }
.opt-key {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  border: 2px solid var(--swan);
  font-size: 12px; font-weight: 900; color: var(--wolf);
}
.opt.selected .opt-key { border-color: var(--blue); background: var(--snow); }
.opt.right { border-color: var(--green-dark); background: var(--green-soft); box-shadow: 0 4px 0 rgba(88, 167, 0, .35); }
.opt.right .opt-key { border-color: var(--green-dark); background: var(--snow); color: var(--green-dark); }
.opt.miss { border-color: var(--red); background: var(--red-soft); box-shadow: 0 4px 0 rgba(255, 75, 75, .35); }
.opt.miss .opt-key { border-color: var(--red); background: var(--snow); color: var(--red); }
.opt:disabled { cursor: default; }
.short-input {
  width: 100%; min-height: 96px; resize: vertical; padding: 12px;
  border: 2px solid var(--swan); border-radius: 14px;
  font: inherit; font-weight: 600; color: var(--eel); background: var(--snow);
}
.short-input:focus { outline: none; border-color: var(--blue); }

/* ---------- 底部反馈横幅（多邻国答题流灵魂） ---------- */
.feedback-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--snow);
  border-top: 2px solid var(--swan);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.feedback-bar.good { background: var(--green-soft); border-color: transparent; }
.feedback-bar.bad { background: var(--red-soft); border-color: transparent; }
.fb-msg {
  flex: 1; min-width: 200px;
  font-weight: 800; color: var(--eel);
  white-space: pre-line; font-size: 15px; line-height: 1.45;
  max-height: 30vh; overflow-y: auto;
}
.feedback-bar.good .fb-msg { color: var(--green-dark); }
.feedback-bar.bad .fb-msg { color: var(--red-dark); }
.fb-btns { display: flex; gap: 10px; margin-left: auto; }
.feedback-bar .fb-btn, .feedback-bar .fb-alt { min-width: 120px; }
.feedback-bar.good .fb-btn { background: var(--snow); color: var(--green-dark); box-shadow: 0 4px 0 rgba(88, 167, 0, .35); }
.feedback-bar.bad .fb-btn { background: var(--snow); color: var(--red-dark); box-shadow: 0 4px 0 rgba(234, 43, 43, .3); }
.feedback-bar.good .fb-btn:active:not(:disabled),
.feedback-bar.bad .fb-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }

/* ---------- 吉祥物：左下角常驻（完成页隐藏；刷题时抬升到反馈横幅上方，横幅过长时由横幅盖住） ---------- */
.mascot {
  position: fixed; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 15;
  width: 76px; height: auto;
  pointer-events: none; user-select: none;
}
body.in-quiz .mascot { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- 完成页 ---------- */
.done-card { text-align: center; padding: 28px 24px; }
.done-emoji { font-size: 44px; }
.done-card h2 { margin: 6px 0 8px; font-size: 22px; font-weight: 900; }
.done-stat { color: var(--wolf); margin: 0 0 16px; }
.done-wrong { text-align: left; }
.done-wrong h3 { font-size: 14px; margin: 0 0 8px; }
.wrong-item {
  padding: 8px 0; border-top: 2px solid var(--polar);
  font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.done-actions { display: flex; gap: 12px; margin-top: 20px; justify-content: center; flex-wrap: wrap; }

/* ---------- 平板 / 桌面 ---------- */
@media (min-width: 640px) {
  .bank-list { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  main { max-width: 760px; }
  .question-card { padding: 32px; }
  .opts { grid-template-columns: repeat(2, 1fr); }
  .feedback-bar { padding-left: calc(16px + max(0px, (100vw - 760px) / 2)); padding-right: calc(16px + max(0px, (100vw - 760px) / 2)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
