/* 540 frame. One sheet of paper printed with two inks, each on its own layer, multiplied onto the
   paper. Layer A is the flood, with the shirt knocked out of it; layer B carries the shirt's folds
   and shadow as grain, and every control. Display type prints in both inks, so it is the dark
   overprint everywhere and shows a fringe where the layers are out of register. */
.tp-root {
  position: absolute;
  inset: 0;
}

.tp {
  --paper: #fdfcf6;
  --off-x: 2.5px;
  --off-y: -1.5px;
  --frame: 84ms;
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
  font-family: "Dela Gothic One", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.tp *,
.tp *::before,
.tp *::after {
  box-sizing: border-box;
}

.tp [hidden] {
  display: none;
}
.tp-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* an ink layer */
.tp-ink {
  position: absolute;
  inset: 0;
  mix-blend-mode: multiply;
}
.tp-a {
  color: var(--a);
  pointer-events: none;
}
.tp-b {
  color: var(--b);
  translate: var(--off-x) var(--off-y);
}

/* a plate is a greyscale picture, black where the ink goes: screened over the ink's own colour it
   leaves ink on white */
.tp-plate {
  position: absolute;
  inset: 0;
  isolation: isolate;
  background: currentColor;
  pointer-events: none;
}
.tp-plate img {
  display: block;
  width: 540px;
  height: 540px;
  mix-blend-mode: screen;
}

/* paper showing through the ink, over both layers */
.tp-grain {
  position: absolute;
  inset: -64px;
  background: url("./grain.png") 0 0 / 256px 256px;
  pointer-events: none;
}

/* display type */
.tp-line {
  position: absolute;
  display: block;
  line-height: 1;
  white-space: nowrap;
  color: transparent;
}
.tp-line[data-prints] {
  color: inherit;
}
/* nothing is set until the face is in and its ink can be measured: the lines, and the labels placed from the
   measured lines, are held back so they cannot move once they show */
.tp:not([data-ready]) .tp-line,
.tp:not([data-ready]) .tp-browse,
.tp:not([data-ready]) .tp-note,
.tp:not([data-ready]) .tp-aside {
  visibility: hidden;
}

/* the poster: the whole sheet is the button that opens the picker */
.tp-trigger {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
}
.tp-sheet {
  position: absolute;
  inset: 0;
}
.tp-sheet::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 5px solid currentColor;
  opacity: 0;
}
.tp-sheet:focus-visible::after {
  opacity: 1;
}

/* a block prints in the second ink alone, lettering knocked out. The first ink is knocked out
   under it, so out of register it shows a sliver of paper on two sides and overprints on the others. */
.tp-browse,
.tp-key {
  display: grid;
  place-items: center;
  line-height: 1;
  white-space: nowrap;
}
.tp-a :is(.tp-browse, .tp-key) {
  background: #fff;
}
.tp-b :is(.tp-browse, .tp-key) {
  background: var(--b);
  color: #fff;
}

.tp-browse {
  position: absolute;
  left: 96px;
  width: 164px;
  height: 46px;
  padding-bottom: 2px;
  font-size: 17px;
  letter-spacing: 0.01em;
}
/* hover: the first ink prints a hard edge beside the block; pressed, the block steps onto it */
.tp:has(.tp-sheet:hover) .tp-a .tp-browse {
  box-shadow: -5px 5px 0 var(--a);
}
.tp-sheet:active .tp-browse {
  translate: -3px 3px;
}
/* the keys print as outlines under the pointer, and step when pressed */
/* the keys are outlines only, so the first ink has nothing to knock out under them */
.tp-a .tp-key {
  background: transparent;
}
.tp-b .tp-key:hover {
  background: none;
  box-shadow: inset 0 0 0 4px var(--b);
  color: var(--b);
}
.tp-b .tp-key:active {
  background: var(--b);
  color: #fff;
  translate: -2px 2px;
}

.tp-note,
.tp-facts,
.tp-aside,
.tp-dim {
  font-family: "Golos Text Variable", sans-serif;
  font-weight: 800;
  font-variant-numeric: lining-nums;
}

.tp-note {
  position: absolute;
  left: 274px;
  display: flex;
  align-items: center;
  width: 194px;
  height: 46px;
  margin: 0;
  font-size: 12.5px;
  line-height: 15px;
  text-wrap: balance;
  pointer-events: none;
}

