/* One Asia Readers — shared styles. Mobile-first. */
:root {
  --orange: #F46A29;
  --blue:   #1A6AA6;
  --ink:    #2b2b2b;
  --muted:  #6b7280;
  --bg:     #fbfaf7;
  --card:   #ffffff;
  --line:   #e7e3db;
  --shadow: 0 2px 10px rgba(0,0,0,.08);
  --radius: 14px;
  --maxw:   1100px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--blue); text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- Header ---------- */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.site-header .wrap {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.site-header img.logo { height: 38px; width: auto; }
.site-header .titles { line-height: 1.15; }
.site-header .series-name { font-weight: 700; color: var(--blue); font-size: 1.05rem; }
.site-header .series-sub  { color: var(--muted); font-size: .78rem; }
.site-header .spacer { flex: 1; }
.back-link {
  font-size: .9rem; color: var(--blue); font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: 10px;
}
.back-link:hover { background: #eef4fa; }

/* ---------- Generic container ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 16px; }

/* ---------- Landing page ---------- */
.intro { padding: 22px 16px 4px; max-width: var(--maxw); margin: 0 auto; }
.intro h1 { color: var(--blue); margin: 0 0 6px; font-size: 1.5rem; }
.intro p  { color: var(--muted); margin: 0; max-width: 60ch; }

.filters {
  max-width: var(--maxw); margin: 0 auto; padding: 16px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.filters .label { font-weight: 600; color: var(--muted); font-size: .85rem; margin-right: 4px; }
.chip {
  border: 1.5px solid var(--line); background: #fff;
  padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  cursor: pointer; color: var(--ink); transition: all .12s;
}
.chip[aria-pressed="true"] { color: #fff; border-color: transparent; }
.chip:hover { border-color: var(--muted); }

.grid {
  max-width: var(--maxw); margin: 0 auto; padding: 8px 16px 48px;
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,.13); }
.card .cover-wrap { position: relative; aspect-ratio: 550 / 778; background: #eee; }
.card .cover-wrap img { width: 100%; height: 100%; object-fit: cover; }
.level-chip {
  position: absolute; top: 8px; right: 8px;
  color: #fff; font-weight: 700; font-size: .72rem;
  padding: 3px 9px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.card .meta { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.card .meta .title { font-weight: 700; color: var(--ink); font-size: 1rem; line-height: 1.2; }
.card .meta .author { color: var(--muted); font-size: .82rem; }
.card .meta .genre  { color: var(--muted); font-size: .74rem; margin-top: 2px; }
.card .actions { margin-top: auto; padding: 0 12px 14px; display: flex; gap: 8px; }
.btn {
  flex: 1; text-align: center; font-weight: 600; font-size: .85rem;
  padding: 9px 8px; border-radius: 10px; cursor: pointer; border: none;
}
.btn-read { background: var(--orange); color: #fff; }
.btn-read:hover { filter: brightness(.95); }
.btn-quiz { background: #eef4fa; color: var(--blue); }
.btn-quiz:hover { background: #e0ecf6; }

/* ---------- Reader (flipbook) ---------- */
.reader-stage {
  background: #1d2733; min-height: calc(100vh - 60px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px; position: relative; user-select: none;
}
.page-frame {
  position: relative; max-width: 560px; width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.page-frame img {
  width: 100%; height: auto; border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff;
}
.nav-arrow {
  position: absolute; top: 0; bottom: 0; width: 28%;
  display: flex; align-items: center; cursor: pointer;
  border: none; background: transparent; color: #fff; opacity: 0; transition: opacity .15s;
}
.nav-arrow:hover { opacity: 1; }
.nav-arrow.prev { left: 0; justify-content: flex-start; padding-left: 6px;
  background: linear-gradient(to right, rgba(0,0,0,.25), transparent); }
.nav-arrow.next { right: 0; justify-content: flex-end; padding-right: 6px;
  background: linear-gradient(to left, rgba(0,0,0,.25), transparent); }
.nav-arrow svg { width: 34px; height: 34px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.reader-bar {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 10px; background: #161e27; color: #cdd6e0; font-size: .9rem;
  position: sticky; bottom: 0;
}
.reader-bar button {
  background: #2a3442; color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: .9rem;
}
.reader-bar button:disabled { opacity: .35; cursor: default; }
.reader-bar .counter { min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; }
.reader-finish {
  margin-top: 8px; text-align: center;
}
.reader-finish a {
  display: inline-block; background: var(--orange); color: #fff; font-weight: 700;
  padding: 12px 22px; border-radius: 12px; font-size: 1rem;
}

/* ---------- Quiz ---------- */
.quiz-head { max-width: 760px; margin: 0 auto; padding: 22px 16px 0; }
.quiz-head h1 { color: var(--blue); margin: 0 0 2px; font-size: 1.5rem; }
.quiz-head .by { color: var(--muted); font-size: .9rem; }
.quiz-wrap { max-width: 760px; margin: 0 auto; padding: 8px 16px 60px; }

.scorebar {
  position: sticky; top: 60px; z-index: 10;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; margin: 14px 0 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--blue);
}
.scorebar .bar { flex: 1; height: 8px; background: #eef0f2; border-radius: 999px; overflow: hidden; }
.scorebar .bar > span { display: block; height: 100%; width: 0; background: var(--orange); transition: width .3s; }

.part { margin: 28px 0; }
.part h2 { color: var(--orange); font-size: 1.15rem; margin: 0 0 4px; }
.part .part-instr { color: var(--muted); font-size: .9rem; margin: 0 0 14px; }

.q { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.q .q-text { font-weight: 600; margin-bottom: 10px; }
.q .q-text .num { color: var(--orange); margin-right: 6px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  text-align: left; border: 1.5px solid var(--line); background: #fff;
  border-radius: 10px; padding: 11px 14px; cursor: pointer; font-size: .95rem;
  display: flex; gap: 10px; align-items: flex-start; transition: all .12s;
}
.option:hover:not(.locked) { border-color: var(--blue); background: #f6fafd; }
.option .key { font-weight: 700; color: var(--muted); }
.option.correct { border-color: #2e9e5b; background: #e9f8ef; }
.option.correct .key { color: #2e9e5b; }
.option.wrong   { border-color: #d6473a; background: #fdecea; }
.option.wrong .key { color: #d6473a; }
.option.locked { cursor: default; }
.option .mark { margin-left: auto; font-weight: 700; }

.feedback { margin-top: 8px; font-size: .88rem; font-weight: 600; min-height: 1em; }
.feedback.ok { color: #2e9e5b; }
.feedback.no { color: #d6473a; }

/* Ordering (Part 2) */
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-item {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.order-item.correct { border-color: #2e9e5b; background: #e9f8ef; }
.order-item.wrong   { border-color: #d6473a; background: #fdecea; }
.order-item .txt { flex: 1; font-size: .9rem; }
.order-item .moves { display: flex; flex-direction: column; gap: 2px; }
.order-item .moves button {
  border: none; background: #eef0f2; border-radius: 6px; width: 30px; height: 22px;
  cursor: pointer; font-size: .8rem; line-height: 1; color: var(--ink);
}
.order-item .moves button:disabled { opacity: .3; cursor: default; }
.order-pos { font-weight: 700; color: var(--muted); width: 18px; text-align: center; }

.check-btn {
  background: var(--orange); color: #fff; border: none; border-radius: 10px;
  padding: 11px 20px; font-weight: 700; font-size: .95rem; cursor: pointer; margin-top: 6px;
}
.check-btn.secondary { background: #eef4fa; color: var(--blue); }

/* Fill-from-box (Part 2 / Part 1 variant) */
.word-bank { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.word-chip {
  background: #eef4fa; color: var(--blue); border: 1px solid #d6e4f0;
  border-radius: 999px; padding: 5px 12px; font-size: .85rem; font-weight: 600;
}
.fill-item {
  display: flex; gap: 10px; align-items: baseline;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.fill-item .txt { flex: 1; line-height: 1.7; }
.fill-item.correct { border-color: #2e9e5b; background: #e9f8ef; }
.fill-item.wrong   { border-color: #d6473a; background: #fdecea; }
.fill-select {
  margin: 0 4px; padding: 4px 6px; border: 1.5px solid var(--blue); border-radius: 8px;
  font-size: .92rem; background: #f6fafd; color: var(--ink); max-width: 100%;
}
.fill-select:disabled { opacity: 1; -webkit-text-fill-color: var(--ink); }
.fill-correct { color: #2e9e5b; font-weight: 700; white-space: nowrap; }

.discuss li { margin-bottom: 12px; }

.result-banner {
  background: #fff; border: 2px solid var(--orange); border-radius: 14px;
  padding: 20px; text-align: center; margin-top: 24px;
}
.result-banner .big { font-size: 1.6rem; font-weight: 800; color: var(--blue); }
.result-banner p { color: var(--muted); margin: 6px 0 0; }

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

.loading, .error { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Larger screens ---------- */
@media (min-width: 640px) {
  .intro h1 { font-size: 1.9rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 26px; }
}
