/* mototest.app. One stylesheet for every page; it implements
   design-system/mototest/MASTER.md (tokens, components, motion rules).
   Mobile first: the base rules are the phone layout, the two breakpoints
   (640px, 960px) only add columns. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --paper: #fffbeb;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --sun: #fde047;
  --card: #ffffff;
  --sky: #bae6fd;
  --mint: #bbf7d0;
  --rose: #fbcfe8;
  --peach: #fed7aa;
  --right: #166534;
  --right-bg: #dcfce7;
  --wrong: #991b1b;
  --wrong-bg: #fee2e2;
  --link: #1d4ed8;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Hiragino Sans", "Microsoft JhengHei", "Noto Sans TC", "Noto Sans JP", "Leelawadee UI", "Noto Sans Thai", Roboto, "Helvetica Neue", Arial, sans-serif;

  --line: 3px solid var(--ink);
  --line-thin: 2px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-small: 3px 3px 0 var(--ink);
  --radius: 24px;
  --radius-small: 14px;
  --radius-pill: 999px;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 1rem; line-height: 1.6; overflow-wrap: break-word; }
:lang(zh), :lang(ja), :lang(th) { line-height: 1.75; }
img, svg { max-width: 100%; }
img { height: auto; }
a { color: inherit; text-underline-offset: 3px; }
p, ul, ol, dl, figure { margin: 0 0 var(--s4); }
h1, h2, h3 { margin: 0 0 var(--s4); font-weight: 900; text-wrap: balance; line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); line-height: 1.2; }
h2 { font-size: clamp(1.375rem, 3.5vw, 2rem); }
h3 { font-size: 1.125rem; font-weight: 800; line-height: 1.35; }
:lang(zh) :is(h1, h2, h3), :lang(ja) :is(h1, h2, h3), :lang(th) :is(h1, h2, h3) { line-height: 1.35; }
/* A Chinese or Japanese heading breaks at its punctuation and spaces, not in
   the middle of a word; a heading too long for the line may still break. */
/* Display headings break between phrases: Chinese at spaces and punctuation
   (a run too long for the line may still break inside: "anywhere" keeps it
   from widening the page), Japanese between phrases where the browser knows
   them. Longer headings (question sentences, tiles) break as running text
   does, so a comma or a question mark never starts a line. */
:lang(zh) :is(h1, h2) { word-break: keep-all; overflow-wrap: anywhere; }
:lang(ja) :is(h1, h2) { word-break: auto-phrase; }
:lang(zh) :is(h1, h2, h3), :lang(ja) :is(h1, h2, h3) { line-break: strict; }
/* Japanese in Japanese letterforms: the shared --font names a Chinese face first. */
:lang(ja) { font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -9999px; top: var(--s2); z-index: 10; padding: var(--s2) var(--s4); background: var(--ink); color: var(--sun); font-weight: 800; border-radius: var(--radius-pill); }
.skip-link:focus { left: var(--s2); }
.tnum { font-variant-numeric: tabular-nums; }
.soft { color: var(--ink-soft); }
.small { font-size: 0.875rem; line-height: 1.5; }

/* ------------------------------------------------------------------ layout */
.site-header, .site-footer, main > * { width: min(100% - 32px, 1080px); margin-inline: auto; }
main > .prose, main > .narrow, .page-guide main > *, .page-privacy main > * { width: min(100% - 32px, 760px); }
main > * { margin-block: var(--s7); }
main > :first-child { margin-top: var(--s5); }
.prose p, .prose li { max-width: 68ch; }
.prose :is(p, li) a, .source a, .hint a, .facts a, .faq a { color: var(--link); }

/* ------------------------------------------------------------------ header */
.site-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); padding-block: var(--s4); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-size: 1.25rem; font-weight: 900; text-decoration: none; }
.brand img { width: 36px; height: 36px; border: var(--line-thin); border-radius: 10px; }
.site-nav { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin-inline-end: auto; }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: var(--s1); font-weight: 800; text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--sun); }
.in-english { font-size: 0.8125rem; font-weight: 400; color: var(--ink-soft); }

/* On a phone the header wraps and the menu may start a row at the left edge:
   the list is placed against the header's right edge, so it always opens on
   screen. From 768px the header is one row and the list sits under its button. */