.tp-aside {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  left: 96px;
  font-family: "Golos Text Variable", sans-serif;
  font-size: 13px;
  font-weight: 800;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.tp-aside:hover {
  text-decoration-thickness: 4px;
}
.tp-aside:focus-visible {
  outline: 4px solid currentColor;
  outline-offset: 4px;
}

/* the proof */
.tp-art {
  position: absolute;
  display: block;
}

.tp-dim {
  position: absolute;
  display: flex;
  align-items: center;
  font-size: 11px;
  line-height: 12px;
  white-space: nowrap;
}
.tp-dim::before,
.tp-dim::after {
  content: "";
  flex: 1;
  background: currentColor;
}
.tp-dim b {
  font-weight: 800;
}
.tp-dim-w {
  height: 10px;
  border: solid currentColor;
  border-width: 0 1.5px;
}
.tp-dim-w::before,
.tp-dim-w::after {
  height: 1.5px;
}
.tp-dim-w b {
  padding: 0 6px;
}
.tp-dim-h {
  flex-direction: column;
  width: 10px;
  border: solid currentColor;
  border-width: 1.5px 0;
}
.tp-dim-h::before,
.tp-dim-h::after {
  width: 1.5px;
}
.tp-dim-h b {
  padding: 6px 0;
  writing-mode: vertical-rl;
  rotate: 180deg;
}

/* the two keys at the end of the file's line stand on its baseline */
.tp-key {
  position: absolute;
  top: 485px;
  height: 31px;
}
.tp-b .tp-key {
  all: unset;
  box-sizing: border-box;
  position: absolute;
  top: 485px;
  display: grid;
  place-items: center;
  height: 31px;
  /* outlined in the second ink, so the file name and the print lead */
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--b);
  color: var(--b);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.tp-b .tp-key:hover {
  background: color-mix(in srgb, var(--b) 12%, transparent);
}
.tp-ink .tp-replace {
  right: 55px;
  width: 100px;
  padding-bottom: 2px;
  font-family: "Dela Gothic One", sans-serif;
  font-size: 13px;
}
.tp-ink .tp-remove {
  right: 18px;
  width: 31px;
}
.tp-remove svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
}
.tp-b .tp-key:focus-visible {
  outline: 4px solid var(--b);
  outline-offset: 3px;
}

.tp-list,
.tp-file {
  outline: none;
}
/* what the file is, as a caption under the print */
.tp-facts {
  position: absolute;
  left: 0;
  width: 540px;
  font-size: 12px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
}
.tp-a .tp-facts {
  color: transparent;
}
/* the inks the artwork's colours will print in: two dots, overprinting where they meet */
.tp-dots {
  display: inline-flex;
  margin: 0 5px 0 2px;
  vertical-align: -1px;
}
.tp-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.tp-dots i + i {
  margin-left: -4px;
}
.tp-a .tp-dots [data-ink="a"] {
  background: var(--a);
}
.tp-b .tp-dots [data-ink="b"] {
  background: var(--b);
}
/* the file has focus: its name is boxed */
.tp-file::after {
  content: "";
  position: absolute;
  left: 9px;
  top: var(--ring-top);
  width: var(--ring-width);
  height: var(--ring-height);
  border: 4px solid currentColor;
  opacity: 0;
  pointer-events: none;
}
.tp-file:focus-visible::after {
  opacity: 1;
}

/* Motion: nothing eases. Every change is a few held frames, like paper animated under a camera:
   the second layer lands out of register and is nudged home, and ink arrives in passes. */
@keyframes tp-register-0 {
  0% { translate: -9px 6px; rotate: -0.5deg; }
  17% { translate: 7px -5px; rotate: 0.35deg; }
  34% { translate: -4px 3px; rotate: -0.2deg; }
  51% { translate: 4.5px -3px; rotate: 0.1deg; }
  68% { translate: 1px 0.5px; rotate: 0deg; }
  85% { translate: 3px -2px; }
}
@keyframes tp-register-1 {
  0% { translate: -9px 6px; rotate: -0.5deg; }
  17% { translate: 7px -5px; rotate: 0.35deg; }
  34% { translate: -4px 3px; rotate: -0.2deg; }
  51% { translate: 4.5px -3px; rotate: 0.1deg; }
  68% { translate: 1px 0.5px; rotate: 0deg; }
  85% { translate: 3px -2px; }
}
.tp[data-pull="0"] .tp-b {
  animation: tp-register-0 calc(var(--frame) * 6) step-end;
}
.tp[data-pull="1"] .tp-b {
  animation: tp-register-1 calc(var(--frame) * 6) step-end;
}

/* a file is over the sheet: the layers will not sit still */
@keyframes tp-boil {
  0% { translate: 5px -3px; }
  25% { translate: -1px 2px; }
  50% { translate: 4px 1px; }
  75% { translate: 0.5px -3px; }
}
.tp[data-dragging] .tp-b {
  animation: tp-boil calc(var(--frame) * 4) step-end infinite;
}
@keyframes tp-refuse {
  0% { translate: -12px 0; }
  25% { translate: 11px 0; }
  50% { translate: -7px 0; }
  75% { translate: 8px 0; }
}
.tp[data-drag-reject] .tp-b {
  animation: tp-refuse calc(var(--frame) * 4) step-end infinite;
}

/* ink arrives in three passes */
@keyframes tp-pass {
  0% { opacity: 0; }
  1% { opacity: 0.4; }
  34% { opacity: 0.75; }
  67% { opacity: 1; }
}
.tp-art,
.tp-line,
.tp-dims,
.tp-facts {
  animation: tp-pass calc(var(--frame) * 3) step-end both;
}
.tp-b .tp-art {
  animation-delay: calc(var(--frame) * 2);
}
.tp-dims,
.tp-facts {
  animation-delay: calc(var(--frame) * 4);
}

/* the grain is a different sheet of paper every few frames */
@keyframes tp-grain {
  0% { translate: 0 0; }
  25% { translate: 37px -23px; }
  50% { translate: -19px 41px; }
  75% { translate: 53px 29px; }
}
.tp-grain {
  animation: tp-grain calc(var(--frame) * 8) step-end infinite;
}

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