/* Library, Readings & Recall · 等级标准词库与分级读物 — LingoFruit Chinese
 * Layered over /tokens.css and /site.css. */

/* ---- Library filter bar ---- */
.lib-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-sm);
}

.lib-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex: 1 1 170px;
  min-width: 0;
}

.lib-controls select,
.lib-controls input {
  width: 100%;
  font-size: var(--text-sm);
  text-transform: none;
  letter-spacing: 0;
}

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

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

/* ---- Library entries ---- */
#rows {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

#rows:empty {
  display: none;
}

.lib-empty {
  padding: var(--s-6) var(--s-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}

.lib-empty-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--ink);
}

.lib-empty-zh {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-3);
  max-width: 46ch;
}

.lib-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-3);
  margin-top: var(--s-3);
}

#rows article {
  border-bottom: 1px solid var(--rule-soft);
  padding: var(--s-4) var(--s-5);
}

#rows article:last-child {
  border-bottom: 0;
}

#rows article > b {
  display: block;
  font-family: var(--font-zh);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

#rows article > p {
  margin: 0;
  max-width: 72ch;
  color: var(--ink-2);
  font-size: var(--text-base);
}

#rows details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--ink);
  min-height: 36px;
  display: flex;
  align-items: center;
  list-style-position: outside;
}

#rows details summary:hover {
  color: var(--accent);
}

#rows details[open] summary {
  color: var(--accent);
  margin-bottom: var(--s-3);
}

#rows details p {
  margin: var(--s-2) 0;
  max-width: 72ch;
  color: var(--ink-2);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.lib-more-wrap {
  margin-top: var(--s-5);
}

/* ---- Graded readings ---- */
.readings-main {
  max-width: 980px;
}

.reading-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-sm);
}

.reading-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  flex: 1 1 200px;
  min-width: 0;
}

.reading-controls select {
  width: 100%;
  font-size: var(--text-sm);
}

.lookup-controls {
  margin-bottom: var(--s-3);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.lookup-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent-rule);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  margin: var(--s-3) 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--ink);
}

.lookup-box p {
  margin: 0 0 var(--s-2);
  color: var(--accent);
  font-weight: 500;
}

.reading-article {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: clamp(22px, 4.5vw, 44px);
  box-shadow: var(--shadow-sm);
}

.reading-article h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-h2);
  margin: 0 0 var(--s-5);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}

.reading-article .cn {
  font-family: var(--font-zh);
  font-size: clamp(1.375rem, 2.5vw, 1.625rem);
  line-height: 1.95;
  color: var(--ink);
  margin: var(--s-5) 0 var(--s-2);
}

.reading-article details {
  border-left: 2px solid var(--rule-strong);
  padding-left: var(--s-4);
  margin: 0 0 var(--s-5);
}

.reading-article summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.reading-article details p {
  margin: var(--s-2) 0;
  font-size: var(--text-sm);
  color: var(--ink-2);
  line-height: 1.65;
}

.reading-article details p:first-of-type {
  color: var(--ochre);
  font-weight: 500;
}

.lookup-word {
  display: inline;
  border: 0;
  background: none;
  padding: 2px 1px;
  border-radius: 4px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease);
}

.lookup-word:hover,
.lookup-word:focus-visible {
  background: var(--accent-soft);
}

/* ---- Recall page ---- */
.recall-main {
  max-width: 820px;
}

.recall-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  margin-top: var(--s-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.recall-back:hover {
  text-decoration: underline;
}

#info {
  color: var(--ink-3);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  margin: 0 0 var(--s-4);
}

.recall-card {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-lg);
  padding: clamp(24px, 5vw, 48px);
  box-shadow: var(--shadow-md);
}

#instruction {
  display: block;
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--s-3);
}

#prompt {
  font-family: var(--font-zh);
  font-size: clamp(1.75rem, 4.5vw, 2.75rem);
  line-height: 1.35;
  color: var(--ink);
  margin: 0 0 var(--s-5);
}

#answer {
  border-top: 1px solid var(--rule);
  margin-top: var(--s-5);
  padding-top: var(--s-5);
}

#han {
  display: block;
  font-family: var(--font-zh);
  font-size: 2.25rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

#pinyin {
  margin: 0 0 var(--s-3);
  color: var(--ochre);
  font-weight: 600;
  font-size: 1.125rem;
}

#explain {
  margin: 0 0 var(--s-5);
  color: var(--ink-2);
  font-size: var(--text-base);
  line-height: 1.65;
  max-width: 62ch;
}

#actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

.recall-note {
  margin-top: var(--s-5);
  font-size: var(--text-sm);
  color: var(--ink-3);
}

/* ---- Per-passage glossary (生词表) ---- */
.gloss{border-top:1px solid var(--rule);margin-top:var(--s-5);padding-top:var(--s-4)}
.gloss h3{font-size:var(--text-sm);letter-spacing:.06em;text-transform:uppercase;color:var(--ink-3);margin:0 0 var(--s-3)}
.gloss ul{list-style:none;margin:0;padding:0}
.gloss li{display:grid;grid-template-columns:auto 1fr auto;column-gap:var(--s-3);row-gap:2px;align-items:baseline;padding:10px 0;border-bottom:1px solid var(--rule-soft)}
.gloss b{grid-column:1;grid-row:1 / span 2;font-size:24px;line-height:1.1;font-family:var(--font-zh);color:var(--ink)}
.gloss .gl-py{grid-column:2;grid-row:1;color:var(--ochre);font-size:15px}
.gloss .gl-en{grid-column:2;grid-row:2;color:var(--ink-2);font-size:14px}
.gloss .gl-lv{grid-column:3;grid-row:1 / span 2;align-self:center;font-size:11px;letter-spacing:.08em;color:var(--ink-4);white-space:nowrap}
@media (max-width:600px){
  .gloss li{grid-template-columns:auto 1fr;column-gap:12px}
  .gloss .gl-py{grid-column:2;grid-row:1}
  .gloss .gl-en{grid-column:2;grid-row:2}
  .gloss .gl-lv{grid-column:2;grid-row:3;align-self:start;justify-self:start;margin-top:4px}
  .gloss b{grid-row:1 / span 3;font-size:22px}
}