.site-header { position: relative; }
.lang-menu { position: static; }
@media (min-width: 768px) { .lang-menu { position: relative; } .lang-menu ul { min-width: 100%; } }
.lang-menu summary { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3); font-weight: 800; list-style: none; cursor: pointer; background: var(--card); border: var(--line-thin); border-radius: var(--radius-pill); }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary::after { content: ""; width: 8px; height: 8px; margin-inline-start: 2px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateY(-2px) rotate(45deg); }
.lang-menu ul { position: absolute; inset-inline-end: 0; z-index: 5; min-width: 0; margin: var(--s2) 0 0; padding: var(--s2); list-style: none; white-space: nowrap; background: var(--card); border: var(--line-thin); border-radius: var(--radius-small); box-shadow: var(--shadow-small); }
.lang-menu li a { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s3); text-decoration: none; border-radius: 10px; }
.lang-menu li a:hover { background: var(--paper); }
.lang-menu li a[aria-current] { font-weight: 800; background: var(--sun); }

/* A one-line offer of the visitor's own language: a link, never a redirect. */
.lang-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s2) var(--s4); margin: 0; padding: var(--s2) var(--s4); background: var(--sun); border-bottom: var(--line-thin); font-weight: 800; }
.lang-bar a { display: inline-flex; align-items: center; min-height: 44px; }
.lang-bar button { min-width: 44px; min-height: 44px; background: none; border: 0; cursor: pointer; }

/* ----------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: var(--s2) var(--s5); font-weight: 800; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer; background: var(--card); color: var(--ink); border: var(--line-thin); border-radius: var(--radius-pill); box-shadow: var(--shadow-small); }
.btn.is-primary { background: var(--ink); color: var(--sun); }
.btn.is-sun { background: var(--sun); }
.btn.is-small { min-height: 44px; padding-inline: var(--s4); }
.btn:hover { background: var(--sun); color: var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: none; }
.store-buttons { display: flex; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s3); }
.store-buttons .btn { flex: 1 1 200px; max-width: 320px; min-height: 56px; font-size: 1.0625rem; }
/* On a phone the script marks the platform; the other store's button goes,
   and the one that is left is the primary button. */
.is-ios [data-store="android"], .is-android [data-store="ios"] { display: none; }
.is-android .btn[data-store="android"] { background: var(--ink); color: var(--sun); }
.is-android .btn[data-store="android"]:hover { background: var(--sun); color: var(--ink); }

/* -------------------------------------------------------------------- hero */
.hero { display: grid; gap: var(--s6); align-items: center; }
.hero h1 { font-size: clamp(2rem, 6.5vw, 3.5rem); line-height: 1.15; }
:lang(zh) .hero h1, :lang(ja) .hero h1, :lang(th) .hero h1 { line-height: 1.3; }
.page-practice .hero h1, .page-guide .hero h1, .page-privacy .hero h1, .page-notfound .hero h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); }
.eyebrow { display: inline-block; margin-bottom: var(--s3); padding: var(--s1) var(--s3); font-size: 0.875rem; font-weight: 800; background: var(--sun); border: var(--line-thin); border-radius: var(--radius-pill); }
.lead { font-size: 1.125rem; color: var(--ink); max-width: 60ch; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); padding: 0; list-style: none; }
.chips li { padding: var(--s1) var(--s3); font-size: 0.875rem; font-weight: 800; background: var(--card); border: var(--line-thin); border-radius: var(--radius-pill); }
.hint { font-size: 0.9375rem; color: var(--ink-soft); }

