/* PAT Logbook label rack: stylesheet for the world module (patbook-loop.js).
   Everything is scoped under .patloop. Tokens are custom properties on that container, so a host
   page can restyle it without touching this file. It loads no fonts: the host supplies the
   families named in --pl-sans and --pl-mono (the fallbacks are used otherwise).
   Everything inside the stage is sized in cqw (1cqw = 1% of the stage width); the stage is 100 x 134.
   Colour rule: PASS green and FAIL red appear only on a stamped result. The rack is timber, the labels paper. */
.patloop {
  --pl-ink: #0c0d0c;
  --pl-paper: #fbfaf6;
  --pl-rule: #c6c9c5;
  --pl-mute: #555a56;
  --pl-pass: #157347;
  --pl-fail: #b42318;
  --pl-board: #b5733f;
  --pl-board-dark: #6f3e1d;
  --pl-sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --pl-mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  display: block;
  width: 100%;
  max-width: 100%;
  container-type: inline-size;
  color: var(--pl-ink);
  font: 400 16px/1.4 var(--pl-sans);
  text-align: left;
}
.patloop *, .patloop *::before, .patloop *::after { box-sizing: border-box; }
.patloop svg { display: block; max-width: 100%; }
.patloop img { display: block; max-width: none; height: auto; }
.patloop .pl-vh { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the stage and the rack board (timber, lit from the top left like the film) */
.patloop .pl-stage { position: relative; container-type: inline-size; aspect-ratio: 100 / 134; }
.patloop .pl-board { position: absolute; left: 2cqw; top: 0; width: 96cqw; height: 134cqw; border-radius: 1.2cqw;
  background:
    repeating-linear-gradient(90deg, rgb(255 236 214 / 7%) 0 .35cqw, transparent .35cqw 1.9cqw, rgb(60 28 8 / 8%) 1.9cqw 2.2cqw, transparent 2.2cqw 4.6cqw),
    linear-gradient(160deg, #c98a52 0%, var(--pl-board) 38%, #8e5229 100%);
  box-shadow: inset 0 0 0 .5cqw rgb(255 225 190 / 18%), inset 0 -1.2cqw 2cqw rgb(60 28 8 / 35%), 0 .6cqw 0 #5a3116, 0 4cqw 6cqw -1cqw rgb(30 14 4 / 55%); }

/* rows: paper labels pinned to the board */
.patloop .pl-rows { position: absolute; inset: 0; z-index: 2; margin: 0; padding: 0; list-style: none; }
.patloop .pl-row { position: absolute; left: 7cqw; top: calc(5cqw + var(--i) * 14.4cqw); width: 86cqw; height: 13.2cqw; transform-origin: 0 0; }
.patloop .pl-row button { all: unset; box-sizing: border-box; position: relative; display: block; width: 100%; height: 100%; cursor: default; }
.patloop .pl-row button::after { content: ""; position: absolute; inset: -.6cqw 0; }   /* the hit area fills the pitch */
.patloop .pl-stage.pl-js .pl-row button { cursor: pointer; }
.patloop .pl-row button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--pl-ink); }
.patloop .pl-face { position: relative; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-content: center; column-gap: 2cqw; row-gap: .5cqw;
  width: 100%; height: 100%; padding: 0 2.4cqw 0 5.4cqw; overflow: hidden; background: var(--pl-paper); border-radius: .6cqw;
  box-shadow: 0 .35cqw 0 rgb(60 28 8 / 35%), 0 1.4cqw 1.6cqw -.6cqw rgb(30 14 4 / 50%); }
.patloop .pl-row.pl-up .pl-face { box-shadow: 0 .35cqw 0 rgb(60 28 8 / 30%), 0 3cqw 3.4cqw -1cqw rgb(30 14 4 / 60%); }
.patloop .pl-face::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1.6cqw; background: var(--pl-pass); }
.patloop .pl-fail .pl-face::before { background: var(--pl-fail); }
.patloop .pl-row.pl-blank .pl-face::before { background: var(--pl-rule); }
.patloop .pl-pin { position: absolute; left: 2.6cqw; top: 50%; width: 1.5cqw; height: 1.5cqw; margin-top: -.75cqw; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f3e3b4, #a3824a 70%); box-shadow: 0 .2cqw .3cqw rgb(0 0 0 / 40%); }
.patloop .pl-name { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 3.9cqw/1.15 var(--pl-sans); letter-spacing: -.005em; }
.patloop .pl-name b { font: 600 3.4cqw/1 var(--pl-mono); font-stretch: 87.5%; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.patloop .pl-read { grid-column: 1; grid-row: 2; justify-self: start; max-width: none; overflow: hidden; white-space: nowrap; font: 500 2.8cqw/1.2 var(--pl-mono); font-stretch: 80%; letter-spacing: .03em; color: var(--pl-mute); font-variant-numeric: tabular-nums; }
.patloop .pl-res { grid-column: 2; grid-row: 1 / 3; position: relative; width: 20cqw; height: 8cqw; display: grid; place-items: center; }
.patloop .pl-empty { font: 500 2.3cqw/1 var(--pl-mono); font-stretch: 87.5%; letter-spacing: .08em; text-transform: uppercase; color: var(--pl-mute); border: .3cqw dashed var(--pl-rule); padding: 2cqw 2.2cqw; }
.patloop .pl-die { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 1.2cqw; background: var(--pl-pass); color: #fff; border-radius: .4cqw; transform-origin: 50% 50%; }
.patloop .pl-fail .pl-die { background: var(--pl-fail); }
.patloop .pl-die b { font: 800 4.2cqw/1 var(--pl-sans); letter-spacing: .02em; text-transform: uppercase; }
.patloop .pl-die svg { width: 3.8cqw; height: 3.8cqw; flex: none; }
.patloop .pl-scan { position: absolute; top: 0; bottom: 0; left: 0; width: .6cqw; background: var(--pl-ink); opacity: 0; }

/* the tally strip under the rows */
.patloop .pl-sum { position: absolute; z-index: 1; left: 7cqw; top: 121.8cqw; width: 86cqw; height: 8cqw; margin: 0; display: flex; align-items: center; padding: 0 2.4cqw 0 4cqw; background: var(--pl-paper); border-left: 1.6cqw solid var(--pl-ink); border-radius: .6cqw; transform-origin: 0 0;
  font: 600 3.3cqw/1 var(--pl-mono); font-stretch: 87.5%; letter-spacing: .02em; font-variant-numeric: tabular-nums; box-shadow: 0 .35cqw 0 rgb(60 28 8 / 35%); }
.patloop .pl-sum.pl-empty-sum { color: var(--pl-mute); }

/* the certificate the rack becomes */
.patloop .pl-cert { position: absolute; left: 5.25cqw; top: 4cqw; width: 89.5cqw; visibility: hidden; background: #fff; box-shadow: 0 0 0 1px rgb(12 13 12 / 14%), 0 2.5cqw 5cqw -1.5cqw rgb(30 14 4 / 60%); }
.patloop .pl-cert img { width: 100%; height: auto; background: #fff; }
.patloop .pl-note { position: absolute; right: 2.5cqw; bottom: 2.5cqw; padding: 1.2cqw 1.8cqw; background: var(--pl-ink); color: #fff; font: 500 2.6cqw/1 var(--pl-mono); font-stretch: 87.5%; letter-spacing: .06em; text-transform: uppercase; opacity: 0; }

/* before the script runs (and with scripts off) the rack shows every row stamped, as the film ends */

/* the steps and hint under the stage (shown only when the script runs), printed on paper */
.patloop .pl-ui { display: none; margin-top: .8em; }
.patloop .pl-ui.pl-on { display: block; }
.patloop .pl-steps { margin: 0; padding: 0; list-style: none; display: flex; background: var(--pl-paper); border: 1px solid var(--pl-ink); }
.patloop .pl-steps li { flex: 1 1 auto; display: flex; }
.patloop .pl-steps li[hidden] { display: none; }
.patloop .pl-steps li:last-child { flex: 0 0 auto; border-left: 1px solid var(--pl-ink); }
.patloop .pl-steps button { all: unset; box-sizing: border-box; cursor: pointer; flex: 1; min-height: 44px; padding: .2em .7em; display: inline-flex; align-items: center; justify-content: center; font: 500 .7em/1 var(--pl-mono); font-stretch: 87.5%; letter-spacing: .05em; text-transform: uppercase; color: var(--pl-ink); }
.patloop .pl-steps button:hover { text-decoration: underline; }
.patloop .pl-steps button:focus-visible { outline: 3px solid var(--pl-ink); outline-offset: -5px; }
.patloop .pl-steps button[aria-current="step"] { background: var(--pl-ink); color: #fff; }
.patloop .pl-steps button[aria-current="step"]:focus-visible { outline-color: #fff; }
.patloop .pl-hint { margin: .55em 0 0; display: inline-flex; align-items: center; gap: .5em; padding: .35em .7em; background: var(--pl-paper); font-size: .88em; font-weight: 600; }
.patloop .pl-hint svg { width: 16px; height: 16px; flex: none; }

