/* LingoFruit Chinese · 灵果中文 — HSK study module
 * Layered over /tokens.css and /site.css. */

.study-hero .deck-note {
  color: var(--ink-3);
  font-size: var(--text-sm);
  margin: var(--s-3) 0 0;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-5);
}

/* ---- Toolbar: levels + session controls + stats ---- */
.toolbar {
  padding: 0 0 var(--s-3);
}

.levels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r-sm);
  padding: 0 14px;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.chip-count {
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: 4px;
  padding: 2px 6px;
}

.chip:hover {
  border-color: var(--accent-mid);
  color: var(--ink);
}

.chip.active {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

.chip.active .chip-count {
  background: rgba(252, 250, 244, 0.18);
  color: var(--surface);
}

.session-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-4);
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}

.cap-control {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
}

.cap-control select {
  min-height: 40px;
  padding: 6px 12px;
  font-size: var(--text-sm);
}

.due-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.due-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

.session-summary {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-top: var(--s-4);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: var(--s-4);
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  line-height: 1.15;
}

.stat span {
  display: block;
  margin-top: 2px;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.stat.due b {
  color: var(--ochre);
}

/* ---- View tabs ---- */
.tabs {
  display: flex;
  gap: var(--s-2);
  margin: var(--s-6) 0 var(--s-4);
  border-bottom: 1px solid var(--rule);
}

.tab {
  min-height: 44px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink-3);
  padding: 0 var(--s-4);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.deck-status {
  text-align: center;
  color: var(--ink-3);
  padding: var(--s-6) var(--s-4);
}

/* ---- Flashcard ---- */
.flash {
  max-width: 720px;
  margin: var(--s-4) auto 0;
}

.flash-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--ink-3);
  font-size: var(--text-sm);
  margin-bottom: var(--s-3);
}

.flash-head .lvl {
  font-weight: 600;
  color: var(--ink-2);
}

.flash-head .prog {
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--accent);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.listen-btn:hover {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
}

.card-wrap {
  perspective: 1400px;
}

.card {
  position: relative;
  width: 100%;
  min-height: 420px;
  transform-style: preserve-3d;
  transition: transform 420ms var(--ease);
  cursor: pointer;
}

.card.flipped {
  transform: rotateY(180deg);
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 3.5vw, 36px);
  text-align: center;
}

.face.back {
  transform: rotateY(180deg);
  overflow-y: auto;
}

.hint {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  color: var(--ink-4);
  text-transform: uppercase;
}

.front-word {
  font-family: var(--font-zh);
  font-weight: 400;
  font-size: clamp(3.5rem, 10vw, 6.25rem);
  line-height: 1.15;
  margin: var(--s-4) 0 var(--s-2);
  color: var(--ink);
}

.back-word {
  font-family: var(--font-zh);
  font-size: clamp(2.25rem, 6.5vw, 3.5rem);
  line-height: 1.15;
  color: var(--ink);
}

.back-pinyin {
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ochre);
  margin: var(--s-2) 0 4px;
}

.back-meaning {
  font-family: var(--font-display);
  font-size: 1.375rem;
  line-height: 1.35;
  color: var(--ink);
  max-width: 34ch;
  margin: 0;
}

.example {
  margin-top: var(--s-4);
  width: 100%;
  border-top: 1px solid var(--rule);
  padding-top: var(--s-3);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.example .ex-zh {
  font-family: var(--font-zh);
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--ink);
}

.example .ex-py {
  font-size: var(--text-sm);
  color: var(--ochre);
}

.example .ex-en {
  font-size: var(--text-sm);
  color: var(--ink-3);
}

.example .ex-credit {
  align-self: center;
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-4);
  text-decoration: none;
}

.example .ex-credit:hover {
  color: var(--ink-2);
  text-decoration: underline;
}

.card-studio-link {
  margin-top: var(--s-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--r-sm);
}

.card-studio-link:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}

/* ---- Grade buttons ---- */
.grades {
  margin-top: var(--s-5);
}

.grades .label {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
  display: block;
  text-align: center;
  margin-bottom: var(--s-3);
}

.grade-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
}

.grade {
  min-height: 58px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  padding: 10px 8px;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: var(--text-sm);
  line-height: 1.25;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}

.grade span {
  display: block;
  font-size: var(--text-xs);
  font-weight: 400;
  opacity: 0.8;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.grade.again { border-color: var(--err-rule); background: var(--err-bg); color: var(--err); }
.grade.hard  { border-color: var(--ochre-rule); background: var(--ochre-soft); color: var(--ochre); }
.grade.good  { border-color: var(--accent); background: var(--accent); color: var(--surface); }
.grade.easy  { border-color: var(--ok-rule); background: var(--ok-bg); color: var(--ok); }

.grade:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(0.97);
}

.grade:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Done screen ---- */
.done {
  max-width: 600px;
  margin: var(--s-5) auto 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  text-align: center;
  padding: clamp(32px, 5vw, 56px) var(--s-5);
  box-shadow: var(--shadow-sm);
}

.done h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-h2);
  margin: 0 0 var(--s-3);
}

.done p {
  color: var(--ink-2);
  max-width: 44ch;
  margin: 0 auto var(--s-5);
}

.btn-row {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Word list ---- */
.list-view {
  padding-top: var(--s-2);
}

.list-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin: var(--s-2) 0 var(--s-4);
}

.search {
  width: 100%;
  max-width: 440px;
}

.list-count {
  font-size: var(--text-sm);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

ul.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  overflow: hidden;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(84px, auto) 1fr auto auto;
  gap: 2px var(--s-4);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  min-height: 60px;
  transition: background var(--t-fast) var(--ease);
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item:hover {
  background: var(--paper);
}

.li-word {
  font-family: var(--font-zh);
  font-size: 1.5rem;
  color: var(--ink);
  grid-row: 1 / span 2;
}

.li-pinyin {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ochre);
}

.li-meaning {
  color: var(--ink-2);
  font-size: var(--text-sm);
  grid-column: 2;
}

.li-badge {
  grid-column: 3;
  grid-row: 1 / span 2;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 3px 9px;
  white-space: nowrap;
}

.li-badge[data-mastered="1"] {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-rule);
}

.li-link {
  grid-column: 4;
  grid-row: 1 / span 2;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
}

.li-link:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}

.list-empty {
  text-align: center;
  color: var(--ink-3);
  padding: var(--s-7) var(--s-4);
}

.list-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: var(--s-4);
}

/* ---- Next step ---- */
.next-step strong {
  display: block;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 2px;
}

.next-step-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
}

@media (max-width: 720px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grade-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card {
    min-height: 400px;
  }

  .session-summary {
    margin-left: 0;
    width: 100%;
  }

  .list-item {
    grid-template-columns: auto 1fr auto;
  }

  .li-link {
    display: none;
  }
}