/* A screenshot in a phone frame, at its real proportions. */
.device { width: min(100%, 300px); margin-inline: auto; overflow: hidden; background: var(--card); border: var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.device img { display: block; width: 100%; }
.shot-row { display: grid; grid-auto-flow: column; grid-auto-columns: min(70%, 260px); gap: var(--s5); margin: 0; padding: var(--s2) var(--s2) var(--s5); overflow-x: auto; list-style: none; scroll-snap-type: x proximity; }
.shot-row li { scroll-snap-align: center; }
.shot-row .device { box-shadow: var(--shadow-small); }
.shot-row figcaption { margin-top: var(--s3); font-size: 0.9375rem; font-weight: 800; text-align: center; }

/* ---------------------------------------------------------------- sections */
.section-head { margin-bottom: var(--s5); }
.section-head p { max-width: 60ch; color: var(--ink-soft); }
.tiles { display: grid; gap: var(--s4); margin: 0; padding: 0; list-style: none; }
.tile { padding: var(--s5) var(--s4); background: var(--card); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.tile:nth-child(4n + 1) { background: var(--sky); }
.tile:nth-child(4n + 2) { background: var(--mint); }
.tile:nth-child(4n + 3) { background: var(--rose); }
.tile:nth-child(4n + 4) { background: var(--peach); }
.tile h3 { margin-bottom: var(--s2); }
.tile p { margin: 0; }
.tile .icon { display: block; margin-bottom: var(--s3); }

.card { padding: var(--s5) var(--s4); background: var(--card); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Facts, each with its source and the day it was last checked. */
.facts dl { display: grid; gap: var(--s3); margin: 0; }
.facts dl > div { padding-bottom: var(--s3); border-bottom: 2px dashed var(--ink); }
.facts dl > div:last-child { padding-bottom: 0; border-bottom: 0; }
.facts dt { font-weight: 800; }
.facts dd { margin: 0; }
.src { display: block; font-size: 0.875rem; color: var(--ink-soft); }
.src a { color: var(--link); }
.step .src { margin-top: var(--s3); padding-top: var(--s3); border-top: 2px dashed var(--ink); }
.checked { font-size: 0.875rem; color: var(--ink-soft); }

.faq details { margin-bottom: var(--s3); background: var(--card); border: var(--line-thin); border-radius: var(--radius-small); }
.faq summary { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: 56px; padding: var(--s3) var(--s4); font-weight: 800; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
/* The sign is drawn, not read: "/ ''" gives it no text for screen readers
   (a browser without that syntax keeps the first declaration). */
.faq summary::after { content: "+"; content: "+" / ""; flex: none; font-size: 1.5rem; line-height: 1; }
.faq details[open] summary::after { content: "−"; content: "−" / ""; }
.faq .answer { padding: 0 var(--s4) var(--s3); }
.faq .answer p:last-child { margin-bottom: 0; }

.cta { padding: var(--s6) var(--s4); text-align: center; background: var(--sun); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cta .store-buttons { justify-content: center; }
.cta .notaff-inline { font-size: 0.875rem; }

/* --------------------------------------------------------------- questions */
.quiz { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.question { padding: var(--s5) var(--s4); background: var(--card); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.q-count { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); font-size: 0.875rem; font-weight: 800; color: var(--ink-soft); }
.q-topic { padding: 2px var(--s3); color: var(--ink); background: var(--sun); border: var(--line-thin); border-radius: var(--radius-pill); }
.q-picture { margin-bottom: var(--s4); text-align: center; }
.q-picture img { display: inline-block; border: var(--line-thin); border-radius: var(--radius-small); }
.q-stem { margin-bottom: var(--s4); font-size: 1.1875rem; font-weight: 800; }
.q-options { display: grid; gap: var(--s3); margin: 0 0 var(--s4); padding: 0; list-style: none; }
.option { display: flex; align-items: flex-start; gap: var(--s3); width: 100%; min-height: 56px; padding: var(--s3) var(--s4); text-align: start; cursor: pointer; background: var(--card); border: var(--line-thin); border-radius: var(--radius-small); box-shadow: var(--shadow-small); }
.option .key { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; font-weight: 800; background: var(--paper); border: var(--line-thin); border-radius: 50%; }
.option .text { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.option:hover:not(:disabled) { background: var(--paper); }
.option:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.option:disabled { cursor: default; box-shadow: none; color: var(--ink); }
.option.is-right { background: var(--right-bg); border-color: var(--right); }
.option.is-wrong { background: var(--wrong-bg); border-color: var(--wrong); }
.option .verdict { display: block; margin-top: var(--s1); font-size: 0.875rem; font-weight: 800; }
.option.is-right .verdict, .option.is-right .mark { color: var(--right); }
.option.is-wrong .verdict, .option.is-wrong .mark { color: var(--wrong); }
.option .mark { flex: none; width: 24px; height: 24px; margin-top: 2px; }
.q-answer summary { display: inline-flex; align-items: center; min-height: 44px; font-weight: 800; cursor: pointer; }
.q-answer > p { margin: var(--s2) 0 0; padding: var(--s3) var(--s4); background: var(--right-bg); border-radius: var(--radius-small); }
.q-explain { margin: var(--s2) 0 0; padding: var(--s3) var(--s4); background: var(--paper); border: var(--line-thin); border-radius: var(--radius-small); }
.q-explain p { margin: 0; }

/* With the script: one question at a time, a progress bar and a result. */
.quiz.is-enhanced .q-answer { display: none; }
.quiz-progress { height: 14px; overflow: hidden; background: var(--card); border: var(--line-thin); border-radius: var(--radius-pill); }
.quiz-progress i { display: block; height: 100%; background: var(--sun); border-right: var(--line-thin); }
.quiz-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s3); }
.result { padding: var(--s6) var(--s4); text-align: center; background: var(--card); border: var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.result :is(h2, h3) { font-size: clamp(1.375rem, 3.5vw, 2rem); font-weight: 900; }
.result .score { font-size: clamp(2.5rem, 10vw, 4rem); font-weight: 900; line-height: 1.1; }
.result .verdict-word { display: inline-block; margin-bottom: var(--s3); padding: var(--s1) var(--s4); font-weight: 900; border: var(--line-thin); border-radius: var(--radius-pill); }
.result.is-pass .verdict-word { background: var(--right-bg); color: var(--right); border-color: var(--right); }
.result.is-fail .verdict-word { background: var(--wrong-bg); color: var(--wrong); border-color: var(--wrong); }
.result .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s3); margin-block: var(--s5); }
.result .store-buttons { justify-content: center; }

/* ------------------------------------------------------------------- guide */
.policy + .policy { padding-top: var(--s6); border-top: var(--line); }
.prose h2 { margin-top: var(--s7); }
.prose h2.version-title { font-size: clamp(1.75rem, 5vw, 2.75rem); margin-top: 0; }
.prose h3 { margin-top: var(--s5); }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose li { margin-bottom: var(--s2); }
.toc { padding: var(--s4); background: var(--card); border: var(--line-thin); border-radius: var(--radius-small); }
.toc ol { margin: 0; padding-inline-start: 1.4em; }
.toc a { display: inline-flex; align-items: center; min-height: 44px; }
.step { counter-increment: step; }
.steps { counter-reset: step; }
.step > h2::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-inline-end: var(--s3); font-size: 1.125rem; vertical-align: middle; background: var(--sun); border: var(--line-thin); border-radius: 50%; }
.note { padding: var(--s4); background: var(--sky); border: var(--line-thin); border-radius: var(--radius-small); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--s2) var(--s3); text-align: start; vertical-align: top; border-bottom: 2px solid var(--ink); }

/* ------------------------------------------------------------------ footer */
.site-footer { margin-top: var(--s8); padding-block: var(--s6); border-top: var(--line); font-size: 0.9375rem; }
.site-footer .notaff { font-weight: 800; }
.site-footer ul { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s5); margin: 0 0 var(--s4); padding: 0; list-style: none; }
.site-footer li a { display: inline-flex; align-items: center; min-height: 44px; }
.site-footer .rights, .site-footer .names { color: var(--ink-soft); }

/* ------------------------------------------------------------- breakpoints */
@media (min-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .facts dl > div { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s4); }
  .question, .card, .tile, .result { padding: var(--s6) var(--s5); }
  .shot-row { grid-auto-columns: 240px; justify-content: safe center; }
}
@media (min-width: 960px) {
  .hero.has-shot { grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tiles.is-wide { grid-template-columns: repeat(2, 1fr); }
  .q-picture img { max-width: 520px; }
}

/* ------------------------------------------------------------------ motion */
/* The page is complete without any of this; reduced motion gets none of it. */
@media (prefers-reduced-motion: no-preference) {
  .btn, .option { transition: transform 80ms ease-out, box-shadow 80ms ease-out, background-color 150ms ease-out; }
  .quiz-progress i { transition: width 200ms ease-out; }
  /* A slide only, never a fade: a question must be readable even where the
     browser does not run the animation (a background tab, a slow phone). */
  .question.is-entering { animation: card-in 200ms ease-out; }
  @keyframes card-in { from { transform: translateX(12px); } to { transform: none; } }
}

@media print {
  .site-header .btn, .lang-menu, .lang-bar, .store-buttons, .quiz-actions { display: none; }
  body { background: #fff; }
}
