/* ══════════════════════════════════════════════════════════
   quiz.css — /toeic/free-test as a quiz.

   The inline <head> script sets html.qz (unless ?view=all) and
   data-qz = start | q | review | result; the page script moves
   between them. The article HTML underneath is unchanged, so
   crawlers, no-JS visitors and ?view=all still get every question,
   answer and explanation on one page.

   Same look as the paid-ad clips (Miboo brand kit): Cloud ground,
   Miboo Yellow, Deep Ink, Headset Blue, Correct Green / Trap Red,
   Kanit headings. Budget Android rules from seo.css still hold: no
   blur, no shadows on the sticky/fixed bars, motion is transform/
   opacity only and stops under prefers-reduced-motion.
══════════════════════════════════════════════════════════ */

:root {
  --qz-bg: #F4F6FB;
  --qz-surface: #FFFFFF;
  --qz-ink: #14213D;
  --qz-soft: #56607A;
  --qz-line: #DCE3F0;
  --qz-sun: #FFE6A3;
  --qz-yellow: #FFC93C;
  --qz-yellow-soft: #FFF1C9;
  --qz-blue: #2563EB;
  --qz-blue-dark: #1D4ED8;
  --qz-green: #17805A;
  --qz-green-soft: #DDF3EA;
  --qz-red: #C9353A;
  --qz-red-soft: #FDE5E6;
  --qz-display: 'Kanit', 'Sarabun', -apple-system, 'Segoe UI', sans-serif;
}

/* ── Progress strip (both views; the dark article strip keeps its look) ── */
.quiz-score .qs-track { display: block; height: 6px; margin-top: 6px; border-radius: 999px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.quiz-score .qs-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--qz-yellow); transition: width .3s ease; }

