/* Topfloor. Boardread's system: paper and ink, Newsreader for words, Libre Franklin for the interface and figures.
   Flat and square. The lift is a number and a mark on a five-band scale. One thing moves per answer: the floor
   counts up and the mark slides. Transform and opacity only, 150 to 700 ms for the count, 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; }
/* an answer's colour is its tier's: common grey, the middle floors amber, a rare one green, the rarest blue */
.t0 { --tc: var(--out); --tc-fg: var(--out-fg); } .t1, .t2 { --tc: var(--near); --tc-fg: var(--near-fg); } .t3 { --tc: var(--ok); --tc-fg: var(--ok-fg); } .t4 { --tc: var(--top); --tc-fg: var(--top-fg); } .tx { --tc: var(--bad); --tc-fg: var(--bad-fg); }
.stage { position: relative; flex: 1 1 0; min-height: 0; }
.game { height: 100%; display: flex; flex-direction: column; }

/* the building: a window on a drawn tower. The car keeps its place; the tower goes past it. */
.tower { position: relative; flex: 1 1 0; min-height: 88px; overflow: hidden; --fh: 18px; --ax: calc((120 + 52) * var(--fh) / 20); --x0: max(8px, calc(50% - var(--ax) - 40px)); }
.strip { position: absolute; left: var(--x0); top: 0; will-change: transform; }
.tw { display: block; width: 100%; height: 100%; overflow: visible; }
.tw path, .tw rect, .tw circle { vector-effect: non-scaling-stroke; }
.tw .fn { font: 800 11px/1 var(--f); fill: currentColor; stroke: none; font-variant-numeric: tabular-nums; }
.tw .bn { font: italic 400 12.5px/1 var(--serif); fill: var(--soft); stroke: none; }
.tw .ans text { font: 600 13.5px/1 var(--serif); fill: var(--tc-fg, currentColor); stroke: none; }
.tw .ans path { stroke: var(--tc-fg, currentColor); }
/* the lit copy shows from the car down: its window ends at the car's floor */
.lit { position: absolute; left: 0; right: 0; bottom: 0; overflow: hidden; pointer-events: none; }
.lit .strip { left: var(--x0); }
.cable { position: absolute; top: 0; left: calc(var(--x0) + var(--ax) - 0.5px); width: 1px; background: var(--ink); }
.car { position: absolute; left: calc(var(--x0) + var(--ax) - var(--fh) * 0.4); width: calc(var(--fh) * 0.8); height: calc(var(--fh) * 0.9); color: var(--ink); }
.car .seam { stroke: var(--paper); stroke-width: 1; fill: none; }
.tower .cable { height: calc(70% - var(--fh) * 0.9); }
.tower .car { top: calc(70% - var(--fh) * 0.9); }

