/* Digit recognition demo, on the notebook's drafting paper */
:root {
  --paper: #F3F7F6;                       /* drafting white */
  --grid: rgba(164, 221, 237, .36);       /* non-photo blue #A4DDED, quieter than the homepage */
  --graphite: #2F353B;
  --graphite-soft: #5A636C;
  --ink: #2A3D9A;                         /* ballpoint: the one ink, for things you can act on */
  --ink-deep: #1F2E78;
  --good: #2E7D4F;                        /* right / wrong marks only: 4.7:1 and 6.1:1 on the paper */
  --bad: #B3261E;

  /* the same square as the homepage grid; whole pixels where CSS round() exists */
  --cols: 28;
  --cell: min(20px, calc((100vw - 32px) / 28));
  --W: calc(var(--cols) * var(--cell));
}
@media (min-width: 720px)  { :root { --cell: 20px; --cols: 34; } }
@media (min-width: 960px)  { :root { --cols: 46; } }
@media (min-width: 1180px) { :root { --cols: 56; } }
@media (min-width: 1360px) { :root { --cols: 60; } }
@supports (width: round(down, 1px, 1px)) {
  :root { --cell: min(20px, round(down, calc((100vw - 32px) / 28), 1px)); }
  @media (min-width: 720px) { :root { --cell: 20px; } }
}

* { box-sizing: border-box; }
html {
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: calc(50% - (var(--W) - var(--cell)) / 2) 0;
  color: var(--graphite);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  font-size: 16px;
  line-height: 25px;
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}
body { margin: 0; overflow-x: clip; }
h1, h2, h3, p, dl, dd { margin: 0; }
button { font: inherit; cursor: pointer; }

a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink-deep); text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

[hidden] { display: none !important; } /* author display rules (e.g. .loader's grid) must not override the hidden attribute */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wrap {
  width: var(--W);
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
}
.wrap > * { grid-column: 1 / -1; min-width: 0; }

/* ---------- header ---------- */
.masthead { height: calc(3 * var(--cell)); align-items: center; }
.back-link { justify-self: start; font-weight: 700; padding: 8px 0; }

/* ---------- page: phones get title, one facts line, lead, the demo, then the results ---------- */
.page { row-gap: 12px; padding-top: var(--cell); padding-bottom: calc(4 * var(--cell)); }
.margin, .main { display: contents; }
.margin > *, .main > * { grid-column: 1 / -1; min-width: 0; }
.page h1 { order: 1; }
.note { order: 2; }
.lead { order: 3; }
.loader, .grid { order: 4; }
.results { order: 5; margin-top: calc(2 * var(--cell)); }

h1 { font-size: 36px; line-height: 40px; font-weight: 800; letter-spacing: -0.01em; }
.lead { font-size: 18px; line-height: 28px; max-width: 34em; }
h2 { font-size: 24px; line-height: 30px; font-weight: 800; }

.note, .results { color: var(--graphite-soft); font-size: 14px; line-height: 20px; font-style: italic; }
.note b { color: var(--graphite); font-weight: 700; font-style: normal; }
.note span + span::before { content: ", "; }
.results-head { margin-bottom: 4px; }
.results dl { font-variant-numeric: tabular-nums lining-nums; }
.results dl div { display: flex; flex-wrap: wrap; column-gap: .5em; }
.results dd { order: -1; min-width: 2.6em; color: var(--graphite); font-weight: 700; font-style: normal; }

/* ---------- buttons: ballpoint for the main action, a pencil outline for the quiet one ---------- */
.btn, .ghost {
  display: inline-flex; align-items: center; min-height: 44px; padding: 10px 20px;
  font-size: 16px; font-weight: 700; line-height: 1.25; border-radius: 0;
}
.btn { background: var(--ink); color: var(--paper); border: 0; }
.btn:hover { background: var(--ink-deep); }
.btn:disabled { background: var(--graphite-soft); cursor: wait; }
.ghost { background: var(--paper); color: var(--graphite); border: 2px solid var(--graphite); padding-inline: 18px; }
.ghost:hover { border-color: var(--ink); color: var(--ink); }

.hint { color: var(--graphite-soft); max-width: 36em; }

/* ---------- loader ---------- */
.loader { display: grid; justify-items: start; gap: 14px; margin-top: var(--cell); }
.loader p { max-width: 36em; }
.loader .bar { width: 100%; max-width: calc(16 * var(--cell)); height: var(--cell); border: 1.5px solid var(--graphite); background: var(--paper); overflow: hidden; }
.loader i { display: block; height: 100%; width: 0; background: var(--graphite); transition: width .2s; }

/* ---------- the demo ---------- */
.grid { display: grid; gap: calc(2 * var(--cell)) calc(2 * var(--cell)); grid-template-columns: minmax(0, 1fr); margin-top: var(--cell); }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }

#pad {
  display: block; width: 100%; max-width: 420px; aspect-ratio: 1;
  box-shadow: 0 0 0 2px var(--graphite); background: #fff;
  touch-action: none; cursor: crosshair;
}
.quick { margin-top: 14px; min-height: 25px; font-size: 16px; line-height: 25px; font-weight: 700; font-variant-numeric: tabular-nums lining-nums; }
.seen { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
#seen { width: 84px; height: 84px; flex-shrink: 0; image-rendering: pixelated; border: 1.5px solid var(--graphite); background: #888; }
.seen p { color: var(--graphite-soft); font-size: 14px; line-height: 20px; font-style: italic; max-width: 30em; }
.draw .hint { margin-top: 16px; }

.models { display: grid; gap: var(--cell); align-content: start; }
.models.busy .guess, .models.busy .bars { opacity: .45; transition: opacity .15s; }
.model { border-top: 2px solid var(--graphite); padding-top: 10px; transition: border-color .2s; }
.model.correct { border-top-color: var(--good); }
.model.wrong { border-top-color: var(--bad); }
.model-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.model h3 { font-size: 18px; line-height: 25px; font-weight: 700; }
.model-head p { color: var(--graphite-soft); font-size: 14px; line-height: 20px; font-style: italic; }
.guess { flex-shrink: 0; min-width: 1.4em; text-align: right; font-size: 36px; line-height: 40px; font-weight: 800; font-variant-numeric: tabular-nums lining-nums; }
.model.correct .guess { color: var(--good); }
.model.wrong .guess { color: var(--bad); }
.model.correct .guess::after { content: " ✓"; font-size: 24px; }
.model.wrong .guess::after { content: " ✗"; font-size: 24px; }
.bars { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.bars div { display: flex; flex-direction: column; justify-content: flex-end; height: 62px; }
.bars span { display: block; height: 2px; background: rgba(47, 53, 59, .4); transition: height .25s; }
.bars div.top span { background: var(--graphite); }
.bars b { margin-top: 2px; font-size: 12px; line-height: 18px; font-weight: 400; color: var(--graphite-soft); text-align: center; font-variant-numeric: lining-nums; }

.tests .hint { margin-bottom: 16px; }
/* my 20 test digits, 0 to 9 in pairs: two rows of ten, four rows of five on phones */
.thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: calc(30 * var(--cell)); }
@media (min-width: 560px) { .thumbs { grid-template-columns: repeat(10, minmax(0, 1fr)); } }
.thumb { position: relative; padding: 0; aspect-ratio: 1; overflow: hidden; background: none; border: 1.5px solid var(--graphite); border-radius: 0; }
.thumb canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.thumb:hover, .thumb.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.thumb .marks { position: absolute; left: 2px; right: 2px; bottom: 2px; display: flex; gap: 2px; }
.thumb .marks i { flex: 1; height: 5px; background: transparent; }
.thumb .marks i.ok { background: var(--good); }
.thumb .marks i.no { background: var(--bad); }
.scores { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 16px; font-variant-numeric: tabular-nums lining-nums; }
.scores strong { font-weight: 700; }
.legend { flex-basis: 100%; color: var(--graphite-soft); font-size: 14px; line-height: 20px; font-style: italic; }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  .lead { font-size: 21px; line-height: 32px; }
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tests { grid-column: 1 / -1; }
}
/* margin column from 960 px: course code, course, term, team, then the original results */
@media (min-width: 960px) {
  .page { row-gap: 0; padding-top: calc(2 * var(--cell)); }
  .margin { display: block; grid-column: 1 / span 8; grid-row: 1; padding-top: 6px; }
  .main { display: block; grid-column: 10 / -1; grid-row: 1; }
  h1 { font-size: 48px; line-height: 48px; }
  .lead { margin-top: 12px; }
  .note b, .note span { display: block; }
  .note span::first-letter { text-transform: uppercase; }
  .note span + span::before { content: none; }
  .results { margin-top: var(--cell); }
  .loader, .grid { margin-top: calc(2 * var(--cell)); }
}

/* inside the portfolio's project window the page drops its own header and notes */
.embed .masthead, .embed .margin, .embed .main > h1, .embed .main > .lead { display: none; }
.embed .page { padding-top: 16px; }
.embed .loader, .embed .grid { margin-top: 0; }
@media (max-width: 719.98px) {
  .embed #pad { max-width: min(100%, 40vh); }   /* keep the result line in view inside the portfolio frame */
}

@media (prefers-reduced-motion: reduce) {
  .loader i, .model, .bars span, .models.busy .guess, .models.busy .bars { transition: none; }
}
@media (forced-colors: active) {
  #pad, #seen { outline: 2px solid CanvasText; }
  .bars span, .loader i { forced-color-adjust: none; background: CanvasText; }
}
