/* OracleQuest 甲骨探源 — jiagu.ca
   One stylesheet, system fonts only, no external requests of any kind.
   Palette is the app's: bone ground, ink strokes, cinnabar accent. */

:root {
  --bg: #f3efe8;
  --bg-2: #ebe5da;
  --surface: #fdfcf7;
  --surface-2: #f6f2ea;
  --ink: #1f1d1b;
  --muted: #6b655d;
  --accent: #b13a2e;
  --accent-ink: #ffffff;
  --accent-wash: #f6e6e1;
  --hairline: #ddd4c5;
  --hairline-soft: #e8e1d4;
  --green: #2f6b3f;
  --green-wash: #e2eddf;
  --amber: #8a5a10;
  --amber-wash: #f3e8d2;
  --orange: #9a4a18;
  --orange-wash: #f5e3d6;
  --shadow: 0 1px 2px rgba(31, 29, 27, .05), 0 6px 18px rgba(31, 29, 27, .05);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a18;
    --bg-2: #211f1c;
    --surface: #262421;
    --surface-2: #2e2b27;
    --ink: #f1ece2;
    --muted: #aaa397;
    --accent: #e0695b;
    --accent-ink: #26120e;
    --accent-wash: #3a2622;
    --hairline: #3d3931;
    --hairline-soft: #332f29;
    --green: #8fc79b;
    --green-wash: #26332a;
    --amber: #e0bd7c;
    --amber-wash: #332d1f;
    --orange: #e9a173;
    --orange-wash: #372721;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        "PingFang SC", "PingFang TC", "Hiragino Sans GB", "Noto Sans CJK SC",
        "Microsoft YaHei", sans-serif;
  overflow-wrap: break-word;
}

[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img, svg { max-width: 100%; }

.wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 680px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 20;
  background: var(--accent); color: var(--accent-ink);
  padding: 12px 18px; border-radius: 0 0 10px 0; text-decoration: none;
}
.skip:focus { left: 0; }

/* ---------------------------------------------------------------- language switching --
   All three languages are in every page. lang.js puts data-lang on <html> and this rule
   shows one. With JavaScript off there is no data-lang, nothing is hidden, and the page
   stays complete — which is the point. */
html[data-lang="zh-Hans"] [data-l]:not([data-l="zh-Hans"]),
html[data-lang="zh-Hant"] [data-l]:not([data-l="zh-Hant"]),
html[data-lang="en"] [data-l]:not([data-l="en"]) { display: none; }

/* Controls that only do something with JavaScript. */
html:not(.js) .js-only { display: none; }

/* Without JavaScript the three languages sit end to end. Inline runs get a separator so
   that 首页 · 首頁 · Home reads as three labels rather than one long word. Block-level
   [data-l] elements (whole paragraphs) are already separated by their own margins. */
html:not([data-lang]) span[data-l] + span[data-l]::before {
  content: "·"; margin: 0 .4em; color: var(--muted); font-weight: 400;
}

/* -------------------------------------------------------------------------- header -- */
header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline-soft);
}
header.site .wrap {
  display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap;
  padding-top: 10px; padding-bottom: 10px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 17px; text-decoration: none; color: var(--ink);
  margin-right: auto; min-height: 44px;
}
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand-cn { font-weight: 700; letter-spacing: .02em; }
.brand-en { font-weight: 600; color: var(--muted); font-size: 15px; }

header.site nav { display: flex; flex-wrap: wrap; gap: 2px 4px; }
header.site nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  padding: 4px 10px; border-radius: 10px;
  font-size: 15px; text-decoration: none; color: var(--muted);
}
header.site nav a:hover { background: var(--surface-2); color: var(--ink); }
header.site nav a[aria-current="page"] { color: var(--ink); font-weight: 650; background: var(--bg-2); }

/* ------------------------------------------------------------------- language bar -- */
.langs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 0; }
.langs button {
  font: inherit; font-size: 14px; min-height: 44px; padding: 6px 14px;
  border-radius: 999px; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--muted);
}
.langs button:hover { color: var(--ink); }
.langs button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}

