/* An optical mark sheet: white form paper, one drop-out ink, black timing marks, pencil.
   Frame coordinates (CSS px): timing track x 14..36; ink rule x 48; text column from x 62.
   Head 24..86, column heads 108..128, a 2 px rule at y 134, then seven rows of 56 px (136..528).
   Timing marks sit on the bubbles' centre line in each row.
   Bubbles 76 x 34, centred on x 280, 380, 480 (right margin 22). */
.om {
  --ink: #e9156a;
  --black: #17171a;
  position: relative;
  width: 540px;
  height: 540px;
  overflow: hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' seed='8'/%3E%3CfeColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .56  0 0 0 .16 -.05'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E"),
    #ffffff;
  color: var(--ink);
  font-family: "Sofia Sans Condensed Variable", sans-serif;
  user-select: none;
}

.om * { box-sizing: border-box; }
.om-defs { position: absolute; width: 0; height: 0; }

/* the ink rule that separates the timing track from the form */
.om::before {
  content: "";
  position: absolute;
  left: 47px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--ink);
}

/* timing marks: black, one per row, read by the scanner */
.om-track {
  position: absolute;
  left: 14px;
  top: 135.5px;
  display: grid;
  grid-template-rows: repeat(7, 56px);
}

.om-track i {
  align-self: center;
  width: 22px;
  height: 10px;
  background: var(--black);
}

.om-head {
  position: absolute;
  left: 62px;
  top: 24px;
  right: 26px;
  display: grid;
  grid-template-columns: 38px 1fr;
  column-gap: 12px;
}

.om-no {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--ink);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  line-height: 38px;
  font-variant-numeric: tabular-nums;
}

.om-q {
  margin: 0;
  font-size: 30px;
  font-weight: 800;
  line-height: 38px;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.om-how {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.01em;
}

.om-cols {
  position: absolute;
  left: 242px;
  top: 108px;
  display: grid;
  grid-template-columns: repeat(3, 76px);
  column-gap: 24px;
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: 0.07em;
  text-align: center;
  text-transform: uppercase;
}

.om-cols span { margin: 0 -12px; }

.om-grid {
  position: absolute;
  left: 48px;
  right: 0;
  top: 134px;
  border-top: 2px solid var(--ink);
}

.om-row {
  position: relative;
  display: grid;
  grid-template-columns: 156px repeat(3, 76px);
  column-gap: 24px;
  align-items: center;
  height: 56px;
  padding-left: 14px;
  border-bottom: 1px solid var(--ink);
}

/* every other row carries a 45-degree screen of the same ink, as a printer would lay a tint */
.om-row:nth-child(odd) {
  background:
    radial-gradient(circle, var(--ink) 0 0.42px, #0000 0.66px) 0 0 / 4px 4px,
    radial-gradient(circle, var(--ink) 0 0.42px, #0000 0.66px) 2px 2px / 4px 4px;
}

.om-day {
  font-size: 27px;
  font-weight: 700;
  line-height: 30px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.om-bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: 76px;
  height: 34px;
  padding: 0;
  border: 1.75px solid var(--ink);
  border-radius: 17px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.om-bubble:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--black); }

.om-letter {
  font-size: 19px;
  font-weight: 700;
  line-height: 20px;
}

/* The pencil mark lies over the printed bubble and its letter. Graphite is not quite opaque, so
   the drop-out ink ghosts through it. */
.om-mark {
  position: absolute;
  inset: -1.75px;
}

.om-mark svg {
  display: block;
  width: 76px;
  height: 34px;
  overflow: visible;
}

/* lighter where the pencil turns round at the top and bottom of each stroke */
.om-mark svg > g > g {
  mask-image: linear-gradient(180deg, #000000b8 0%, #000 24%, #000 76%, #000000b8 100%);
}

.om-pass {
  fill: none;
  stroke: url(#om-lead);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

/* The mark is built stroke by stroke: the path is drawn along its length, out and then back. */
.om-pass-1 { stroke-width: 3.5; stroke-opacity: 0.6; transition: stroke-dashoffset 250ms cubic-bezier(0.3, 0.2, 0.5, 1); }
.om-pass-2 { stroke-width: 4.4; stroke-opacity: 0.46; transition: stroke-dashoffset 170ms cubic-bezier(0.3, 0.2, 0.5, 1) 215ms; }
.om-slip { stroke-width: 3.3; stroke-opacity: 0.5; transition: stroke-dashoffset 30ms linear calc(var(--slip) * 250ms); }

.om-mark[data-unchecked] .om-pass {
  stroke-dashoffset: 1;
  transition: none;
}
