/*
 * read.gonglogic.com — the library and the reading surface.
 *
 * Only what the library has that the theme does not. Everything structural (header,
 * family bar, hero, sections, buttons, footer) comes from the site's own stylesheet,
 * the same decision the studio subsite records: a subsite with its own type and
 * buttons looks like a different company, and a careful imitation is worse to maintain
 * than reuse.
 */

/* ── the catalogue ──────────────────────────────────────────────────────────── */

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  list-style: none;
  margin: 0 0 2.5rem;
  padding: 0;
}

.library-card__link {
  display: block;
  height: 100%;
  padding: 1.1rem 1.2rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.6rem;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.library-card__link:hover,
.library-card__link:focus-visible {
  border-color: rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

.library-card__kind {
  display: inline-block;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}

.library-card__title { margin: 0 0 0.25rem; font-size: 1.05rem; line-height: 1.3; }
.library-card__sub   { margin: 0 0 0.5rem; font-size: 0.88rem; opacity: 0.75; }
.library-card__meta  { margin: 0; font-size: 0.8rem; opacity: 0.65; }

.library-group__head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}
.library-group__count { font-size: 0.85rem; opacity: 0.6; }

.library-note {
  padding: 0.9rem 1.1rem;
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.04);
  margin: 0 0 1.5rem;
}
.library-note--warn { background: rgba(200, 120, 0, 0.12); }
.library-fineprint { font-size: 0.85rem; opacity: 0.7; }
.library-empty { opacity: 0.7; }

/* ── plans ──────────────────────────────────────────────────────────────────── */

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1.2rem;
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  max-width: 42rem;
}
.plan-card {
  padding: 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 0.6rem;
  background: #fff;
}
.plan-card__name  { margin: 0 0 0.6rem; font-size: 1.1rem; }
.plan-card__price { margin: 0 0 0.3rem; font-size: 1.6rem; }
.plan-card__price span { font-size: 0.9rem; opacity: 0.65; }
.plan-card__note  { margin: 0 0 1.2rem; font-size: 0.88rem; opacity: 0.75; }

.account-list { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1.5rem; margin: 0 0 1.5rem; }
.account-list dt { opacity: 0.65; }
.account-list dd { margin: 0; }

/* ── chapters ───────────────────────────────────────────────────────────────── */

.chapter-list { list-style: none; margin: 0; padding: 0; }
.chapter-list__item { border-bottom: 1px solid rgba(0, 0, 0, 0.08); padding: 0.9rem 0; }
.chapter-list__link {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  text-decoration: none;
  color: inherit;
}
.chapter-list__link--locked { opacity: 0.45; cursor: default; }
.chapter-list__num { min-width: 2rem; font-variant-numeric: tabular-nums; opacity: 0.5; }
.chapter-list__name { font-size: 1.02rem; }
.chapter-list__en { font-size: 0.85rem; opacity: 0.6; }
.chapter-list__focus { margin: 0.35rem 0 0 2.9rem; font-size: 0.84rem; opacity: 0.65; }

/* ── the reader ─────────────────────────────────────────────────────────────── */