/* -------------------------------------------------------------------------- typography -- */
main { padding: 4px 0 64px; }
h1 { font-size: clamp(28px, 6.4vw, 40px); line-height: 1.2; margin: 22px 0 10px; letter-spacing: -.01em; }
h2 { font-size: clamp(20px, 4.4vw, 25px); line-height: 1.3; margin: 44px 0 10px; }
h3 { font-size: 18px; margin: 26px 0 6px; }
p { margin: 0 0 14px; }
.lede { font-size: clamp(18px, 3.4vw, 20px); color: var(--muted); line-height: 1.55; }
.meta { color: var(--muted); font-size: 15px; }
.section-note { color: var(--muted); font-size: 15px; }
.prose p { margin-bottom: 16px; }

/* -------------------------------------------------------------------------- cards -- */
.card-box {
  background: var(--surface); border: 1px solid var(--hairline-soft);
  border-radius: var(--radius); padding: 18px 20px; margin: 18px 0;
  box-shadow: var(--shadow);
}
.card-box.accent { border-color: var(--accent); background: var(--accent-wash); }
.card-box strong { color: var(--accent); }

/* -------------------------------------------------------------------------- hero -- */
.hero { padding: 18px 0 4px; }
.hero h1 { margin-top: 14px; }
.hero .lede { max-width: 42em; }

.hero-strip {
  list-style: none; display: grid; gap: 10px; padding: 0; margin: 26px 0 10px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}
.hero-strip a {
  display: grid; grid-template-columns: auto auto auto; align-items: center;
  justify-content: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--hairline-soft);
  border-radius: 14px; padding: 14px 8px 10px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); min-height: 88px;
}
.hero-strip a:hover { border-color: var(--accent); }
.hero-svg { width: 38px; height: 38px; color: var(--ink); }
.hero-arrow { color: var(--muted); font-size: 15px; }
.hero-modern { font-size: 30px; line-height: 1; font-weight: 500; }
.hero-gloss {
  grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 13px;
}

/* -------------------------------------------------------------------------- stats -- */
.stats {
  list-style: none; margin: 26px 0; padding: 18px 10px; display: grid; gap: 14px 6px;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  background: var(--surface); border: 1px solid var(--hairline-soft);
  border-radius: var(--radius); box-shadow: var(--shadow); text-align: center;
}
.stats li { color: var(--muted); font-size: 13px; line-height: 1.35; }
.stats b {
  display: block; color: var(--accent); font-size: 30px; font-weight: 700;
  line-height: 1.1; letter-spacing: -.02em; margin-bottom: 2px;
}

/* --------------------------------------------------------------------------- CTA -- */
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 22px; border-radius: 999px;
  font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-wash); filter: none; }

/* Download area. `data-store-state` on the block is the one switch that flips the site
   from "coming soon" to "on the App Store" — see docs/WEBSITE.md. */
.download { margin: 24px 0 8px; }
.download[data-store-state="coming-soon"] .when-live { display: none; }
.download[data-store-state="live"] .when-soon { display: none; }
.store-note { color: var(--muted); font-size: 15px; margin-top: 10px; }
.btn[aria-disabled="true"] {
  background: var(--surface); color: var(--muted); border-color: var(--hairline);
  cursor: default;
}
.btn[aria-disabled="true"]:hover { filter: none; }

/* ------------------------------------------------------------------- walk-through -- */
.steps { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 34px; }
.step { display: grid; gap: 14px; align-items: center; }
@media (min-width: 720px) {
  .step { grid-template-columns: 238px 1fr; gap: 28px; }
  .step:nth-child(even) .shot { order: 2; }
}
.shot {
  margin: 0; background: var(--bg-2); border: 1px solid var(--hairline);
  border-radius: 22px; padding: 8px; box-shadow: var(--shadow);
  max-width: 238px; justify-self: center;
}
.shot img { display: block; width: 100%; height: auto; border-radius: 15px; }
.shot figcaption { color: var(--muted); font-size: 13px; padding: 7px 4px 1px; text-align: center; }
.step-body h3 { margin-top: 0; }
.step-num {
  display: inline-block; min-width: 26px; height: 26px; line-height: 26px; text-align: center;
  border-radius: 999px; background: var(--accent-wash); color: var(--accent);
  font-size: 14px; font-weight: 700; margin-right: 8px;
}

