/* One weight of one typeface: hierarchy comes from size, colour and space, which also keeps the font file small */
@font-face {
  font-family: "Serif SC";
  src: url("fonts/serif-sc.woff2?v=011fb817") format("woff2");
  font-weight: 500;
  font-display: block;
}

:root {
  /* Each colour has one job: ink for text, copper for everything that needs attention, paper for the ground */
  --paper: #fbf7ee;
  /* A faint grain, so the ground reads as paper rather than a flat colour */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .2 .08 0 0 0 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --ink: #15171a;
  --copper: #7c4030;
  --soft: #6b655a;
  --faint: #8f897c;
  --rule: #e6dfcf;

  --fs-small: 13px;
  --fs-body: 16px;
  --fs-option: 18px;
  --fs-verse: 23px;
  --fs-title: 46px;
  --fs-score: 76px;

  --t-press: .12s;
  --t-state: .18s;
  --t-move: .35s;
  --t-page: .4s;
}

* { box-sizing: border-box; margin: 0; -webkit-tap-highlight-color: transparent; }

html { background: var(--paper); -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--paper) var(--grain);
  color: var(--ink);
  font-family: "Serif SC", serif;
  font-weight: 500;
  font-synthesis: none;
  font-size: var(--fs-body);
  line-height: 1.7;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 28px) 24px calc(env(safe-area-inset-bottom) + 36px);
  animation: fade var(--t-state) ease both;
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.label { font-size: var(--fs-small); color: var(--soft); letter-spacing: .08em; }

.link {
  position: relative;
  font-size: var(--fs-small);
  color: var(--soft);
  letter-spacing: .08em;
}
/* Small to look at, about 44px to tap */
.link::after { content: ""; position: absolute; inset: -14px -10px; }

.primary {
  display: block;
  width: 100%;
  padding: 15px;
  background: var(--copper);
  color: var(--paper);
  letter-spacing: .24em;
  text-indent: .24em;
  transition: opacity var(--t-press);
}
.primary:active { opacity: .78; }
.primary:disabled { background: var(--rule); color: var(--faint); cursor: default; }

.secondary {
  display: block;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--rule);
  letter-spacing: .24em;
  text-indent: .24em;
  transition: border-color var(--t-state);
}
.secondary:active { border-color: var(--copper); }

/* Home */
.brand { padding: 44px 0 40px; text-align: center; }
.brand h1 {
  font-size: var(--fs-title);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: .3em;
  text-indent: .3em;
}
.brand h1::after { content: ""; display: block; width: 24px; height: 2px; margin: 18px auto 0; background: var(--copper); }
.brand p { margin-top: 16px; color: var(--soft); font-size: var(--fs-small); letter-spacing: .14em; text-indent: .14em; }

.section { padding: 26px 0; border-top: 1px solid var(--rule); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.testaments { position: relative; display: flex; gap: 32px; margin-bottom: 18px; padding-bottom: 4px; }
.testaments button {
  position: relative;
  color: var(--faint);
  letter-spacing: .14em;
  transition: color var(--t-state);
}
.testaments button::after { content: ""; position: absolute; inset: -12px -10px; }
.testaments button.on { color: var(--copper); }
.seg-ink {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1px;
  background: var(--copper);
  transition: transform var(--t-move), width var(--t-move);
}

.book-row { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 44px; margin-bottom: 6px; text-align: left; }
.book-name { font-size: 22px; letter-spacing: .08em; }

.picker { margin: 10px 0 22px; padding: 16px 0 2px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.picker-empty { margin: 6px 0 4px; color: var(--soft); }
.book-group { margin-bottom: 16px; }
.book-group .label { margin-bottom: 8px; }
.book-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.book-chip {
  min-height: 44px;
  padding: 6px 2px;
  border: 1px solid var(--rule);
  font-size: 14px;
  white-space: nowrap;
  transition: background var(--t-state), color var(--t-state), border-color var(--t-state);
}
.book-chip.wide { grid-column: span 2; }
.book-chip.started { border-color: var(--faint); }
.book-chip.on { background: var(--copper); border-color: var(--copper); color: var(--paper); }

.chapters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.chapters.long { max-height: 300px; overflow-y: auto; }
.chapter {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--soft);
  transition: background var(--t-state), color var(--t-state);
}
/* The cells are a little under 44px on phones; the tap area closes the gaps between them */
.chapter::before { content: ""; position: absolute; inset: -3px; }
.chapter.done { color: var(--ink); }
.chapter.done::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--copper);
}
.chapter.on { background: var(--copper); color: var(--paper); }
.chapter.on.done::after { background: var(--paper); }

