/* LingoFruit Chinese · 灵果中文 — grammar module styles
 * Mobile-first, wide layout, matching the site's green/cream design language.
 */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: #183e34;
  background: #f8f6ef;
  font: 17px/1.55 system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
a { color: inherit; }
main, header, footer { max-width: 1280px; margin: auto; padding: 0 clamp(20px, 5vw, 70px); }

/* ---------- header / footer (shared with site) ---------- */
header, footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
header { height: 84px; border-bottom: 1px solid #ccd4c6; }
footer { border-top: 1px solid #c8d0c4; padding-top: 16px; padding-bottom: 20px; color: #657366; font-size: 14px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 750; }
.brand img { width: 38px; height: 38px; }
nav { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
nav a { text-decoration: none; }
nav a:hover { text-decoration: underline; }
nav a[aria-current="page"] { color: #184f39; font-weight: 700; }

/* ---------- hero ---------- */
.hero { padding: clamp(28px, 5vw, 60px) 0 8px; }
.hero .tag { font-size: 12px; font-weight: 720; letter-spacing: .14em; color: #566b5b; }
.hero h1 { font: normal clamp(32px, 4.6vw, 58px)/1.06 Georgia, serif; letter-spacing: -.03em; margin: 14px 0 10px; }
.hero h1 i { color: #507957; font-style: italic; }
.lead { max-width: 62ch; color: #425b50; font-size: 18px; margin: 0 0 18px; }

.hero-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; }
.search {
  flex: 1 1 260px; border: 1px solid #c8d0c4; background: #fffdf8; color: #183e34;
  border-radius: 10px; padding: 12px 16px; font: inherit;
}
.search:focus { outline: 3px solid #b77030; outline-offset: 2px; border-color: #588366; }
.btn {
  display: inline-block; background: #184f39; color: #fff; border-radius: 8px;
  padding: 13px 23px; text-decoration: none; font-weight: 650; border: none; cursor: pointer; font-size: 16px;
}
.btn:hover { background: #0d3a2a; }
.btn.ghost { background: transparent; color: #184f39; border: 1px solid #c8d0c4; }
.btn.ghost:hover { border-color: #588366; background: #fffdf8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0 4px; }
.stat {
  background: #fffdf8; border: 1px solid #d5dacf; border-radius: 12px;
  padding: 14px 16px; text-align: center;
}
.stat b { display: block; font-size: 26px; font-family: Georgia, serif; color: #184f39; }
.stat span { font-size: 12px; letter-spacing: .08em; color: #566b5b; text-transform: uppercase; }
.stat.due b { color: #b77030; }

/* ---------- section headings ---------- */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 34px 0 6px; }
.section-head h2 { font: normal clamp(24px, 3vw, 34px)/1.15 Georgia, serif; margin: 0; letter-spacing: -.02em; }
.section-head .sub { color: #657366; font-size: 14px; }

/* ---------- topic grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; padding: 10px 0 6px; }
.topic-card {
  display: flex; flex-direction: column; gap: 8px; text-decoration: none;
  background: #fffdf8; border: 1px solid #d5dacf; border-radius: 14px; padding: 18px 18px 16px;
  box-shadow: 0 8px 22px rgba(66, 56, 40, .05); transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
}
.topic-card:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(66, 56, 40, .1); border-color: #b9c6b4; }
.topic-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topic-zh { font-size: 20px; color: #184f39; }
.badge { font-size: 12px; font-weight: 650; color: #566b5b; background: #eef0e6; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.badge-due { color: #a4412f; background: #f6e4dd; }
.badge-mastered { color: #184f39; background: #dfe9dd; }
.topic-card h3 { font: 700 19px/1.25 Georgia, serif; margin: 4px 0 0; letter-spacing: -.01em; }
.topic-card p { margin: 0; color: #4c6053; font-size: 15px; }
.topic-card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; border-top: 1px dashed #e0e3d6; }
.topic-card-foot .lv { font-size: 12px; letter-spacing: .08em; color: #566b5b; text-transform: uppercase; }
.topic-card-foot .go { font-size: 14px; font-weight: 650; color: #184f39; }

/* ---------- topic detail ---------- */
.back {
  background: none; border: none; cursor: pointer; font: inherit; font-weight: 650;
  color: #184f39; padding: 16px 0 6px; font-size: 15px;
}
.back:hover { text-decoration: underline; }
.topic-hero { padding: 10px 0 6px; }
.topic-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.topic-hero-top .tag { font-size: 12px; font-weight: 720; letter-spacing: .14em; color: #566b5b; }
.topic-hero-top .status { font-size: 13px; color: #657366; }
.topic-hero h1 { font: normal clamp(30px, 4.4vw, 52px)/1.08 Georgia, serif; letter-spacing: -.03em; margin: 12px 0 8px; }
.topic-hero h1 .zh-title { color: #507957; font-family: system-ui, 'PingFang SC', sans-serif; font-size: .62em; font-weight: 700; }

.block { padding: 18px 0 4px; }
.block h2 { font: normal clamp(22px, 3vw, 30px)/1.15 Georgia, serif; margin: 0 0 8px; letter-spacing: -.02em; }
.block h2 .h2-note { font-size: 13px; font-family: system-ui, sans-serif; color: #9aa79c; letter-spacing: 0; font-weight: 400; }
.explain { max-width: 70ch; color: #425b50; font-size: 17px; margin: 0 0 10px; }
.explain b { color: #183e34; }

.pattern {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #eef0e6; border: 1px solid #d5dacf; border-radius: 10px; padding: 12px 16px;
}
.pattern-label { font-size: 11px; letter-spacing: .14em; color: #566b5b; text-transform: uppercase; font-weight: 700; }
.pattern code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 15px; color: #184f39; }

/* examples */
ul.examples, ul.mistakes { list-style: none; margin: 4px 0 0; padding: 0; }
.examples li.ex {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 14px; row-gap: 2px; align-items: baseline;
  padding: 12px 14px; border-bottom: 1px solid #e2e5da; border-radius: 8px;
}
.examples li.ex:hover { background: #fffdf8; }
.ex-zh { font-size: 20px; color: #183e34; }
.ex-py { font: italic 15px/1.3 Georgia, serif; color: #916138; }
.ex-en { color: #657366; font-size: 15px; grid-column: 1 / -1; }
.speak {
  border: 1px solid #c8d0c4; background: #fff; color: #184f39; border-radius: 999px;
  width: 32px; height: 32px; cursor: pointer; font-size: 14px; line-height: 1; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  grid-column: 2; grid-row: 1 / span 2; align-self: center; justify-self: end;
}
.speak:hover { border-color: #588366; background: #f0f5ee; }

/* common mistakes */
.mistakes li.mistake { padding: 14px 16px; border: 1px solid #e4ded0; border-radius: 12px; margin: 10px 0; background: #fffdf8; }
.mk-wrong, .mk-fix { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.mk-wrong span[lang="zh"], .mk-fix span[lang="zh"] { font-size: 19px; }
.mk-wrong span[lang="zh"] { color: #a4412f; text-decoration: line-through; text-decoration-color: #d98a72; }
.mk-mark { font-weight: 700; font-size: 14px; }
.mk-wrong .mk-mark { color: #a4412f; }
.mk-mark.ok { color: #2c5f4e; }
.mk-py { font: italic 14px/1.3 Georgia, serif; color: #916138; }
.mk-why { color: #4c6053; font-size: 14px; margin: 6px 0 6px; padding-left: 22px; }
.mk-fix { color: #184f39; }

.topic-actions { padding: 22px 0 40px; }

/* ---------- practice player ---------- */
.practice-head { display: flex; align-items: center; gap: 12px; padding: 16px 0 10px; }
.practice-head .mode-label { font-weight: 650; color: #566b5b; }
.practice-head .prog { margin-left: auto; font-variant-numeric: tabular-nums; color: #657366; font-size: 14px; }
.practice-card {
  background: #fffdf8; border: 1px solid #d5dacf; border-radius: 18px;
  box-shadow: 0 14px 34px rgba(66, 56, 40, .08); padding: clamp(20px, 4vw, 32px);
}
.prompt { font-size: 20px; color: #183e34; text-align: center; margin-bottom: 18px; font-weight: 600; }

.answer-tray {
  min-height: 64px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center;
  border: 2px dashed #c8d0c4; border-radius: 12px; padding: 12px; margin-bottom: 18px; background: #fbfaf3;
}
.tray-hint { color: #9aa79c; font-size: 14px; }
.slot {
  border: 1px solid #588366; background: #eef4ec; color: #184f39; border-radius: 10px;
  padding: 10px 16px; font-size: 20px; font-weight: 650; cursor: pointer; font-family: inherit;
}
.slot:hover { background: #e2ecdf; }
.answer-tray.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.token-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 6px; }
.token {
  border: 1px solid #c8d0c4; background: #fff; color: #183e34; border-radius: 12px;
  padding: 12px 18px; font-size: 20px; font-weight: 650; cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 6px rgba(66,56,40,.05);
}
.token:hover { border-color: #588366; background: #f0f5ee; transform: translateY(-1px); }

.feedback { min-height: 24px; text-align: center; font-weight: 650; font-size: 16px; margin: 10px 0 4px; }
.feedback.ok { color: #2c5f4e; }
.feedback.err { color: #a4412f; }

.practice-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

.answer-card {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center;
  margin-top: 18px; padding: 16px; border: 1px solid #d5e0d0; border-radius: 12px; background: #f0f5ee;
}
.answer-zh { font-size: 24px; color: #184f39; }
.answer-en { color: #4c6053; font-size: 15px; }
.answer-note { width: 100%; text-align: center; color: #657366; font-size: 13px; font-style: italic; }

/* ---------- done screen ---------- */
.done { text-align: center; padding: 60px 20px; }
.done h2 { font: normal clamp(28px, 5vw, 44px)/1.1 Georgia, serif; margin: 0 0 10px; }
.done p { color: #4c6053; max-width: 46ch; margin: 0 auto 22px; }
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- focus ---------- */
:focus-visible { outline: 3px solid #698b6f; outline-offset: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 750px) {
  header { height: 66px; }
  nav { gap: 12px; font-size: 14px; }
  .brand img { width: 29px; height: 29px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .topic-card { padding: 14px; }
  .topic-card h3 { font-size: 17px; }
  .token, .slot { font-size: 18px; padding: 10px 14px; }
  .prompt { font-size: 18px; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; }
}