/* ------------------------------------------------------------------------ features -- */
.features {
  list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.features li {
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.features h3 { margin: 0 0 6px; font-size: 17px; }
.features p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------------------------------------------------------------------- glyph index -- */
.controls {
  position: sticky; top: 0; z-index: 5;
  display: grid; gap: 10px; margin: 20px 0 6px; padding: 12px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--hairline-soft);
}
@media (min-width: 640px) {
  .controls { grid-template-columns: 1fr 260px; align-items: center; }
  .controls .chips { grid-column: 1 / -1; }
}
.field { display: block; }
.field input, .field select {
  font: inherit; font-size: 16px; width: 100%; min-height: 46px;
  padding: 9px 14px; border-radius: 12px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
}
.field input::placeholder { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
/* On a phone the chips become one horizontally scrolling row, like the app's own filter
   bar, so the sticky controls never eat a quarter of the screen. */
@media (max-width: 759px) {
  .controls { position: static; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
}
.chip {
  font: inherit; font-size: 14px; min-height: 44px; padding: 5px 13px;
  border-radius: 999px; cursor: pointer;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--muted);
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.result-count { color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.empty { color: var(--muted); }

.chapter { scroll-margin-top: 90px; }
.chapter h2 { margin-bottom: 2px; }
.chapter h2 b { color: var(--accent); font-size: .72em; margin-right: .45em; }
.chapter-sub { color: var(--muted); font-size: 15px; margin-bottom: 14px; }

.grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
.grid .card a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  height: 100%; min-height: 138px; padding: 12px 6px 10px;
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 14px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
}
.grid .card a:hover { border-color: var(--accent); }
.card-art { display: block; height: 46px; margin-bottom: 4px; }
.card-svg { width: 46px; height: 46px; color: var(--ink); }
.card-modern { font-size: 21px; line-height: 1.15; font-weight: 500; }
.card-modern .trad { font-style: normal; color: var(--muted); font-size: .8em; margin-left: .25em; }
.card-pinyin { font-size: 13px; color: var(--accent); }
.card-gloss {
  font-size: 12px; color: var(--muted); text-align: center; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dot {
  position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
}
.dot-certain { background: var(--green); }
.dot-probable { background: var(--amber); }
.dot-disputed { background: var(--orange); }
.dot-unknown { background: var(--muted); }

/* --------------------------------------------------------------------- glyph detail -- */
.crumb { margin: 16px 0 0; font-size: 15px; }
.glyph-head {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: 112px 1fr; margin: 14px 0 6px;
}
@media (min-width: 560px) { .glyph-head { grid-template-columns: 150px 1fr; gap: 26px; } }
.glyph-head-art {
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); aspect-ratio: 1;
}
.hero-glyph { width: 100%; height: auto; color: var(--ink); }
.glyph-head h1 { margin: 0 0 4px; font-size: clamp(34px, 9vw, 52px); }
.modern-big { font-size: 1.15em; }
.trad-big { color: var(--muted); font-size: .6em; margin-left: .3em; font-weight: 500; }
.pinyin { font-size: 17px; color: var(--accent); margin: 0 0 6px; }
.pinyin .sep { color: var(--hairline); }
.pinyin .eng { color: var(--muted); }
.meanings { margin: 0 0 10px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 3px 11px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.badge-certain { background: var(--green-wash); color: var(--green); }
.badge-probable { background: var(--amber-wash); color: var(--amber); }
.badge-disputed { background: var(--orange-wash); color: var(--orange); }
.badge-plain { background: var(--surface-2); color: var(--muted); }
.story { font-size: 18px; }

.variants { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.variant {
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: var(--radius);
  padding: 14px 16px 12px; box-shadow: var(--shadow);
}
.variant-art { display: flex; justify-content: center; padding: 4px 0 10px; }
.variant-svg { width: 84px; height: 84px; color: var(--ink); }
.variant-tag {
  margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent);
}
.variant-note { margin: 0 0 8px; font-size: 15px; }
.cite { margin: 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--hairline-soft);
  padding-top: 8px; }
.cite-none { font-style: italic; }

.evolution {
  list-style: none; padding: 14px 4px; margin: 16px 0 0; display: flex; gap: 6px;
  justify-content: space-between; align-items: end; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--hairline-soft);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.evo-step {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex: 1 1 0; min-width: 62px; position: relative;
}
.evo-step + .evo-step::before {
  content: "→"; position: absolute; left: -10px; top: 26px; color: var(--hairline); font-size: 14px;
}
.evo-art { display: flex; align-items: center; justify-content: center; height: 58px; }
.evo-svg { width: 52px; height: 52px; color: var(--ink); }
.evo-char { font-size: 40px; line-height: 1; }
.evo-name { font-size: 12px; color: var(--muted); text-align: center; }

.sources { list-style: none; padding: 0; margin: 14px 0 10px; display: grid; gap: 8px; }
.sources li {
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 12px;
  padding: 10px 14px; font-size: 15px;
}
.src-pub { display: block; }
.src-detail { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.related { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.related a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px;
  justify-content: center; padding: 10px 6px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 12px;
}
.related a:hover { border-color: var(--accent); }
.rel-char { font-size: 22px; }
.rel-gloss { font-size: 12px; color: var(--muted); text-align: center; }

.pager { display: flex; justify-content: space-between; gap: 10px; margin: 40px 0 0; }
.pager a {
  display: flex; flex-direction: column; min-height: 56px; justify-content: center;
  padding: 8px 18px; border-radius: 12px; text-decoration: none;
  border: 1px solid var(--hairline-soft); background: var(--surface); color: var(--ink);
}
.pager a:hover { border-color: var(--accent); }
.pager .next { margin-left: auto; text-align: right; }
.step-label { font-size: 12px; color: var(--muted); }
.step-char { font-size: 22px; }

/* ------------------------------------------------------------------------ Q&A pages -- */
.qa h2 { font-size: 19px; margin-top: 34px; }
.effective { color: var(--muted); font-size: 15px; }
.badge-key { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.badge-key li {
  background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 12px;
  padding: 12px 14px;
}
.badge-key .badge { margin-bottom: 8px; }
.badge-key li > span:last-child { display: block; }

table.plain { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 15px; }
table.plain th, table.plain td {
  border-bottom: 1px solid var(--hairline-soft); padding: 9px 8px; text-align: left; vertical-align: top;
}
table.plain th { color: var(--muted); font-weight: 600; }

/* -------------------------------------------------------------------------- footer -- */
footer.site {
  border-top: 1px solid var(--hairline-soft); background: var(--surface);
  color: var(--muted); font-size: 14px; padding: 22px 0 36px;
}
footer.site a { color: var(--muted); }
footer.site a:hover { color: var(--accent); }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0 0 8px; }
.foot-links a { display: inline-flex; align-items: center; min-height: 44px; }
.foot-note { margin: 0; max-width: 60em; }

/* ------------------------------------------------------------------ reduced motion -- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* --------------------------------------------------------------------------- print -- */
@media print {
  header.site nav, .langs, .controls, .pager, .skip { display: none; }
  body { background: #fff; color: #000; }
}

/* --------------------------------------------------------------------- dot legend -- */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  color: var(--muted); font-size: 13px; margin: 6px 0 22px;
}
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item .dot { position: static; }
.legend a { display: inline-flex; align-items: center; min-height: 28px; }

/* ------------------------------------------------------------- app note on glyphs -- */
.in-app { display: grid; gap: 16px; margin-top: 54px; align-items: center; }
@media (min-width: 720px) { .in-app { grid-template-columns: 200px 1fr; gap: 30px; } }
.in-app .shot { max-width: 200px; }
.in-app h2 { margin-top: 0; }