.counts { display: flex; gap: 28px; }
.count { position: relative; color: var(--faint); padding-bottom: 3px; border-bottom: 1px solid transparent; transition: color var(--t-state), border-color var(--t-state); }
.count::after { content: ""; position: absolute; inset: -12px -12px; }
.count.on { color: var(--copper); border-bottom-color: var(--copper); }

.start { padding-top: 6px; }
.review {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-top: 28px;
  text-align: left;
}
.review span:last-child { color: var(--soft); }

.motto { margin-top: 52px; text-align: center; color: var(--faint); font-size: var(--fs-small); line-height: 2; letter-spacing: .06em; }

.credit { margin-top: 14px; font-size: 12px; letter-spacing: .08em; }

/* Question */
.topbar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.progress { height: 1px; background: var(--rule); margin-bottom: 44px; }
.progress i { display: block; height: 1px; background: var(--copper); transition: width var(--t-page) ease; }

.stem { font-size: var(--fs-verse); line-height: 1.75; min-height: 4.2em; margin-bottom: 26px; }
.blank {
  display: inline-block;
  min-width: 3em;
  height: 1.1em;
  margin: 0 .15em;
  border-bottom: 1px solid var(--ink);
  vertical-align: baseline;
}
.filled { color: var(--copper); border-bottom: 1px solid var(--copper); padding: 0 .1em; }

.options { border-top: 1px solid var(--rule); }
.option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: var(--fs-option);
  line-height: 1.5;
  text-align: left;
  transition: color var(--t-state), background var(--t-state);
}
.option:active { background: #f3ecdc; }
@media (hover: hover) {
  .option:hover:not(:disabled) { background: #f6f0e2; }
}
.option:disabled { cursor: default; color: var(--ink); }
/* Copper marks the answer in the text, so right and wrong are told by ink, grey and the marks */
.option.right { color: var(--ink); }
.option.wrong { color: var(--soft); }
.option.wrong span:first-child { text-decoration: line-through; text-decoration-thickness: 1px; }
.option svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; }

/* The verse is what the player should leave with */
.fresh { animation: fade var(--t-state) ease both; }
.verse-card { margin-top: 24px; animation: enter var(--t-page) ease both; }
.verse-card .ref { display: block; margin-bottom: 6px; color: var(--soft); font-size: var(--fs-small); letter-spacing: .08em; }
.verse-card p { line-height: 1.85; }
.mark { color: var(--copper); }
/* Proper names are underlined in the printed Chinese Union Version */
.name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-skip-ink: none; }
.actions { display: flex; flex-direction: column; gap: 18px; align-items: center; margin-top: 26px; }

/* Short phones: tighten the space around the question so an answered screen still fits */
@media (max-height: 700px) {
  .progress { margin-bottom: 22px; }
  .stem { min-height: 0; margin-bottom: 18px; }
  .verse-card { margin-top: 16px; }
  .actions { margin-top: 18px; gap: 14px; }
}

/* Chapter reading. The page opens scrolled to the verse, so the way back must stay in view */
.back-bar {
  position: sticky;
  top: 0;
  margin: 0 -24px;
  padding: calc(env(safe-area-inset-top) + 14px) 24px 14px;
  background: var(--paper) var(--grain);
  border-bottom: 1px solid var(--rule);
}
body[data-screen="chapter"] #app { padding-top: 0; }
.read h2, .read p { scroll-margin-top: 70px; }
.read-title { font-size: 24px; letter-spacing: .08em; margin: 26px 0 26px; }
.read h2 { margin: 30px 0 12px; font-size: var(--fs-small); font-weight: 500; color: var(--soft); letter-spacing: .14em; }
.read p { margin-bottom: 12px; line-height: 1.95; }
.read .num { margin-right: .4em; font-size: 12px; color: var(--faint); }
.read .here { margin: 0 -10px 12px; padding: 4px 10px; background: rgba(124, 64, 48, .1); }
.read .here .num { color: var(--soft); }

/* Result */
.score { padding: 56px 0 8px; text-align: center; }
.score b { font-size: var(--fs-score); font-weight: 500; line-height: 1.1; }
.score span { font-size: 24px; color: var(--soft); margin-left: .2em; }
.score-note { text-align: center; color: var(--soft); margin-bottom: 38px; letter-spacing: .04em; }
.missed { border-top: 1px solid var(--rule); padding: 20px 0; }
.missed .ref { display: block; margin-bottom: 4px; color: var(--soft); font-size: var(--fs-small); letter-spacing: .08em; }
.missed p { line-height: 1.85; }
.missed-title { margin-bottom: 14px; }
.result-actions { display: flex; flex-direction: column; gap: 12px; padding-top: 22px; border-top: 1px solid var(--rule); }

/* Respect the system setting: changes still happen, without the movement */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