.reader-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.reader-nav__chapter { opacity: 0.6; font-size: 0.9rem; }
.reader-speak {
  margin-left: auto;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 2rem;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.reader-pages { list-style: none; margin: 0; padding: 0; }
.reader-page { margin: 0 0 1.9rem; }
.reader-page__speaker {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-bottom: 0.3rem;
}
.reader-page__source {
  margin: 0 0 0.45rem;
  font-size: 1.45rem;
  line-height: 2.5;   /* room for the reading above each token */
}
.reader-page__translation { margin: 0; opacity: 0.78; }

/*
 * A token. `ruby` puts the reading above it — furigana, pinyin, Jyutping — which is
 * the thing these readers exist for, and which the server decides: a reading equal to
 * the word itself is not rendered at all.
 */
.reader-word {
  position: relative;
  cursor: pointer;
  border-radius: 0.2rem;
  transition: background-color 0.12s ease;
}
.reader-word:hover { background: rgba(0, 0, 0, 0.06); }
.reader-word rt { font-size: 0.42em; opacity: 0.6; font-weight: 400; }

/* Tapped, and everything sharing its alignment. */
.reader-word--lit { background: rgba(255, 196, 0, 0.35); }
.reader-translation--lit { background: rgba(255, 196, 0, 0.35); border-radius: 0.2rem; }

.reader-tip {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 0.5rem);
  z-index: 20;
  min-width: 13rem;
  max-width: 21rem;
  padding: 0.8rem 0.95rem;
  border-radius: 0.5rem;
  background: #1d1d1f;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: left;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  cursor: default;
}
.reader-tip__head { margin: 0 0 0.2rem; font-weight: 600; }
.reader-tip__pos  { margin: 0 0 0.35rem; font-size: 0.78rem; opacity: 0.6; }
.reader-tip__def  { margin: 0; }
.reader-tip__more { margin: 0.4rem 0 0; font-size: 0.84rem; opacity: 0.75; }
.reader-tip__say {
  margin-top: 0.6rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 1rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.reader-foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  .library-card__link, .plan-card { background: #1c1c1e; border-color: rgba(255,255,255,0.12); }
  .reader-speak { background: #1c1c1e; color: inherit; border-color: rgba(255,255,255,0.22); }
  .reader-word:hover { background: rgba(255, 255, 255, 0.1); }
  .library-note { background: rgba(255,255,255,0.07); }
}

/* ── study material: the words, the phrases, the check ───────────────────────── */

.study { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid rgba(0, 0, 0, 0.08); }
.study__head { margin: 2rem 0 0.9rem; font-size: 1.15rem; }

.vocab-list { list-style: none; margin: 0; padding: 0; }
.vocab-list__item {
  display: grid;
  grid-template-columns: minmax(6rem, auto) minmax(0, auto) 1fr;
  gap: 0.3rem 1rem;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.vocab-list--phrases .vocab-list__item { grid-template-columns: minmax(10rem, 1.2fr) 1fr; }
.vocab-list__word    { font-size: 1.08rem; }
.vocab-list__reading { font-size: 0.85rem; opacity: 0.6; }
.vocab-list__meaning { opacity: 0.8; }

.quiz { list-style: none; margin: 0; padding: 0; counter-reset: q; }
.quiz__q {
  padding: 1.1rem 0 1.3rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.quiz__vocab  { margin: 0 0 0.4rem; font-size: 1.1rem; }
.quiz__prompt { margin: 0 0 0.8rem; font-weight: 500; }
.quiz__options { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.quiz__option {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.9rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0.45rem;
  background: #fff;
  cursor: pointer;
  font: inherit;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.quiz__option:hover:not(:disabled) { border-color: rgba(0, 0, 0, 0.4); }
.quiz__option:disabled { cursor: default; }
.quiz__option--right { background: rgba(40, 160, 90, 0.16); border-color: rgba(40, 160, 90, 0.5); }
.quiz__option--wrong { background: rgba(200, 60, 60, 0.14); border-color: rgba(200, 60, 60, 0.45); }
.quiz__feedback { margin: 0.7rem 0 0; font-size: 0.9rem; opacity: 0.85; }

@media (prefers-color-scheme: dark) {
  .quiz__option { background: #1c1c1e; border-color: rgba(255,255,255,0.18); }
}

/* ── flashcards ─────────────────────────────────────────────────────────────── */

.deck-native { margin: 0 0 0.3rem; font-size: 1.15rem; }
.deck-about  { margin: 0 0 1.8rem; opacity: 0.72; }

.deck-progress { margin: 0 0 1rem; font-size: 0.85rem; opacity: 0.6; font-variant-numeric: tabular-nums; }
.deck-cards { list-style: none; margin: 0 0 1.5rem; padding: 0; }

.deck-card__face {
  display: block;
  width: 100%;
  min-height: 11rem;
  padding: 2.2rem 1.5rem;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 0.75rem;
  background: #fff;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: border-color 0.15s ease;
}
.deck-card__face:hover { border-color: rgba(0, 0, 0, 0.32); }
.deck-card__word { display: block; font-size: 2rem; line-height: 1.3; }
.deck-card__pos  { display: block; margin-top: 0.5rem; font-size: 0.82rem; opacity: 0.55; }

.deck-card__back {
  margin-top: 0.9rem;
  padding: 1.2rem 1.4rem;
  border-radius: 0.6rem;
  background: rgba(0, 0, 0, 0.045);
}
.deck-card__translation { margin: 0 0 0.5rem; font-size: 1.2rem; }
.deck-card__definition  { margin: 0 0 0.8rem; opacity: 0.8; }
.deck-card__example     { margin: 0 0 0.2rem; font-size: 1.05rem; }
.deck-card__example-en  { margin: 0; opacity: 0.7; font-size: 0.92rem; }

.deck-controls { display: flex; gap: 0.8rem; }
.deck-controls .button { flex: 1; }
.deck--done .deck-controls { display: none; }
.deck-score { margin-top: 1.2rem; font-size: 0.95rem; }

@media (prefers-color-scheme: dark) {
  .deck-card__face { background: #1c1c1e; border-color: rgba(255,255,255,0.14); }
  .deck-card__back { background: rgba(255,255,255,0.07); }
}

/* ── dictionary ─────────────────────────────────────────────────────────────── */

.dict-langs { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; margin: 0 0 1.5rem; padding: 0; }
.dict-lang {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 2rem;
  font-size: 0.85rem;
  text-decoration: none;
  color: inherit;
}
.dict-lang span { opacity: 0.5; margin-left: 0.3rem; font-variant-numeric: tabular-nums; }
.dict-lang--on { background: #1d1d1f; color: #fff; border-color: #1d1d1f; }

.dict-search { display: block; margin: 0 0 1.6rem; }
.dict-search__label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; opacity: 0.65; }
.dict-search__input {
  width: 100%;
  padding: 0.75rem 1rem;
  font: inherit;
  font-size: 1.1rem;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 0.5rem;
  background: #fff;
}

.dict-results { list-style: none; margin: 0 0 2rem; padding: 0; }
.dict-entry { padding: 0.9rem 0; border-bottom: 1px solid rgba(0, 0, 0, 0.07); }
.dict-entry__head { margin: 0 0 0.3rem; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.dict-entry__word { font-size: 1.25rem; }
.dict-entry__reading { opacity: 0.6; font-size: 0.9rem; }
.dict-entry__pos { font-size: 0.78rem; opacity: 0.5; }
.dict-entry__def { margin: 0; }
.dict-entry__more { margin: 0.3rem 0 0; font-size: 0.88rem; opacity: 0.72; }
.dict-none { opacity: 0.6; padding: 0.9rem 0; }
.dict-note { font-size: 0.85rem; opacity: 0.62; }

@media (prefers-color-scheme: dark) {
  .dict-search__input { background: #1c1c1e; color: inherit; border-color: rgba(255,255,255,0.2); }
  .dict-lang--on { background: #f5f5f7; color: #1d1d1f; border-color: #f5f5f7; }
}