.readout { flex: none; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 12px var(--pad) 12px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.floor { display: flex; align-items: baseline; gap: 10px; }
.floor b { font: 800 44px/1 var(--f); letter-spacing: -0.04em; }
/* the floor counter: three reels of digits behind a window one digit high */
.odo { display: inline-flex; height: 1em; overflow: hidden; }
.odo .col + .col { margin-left: -0.05em; }
.odo .col { display: block; height: 1em; transition: opacity 150ms var(--ease); }
.odo .col.off { opacity: 0; width: 0; }
.odo .reel { display: flex; flex-direction: column; will-change: transform; }
.odo .reel span { display: block; height: 1em; line-height: 1; }
.band { display: flex; align-items: baseline; gap: 10px; }
.band strong { font: 500 22px/1 var(--serif); letter-spacing: -0.01em; }

.q { flex: none; padding: 16px var(--pad) calc(20px + var(--sab)); will-change: transform; }
.screen { display: grid; }
.q-row { display: flex; align-items: baseline; justify-content: space-between; }
.time, .pts { font: 800 20px/1 var(--f); }
.time.hot { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.fuse { height: 2px; margin-top: 10px; background: var(--rule); }
.fuse i { display: block; height: 100%; background: var(--ink); transform-origin: 0 50%; will-change: transform; }
.q-text { margin-top: 18px; font: 500 36px/1.05 var(--serif); letter-spacing: -0.015em; text-wrap: balance; overflow-wrap: anywhere; outline: none; }
.slot { display: flex; gap: 10px; margin-top: 20px; will-change: transform; }
.slot input { flex: 1 1 0; min-width: 0; height: 56px; border: 2px solid var(--ink); border-radius: 0; background: var(--paper); color: var(--ink); padding: 0 14px; font: 600 20px/1 var(--f); outline: none; -webkit-appearance: none; appearance: none; }
.slot input:focus-visible { outline: none; box-shadow: inset 0 -4px 0 var(--ink); }
.go { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border: 2px solid var(--ink); background: var(--paper); color: var(--faint); transition: transform 120ms var(--ease); }
.go.ready { background: var(--ink); color: var(--paper); }
.go:active { transform: scale(0.94); }
.note { margin-top: 12px; font: 400 14px/1.4 var(--f); color: var(--soft); }
.note.bad { color: var(--bad-fg); font-weight: 600; }
.slot.bad input { border-color: var(--bad); }
#st-tier { color: var(--tc-fg, var(--soft)); }
/* the answer's tier as five steps: filled up to where it landed */
.lamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; height: 2px; margin-top: 10px; background: none; }
.lamps i { background: var(--rule); }
.lamps i.on { background: var(--tc, var(--ink)); animation: step 160ms var(--ease) calc(var(--i) * 60ms) backwards; }
@keyframes step { from { opacity: 0; } }
.q .btn { margin-top: 20px; height: 56px; }

.btn { margin-top: 20px; height: 56px; }

.ledger { flex: 1 1 0; min-height: 0; overflow: hidden; padding: 20px var(--pad) 0; }
.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 44px; 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 .no .m { text-decoration: line-through; color: var(--soft); }
.links .p { font-weight: 800; text-align: right; }

.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; }
.e-score { display: flex; align-items: baseline; gap: 10px; }
.e-score b { font: 800 96px/0.8 var(--f); letter-spacing: -0.05em; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 88px; align-items: end; border-bottom: 2px solid var(--ink); }
.bars i { height: calc(var(--h) * 100%); background: var(--tc, var(--ink)); transform-origin: 50% 100%; animation: rise 220ms var(--ease) calc(var(--i) * 45ms) backwards; }
.bars i.tx { height: 4px; }
@keyframes rise { from { transform: scaleY(0); } }
.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 .tx .a, .rows .tx .p { color: var(--bad-fg); }
.rows .sub b { font-weight: 600; color: var(--tc-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; }
.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: 760px) { .tower { --fh: 21px; } }
/* wide screens: one composition. The tower stands left of the middle at full height, the floor and the question
   are set beside the car, with nothing boxed. */
@media (min-width: 900px) {
  .app { max-width: 1120px; }
  .game { display: grid; grid-template-columns: minmax(0, 1fr) 440px; grid-template-rows: 1fr auto auto 1.3fr; column-gap: 24px; }
  .tower { grid-column: 1; grid-row: 1 / -1; --fh: 24px; --x0: calc(100% - var(--ax) * 2 - 120px); }
  .tower .cable { height: calc(56% - var(--fh) * 0.9); }
  .tower .car { top: calc(56% - var(--fh) * 0.9); }
  .readout { grid-column: 2; grid-row: 2; border-top: 0; padding-top: 0; }
  .floor b { font-size: 80px; }
  .q { grid-column: 2; grid-row: 3; padding-top: 24px; }
  /* the result stays a column of reading width in the middle of the wide page */
  .end { padding-left: max(var(--pad), calc((100% - 480px) / 2)); padding-right: max(var(--pad), calc((100% - 480px) / 2)); }
}

/* the phone keyboard is up: the window is about 400 px high. Everything is set tighter so the question, the box,
   its note and the next button are all above the keys, with the lift still in view. */
@media (max-height: 520px) and (max-width: 899px) {
  .tower { min-height: 48px; }
  .readout { padding-top: 6px; padding-bottom: 6px; }
  .floor b { font-size: 32px; }
  .band strong { font-size: 18px; }
  .q { padding-top: 10px; padding-bottom: 10px; }
  .q-text { margin-top: 10px; font-size: 28px; }
  .slot { margin-top: 12px; }
  .slot input, .go { height: 48px; }
  .go { width: 48px; }
  .note { margin-top: 8px; font-size: 13px; }
  .q .btn { margin-top: 12px; height: 48px; }
}
