/* Face the Figure. Boardread's system: paper and ink, Newsreader for words, Libre Franklin for the interface and
   figures. Flat and square. Right and wrong are words and marks in ink, not colour. One thing moves per round: the
   sealed figure turns over and counts up. Transform and opacity only, 90 to 220 ms, one curve. */
@font-face { font-family: "Libre Franklin"; font-weight: 400; font-display: swap; src: url("/fonts/LibreFranklin-400.woff2") format("woff2"); }
@font-face { font-family: "Libre Franklin"; font-weight: 600; font-display: swap; src: url("/fonts/LibreFranklin-600.woff2") format("woff2"); }
@font-face { font-family: "Libre Franklin"; font-weight: 800; font-display: swap; src: url("/fonts/LibreFranklin-800.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-weight: 400 600; font-display: swap; src: url("/fonts/Newsreader-var.woff2?v=4cd42e5a") format("woff2"); }
@font-face { font-family: "Franklin Fallback"; src: local("Arial"); size-adjust: 103%; ascent-override: 92%; descent-override: 22%; line-gap-override: 0%; }

:root {
  --paper: #fff; --ink: #121212; --soft: #5a5a5a; --faint: #a3a3a3; --rule: #e2e2e2; --wash: #f1f1f1;
  --f: "Libre Franklin", "Franklin Fallback", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --pad: 20px;
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) { :root { --paper: #121212; --ink: #ededed; --soft: #a0a0a0; --faint: #6b6b6b; --rule: #2b2b2b; --wash: #1e1e1e; } }

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--paper); color: var(--ink); font: 400 16px/1.4 var(--f); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button { font: inherit; color: inherit; border-radius: 0; cursor: pointer; }
button, a, input { touch-action: manipulation; }      /* no double-tap zoom, so no wait before a tap counts */
a { color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cap { font: 600 11px/1.2 var(--f); letter-spacing: 0.12em; text-transform: uppercase; color: var(--soft); }
.cap b { font-weight: 600; color: var(--ink); }
.num { font-variant-numeric: tabular-nums lining-nums; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.app { position: fixed; inset: 0 0 auto 0; height: var(--vh, 100dvh); display: flex; flex-direction: column; max-width: 520px; margin: 0 auto; --W: min(100vw, 520px); }
.top { flex: none; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 var(--pad); border-bottom: 1px solid var(--ink); }
.brand { font: 600 23px/1 var(--serif); letter-spacing: -0.01em; text-decoration: none; padding: 11px 0; margin: -11px 0; } /* 44 px to hit, the bar does not grow */
.tools { display: flex; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; transition: transform 120ms var(--ease); }
.icon-btn:active { transform: scale(0.92); }
#sound[aria-pressed="false"] .wave, #sound[aria-pressed="true"] .mute { display: none; }

/* the result colours, one set for the three games. A fill carries white letters at 4.5:1 or better; the -fg tones are
   for coloured words on the page and are lighter on a dark page. High contrast swaps in orange, blue and violet and
   shows a miss in ink, for eyes that confuse red and green. */
:root { --ok: #2f7d4c; --near: #9a6700; --out: #6b7075; --bad: #b3372c; --top: #1f5fa8; --on-bad: #fff;
  --ok-fg: var(--ok); --near-fg: var(--near); --out-fg: var(--out); --bad-fg: var(--bad); --top-fg: var(--top); }
@media (prefers-color-scheme: dark) { :root { --out: #4a4e52; --ok-fg: #6cc592; --near-fg: #d9a441; --out-fg: #a0a0a0; --bad-fg: #f0857a; --top-fg: #7fb2ea; } }
.app[data-hc="1"] { --ok: #b84e08; --near: #1f6fb5; --top: #6b3fa0; --bad: var(--ink); --on-bad: var(--paper); --ok-fg: #b84e08; --near-fg: #1f6fb5; --top-fg: #6b3fa0; --bad-fg: var(--ink); }
@media (prefers-color-scheme: dark) { .app[data-hc="1"] { --ok-fg: #f08a4b; --near-fg: #6fb1ee; --top-fg: #b99ae6; } }
.hc { justify-self: start; padding: 4px 0; }
.stage { position: relative; flex: 1 1 0; min-height: 0; }
.game { height: 100%; display: flex; flex-direction: column; }
.hud { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 16px var(--pad) 0; }
.hud .cap b { font: 800 15px/1 var(--f); letter-spacing: 0; margin-left: 4px; }
.hud .sep { display: inline-block; width: 14px; }
.pips { list-style: none; padding: 0; display: flex; gap: 5px; }
.pips li { width: 14px; height: 14px; border: 1.5px solid var(--faint); }
.pips li.now { border: 2px solid var(--ink); }
.pips li.new { animation: pip 180ms var(--ease); }
@keyframes pip { from { transform: scale(1.6); } }
.pips li.ok { background: var(--ok); border-color: var(--ok); }
.pips li.no { position: relative; background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.pips li.no::after { content: "×"; position: absolute; inset: 0; display: grid; place-items: center; font: 800 12px/1 var(--f); }

.ask { flex: none; padding: 28px var(--pad) 0; display: grid; gap: 10px; }
.q { min-height: calc(3 * 1.08em); font: 500 32px/1.08 var(--serif); letter-spacing: -0.015em; outline: none; text-wrap: balance; overflow-wrap: anywhere; }

/* the two figures: a table of two columns between two rules */
.pair { flex: none; display: grid; grid-template-columns: 1fr 1fr; margin: 28px var(--pad) 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); }
.fc { position: relative; min-width: 0; padding: 16px 0 18px; display: grid; align-content: start; grid-template-rows: auto minmax(58px, auto) auto auto auto; will-change: transform; }
.fc + .fc { border-left: 1px solid var(--rule); padding-left: 16px; }
.fc:first-child { padding-right: 16px; }
.tag { display: inline-grid; place-items: center; width: 22px; height: 22px; background: var(--ink); color: var(--paper); font: 800 12px/1 var(--f); }
.verdict-tag { position: absolute; top: 16px; right: 0; height: 22px; display: inline-grid; place-items: center; padding: 0 8px; font: 800 11px/1 var(--f); letter-spacing: 0.1em; text-transform: uppercase; }
.verdict-tag.ok { background: var(--ok); color: #fff; }
.verdict-tag.no { background: var(--bad); color: var(--on-bad); }
/* the revealed figure is weighed in the colour of the call */
.fc.right .bar i { background: var(--ok); }
.fc.wrong .bar i { background: var(--bad); }
.subj { font: 600 25px/1.08 var(--serif); letter-spacing: -0.01em; margin-top: 12px; overflow-wrap: anywhere; hyphens: auto; }
.what { margin-top: 12px; }
.fig { display: flex; align-items: baseline; height: 56px; margin-top: 6px; font: 800 44px/56px var(--f); letter-spacing: -0.02em; white-space: nowrap; transform-origin: 50% 55%; }
.fig[data-len="l"] { font-size: 36px; }
.fig[data-len="xl"] { font-size: 30px; }
.fig .cur { font-size: 0.6em; margin-right: 2px; align-self: center; }
.fig .u { font-size: 0.42em; font-weight: 600; letter-spacing: 0; margin-left: 5px; }
.fig .p { display: inline-block; }
.fc.sealed .fig { justify-content: center; border: 2px dashed var(--ink); font-size: 30px; }
.bar { height: 10px; margin-top: 12px; background: var(--wash); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); will-change: transform; }
.fc.sealed .bar { background: none; border: 1px dashed var(--faint); }
.src { min-height: 16px; margin-top: 10px; font: 400 12px/16px var(--f); color: var(--soft); }
.src a { text-underline-offset: 2px; }

/* under the table: what the call came to, then the links already called, as many as fit */
.ledger { flex: 1 1 0; min-height: 0; overflow: hidden; padding: 16px var(--pad) 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 12px; }
.v-line { min-height: 22px; font: 400 17px/22px var(--serif); }
.links { list-style: none; padding: 0; height: 100%; display: flex; flex-direction: column; flex-wrap: wrap; overflow: hidden; }
.links li { flex: none; width: 100%; display: grid; grid-template-columns: 18px 1fr auto 36px; gap: 10px; align-items: baseline; height: 38px; align-content: center; border-top: 1px solid var(--rule); font: 400 14px/1 var(--f); }
.links .n { color: var(--soft); }
.links .a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.links .m { font: 600 10.5px/1 var(--f); letter-spacing: 0.1em; text-transform: uppercase; }
.links .ok .m { color: var(--ok-fg); }
.links .no .m { color: var(--bad-fg); }
.links .p { font-weight: 800; text-align: right; }

.panel { flex: none; padding: 12px var(--pad) calc(20px + var(--sab)); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.key { position: relative; height: 84px; display: grid; align-content: center; justify-items: start; gap: 8px; padding: 0 16px; border: 2px solid var(--ink); background: var(--paper); text-align: left; touch-action: manipulation; transition: transform 120ms var(--ease), opacity 150ms var(--ease); }
#k-up { background: var(--ink); color: var(--paper); }
#k-up .ks { color: inherit; opacity: 0.7; }
.key .kl { font: 800 24px/1 var(--f); letter-spacing: -0.01em; }
.key i { position: absolute; right: 14px; top: 12px; font: 600 18px/1 var(--f); font-style: normal; }
.key:active:not(:disabled) { transform: scale(0.97); }
.key.fade { opacity: 0.25; }
.nextbtn { height: 84px; font-size: 17px; }
.panel .textbtn { display: block; margin: 0 auto; }
.btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 52px; border: 2px solid var(--ink); background: var(--ink); color: var(--paper); font: 600 15px/1 var(--f); letter-spacing: 0.02em; transition: transform 120ms var(--ease); }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: none; color: var(--ink); }
.textbtn { border: 0; background: none; padding: 12px 0; font: 600 14px/1 var(--f); text-decoration: underline; text-underline-offset: 3px; }
.home { font: 400 13px/1 var(--f); color: var(--soft); }
.home a { text-underline-offset: 3px; }
.fine { font: 400 13px/1.4 var(--f); color: var(--soft); }
.fail { padding: 40px var(--pad); font: 400 20px/1.3 var(--serif); }

/* the start card: a page of its own, read top to bottom */
.scrim { display: none; }
.intro { position: fixed; inset: 0; z-index: 10; background: var(--paper); display: grid; align-content: center; justify-items: start; gap: 16px; padding: 32px max(var(--pad), calc((100vw - 440px) / 2)); overflow: auto; }
.intro .title { font: 600 56px/0.95 var(--serif); letter-spacing: -0.02em; margin-top: -4px; }
.intro .lede { font: 400 22px/1.25 var(--serif); max-width: 18em; }
.intro .how { font: 400 15px/1.4 var(--f); color: var(--soft); }
.intro .how b { color: var(--ink); font-weight: 600; }
.intro .btn { margin-top: 8px; justify-self: stretch; }

/* the result: a sheet in place of the table */
.end { position: absolute; inset: 0; background: var(--paper); overflow: hidden auto; overscroll-behavior: contain; padding: 28px var(--pad) calc(32px + var(--sab)); display: grid; align-content: start; gap: 24px; animation: sheet 220ms var(--ease); }
@keyframes sheet { from { opacity: 0; transform: translateY(12px); } }
.e-head { display: grid; gap: 12px; }
.e-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.e-score { font: 800 96px/0.8 var(--f); letter-spacing: -0.05em; outline: none; }
.e-score small { font-size: 0.42em; font-weight: 600; letter-spacing: -0.02em; color: var(--soft); }
.e-rank { font: 500 30px/1 var(--serif); letter-spacing: -0.01em; text-align: right; }
.e-line { font: 400 17px/1.35 var(--serif); }
.card { border: 1px solid var(--ink); padding: 16px; display: grid; gap: 16px; }
.card-top { display: flex; align-items: baseline; justify-content: space-between; }
.squares { display: flex; gap: 6px; }
.squares i { flex: 1 1 0; aspect-ratio: 1; max-width: 44px; border: 2px solid var(--ink); animation: pop 200ms var(--ease) calc(var(--i) * 45ms) backwards; }
.squares i { border-color: var(--bad); background: var(--bad); }
.squares i.ok { background: var(--ok); border-color: var(--ok); }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
.share-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); font: 400 13px/1.3 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.share-text.open { position: static; width: auto; height: auto; clip-path: none; }
.next-in { display: flex; align-items: baseline; justify-content: space-between; padding-top: 16px; border-top: 1px solid var(--rule); }
.next-in b { font: 800 20px/1 var(--f); }
.block { display: grid; gap: 4px; padding-top: 20px; border-top: 1px solid var(--ink); }
.rows { list-style: none; padding: 0; }
.rows li { display: grid; grid-template-columns: 18px 1fr auto; gap: 4px 10px; padding: 12px 0; border-top: 1px solid var(--rule); font: 400 15px/1.25 var(--f); }
.rows li:first-child { border-top: 0; }
.rows .n { color: var(--soft); }
.rows .a { font: 500 18px/1.2 var(--serif); }
.rows .p { font-weight: 800; }
.rows .no .a, .rows .no .p { color: var(--bad-fg); }
.rows .ok .p { color: var(--ok-fg); }
.rows .sub { grid-column: 2 / -1; font: 400 12.5px/1.4 var(--f); color: var(--soft); }
.rows .sub a { text-underline-offset: 2px; }
/* a link on a phone is 44 px to hit: padding for the hit area, equal negative margin so the row does not grow */
@media (max-width: 900px), (pointer: coarse) { .rows .sub a { display: inline-block; padding: 14px 4px; margin: -14px -4px; } }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { display: grid; gap: 6px; }
.stats dt { font: 600 10.5px/1.2 var(--f); letter-spacing: 0.1em; text-transform: uppercase; color: var(--soft); order: 2; }
.stats dd { font: 800 30px/1 var(--f); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stats { padding-top: 12px; }
.credit { font: 400 12px/1.4 var(--f); color: var(--soft); }
/* a reason to come back: the streak, the last seven days, the day's leading article */
.again { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.streak { display: flex; align-items: baseline; gap: 10px; }
.streak b { font: 800 44px/0.8 var(--f); letter-spacing: -0.04em; }
.week { list-style: none; padding: 0; display: flex; gap: 6px; }
.week li { display: grid; justify-items: center; gap: 6px; font: 600 10px/1 var(--f); color: var(--soft); }
.week li::after { content: ""; width: 18px; height: 18px; border: 1.5px solid var(--faint); }
.week li.on::after { background: var(--ink); border-color: var(--ink); }
.week li.today { color: var(--ink); }
.week li.today::after { border: 2px solid var(--ink); }
.today-link { font: 400 17px/1.35 var(--serif); }
.today-link a { text-underline-offset: 3px; }
/* the result is set down a block at a time */
.end > * { animation: rise 220ms var(--ease) backwards; }
.end > :nth-child(2) { animation-delay: 40ms; } .end > :nth-child(3) { animation-delay: 80ms; } .end > :nth-child(4) { animation-delay: 120ms; }
.end > :nth-child(n + 5) { animation-delay: 160ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); z-index: 20; padding: 12px 16px; background: var(--ink); color: var(--paper); font: 600 13px/1 var(--f); opacity: 0; transform: translate(-50%, 8px); transition: opacity 150ms var(--ease), transform 150ms var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (min-height: 780px) {
  .ask { padding-top: 36px; }
  .q { font-size: 36px; }
  .pair { margin-top: 32px; }
  .fc { padding: 20px 0 24px; }
  .fig { height: 64px; font-size: 50px; line-height: 64px; }
  .fig[data-len="l"] { font-size: 40px; }
  .fig[data-len="xl"] { font-size: 32px; }
}