/* ── Result card (both views) ────────────────────────────── */
.qc-result {
  background: var(--qz-surface); color: var(--qz-ink);
  border: 1px solid var(--qz-line); border-radius: 22px;
  padding: 22px 18px; margin: 28px 0;
}
.qc-result p { margin: 0; }
.qc-head { display: flex; align-items: center; gap: 12px; }
.qc-head .qc-miboo { width: 72px; height: auto; flex: none; }
.qc-kicker { font-weight: 700; font-size: .95rem; color: var(--qz-soft); }
.qc-result h2 { font-family: var(--qz-display); font-weight: 700; font-size: 1.55rem; line-height: 1.25; letter-spacing: 0; margin: 0; }
.qc-scorebox { display: flex; align-items: center; gap: 16px; margin: 18px 0 6px; }
.qc-ring { position: relative; width: 112px; height: 112px; flex: none; }
.qc-ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.qc-ring-bg { fill: none; stroke: var(--qz-bg); stroke-width: 12; }
.qc-ring-fg { fill: none; stroke: var(--qz-blue); stroke-width: 12; stroke-linecap: round; }
.qc-ring-good .qc-ring-fg { stroke: var(--qz-green); }
.qc-ring-low .qc-ring-fg { stroke: #F59E0B; }
.qc-result .qc-score {
  position: absolute; inset: 0; margin: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--qz-display); font-weight: 700; font-size: 2.3rem; line-height: 1;
}
.qc-result .qc-score small { font-size: .5em; font-weight: 600; color: var(--qz-soft); margin-left: 2px; }
.qc-result .qc-band { font-family: var(--qz-display); font-weight: 600; font-size: 1.15rem; line-height: 1.35; margin: 0 0 4px; }
.qc-result .qc-next { color: var(--qz-soft); font-size: .95rem; line-height: 1.6; }
.qc-result h3 { font-family: var(--qz-display); font-weight: 600; font-size: 1.12rem; letter-spacing: 0; margin: 20px 0 8px; }
.qc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.qc-chips span {
  font-size: .9rem; font-weight: 700; line-height: 1.5;
  padding: 3px 11px; border-radius: 999px; background: var(--qz-red-soft); color: var(--qz-ink);
}
.qc-review { margin-top: 14px; }
.qc-review summary {
  cursor: pointer; list-style: none; padding: 8px 0;
  font-family: var(--qz-display); font-weight: 600; font-size: 1rem; color: var(--qz-blue);
}
.qc-review summary::-webkit-details-marker { display: none; }
.qc-review summary::after { content: " ▾"; }
.qc-review[open] summary::after { content: " ▴"; }
.qc-result .qc-weak { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.qc-result .qc-weak li { margin: 0; padding: 0; border: 0; background: none; font-size: .95rem; line-height: 1.45; }
.qc-result .qc-weak li::before { content: none; }
.qc-result .qc-weak a {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: center;
  padding: 10px 12px; border-radius: 14px; background: var(--qz-red-soft);
  color: var(--qz-ink); text-decoration: none;
}
.qc-wn {
  grid-row: span 2; align-self: center;
  font-family: var(--qz-display); font-weight: 700; font-size: .85rem; white-space: nowrap;
  background: var(--qz-surface); border-radius: 999px; padding: 2px 10px;
}
.qc-wt { font-weight: 600; }
.qc-wgo { font-size: .84rem; font-weight: 700; color: var(--qz-red); }
.qc-result .qc-weak li.ok { background: var(--qz-green-soft); border-radius: 14px; padding: 10px 12px; }
.qc-result .qc-form { background: var(--qz-yellow-soft); border: 0; border-radius: 18px; padding: 16px; margin-top: 20px; }
.qc-result .qc-form h3 { margin: 0 0 4px; }
.qc-result .qc-form p { color: var(--qz-ink); font-size: .93rem; margin-bottom: 12px; }
.qc-result .qc-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: end; }
.qc-result .qc-fields label { min-width: 0; }
.qc-result .qc-fields .qc-nodate { grid-column: 1 / -1; min-height: 0; }
.qc-result .qc-fields select, .qc-result .qc-fields input[type="date"] {
  width: 100%; min-width: 0; border-radius: 10px; border: 1px solid var(--qz-line); background: var(--qz-surface);
}
/* LINE green dark enough for white bold text at this size (AA large). */
.qc-result .qc-line-go {
  margin-top: 14px; padding: 12px 16px; min-height: 64px;
  background: #04A043; color: #fff; border: 0; border-radius: 16px;
  box-shadow: 0 4px 0 #02792F;
  font-family: var(--qz-display); font-weight: 700; font-size: 1.2rem;
  transition: background .15s, transform .1s;
}
.qc-result .qc-line-go:hover { background: #038A3A; color: #fff; }
.qc-result .qc-line-go:active { transform: translateY(2px); box-shadow: 0 2px 0 #02792F; }
.qc-line-main { display: inline-flex; align-items: center; gap: 8px; }
.qc-line-main svg { width: 24px; height: 24px; flex: none; }
.qc-result .qc-line-go small { font-family: 'Sarabun', sans-serif; font-weight: 600; font-size: .86rem; }
.qc-result .qc-go-alt { border: 2px solid var(--qz-ink); border-radius: 14px; background: var(--qz-surface); font-weight: 700; }
.qc-result .qc-go-alt:hover { background: var(--qz-bg); }
.qc-result .qc-fine { color: var(--qz-soft); }

/* ══ Quiz view ═════════════════════════════════════════════ */
.qz-chips, .qz-start { display: none; }

html.qz { scroll-padding-top: 120px; }
html.qz body { background: var(--qz-bg); color: var(--qz-ink); font-size: 16px; line-height: 1.7; }
html.qz body::before { display: none; }
/* One soft sun behind the page, as in the ads. Fixed and painted once. */
html.qz body::after {
  content: ""; position: fixed; top: -170px; right: -190px; z-index: 0;
  width: 440px; height: 440px; border-radius: 50%;
  background: var(--qz-sun); pointer-events: none;
}
/* While answering, the sun would be cut by the sticky strip, so it shows on the start and result screens only. */
html.qz[data-qz="q"] body::after, html.qz[data-qz="review"] body::after { display: none; }
html.qz .topbar { background: var(--qz-surface); border-bottom: 1px solid var(--qz-line); }
html.qz footer { background: transparent; border-top: 1px solid var(--qz-line); color: var(--qz-soft); }
html.qz .topbar .cta-sm {
  background: var(--qz-surface); color: var(--qz-ink); border: 1.5px solid var(--qz-ink); border-radius: 999px;
  font-family: var(--qz-display); font-weight: 600; font-size: .86rem; letter-spacing: 0; text-transform: none;
  padding: 5px 14px;
}
html.qz main { padding: 18px 0 128px; }
html.qz main .wrap { max-width: 600px; padding-left: 20px; padding-right: 20px; position: relative; }
html.qz main .wrap::before { display: none; }

/* The article parts stay in the HTML but out of the quiz. */
html.qz .crumb, html.qz .lede, html.qz .meta, html.qz .note,
html.qz main .wrap > h2, html.qz main .wrap > h2 + p,
html.qz .table-scroll, html.qz .tip, html.qz .cta, html.qz .faq, html.qz .related { display: none; }
html.qz .q, html.qz main .card { display: none; }
html.qz .q.qz-cur, html.qz main .card.qz-cur { display: block; }
html.qz:not([data-qz="start"]) main .wrap > h1 { display: none; }
html.qz[data-qz="start"] .quiz-score,
html.qz[data-qz="review"] .quiz-score,
html.qz[data-qz="result"] .quiz-score { display: none; }
html.qz[data-qz="review"] .qc-result { display: none; }

/* ── Start screen ───────────────────────────────────────── */
html.qz[data-qz="start"] .qz-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
html.qz[data-qz="start"] .qz-start { display: block; }
.qz-chip {
  font-family: var(--qz-display); font-weight: 600; font-size: .85rem; line-height: 1.6;
  padding: 2px 12px; border-radius: 999px;
  background: var(--qz-surface); border: 1.5px solid var(--qz-ink);
}
.qz-chip-y { background: var(--qz-yellow); border-color: var(--qz-yellow); }
html.qz main .wrap > h1 {
  font-family: var(--qz-display); font-weight: 700; letter-spacing: 0;
  font-size: clamp(2rem, 8.6vw, 2.75rem); line-height: 1.2;
  margin: 12px 0 10px; padding-right: 112px; color: var(--qz-ink);
}
.qz-miboo { position: absolute; top: 0; right: 8px; width: 108px; height: auto; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .qz-miboo { animation: qz-bob 2.8s ease-in-out infinite; transform-origin: 50% 90%; }
}
@keyframes qz-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}
.qz-start .qz-sub { font-size: 1.12rem; font-weight: 700; line-height: 1.5; margin: 0 0 14px; }
html.qz .qz-perks { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
html.qz .qz-perks li {
  margin: 0; padding: 4px 12px; font-size: .9rem; font-weight: 700; line-height: 1.6;
  background: var(--qz-surface); border: 1px solid var(--qz-line); border-radius: 999px;
}
html.qz .qz-perks li::before { content: none; }
.qz-go {
  display: block; width: 100%; min-height: 58px; padding: 12px 20px;
  border: 0; border-radius: 16px; cursor: pointer;
  background: var(--qz-blue); color: #fff; box-shadow: 0 4px 0 var(--qz-blue-dark);
  font-family: var(--qz-display); font-weight: 700; font-size: 1.22rem; line-height: 1.3;
  transition: background .15s, transform .1s;
}
.qz-go:hover { background: var(--qz-blue-dark); }
.qz-go:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--qz-blue-dark); }
.qz-go:focus-visible, html.qz .opt:focus-visible { outline: 3px solid var(--qz-yellow); outline-offset: 3px; }
.qz-get { margin-top: 20px; padding: 14px 16px; background: var(--qz-surface); border: 1px solid var(--qz-line); border-radius: 18px; }
.qz-get b { font-family: var(--qz-display); font-weight: 600; font-size: 1.02rem; }
html.qz .qz-get ul { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
html.qz .qz-get li { margin: 0; padding-left: 26px; position: relative; font-size: .95rem; line-height: 1.55; }
html.qz .qz-get li::before { content: "✓"; position: absolute; left: 4px; top: 0; font-size: 1em; font-weight: 800; color: var(--qz-green); }
.qz-all { display: inline-block; margin-top: 14px; font-size: .88rem; color: var(--qz-soft); }

/* ── Progress strip ─────────────────────────────────────── */
html.qz .quiz-score {
  position: sticky; top: 60px; z-index: 5;
  margin: 0 -20px; padding: 10px 20px 12px;
  background: var(--qz-bg); color: var(--qz-ink); border: 0; border-radius: 0;
  font-family: var(--qz-display); font-weight: 600; font-size: .95rem; letter-spacing: 0; text-align: left;
}
html.qz .quiz-score .qs-track { height: 8px; margin-top: 8px; background: var(--qz-line); }

/* ── Question card ──────────────────────────────────────── */
html.qz .q.qz-cur {
  background: var(--qz-surface); border: 1px solid var(--qz-line); border-radius: 22px;
  padding: 20px 16px; margin: 14px 0 0;
}
@media (prefers-reduced-motion: no-preference) {
  html.qz .q.qz-cur, html.qz .qc-result { animation: qz-in .28s ease-out both; }
}
@keyframes qz-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
html.qz .q-num { display: none; }
html.qz .q-stem { font-weight: 700; font-size: 1.2rem; line-height: 1.65; margin: 0 0 16px; color: var(--qz-ink); }
.qz-blank {
  display: inline-block; min-width: 3em; padding: 0 .45em; margin: 0 .12em;
  border-radius: 10px; background: var(--qz-yellow); color: var(--qz-ink);
  font-family: var(--qz-display); font-weight: 700; text-align: center; line-height: 1.5;
}
.qz-blank.filled { background: var(--qz-green-soft); color: var(--qz-green); text-align: left; }
html.qz .q ol.opts { gap: 10px; }
html.qz .opt {
  align-items: center; gap: 14px; min-height: 58px; padding: 10px 14px;
  border: 2px solid var(--qz-line); border-radius: 16px; background: var(--qz-surface);
  font-size: 1.06rem; font-weight: 600; line-height: 1.45; color: var(--qz-ink);
  transition: border-color .15s, background .15s, opacity .15s, transform .1s;
}
html.qz .opt:not([disabled]):hover { border-color: var(--qz-blue); background: #F7FAFF; }
html.qz .opt:not([disabled]):active { transform: scale(.985); }
html.qz .opt-letter {
  width: 36px; height: 36px; border: 0; background: var(--qz-bg); color: var(--qz-ink);
  font-family: var(--qz-display); font-weight: 700; font-size: 1rem;
}
html.qz .opt-text { padding-top: 0; }
html.qz .opt.correct { border-color: var(--qz-green); background: var(--qz-green); color: #fff; }
html.qz .opt.correct .opt-letter { background: #fff; color: var(--qz-green); }
html.qz .opt.wrong { border-color: var(--qz-red); background: var(--qz-red-soft); }
html.qz .opt.wrong .opt-letter { background: var(--qz-red); color: #fff; }
html.qz .q.answered .opt:not(.correct):not(.wrong) { opacity: .5; }

/* Feedback right under the options, then the explanation as a soft card. */
.qz-fb {
  margin: 14px 0 0; padding: 10px 14px; border-radius: 14px;
  font-family: var(--qz-display); font-weight: 600; font-size: 1.08rem; line-height: 1.45; color: var(--qz-ink);
}
.qz-fb.ok { background: var(--qz-green-soft); }
.qz-fb.no { background: var(--qz-red-soft); }
.qz-fb-i { font-weight: 800; }
.qz-fb.ok .qz-fb-i { color: var(--qz-green); }
.qz-fb.no .qz-fb-i { color: var(--qz-red); }
html.qz details.answer { margin-top: 10px; padding: 0; border: 0; }
html.qz details.answer summary { display: none; }
html.qz details.answer .body {
  padding: 14px 16px; border-radius: 16px; background: var(--qz-bg);
  font-size: .97rem; line-height: 1.7; color: var(--qz-ink);
}
html.qz details.answer .body p { margin: 0 0 8px; }
html.qz details.answer .body p:last-child { margin-bottom: 0; }
html.qz details.answer .body .key {
  display: inline-block; padding: 1px 12px; border-radius: 999px;
  background: var(--qz-green-soft); color: var(--qz-ink);
  font-family: var(--qz-display); font-weight: 600;
}

/* Part 6 passage, shown above ข้อ 13–15. */
html.qz main .card.qz-cur {
  background: var(--qz-surface); border: 1px solid var(--qz-line); border-radius: 18px;
  padding: 14px 16px; margin: 14px 0 0; font-size: .95rem; line-height: 1.7;
}
html.qz main .card.qz-cur::before {
  content: "อ่านอีเมลนี้ แล้วตอบข้อ 13–15"; display: block; margin-bottom: 8px;
  font-family: var(--qz-display); font-weight: 600; font-size: .9rem; color: var(--qz-soft);
}
html.qz main .card p { margin: 0 0 8px; }
html.qz main .card p:last-child { margin-bottom: 0; }

/* ── Fixed "next" bar ───────────────────────────────────── */
.qz-nextbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--qz-surface); border-top: 1px solid var(--qz-line);
}
.qz-nextbar[hidden] { display: none; }
.qz-nextbar .qz-go { max-width: 560px; margin: 0 auto; }

html.qz .qc-result { margin-top: 14px; }

@media (min-width: 640px) {
  .qz-miboo { width: 140px; right: 12px; }
  html.qz main .wrap > h1 { padding-right: 160px; }
  .qc-head .qc-miboo { width: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  .qz-go, .qc-result .qc-line-go, html.qz .opt, .quiz-score .qs-fill { transition: none; }
}
@media print {
  html.qz .q, html.qz main .card { display: block; }
  .qz-chips, .qz-start, .qz-nextbar { display: none !important; }
}
